Changeset 13614

Show
Ignore:
Timestamp:
05/07/08 04:51:34 (7 months ago)
Author:
wolfram
Message:

+ refs#6461, make highlightMatch take one of: first, all, none

Location:
dijit/trunk
Files:
2 modified

Legend:

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

    r13547 r13614  
    4040                autoComplete: true, 
    4141 
    42                 // highlightMatch: Boolean 
     42                // highlightMatch: String 
     43                //              One of: "first", "all" or "none". 
    4344                //              If the ComboBox opens with the serach results and the searched 
    4445                //              string can be found it will be highlighted. 
    4546                //              This value is not considered when labelType!="text" to not 
    4647                //              screw up any mark up the label might contain. 
    47                 highlightMatch: true, 
     48                highlightMatch: "first", 
    4849                 
    4950                // searchDelay: Integer 
     
    636637                        var labelType = this.labelType; 
    637638                        // 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                        if (this.highlightMatch!="none" && this.labelType=="text" && this._lastInput){ 
    639640                                label = this.doHighlight(label); 
    640641                                labelType = "html"; 
     
    649650                        //              to implement your custom highlighing. 
    650651                        return this._escapeHtml(label).replace( 
    651                                 new RegExp("("+ this._escapeHtml(this._lastInput) +")", "i"), 
     652                                // Add greedy when this.highlightMatch=="all" 
     653                                new RegExp("("+ this._escapeHtml(this._lastInput) +")", "i"+(this.highlightMatch=="all"?"g":"")), 
    652654                                '<span class="dijitComboBoxHighlightMatch">$1</span>'); 
    653655                        // returns String, (almost) valid HTML (entities encoded) 
  • dijit/trunk/tests/form/test_ComboBox.html

    r13288 r13614  
    205205        </div> 
    206206        <hr> 
    207         <p>ComboBox #4: url, autoComplete=false required=true and highlightMatch=false</p> 
     207        <p>ComboBox #4: url, autoComplete=false required=true and highlightMatch="none"</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" 
     220                        highlightMatch="none" 
    221221        > 
    222222        <span>Value: <input id="value4" disabled></span> 
    223223        <hr> 
    224         <p>A ComboBox with no arrow</p> 
     224        <p>A ComboBox with no arrow, and with highlightMatch="all", which highlights all matches (the server is not searching accordingly!)</p> 
    225225        <input dojoType="dijit.form.ComboBox" 
    226226                        value="California" 
     
    230230                        autoComplete="false" 
    231231                        hasDownArrow="false" 
     232                        highlightMatch="all" 
    232233        > 
    233234        <hr>