Changeset 8926

Show
Ignore:
Timestamp:
06/05/07 09:23:47 (18 months ago)
Author:
doughays
Message:

Fixes #3271. Proxy commit for haysmark.
Rename AutoCompleter? to ComboBox? and Select to FilteringSelect?.

Location:
dijit/trunk
Files:
11 modified
7 moved

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/ComboBox.js

    r8913 r8926  
    1 dojo.provide("dijit.form.AutoCompleter"); 
     1dojo.provide("dijit.form.ComboBox"); 
    22 
    33dojo.require("dijit.util.scroll"); 
     
    99 
    1010dojo.declare( 
    11         "dijit.form.AutoCompleterMixin", 
     11        "dijit.form.ComboBoxMixin", 
    1212        dijit.form._DropDownTextBox, 
    1313        { 
    1414                // summary: 
    15                 //              Auto-completing text box, and base class for Select widget. 
     15                //              Auto-completing text box, and base class for FilteringSelect widget. 
    1616                // 
    1717                //              The drop down box's values are populated from an class called 
     
    1919                //              that the user has typed into the input box. 
    2020                // 
    21                 //              Some of the options to the AutoCompleter are actually arguments to the data 
     21                //              Some of the options to the ComboBox are actually arguments to the data 
    2222                //              provider. 
    2323 
     
    2929 
    3030                // store: Object 
    31                 //              Reference to data provider object created for this AutoCompleter 
     31                //              Reference to data provider object created for this ComboBox 
    3232                //              according to "dataProviderClass" argument. 
    3333                store: null, 
     
    4747                //              URL argument passed to data provider object (class name specified in "dataProviderClass") 
    4848                //              An example of the URL format for the default data provider is 
    49                 //              "autoCompleterData.js" 
     49                //              "comboBoxData.js" 
    5050                url: "", 
    5151 
     
    7272 
    7373                // ignoreCase: Boolean 
    74                 //              Does the AutoCompleter menu ignore case? 
     74                //              Does the ComboBox menu ignore case? 
    7575                ignoreCase: true, 
    7676 
    7777                // value: String 
    78                 //              The initial value of the AutoCompleter. 
     78                //              The initial value of the ComboBox. 
    7979                //              This is the value that actually appears in the text area. 
    8080                value:"", 
    8181 
    82                 templatePath: dojo.moduleUrl("dijit.form", "templates/AutoCompleter.html"), 
     82                templatePath: dojo.moduleUrl("dijit.form", "templates/ComboBox.html"), 
    8383 
    8484                _hasMasterPopup:true, 
    8585 
    86                 _popupClass:"dijit.form._AutoCompleterMenu", 
     86                _popupClass:"dijit.form._ComboBoxMenu", 
    8787 
    8888                _getCaretPos: function(/*DomNode*/ element){ 
     
    164164                                                this._arrowPressed(); 
    165165                                                // bring up full list 
    166                                                 this._startSearch(""); 
     166                                                //this._startSearch(""); 
     167                                                doSearch=true; 
    167168                                        }else{ 
    168169                                                evt.keyCode==dojo.keys.PAGE_DOWN ? this._popupWidget.pageDown(): this._popupWidget._highlightNextOption(); 
     
    214215                                                this._hideResultList(); 
    215216                                        } 
    216                                         else{doSearch=this.autoComplete;} 
     217                                        else{doSearch=true;} 
    217218                                        break; 
    218219 
     
    227228                                        this._prev_key_esc = false; 
    228229                                        this._prev_key_backspace = true; 
    229                                         doSearch=this.autoComplete; 
     230                                        doSearch=true; 
    230231                                        if(!this.textbox.value.length){ 
    231232                                                this.setValue(""); 
     
    244245                                        this._prev_key_esc = false; 
    245246                                        if(evt.charCode!=0){ 
    246                                                 doSearch=this.autoComplete; 
     247                                                doSearch=true; 
    247248                                        } 
    248249                        } 
     
    299300// Bill: above loop could be done w/ "dojo.forEach(results, function(tr){" or better yet map() 
    300301// 
    301 // But actually the interface between AutoCompleterMenu and Autocompleter is strange to me. 
    302 // AutoCompleterMenu should be in charge of the 
     302// But actually the interface between ComboBoxMenu and Autocompleter is strange to me. 
     303// ComboBoxMenu should be in charge of the 
    303304// DOM manipulation (creating text nodes, etc).   autocompleter should just pass in a list of 
    304305// items 
     
    310311                _createOption:function(/*Object*/ tr){ 
    311312                        // summary: creates an option to appear on the popup menu 
    312                         // subclassed by Select 
     313                        // subclassed by FilteringSelect 
    313314                        var td = document.createElement("div"); 
    314315                        td.appendChild(document.createTextNode(this.store.getValue(tr, this.searchAttr))); 
     
    400401                _startSearch: function(/*String*/ key){ 
    401402                        this.makePopup(); 
    402                         // create a new query to prevent accidentally querying for a hidden value from Select's keyField 
     403                        // create a new query to prevent accidentally querying for a hidden value from FilteringSelect's keyField 
    403404                        var query={}; 
    404405                        query[this.searchAttr]=key+"*"; 
     
    409410                _assignHiddenValue:function(/*Object*/ keyValArr, /*DomNode*/ option){ 
    410411                        // sets the hidden value of an item created from an <option value="CA"> 
    411                         // AutoCompleter does not care about the value; Select does though 
    412                         // Select overrides this method 
     412                        // ComboBox does not care about the value; FilteringSelect does though 
     413                        // FilteringSelect overrides this method 
    413414                }, 
    414415 
     
    426427                                        // go backwards to create the options list 
    427428                                        // have to go backwards because we are removing the option nodes 
    428                                         // the option nodes are visible once the AutoCompleter initializes 
     429                                        // the option nodes are visible once the ComboBox initializes 
    429430                                        for(var x=ol-1; x>=0; x--){ 
    430431                                                var text = opts[x].innerHTML; 
    431432                                                var keyValArr ={}; 
    432433                                                keyValArr[this.searchAttr]=String(text); 
    433                                                 // Select: assign the value attribute to the hidden value 
     434                                                // FilteringSelect: assign the value attribute to the hidden value 
    434435                                                this._assignHiddenValue(keyValArr, opts[x]); 
    435436                                                data.unshift(keyValArr); 
     
    444445                        } 
    445446                        // call the associated Textbox postCreate 
    446                         // ValidationTextbox for AutoCompleter; MappedTextbox for Select 
     447                        // ValidationTextbox for ComboBox; MappedTextbox for FilteringSelect 
    447448                        this.parentClass=dojo.getObject(this.declaredClass, false).superclass; 
    448449                        this.parentClass.postCreate.apply(this, arguments); 
     
    455456 
    456457dojo.declare( 
    457         "dijit.form._AutoCompleterMenu", 
     458        "dijit.form._ComboBoxMenu", 
    458459        [dijit.base.FormElement, dijit.base.TemplatedWidget], 
    459460 
    460461// Bill:  
    461 // I'd like the interface to AutoCompleterMenu to be higher level, 
     462// I'd like the interface to ComboBoxMenu to be higher level, 
    462463// taking a list of items to initialize it, and returns the selected item 
    463464// 
    464 //                new _AutoCompleterMenu({ 
     465//                new _ComboBoxMenu({ 
    465466//                                 items: /*dojo.data.Item[]*/ items, 
    466467//                                 labelFunc: dojo.hitc(this, "_makeLabel"), 
     
    482483        { 
    483484                // summary: 
    484                 //      Focus-less div based menu for internal use in AutoCompleter 
     485                //      Focus-less div based menu for internal use in ComboBox 
    485486 
    486487                templateString:"<div class='dijitMenu' dojoAttachEvent='onclick; onmouseover; onmouseout;' tabIndex='-1' style='display:none; position:absolute; overflow:\"auto\";'></div>", 
     
    494495                open:function(/*Widget*/ widget){ 
    495496                        this.onValueChanged=dojo.hitch(widget, widget._selectOption); 
    496                         // connect onkeypress to AutoCompleter 
     497                        // connect onkeypress to ComboBox 
    497498                        this._onkeypresshandle=dojo.connect(this.domNode, "onkeypress", widget, "onkeypress"); 
    498499                        return dijit.util.PopupManager.openAround(widget.domNode, this); 
     
    627628 
    628629dojo.declare( 
    629         "dijit.form.AutoCompleter", 
    630         [dijit.form.ValidationTextbox, dijit.form.AutoCompleterMixin], 
     630        "dijit.form.ComboBox", 
     631        [dijit.form.ValidationTextbox, dijit.form.ComboBoxMixin], 
    631632        {} 
    632633); 
  • dijit/trunk/form/DateTextbox.js

    r8881 r8926  
    1515                //              A validating, serializable, range-bound date text box. 
    1616                // constraints object: min, max 
    17                 templatePath: dojo.moduleUrl("dijit.form", "templates/AutoCompleter.html"), 
     17                templatePath: dojo.moduleUrl("dijit.form", "templates/ComboBox.html"), 
    1818                regExpGen: dojo.date.locale.regexp, 
    1919                compare: dojo.date.compare, 
  • dijit/trunk/form/FilteringSelect.js

    r8823 r8926  
    1 dojo.provide("dijit.form.Select"); 
     1dojo.provide("dijit.form.FilteringSelect"); 
    22 
    3 dojo.require("dijit.form.AutoCompleter"); 
     3dojo.require("dijit.form.ComboBox"); 
    44 
    55dojo.declare( 
    6         "dijit.form.Select", 
    7         [dijit.form.MappedTextbox, dijit.form.AutoCompleterMixin], 
     6        "dijit.form.FilteringSelect", 
     7        [dijit.form.MappedTextbox, dijit.form.ComboBoxMixin], 
    88        { 
    99                /* 
     
    4040                _callbackSetLabel: function(/*Object*/ result){ 
    4141                        // summary 
    42                         //      Callback function that dynamically sets the label of the AutoCompleter 
     42                        //      Callback function that dynamically sets the label of the ComboBox 
    4343 
    4444                        if(!result.length){ 
     
    5656                _setValue:function(/*String*/ value, /*String*/ displayedValue){ 
    5757                        this.valueNode.value = value; 
    58                         dijit.form.Select.superclass.setValue.apply(this, arguments); 
     58                        dijit.form.FilteringSelect.superclass.setValue.apply(this, arguments); 
    5959                }, 
    6060 
     
    8686                labelFunc: function(/*Object*/ item, /*dojo.data.store*/ store){ 
    8787                        // summary: Event handler called when the label changes 
    88                         // returns the label that the AutoCompleter should display 
     88                        // returns the label that the ComboBox should display 
    8989                        return store.getValue(item, this.searchAttr); 
    9090                }, 
     
    9393                        // summary: creates an option to appear on the popup menu 
    9494 
    95                         var td=dijit.form.AutoCompleterMixin.prototype._createOption.apply(this, arguments); 
     95                        var td=dijit.form.ComboBoxMixin.prototype._createOption.apply(this, arguments); 
    9696                        // #3129 
    9797                        if(this.labelAttr){ 
     
    110110                onkeyup: function(/*Event*/ evt){ 
    111111                        // summary: internal function 
    112                         // Select needs to wait for the complete label before committing to a reverse lookup 
     112                        // FilteringSelect needs to wait for the complete label before committing to a reverse lookup 
    113113                        //this.setDisplayedValue(this.textbox.value); 
    114114                }, 
     
    116116                _assignHiddenValue:function(/*Object*/ keyValArr, /*DomNode*/ option){ 
    117117                        // summary: 
    118                         //      Overrides AutoCompleter._assignHiddenValue for creating a data store from an options list. 
     118                        //      Overrides ComboBox._assignHiddenValue for creating a data store from an options list. 
    119119                        //      Takes the <option value="CA"> and makes the CA the hidden value of the item. 
    120120                        keyValArr[this.keyAttr]=option.value; 
     
    123123                _doSelect: function(/*Event*/ tgt){ 
    124124                        // summary: 
    125                         //      AutoCompleter's menu callback function 
    126                         //      Select overrides this to set both the visible and hidden value from the information stored in the menu 
     125                        //      ComboBox's menu callback function 
     126                        //      FilteringSelect overrides this to set both the visible and hidden value from the information stored in the menu 
    127127 
    128128                        this._setValueFromItem(tgt.item); 
  • dijit/trunk/form/templates/ComboBox.html

    r8855 r8926  
    1 <fieldset class='dijit dijitInline dijitLeft dijitAutoCompleter' id="widget_${id}" name="${name}" 
     1<fieldset class='dijit dijitInline dijitLeft dijitComboBox' id="widget_${id}" name="${name}" 
    22        dojoAttachEvent="onmouseover:setStateClass;onmouseout:setStateClass;"    
    33> 
    44<table cellspacing=0 cellpadding=0> 
    55        <tr> 
    6                 <td class='dijitReset dijitStretch dijitAutoCompleterInput' 
     6                <td class='dijitReset dijitStretch dijitComboBoxInput' 
    77                        ><input class='XdijitInputField' type="text" autocomplete="off" name="${name}" 
    88                        dojoAttachEvent="onkeypress; onkeyup; onfocus; onblur; compositionend;" 
  • dijit/trunk/form/_DropDownTextBox.js

    r8867 r8926  
    1111                //              Mixin text box with drop down 
    1212 
    13                 templatePath: dojo.moduleUrl("dijit.form", "templates/AutoCompleter.html"), 
     13                templatePath: dojo.moduleUrl("dijit.form", "templates/ComboBox.html"), 
    1414 
    1515                // _popupWidget: Widget 
     
    2525 
    2626                // _popupClass: String 
    27                 //      Class of master popup (dijit.form._AutoCompleterMenu) 
     27                //      Class of master popup (dijit.form._ComboBoxMenu) 
    2828                _popupClass:"", 
    2929 
  • dijit/trunk/tests/form/test_ComboBox.html

    r8729 r8926  
    33<html> 
    44<head> 
    5 <title>Dojo AutoCompleter Widget Test</title> 
     5<title>Dojo ComboBox Widget Test</title> 
    66 
    77<script type="text/javascript" src="../testBidi.js"></script> 
     
    1313<script type="text/javascript" src="../../../dojo/dojo.js"></script> 
    1414<script type="text/javascript"> 
    15         dojo.require("dijit.form.AutoCompleter"); 
     15        dojo.require("dijit.form.ComboBox"); 
    1616        dojo.require("dijit.util.manager"); 
    1717        dojo.require("dijit.util.parser");      // scan page for widgets and instantiate them 
     
    2828        function setVal2(val){ 
    2929                document.getElementById('value2').value=val; 
    30                 console.debug("Value changed to ["+val+"] in second AutoCompleter (#1652)"); 
     30                console.debug("Value changed to ["+val+"] in second ComboBox (#1652)"); 
    3131        } 
    3232        function setVal3(val){ 
     
    3636        function init(){ 
    3737                //var store=new dojo.data.JsonItemStore({}); 
    38                 combo = new dijit.form.AutoCompleter({data:{items:[{name:"California", label:"California"}]}, name:"prog",autocomplete:false,searchAttr:"name", labelField:"label", labelType:"text"}, document.getElementById("progCombo")); 
     38                combo = new dijit.form.ComboBox({data:{items:[{name:"California", label:"California"}]}, name:"prog",autocomplete:false,searchAttr:"name", labelField:"label", labelType:"text"}, document.getElementById("progCombo")); 
    3939        } 
    4040        dojo.addOnLoad(init); 
     
    5050 
    5151<body class="tundra"> 
    52 <h1>Dojo AutoCompleter Widget Test</h1> 
     52<h1>Dojo ComboBox Widget Test</h1> 
    5353<p> 
    54 A AutoCompleter is like a text &lt;input&gt; field (ie, you can input any value you want), 
     54A ComboBox is like a text &lt;input&gt; field (ie, you can input any value you want), 
    5555but it also has a list of suggested values that you can choose from. 
    5656The drop down list is filtered by the data you have already typed in. 
     
    5858<form action="#" method="GET"> 
    5959  
    60     <p>AutoCompleter #1: inlined data, autocomplete=false, default value of CA (California)</p> 
     60    <p>ComboBox #1: inlined data, autocomplete=false, default value of CA (California)</p> 
    6161    <label for="setvaluetest">US State test 1: </label> 
    6262        <select id="setvaluetest" 
    6363                        name="state1" 
    64                         dojoType="dijit.form.AutoCompleter" 
     64                        dojoType="dijit.form.ComboBox" 
    6565                        class="medium" 
    6666                        searchAttr="name" 
     
    141141        <hr> 
    142142 
    143         <p>AutoCompleter #2: url, autocomplete=true:</p> 
     143        <p>ComboBox #2: url, autocomplete=true:</p> 
    144144        <label for="datatest">US State test 2: </label> 
    145         <input dojoType="dijit.form.AutoCompleter" 
     145        <input dojoType="dijit.form.ComboBox" 
    146146                        value="California" 
    147147                        class="medium" 
    148                         url="autoCompleterData.json" 
     148                        url="comboBoxData.json" 
    149149                        searchAttr="name" 
    150150                        labelField="label" 
     
    160160        <hr> 
    161161                 
    162     <p>AutoCompleter #3: initially disabled, url, autocomplete=false:</p> 
     162    <p>ComboBox #3: initially disabled, url, autocomplete=false:</p> 
    163163    <label for="combo3">US State test 3: </label> 
    164164        <input id="combo3" 
    165                         dojoType="dijit.form.AutoCompleter" 
     165                        dojoType="dijit.form.ComboBox" 
    166166                        value="California" 
    167167                        class="medium" 
    168                         url="autoCompleterData.json" 
     168                        url="comboBoxData.json" 
    169169                        searchAttr="name" 
    170170                        labelField="label" 
     
    185185    <p>Multiple autocompleters on a single line:</p> 
    186186    <label for="one">US State 1: </label> 
    187         <input dojoType="dijit.form.AutoCompleter" 
     187        <input dojoType="dijit.form.ComboBox" 
    188188                        value="California" 
    189189                        id="one" 
    190                         url="autoCompleterData.json" 
     190                        url="comboBoxData.json" 
    191191                        searchAttr="name" 
    192192                        labelField="label" 
     
    196196                        autocomplete="false" 
    197197        >       <label for="two">US State 2: </label> 
    198         <input dojoType="dijit.form.AutoCompleter" 
     198        <input dojoType="dijit.form.ComboBox" 
    199199                        value="California" 
    200200                        id="two" 
    201                         url="autoCompleterData.json" 
     201                        url="comboBoxData.json" 
    202202                        searchAttr="name" 
    203203                        labelField="label" 
  • dijit/trunk/tests/form/test_ComboBox_destroy.html

    r8693 r8926  
    1717<script type="text/javascript"> 
    1818         
    19         dojo.require("dijit.form.AutoCompleter"); 
     19        dojo.require("dijit.form.ComboBox"); 
    2020        dojo.require("dijit.util.manager"); 
    2121        dojo.require("dijit.util.parser");      // scan page for widgets and instantiate them 
     
    2727        dojo.addOnLoad(init); 
    2828        function init(){ 
    29         //new dijit.form.AutoCompleter({name:"prog", id:"combo_02",autocomplete:false,url:"autoCompleterData.js",searchField:"name"}, document.getElementById("progCombo")); 
     29        //new dijit.form.ComboBox({name:"prog", id:"combo_02",autocomplete:false,url:"comboBoxData.js",searchField:"name"}, document.getElementById("progCombo")); 
    3030        dojo.connect(dojo.byId("killit"), "onclick", function() { 
    3131            dijit.byId("combo_01").destroy(true); 
     
    5151<form action="#" method="GET"> 
    5252   <input type="button" id="killit" name="killit" value="killit" /> 
    53         <select name="state" searchField="name" keyField="abbreviation" id="combo_01" dojoType="dijit.form.AutoCompleter" style="width: 300px;" name="foo.bar1" autocomplete="false" 
     53        <select name="state" searchField="name" keyField="abbreviation" id="combo_01" dojoType="dijit.form.ComboBox" style="width: 300px;" name="foo.bar1" autocomplete="false" 
    5454        > 
    5555                <option value="AL">Alabama</option> 
  • dijit/trunk/tests/form/test_FilteringSelect.html

    r8775 r8926  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    22        "http://www.w3.org/TR/html4/strict.dtd"> 
    33<html> 
    44<head> 
    55<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    6 <title>Dojo Select Widget Test</title> 
     6<title>Dojo FilteringSelect Widget Test</title> 
    77 
    88<script type="text/javascript" src="../testBidi.js"></script> 
     
    1414<script type="text/javascript" src="../../../dojo/dojo.js"></script> 
    1515<script type="text/javascript"> 
    16         dojo.require("dijit.form.Select"); 
     16        dojo.require("dijit.form.FilteringSelect"); 
    1717        dojo.require("dijit.util.parser");      // scan page for widgets and instantiate them 
    1818</script> 
     
    3333                return label; 
    3434        } 
    35