improving labels and placeholders

This commit is contained in:
Rolux 2010-02-20 16:35:58 +05:30
parent 26cb4b5c15
commit 5a96969efd

View file

@ -1700,7 +1700,6 @@ requires
self.options.type == "textarea" ? "textarea" : "input", self
)
.attr({
placeholder: self.placeholder,
type: self.options.type == "textarea" ? null : self.options.type
})
.addClass(
@ -1712,6 +1711,8 @@ requires
.change(change)
.appendTo(that);
self.options.placeholder && that.$input.val(self.option);
if (self.options.clear) {
that.$clear = new Ox.Button({
style: "symbol",
@ -1759,9 +1760,21 @@ requires
callback(items);
}
function blur() {
that.loseFocus();
if (self.options.placeholder && that.$input.val() === "") {
that.$input.addClass("OxPlaceholder").val(self.option);
}
if (self.options.autocomplete) {
$document.unbind("keydown", keypress);
$document.unbind("keypress", keypress);
}
}
function call() {
var value = that.$input.val();
if (self.options.autocomplete) {
//Ox.print("###", self.option, value, callback)
Ox.isFunction(self.options.autocomplete) ? (
self.option ?
self.options.autocomplete(self.option, value, callback) :
@ -1800,21 +1813,15 @@ requires
that.$input.blur();
}
function clear() {
that.$input.val("").focus();
//call();
}
function change(event, data) {
self.option = data.value; // fixme: could be "title" as well
if (self.options.label) {
self.label = data.value; // fixme: could be "title" as well
that.$label.html(self.label);
that.$label.html(self.option);
that.$input.focus();
call();
} else {
self.placeholder = data.value; // fixme: could be "title" as well
if (that.$input.is(".OxPlaceholder")) {
that.$input.val(self.placeholder);
that.$input.val(self.option);
//that.$input.focus();
} else {
that.$input.focus();
@ -1823,15 +1830,9 @@ requires
}
}
function blur() {
that.loseFocus();
if (that.$input.val() === "") {
that.$input.addClass("OxPlaceholder").val(that.$input.attr("placeholder"));
}
if (self.options.autocomplete) {
$document.unbind("keydown", keypress);
$document.unbind("keypress", keypress);
}
function clear() {
that.$input.val("").focus();
//call();
}
function focus() {