1 |
8ab3e9ed
|
Erik Kristensen
|
|
2 |
|
|
/**
|
3 |
|
|
* Provides suggestions for state names (USA).
|
4 |
|
|
* @class
|
5 |
|
|
* @scope public
|
6 |
|
|
*/
|
7 |
|
|
function StateSuggestions(text) {
|
8 |
|
|
this.states = text;
|
9 |
|
|
}
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
|
|
* Request suggestions for the given autosuggest control.
|
13 |
|
|
* @scope protected
|
14 |
|
|
* @param oAutoSuggestControl The autosuggest control to provide suggestions for.
|
15 |
|
|
*/
|
16 |
|
|
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
|
17 |
|
|
bTypeAhead /*:boolean*/) {
|
18 |
|
|
var aSuggestions = [];
|
19 |
|
|
var sTextboxValue = oAutoSuggestControl.textbox.value;
|
20 |
|
|
|
21 |
|
|
if (sTextboxValue.length > 0){
|
22 |
|
|
|
23 |
|
|
//search for matching states
|
24 |
|
|
for (var i=0; i < this.states.length; i++) {
|
25 |
7581a050
|
Ermal Lu?i
|
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
|
26 |
8ab3e9ed
|
Erik Kristensen
|
aSuggestions.push(this.states[i]);
|
27 |
|
|
}
|
28 |
|
|
}
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
//provide suggestions to the control
|
32 |
|
|
oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
|
33 |
7581a050
|
Ermal Lu?i
|
};
|