| 1 |
define([ |
| 2 |
"dojo/_base/kernel", |
| 3 |
"dijit/form/ValidationTextBox", |
| 4 |
"dijit/form/ComboBoxMixin", |
| 5 |
"dojo/_base/declare" |
| 6 |
], function(kernel, ValidationTextBox, ComboBoxMixin, declare){ |
| 7 |
kernel.experimental("dojox.form.MultiComboBox"); |
| 8 |
|
| 9 |
return declare("dojox.form.MultiComboBox", [ValidationTextBox, ComboBoxMixin],{ |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
delimiter: ",", |
| 16 |
|
| 17 |
_previousMatches: false, |
| 18 |
|
| 19 |
_setValueAttr: function(value){ |
| 20 |
if(this.delimiter && value.length != 0){ |
| 21 |
value = value+this.delimiter+" "; |
| 22 |
arguments[0] = this._addPreviousMatches(value); |
| 23 |
} |
| 24 |
this.inherited(arguments); |
| 25 |
}, |
| 26 |
|
| 27 |
_addPreviousMatches: function( text){ |
| 28 |
if(this._previousMatches){ |
| 29 |
if(!text.match(new RegExp("^"+this._previousMatches))){ |
| 30 |
text = this._previousMatches+text; |
| 31 |
} |
| 32 |
text = this._cleanupDelimiters(text); |
| 33 |
} |
| 34 |
return text; |
| 35 |
}, |
| 36 |
|
| 37 |
_cleanupDelimiters: function( text){ |
| 38 |
if(this.delimiter){ |
| 39 |
text = text.replace(new RegExp(" +"), " "); |
| 40 |
text = text.replace(new RegExp("^ *"+this.delimiter+"* *"), ""); |
| 41 |
text = text.replace(new RegExp(this.delimiter+" *"+this.delimiter), this.delimiter); |
| 42 |
} |
| 43 |
return text; |
| 44 |
}, |
| 45 |
|
| 46 |
_autoCompleteText: function( text){ |
| 47 |
arguments[0] = this._addPreviousMatches(text); |
| 48 |
this.inherited(arguments); |
| 49 |
}, |
| 50 |
|
| 51 |
_startSearch: function( text){ |
| 52 |
text = this._cleanupDelimiters(text); |
| 53 |
var re = new RegExp("^.*"+this.delimiter+" *"); |
| 54 |
|
| 55 |
if((this._previousMatches = text.match(re))){ |
| 56 |
arguments[0] = text.replace(re, ""); |
| 57 |
} |
| 58 |
this.inherited(arguments); |
| 59 |
} |
| 60 |
}); |
| 61 |
}); |