From db0af09c90279deeff16b34b43a282fba1193972 Mon Sep 17 00:00:00 2001 From: Rolux Date: Thu, 18 Feb 2010 20:12:53 +0530 Subject: [PATCH] autocomplete, continued --- build/js/ox.ui.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 10b55f0b..ae80941f 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -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,