autocomplete, continued

This commit is contained in:
Rolux 2010-02-19 00:38:41 +05:30
parent 71ebac9fbe
commit 851fd11e3f
2 changed files with 7 additions and 5 deletions

View File

@ -1537,7 +1537,7 @@ requires
.defaults({
autocomplete: null,
id: "",
placeholder: "",
placeholder: "", // can be [], will result in select
size: "medium",
type: "text"
})
@ -1577,7 +1577,7 @@ requires
var selected = 0;
if (items.length) {
items = $.map(items, function(title, position) {
if (that.val().toLowerCase() == title.toLowerCase()) {
if (that.val().toLowerCase() == Ox.stripTags(title.toLowerCase())) {
selected = position;
}
return {
@ -1622,7 +1622,7 @@ requires
var value = that.val();
if (self.options.autocomplete && value != self.value) {
self.value = value;
self.options.autocomplete(self.value, autocomplete);
self.options.autocomplete(value, autocomplete);
}
}, 25);
}

View File

@ -331,7 +331,6 @@
autocomplete: function(value, callback) {
value = value.toLowerCase();
var items = [],
regexp = new RegExp("(" + value + ")", "ig"),
states = [
"Alabama", "Alaska", "Arizona", "Arkansas", "California",
"Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida",
@ -350,7 +349,10 @@
} else {
$.each(states, function(i, state) {
if (state.toLowerCase().indexOf(value) > -1) {
items.push(state.replace(regexp, "<span class=\"OxHighlight\">$1</span>"));
items.push(state.replace(
new RegExp("(" + value + ")", "ig"),
"<span class=\"OxHighlight\">$1</span>")
);
}
});
}