Changeset 13288

Show
Ignore:
Timestamp:
04/08/08 15:38:57 (8 months ago)
Author:
wolfram
Message:

+ highlightMatch option to combobox, fixes#6461
+ CSS dijitComboBoxHighlightMatch class

Location:
dijit/trunk
Files:
5 modified

Legend:

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

    r13269 r13288  
    3939                autoComplete: true, 
    4040 
     41                // highlightMatch: Boolean 
     42                //              If the ComboBox opens with the serach results and the searched 
     43                //              string can be found it will be highlighted. 
     44                //              This value is not considered when labelType!="text" to not 
     45                //              screw up any mark up the label might contain. 
     46                highlightMatch: true, 
     47                 
    4148                // searchDelay: Integer 
    4249                //              Delay in milliseconds between when user types something and we start 
     
    506513                        this.item = null; // #4872 
    507514                        var query = dojo.clone(this.query); // #5970 
     515                        this._lastInput = key; // Store exactly what was entered by the user. 
    508516                        this._lastQuery = query[this.searchAttr] = this._getQueryString(key); 
    509517                        // #5970: set _lastQuery, *then* start the timeout 
     
    625633 
    626634                _getMenuLabelFromItem:function(/*Item*/ item){ 
    627                         return { 
    628                                 html: this.labelType=="html",  
    629                                 label: this.store.getValue(item, this.labelAttr || this.searchAttr) 
    630                         }; 
     635                        var label = this.store.getValue(item, this.labelAttr || this.searchAttr); 
     636                        var labelType = this.labelType; 
     637                        // If labelType is not "text" we don't want to screw any markup ot whatever. 
     638                        if (this.highlightMatch==true && this.labelType=="text" && this._lastInput){ 
     639                                label = this.doHighlight(label); 
     640                                labelType = "html"; 
     641                        } 
     642                        return {html: labelType=="html", label: label}; 
     643                }, 
     644                 
     645                doHighlight:function(/*String*/label){ 
     646                        // summary: 
     647                        //              Highlights the string entered by the user in the menu, by default this 
     648                        //              highlights the first occurence found. Override this method 
     649                        //              to implement your custom highlighing. 
     650                        var rx = new RegExp("("+this._lastInput+")", "i"); 
     651                        return label.replace(rx, '<span class="dijitComboBoxHighlightMatch">$1</span>'); 
    631652                }, 
    632653 
     
    653674        "dijit.form._ComboBoxMenu", 
    654675        [dijit._Widget, dijit._Templated], 
    655  
    656676        { 
    657677                //      summary: 
  • dijit/trunk/tests/form/test_ComboBox.html

    r13269 r13288  
    205205        </div> 
    206206        <hr> 
    207         <p>ComboBox #4: url, autoComplete=false required=true:</p> 
     207        <p>ComboBox #4: url, autoComplete=false required=true and highlightMatch=false</p> 
    208208        <label for="combobox4">US State test 4: </label> 
    209209        <input dojoType="dijit.form.ComboBox" 
     
    218218                        id="combobox4" 
    219219                        required="true" 
     220                        highlightMatch="false" 
    220221        > 
    221222        <span>Value: <input id="value4" disabled></span> 
  • dijit/trunk/themes/nihilo/form/Common.css

    r12100 r13288  
    8181        background: transparent url('../images/warning.png') no-repeat center center; 
    8282} 
     83 
     84/* The highlight is shown in the ComboBox menu. */ 
     85.nihilo .dijitComboBoxHighlightMatch { 
     86        background-color:#d3d3d3; 
     87} 
  • dijit/trunk/themes/soria/form/Common.css

    r12104 r13288  
    8181        background: transparent url('../images/warning.png') no-repeat center center; 
    8282} 
     83 
     84/* The highlight is shown in the ComboBox menu. */ 
     85.soria .dijitComboBoxHighlightMatch { 
     86        background-color:#f9f7ba; 
     87} 
  • dijit/trunk/themes/tundra/form/Common.css

    r13051 r13288  
    125125        background: url("../images/validationInputBg.gif") repeat-x top left #fff; 
    126126} 
     127 
     128/* The highlight is shown in the ComboBox menu. */ 
     129.tundra .dijitComboBoxHighlightMatch { 
     130        background-color:#a5beda; 
     131}