From e8c225a8799361427d7f34107a7953b56661df11 Mon Sep 17 00:00:00 2001 From: Rolux Date: Sun, 7 Feb 2010 20:42:14 +0530 Subject: [PATCH] fix for enter key --- build/js/ox.ui.js | 50 ++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index b08eebc..e3b3df8 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1914,36 +1914,42 @@ requires function click(event) { var item, + position, $target = $(event.target); that.hideMenu(); if ($target.is(".OxCell")) { - item = that.items[$target.parent().data("position")]; + position = $target.parent().data("position"); + item = that.items[position]; if (!item.options("disabled")) { - if (that.options("parent")) { - that.options("parent").hideMenu(); - } - if (!item.options("items").length) { - if (item.options("checked") !== null && (!item.options("group") || !item.options("checked"))) { - item.options({ - checked: !item.options("checked") - }); - Ox.Event.trigger("click." + that.id, { - id: item.options("id"), - value: item.options("title")[0] // fixme: value or title? - }); - } - if (item.options("title").length == 2) { - item.toggleTitle(); - } - } + clickItem(position); } } } - function clickItem() { - // called on key.enter + function clickItem(position) { + var item = that.items[position]; + if (that.options("parent")) { + that.options("parent").hideMenu(); + } + if (!item.options("items").length) { + if (item.options("checked") !== null && (!item.options("group") || !item.options("checked"))) { + item.options({ + checked: !item.options("checked") + }); + Ox.Event.trigger("click." + that.id, { + id: item.options("id"), + value: item.options("title")[0] // fixme: value or title? + }); + } + if (item.options("title").length == 2) { + item.toggleTitle(); + } + } + } + + function clickSelectedItem() { if (self.options.selected > -1) { - that.items[self.options.selected].trigger("click"); + clickItem(self.options.selected); } else { that.hideMenu(); } @@ -2279,7 +2285,7 @@ requires key_left: selectSupermenu, key_right: selectSubmenu, key_escape: that.hideMenu, - key_enter: clickItem + key_enter: clickSelectedItem }); setTimeout(function() { $document.bind("click", click);