Changeset 10527

Show
Ignore:
Timestamp:
09/16/07 21:17:19 (8 months ago)
Author:
peller
Message:

Merge attributemap branch. Still need to move style/class quirks from _Widget to parser, fix Slider,TextArea?,ComboBox?,FilteringSelect? widgets. Refs #3058

Location:
dijit/trunk
Files:
22 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/changes.txt

    r9679 r10527  
    2626createWidget() call removed since multiple renderers are no longer supported (see next section). 
    2727 
    28 At least for the dijit widgets, all widgets are guaranteed to work programatically, which in 
     28At least for the dijit widgets, all widgets are guaranteed to work programmatically, which in 
    2929effect means that all widgets must have templates, unless the default <div> works. 
    3030 
     
    5959(not separated by semi-colons) 
    6060 
     61Standard HTML attributes like 'id', 'name', 'lang', etc. are carried over programmatically 
     62by the _Widget constructor and do not need to be declared in the template (see _Widget.attributeMap) 
     63 
    6164Parent/Child relationships 
    6265-------------------------- 
  • dijit/trunk/Dialog.js

    r10409 r10527  
    8484                templatePath: dojo.moduleUrl("dijit", "templates/Dialog.html"), 
    8585 
    86                 // title: String 
    87                 //              Title of the dialog 
    88                 title: "", 
    89  
    9086                // open: Boolean 
    9187                //              is True or False depending on state of dialog 
     
    9591 
    9692                _lastFocusItem:null, 
     93 
     94                attributeMap: dojo.mixin(dojo.clone(dijit._Widget.prototype.attributeMap), 
     95                        {title: "titleBar"}), 
    9796 
    9897                postCreate: function(){ 
     
    193192                                // see if we are shift-tabbing from titleBar 
    194193                                if(node == this.titleBar && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ 
    195                                         if (this._lastFocusItem){ 
     194                                        if(this._lastFocusItem){ 
    196195                                                this._lastFocusItem.focus(); // send focus to last item in dialog if known 
    197196                                        } 
     
    199198                                }else{ 
    200199                                        // see if the key is for the dialog 
    201                                         while (node){ 
     200                                        while(node){ 
    202201                                                if(node == this.domNode){ 
    203                                                         if (evt.keyCode == dojo.keys.ESCAPE){ 
    204                                                                 this.hide(); 
     202                                                        if(evt.keyCode == dojo.keys.ESCAPE){ 
     203                                                                this.hide();  
    205204                                                        }else{ 
    206205                                                                return; // just let it go 
     
    210209                                        } 
    211210                                        // this key is for the disabled document window 
    212                                         if (evt.keyCode != dojo.keys.TAB){ // allow tabbing into the dialog for a11y 
     211                                        if(evt.keyCode != dojo.keys.TAB){ // allow tabbing into the dialog for a11y 
    213212                                                dojo.stopEvent(evt); 
    214213                                        // opera won't tab to a div 
  • dijit/trunk/form/Button.js

    r10409 r10527  
    235235        templatePath: dojo.moduleUrl("dijit.form", "templates/ComboButton.html"), 
    236236 
     237        attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), 
     238                {id:"", name:""}), 
     239 
    237240        // optionsTitle: String 
    238241        //  text that describes the options menu (accessibility) 
  • dijit/trunk/form/InlineEditBox.js

    r10492 r10527  
    191191                                var isFirst = true; 
    192192                                dojo.forEach(value.split("\n"), function(line){ 
    193                                         if(isFirst){ isFirst = false; } 
    194                                         else { 
     193                                        if(isFirst){ 
     194                                                isFirst = false; 
     195                                        }else{ 
    195196                                                _this.textNode.appendChild(document.createElement("BR")); // preserve line breaks 
    196197                                        } 
  • dijit/trunk/form/Slider.js

    r10445 r10527  
    4141 
    4242        widgetsInTemplate: true, 
     43 
     44        attributeMap: dojo.mixin(dojo.clone(dijit._Widget.prototype.attributeMap), 
     45                {id:"", name:"valueNode"}), 
    4346 
    4447        baseClass: "dijitSlider", 
  • dijit/trunk/form/templates/Button.html

    r9820 r10527  
    33        ><div class='dijitRight' 
    44        ><button class="dijitStretch dijitButtonNode dijitButtonContents" dojoAttachPoint="focusNode,titleNode" 
    5                 tabIndex="${tabIndex}" type="${type}" id="${id}" name="${name}" waiRole="button" waiState="labelledby-${id}_label" 
     5                type="${type}" waiRole="button" waiState="labelledby-${id}_label" 
    66                ><div class="dijitInline ${iconClass}"></div 
    77                ><span class="dijitButtonText" id="${id}_label" dojoAttachPoint="containerNode">${label}</span 
  • dijit/trunk/form/templates/CheckBox.html

    r10421 r10527  
    11<span class="${baseClass}" baseClass="${baseClass}" 
    22        ><input 
    3                 id="${id}" tabIndex="${tabIndex}" type="${_type}" name="${name}" value="${value}" 
     3                type="${_type}" 
    44                class="dijitCheckBoxInput" 
    55                dojoAttachPoint="inputNode,focusNode" 
  • dijit/trunk/form/templates/ComboBox.html

    r10421 r10527  
    33        ><tr 
    44                ><td class='dijitReset dijitStretch dijitInputField' dojoAttachPoint="nodeWithBorder" 
    5                         ><input type="text" autocomplete="off" name="${name}" 
     5                        ><input type="text" autocomplete="off" 
    66                        dojoAttachEvent="onkeypress, onkeyup, onfocus, onblur, compositionend" 
    7                         dojoAttachPoint="textbox,focusNode" id='${id}' 
    8                         tabIndex='${tabIndex}' size='${size}' maxlength='${maxlength}' 
    9                         waiRole="combobox" 
     7                        dojoAttachPoint="textbox,focusNode" waiRole="combobox" 
    108                /></td 
    119                ><td class='dijitReset dijitRight dijitButtonNode dijitDownArrowButton' 
  • dijit/trunk/form/templates/ComboButton.html

    r10339 r10527  
    1 <table class='dijit dijitReset dijitInline dijitLeft dijitComboButton'  baseClass='dijitComboButton' 
    2         id="${id}" name="${name}" cellspacing='0' cellpadding='0' 
     1<table class='dijit dijitReset dijitInline dijitLeft dijitComboButton' baseClass='dijitComboButton' 
     2        cellspacing='0' cellpadding='0' 
    33        dojoAttachEvent="onmouseover:_onMouse,onmouseout:_onMouse,onmousedown:_onMouse"> 
    44        <tr> 
     
    1515                        baseClass="dijitComboButtonDownArrow" 
    1616                        title="${optionsTitle}" 
    17                         tabIndex="${tabIndex}" 
    1817                        waiRole="button" waiState="haspopup-true" 
    1918                ><div waiRole="presentation">&#9660;</div> 
  • dijit/trunk/form/templates/DropDownButton.html

    r9833 r10527  
    22        dojoAttachEvent="onmouseover:_onMouse,onmouseout:_onMouse,onmousedown:_onMouse,onclick:_onArrowClick,onkeypress:_onKey" 
    33        ><div class='dijitRight'> 
    4         <button tabIndex="${tabIndex}" class="dijitStretch dijitButtonNode dijitButtonContents" type="${type}" id="${id}" name="${name}" 
     4        <button class="dijitStretch dijitButtonNode dijitButtonContents" type="${type}" 
    55                dojoAttachPoint="focusNode,titleNode" waiRole="button" waiState="haspopup-true,labelledby-${id}_label" 
    66                ><div class="dijitInline ${iconClass}"></div 
  • dijit/trunk/form/templates/HorizontalSlider.html

    r10445 r10527  
    1 <table class="dijit dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" id="${id}" 
     1<table class="dijit dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" 
    22        ><tr class="dijitReset" 
    33                ><td class="dijitReset" colspan="2"></td 
     
    1313                ></td 
    1414                ><td class="dijitReset" 
    15                         ><input dojoAttachPoint="valueNode" name="${name}" type="hidden" 
     15                        ><input dojoAttachPoint="valueNode" type="hidden" 
    1616                        /><div style="position:relative;" dojoAttachPoint="sliderBarContainer" 
    1717                                ><div dojoAttachPoint="progressBar" class="dijitSliderBar dijitHorizontalSliderBar dijitSliderProgressBar dijitHorizontalSliderProgressBar" dojoAttachEvent="onclick:_onBarClick" 
    18                                         ><div tabIndex="${tabIndex}" dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable dijitHorizontalSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" 
     18                                        ><div dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable dijitHorizontalSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" 
    1919                                                ><div class="dijitSliderImageHandle dijitHorizontalSliderImageHandle"></div 
    2020                                        ></div 
  • dijit/trunk/form/templates/Spinner.html

    r10421 r10527  
    66                <td rowspan="2" class="dijitReset dijitStretch dijitInputField" dojoAttachPoint="nodeWithBorder"> 
    77                        <input dojoAttachPoint="textbox,focusNode" type="${type}" dojoAttachEvent="onfocus,onkeyup" 
    8                                 name="${name}" size="${size}" maxlength="${maxlength}" 
    9                                 waiRole="spinbutton" autocomplete="off" tabIndex="${tabIndex}" id="${id}" 
     8                                waiRole="spinbutton" autocomplete="off" 
    109                        /></td> 
    1110                <td class="dijitReset dijitRight dijitButtonNode dijitUpArrowButton" 
  • dijit/trunk/form/templates/TextBox.html

    r10421 r10527  
    11<input dojoAttachPoint='textbox,focusNode' dojoAttachEvent='onfocus,onkeyup,onkeypress:_onKeyPress' autocomplete="off" 
    2         id='${id}' name='${name}' class="dijitInputField" type='${type}' size='${size}' maxlength='${maxlength}' tabIndex='${tabIndex}'/> 
     2        class="dijitInputField" type='${type}' /> 
  • dijit/trunk/form/templates/VerticalSlider.html

    r10445 r10527  
    1 <table class="dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" id="${id}" 
     1<table class="dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" 
    22><tbody class="dijitReset" 
    33        ><tr class="dijitReset" 
    44                ><td class="dijitReset"></td 
    55                ><td class="dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer" 
    6                         ><div class="dijitVerticalSliderIncrementIcon" tabIndex=-1 style="display:none" dojoAttachPoint="incrementButton" dojoAttachEvent="onclick: increment"><span class="dijitSliderButtonInner">+</a></span></div 
     6                        ><div class="dijitVerticalSliderIncrementIcon" tabIndex="-1" style="display:none" dojoAttachPoint="incrementButton" dojoAttachEvent="onclick: increment"><span class="dijitSliderButtonInner">+</a></span></div 
    77                ></td 
    88                ><td class="dijitReset"></td 
     
    1818                ><td dojoAttachPoint="leftDecoration" class="dijitReset" style="text-align:center;height:100%;"></td 
    1919                ><td class="dijitReset" style="height:100%;" 
    20                         ><input dojoAttachPoint="valueNode" type="hidden" name="${name}" 
     20                        ><input dojoAttachPoint="valueNode" type="hidden" 
    2121                        /><center style="position:relative;height:100%;" dojoAttachPoint="sliderBarContainer" 
    2222                                ><div dojoAttachPoint="remainingBar" class="dijitSliderBar dijitVerticalSliderBar dijitSliderRemainingBar dijitVerticalSliderRemainingBar" dojoAttachEvent="onclick:_onBarClick"></div 
    2323                                ><div dojoAttachPoint="progressBar" class="dijitSliderBar dijitVerticalSliderBar dijitSliderProgressBar dijitVerticalSliderProgressBar" dojoAttachEvent="onclick:_onBarClick" 
    24                                         ><div tabIndex="${tabIndex}" dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" style="vertical-align:top;" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" 
     24                                        ><div dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" style="vertical-align:top;" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" 
    2525                                                ><div class="dijitSliderImageHandle dijitVerticalSliderImageHandle"></div 
    2626                                        ></div 
  • dijit/trunk/form/Textarea.js

    r10430 r10527  
    105105                        // An additional problem is that the browser gives the document object a 
    106106                        // very cryptic accessible name, e.g. 
    107                         // wyciwyg://13/http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_InlineEditBox.html 
     107                        // wysiwyg://13/http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_InlineEditBox.html 
    108108                        // When focus is fired from the document object, the screen reader speaks 
    109109                        // the accessible name.  The cyptic accessile name is confusing. 
  • dijit/trunk/form/TextBox.js

    r10373 r10527  
    2929                // size: String 
    3030                //              HTML INPUT tag size declaration. 
    31                 size: "20", 
     31                size: "", 
    3232 
    3333                // maxlength: String 
    3434                //              HTML INPUT tag maxlength declaration. 
    35                 maxlength: "999999", 
     35                maxlength: "", 
    3636 
    3737                templatePath: dojo.moduleUrl("dijit.form", "templates/TextBox.html"), 
     38 
     39                attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), 
     40                        {size:"focusNode", maxlength:"focusNode"}), 
    3841 
    3942                getTextValue: function(){ 
  • dijit/trunk/form/_FormWidget.js

    r10409 r10527  
    5757        //              Fires onChange for each value change or only on demand 
    5858        intermediateChanges: false, 
     59 
     60        // These mixins assume that the focus node is an INPUT, as many but not all _FormWidgets are. 
     61        // Don't attempt to mixin the 'type' attribute here programatically -- it must be declared 
     62        // directly in the template as read by the parser in order to function 
     63        attributeMap: dojo.mixin(dojo.clone(dijit._Widget.prototype.attributeMap), 
     64                {id:"focusNode", name:"focusNode", value:"focusNode", tabIndex:"focusNode", alt:"focusNode"}), 
    5965 
    6066        setDisabled: function(/*Boolean*/ disabled){ 
     
    147153 
    148154                // get original class (non state related) specified in template 
    149                 var origClass = (this.styleNode||this.domNode).className; 
     155                var origClass = (this.stateNode||this.domNode).className; 
    150156 
    151157                // compute list of classname representing the states of the widget 
     
    177183                } 
    178184 
    179                 (this.styleNode || this.domNode).className = origClass + " " + classes.join(" "); 
     185                (this.stateNode || this.domNode).className = origClass + " " + classes.join(" "); 
    180186        }, 
    181187 
  • dijit/trunk/layout/StackContainer.js

    r10519 r10527  
    381381                                        break; 
    382382                                case dojo.keys.DELETE: 
    383                                         if (this._currentChild.closable){ 
     383                                        if(this._currentChild.closable){ 
    384384                                                this.onCloseButtonClick(this._currentChild); 
    385385                                                dojo.stopEvent(evt); 
  • dijit/trunk/layout/templates/TooltipDialog.html

    r9732 r10527  
    1 <div id="${id}" class="dijitTooltipDialog" > 
     1<div class="dijitTooltipDialog" > 
    22        <div class="dijitTooltipContainer"> 
    3                 <div  class ="dijitTooltipContents dijitTooltipFocusNode" dojoAttachPoint="containerNode" tabindex="0" waiRole="dialog"></div> 
     3                <div class ="dijitTooltipContents dijitTooltipFocusNode" dojoAttachPoint="containerNode" tabindex="0" waiRole="dialog"></div> 
    44        </div> 
    55        <span dojoAttachPoint="tabEnd" tabindex="0" dojoAttachEvent="focus:_cycleFocus"></span> 
  • dijit/trunk/templates/Dialog.html

    r9703 r10527  
    11<div class="dijitDialog"> 
    2                 <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar" tabindex="0" waiRole="dialog" title="${title}"> 
    3                 <span dojoAttachPoint="titleNode" class="dijitDialogTitle">${title}</span> 
    4                 <span dojoAttachPoint="closeButtonNode" class="dijitDialogCloseIcon" dojoAttachEvent="onclick: hide"> 
    5                         <span dojoAttachPoint="closeText" class="closeText">x</span> 
    6                 </span> 
     2        <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar" tabindex="0" waiRole="dialog"> 
     3        <span dojoAttachPoint="titleNode" class="dijitDialogTitle">${title}</span> 
     4        <span dojoAttachPoint="closeButtonNode" class="dijitDialogCloseIcon" dojoAttachEvent="onclick: hide"> 
     5                <span dojoAttachPoint="closeText" class="closeText">x</span> 
     6        </span> 
    77        </div> 
    88                <div dojoAttachPoint="containerNode" class="dijitDialogPaneContent"></div> 
  • dijit/trunk/_Templated.js

    r10450 r10527  
    4141                buildRendering: function(){ 
    4242                        // summary: 
    43                         //              Construct the UI for this widget from a template. 
    44                         // description: 
     43                        //              Construct the UI for this widget from a template, setting this.domNode. 
     44 
    4545                        // Lookup cached version of template, and download to cache if it 
    4646                        // isn't there already.  Returns either a DomNode or a string, depending on 
    4747                        // whether or not the template contains ${foo} replacement parameters. 
    48  
    4948                        var cached = dijit._Templated.getCachedTemplate(this.templatePath, this.templateString); 
    5049 
     
    7574                        // attachment points which should be defined on the template node. 
    7675                        this._attachTemplateNodes(node); 
    77                         if(this.srcNodeRef){ 
    78                                 dojo.style(this.styleNode || node, "cssText", this.srcNodeRef.style.cssText); 
    79                                 if(this.srcNodeRef.className){ 
    80                                         node.className += " " + this.srcNodeRef.className; 
    81                                 } 
     76 
     77                        var source = this.srcNodeRef; 
     78                        if(source && source.parentNode){ 
     79                                source.parentNode.replaceChild(node, source); 
    8280                        } 
    8381 
    8482                        this.domNode = node; 
    85                         if(this.srcNodeRef && this.srcNodeRef.parentNode){ 
    86                                 this.srcNodeRef.parentNode.replaceChild(this.domNode, this.srcNodeRef); 
    87                         } 
    8883                        if(this.widgetsInTemplate){ 
    89                                 var childWidgets = dojo.parser.parse(this.domNode); 
     84                                var childWidgets = dojo.parser.parse(node); 
    9085                                this._attachTemplateNodes(childWidgets, function(n,p){ 
    9186                                        return n[p]; 
     
    9388                        } 
    9489 
    95                         this._fillContent(this.srcNodeRef); 
     90                        this._fillContent(source); 
    9691                }, 
    9792 
  • dijit/trunk/_Widget.js

    r10486 r10527  
    2020        dir: "", 
    2121 
     22        // class: String 
     23        // HTML class attribute 
     24        "class": "", 
     25 
     26        // style: String 
     27        // HTML style attribute 
     28        style: "", 
     29 
     30        // title: String 
     31        // HTML title attribute 
     32        title: "", 
     33 
    2234        // srcNodeRef: DomNode 
    2335        //              pointer to original dom node 
    2436        srcNodeRef: null, 
    2537 
    26         // domNode DomNode: 
     38        // domNode: DomNode 
    2739        //              this is our visible representation of the widget! Other DOM 
    2840        //              Nodes may by assigned to other properties, usually through the 
     
    3143        domNode: null, 
    3244 
     45        // attributeMap: Object 
     46        //              A map of attributes -- typically standard HTML attributes -- to transfer 
     47        //              from the parsed node into the new dom, at the widget's domNode, by default. 
     48        //              Other node references can be specified as properties of 'this' 
     49        attributeMap: {id:"", dir:"", lang:"", "class":"", style:"", title:""},  // TODO: add on* handlers? 
     50 
    3351        //////////// INITIALIZATION METHODS /////////////////////////////////////// 
    3452 
     
    3755        }, 
    3856 
    39         create: function(params, srcNodeRef) { 
     57        create: function(params, srcNodeRef){ 
    4058                // summary: 
    4159                //              To understand the process by which widgets are instantiated, it 
     
    89107 
    90108                this.buildRendering(); 
     109 
     110                // Copy attributes listed in attributeMap into the newly created DOM for the widget 
     111                // The placement of these attributes is according to the property mapping in attributeMap 
     112                // Note special handling for 'style' and 'class' attributes which are lists and can 
     113                // have elements from both old and new structures, and some attributes like "type" 
     114                // cannot be processed this way as they are not mutable. 
     115 
     116//KLUDGE: skip the widgets which aren't yet working.  See #3058 
     117if(!/dijit\.form\.(Slider|TextArea|ComboBox|FilteringSelect)/.test(this.declaredClass)) 
     118 
     119                for(var attr in this.attributeMap){ 
     120                        if(this.domNode){ 
     121                                var node = this[this.attributeMap[attr] || "domNode"]; 
     122                                var value = this[attr]; 
     123                                if(value !== "" || (params && params[attr])){ 
     124                                        var domValue = node.getAttribute(attr); 
     125                                        // Deal with IE quirks for 'class' and 'style' 
     126                                        switch(attr){ 
     127                                        case "class": 
     128                                                domValue = node.className; 
     129                                                break; 
     130                                        case "style": 
     131                                                if(domValue && dojo.isObject(domValue)){ 
     132                                                        domValue = domValue.cssText; // required for IE, doesn't work in Opera 
     133                                                } 
     134                                        } 
     135                                        if(domValue){ 
     136                                                var delim = {style: ";", "class": " "}[attr]; 
     137                                                // style and class attributes are special and contain lists 
     138                                                // which need to be combined 
     139                                                if(delim){ 
     140                                                        value += delim + domValue; 
     141                                                        domValue = null; 
     142