autocomplete, continued

This commit is contained in:
Rolux 2010-02-19 16:04:51 +05:30
parent 27ed00f6ff
commit 2860ccd20b
2 changed files with 17 additions and 9 deletions

View File

@ -1564,10 +1564,10 @@ requires
if (self.options.label) { if (self.options.label) {
self.options.label = Ox.makeArray(self.options.label); self.options.label = Ox.makeArray(self.options.label);
self.label = self.options.label[0]; self.label = self.options.label[self.options.selected];
} else if (self.options.placeholder) { } else if (self.options.placeholder) {
self.options.placeholder = Ox.makeArray(self.options.placeholder); self.options.placeholder = Ox.makeArray(self.options.placeholder);
self.placeholder = self.options.placeholder[0]; self.placeholder = self.options.placeholder[self.options.selected];
} }
if (Ox.isArray(self.options.autocomplete)) { if (Ox.isArray(self.options.autocomplete)) {
autocomplete = self.options.autocomplete; autocomplete = self.options.autocomplete;
@ -1596,7 +1596,11 @@ requires
group: self.placeholderId, // fixme: same id, works here, but should be different group: self.placeholderId, // fixme: same id, works here, but should be different
title: title title: title
}; };
}) }),
offset: {
left: 4,
top: 0
}
}); });
that.bindEvent("change_" + self.placeholderId, changePlaceholder); that.bindEvent("change_" + self.placeholderId, changePlaceholder);
} }
@ -1650,7 +1654,7 @@ requires
value = value.toLowerCase(); value = value.toLowerCase();
var items = []; var items = [];
if (value === "") { if (value === "") {
items = self.options.autocomplete[self.placeholder]; // items = self.options.autocomplete[self.placeholder];
} else { } else {
$.each(self.options.autocomplete[self.placeholder], function(i, item) { $.each(self.options.autocomplete[self.placeholder], function(i, item) {
if (item.toLowerCase().indexOf(value) > -1) { if (item.toLowerCase().indexOf(value) > -1) {
@ -1699,11 +1703,12 @@ requires
} }
function cancel() { function cancel() {
that.$input.trigger("blur"); that.$input.blur();
} }
function clear() { function clear() {
that.$input.val(""); that.$input.val("").focus();
//call();
} }
function change() { function change() {
@ -1715,8 +1720,10 @@ requires
self.placeholder = data.value; // fixme: could be "title" as well self.placeholder = data.value; // fixme: could be "title" as well
if (that.$input.is(".OxPlaceholder")) { if (that.$input.is(".OxPlaceholder")) {
that.$input.val(self.placeholder); that.$input.val(self.placeholder);
} else {
that.$input.focus();
call();
} }
call();
} }
function blur() { function blur() {

View File

@ -398,8 +398,9 @@
clear: true, clear: true,
highlight: true, highlight: true,
id: "citystate", id: "citystate",
placeholder: ["City", "State"] placeholder: ["City", "State"],
}).addClass("margin").width(128).appendTo(mainPanel); selected: 1
}).addClass("margin").width(160).appendTo(mainPanel);
//*/ //*/
function switchTheme() { function switchTheme() {
if (Ox.theme() == "classic") { if (Ox.theme() == "classic") {