autocomplete, continued

This commit is contained in:
Rolux 2010-02-18 20:12:53 +05:30
parent 966359bf99
commit db0af09c90

View file

@ -1625,6 +1625,11 @@ requires
}
}
}, 50);
/*
if (event.keyCode == 38 || event.keyCode == 40) {
return false;
}
*/
}
function onClick(event, data) {
Ox.print("onClick", data)
@ -1632,7 +1637,7 @@ requires
self.menu.hideMenu();
}
function onDeselect(event, data) {
that.val("");
that.val(self.value);
}
function onSelect(event, data) {
self.value = that.val().substr(0, selection()[0]);
@ -2623,38 +2628,46 @@ requires
};
that.showMenu = function() {
Ox.print("showMenu")
Ox.print("showMenu");
if (!self.options.parent && !that.$layer.parent().length) {
that.$layer.appendTo($body);
}
that.parent().length || that.appendTo($body);
that.css({
left: "-1000px",
top: "-1000px",
}).show();
var offset = self.options.element.offset(),
width = self.options.element.outerWidth(),
height = self.options.element.outerHeight(),
left = offset.left + self.options.offset.left + (self.options.side == "bottom" ? 0 : width),
top = offset.top + self.options.offset.top + (self.options.side == "bottom" ? height : 0),
menuHeight = that.$content.outerHeight();
menuHeight = that.$content.outerHeight(); // fixme: why is outerHeight 0 when hidden?
menuMaxHeight = Math.floor($window.height() - top - 16),
Ox.print("menuHeight", menuHeight, "menuMaxHeight", menuMaxHeight);
Ox.print("menuHeight", menuHeight, "menuMaxHeight", menuMaxHeight, that.items.length);
if (self.options.parent) {
if (menuHeight > menuMaxHeight) {
top = Ox.limit(top - menuHeight + menuMaxHeight, self.options.parent.offset().top, top);
menuMaxHeight = Math.floor($window.height() - top - 16);
}
}
/*
that.css({
left: left + "px",
top: top + "px"
}).show();
*/
that.css({
left: left + "px",
top: top + "px"
});
if (menuHeight > menuMaxHeight) {
that.$container.height(menuMaxHeight - itemHeight - 8); // margin
that.$scrollbars.down.show();
} else {
that.$container.height(menuHeight);
}
if (!self.options.parent) {
that.gainFocus();
}
!self.options.parent && that.gainFocus();
that.bindEvent({
key_up: selectPreviousItem,
key_down: selectNextItem,