From 1fa8426eb270e5d6083eea6ddd7b007237a84e88 Mon Sep 17 00:00:00 2001 From: Rolux Date: Mon, 8 Feb 2010 15:47:00 +0530 Subject: [PATCH] fixing mainmenu bugs --- build/js/ox.ui.js | 92 +++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 31 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 61eaae5..cf737ce 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1872,35 +1872,46 @@ requires function mousemove(event) { var $target = $(event.target), - position = $target.data("position"); - if (self.focused && position != self.selected) { - clickTitle(position); + position = typeof $target.data("position") != "undefined" ? $target.data("position") : -1; + if (self.focused) { + if (self.focused && position != self.selected) { + clickTitle(position); + } } } function clickMenu() { - Ox.print("clickMenu!!") + Ox.print("self.selected", self.selected) that.titles[self.selected].removeClass("OxSelected"); self.selected = -1; self.focused = false; } function clickTitle(position) { - Ox.print("clickMenu", position) - var title = that.titles[position], - menu = that.menus[position]; - if (self.selected > -1) { - that.menus[self.selected].hideMenu(); - that.titles[self.selected].removeClass("OxSelected") - } - if (self.selected == position) { - self.focused = false; - self.selected = -1; + var menu, title; + if (position == -1) { + if (self.selected > -1) { + that.menus[self.selected].hideMenu(); + that.titles[self.selected].removeClass("OxSelected"); + self.selected = -1; + } } else { - self.focused = true; - self.selected = position; - that.titles[self.selected].addClass("OxSelected"); - that.menus[self.selected].showMenu(); + title = that.titles[position], + menu = that.menus[position]; + if (self.selected > -1) { + that.menus[self.selected].hideMenu(); + that.titles[self.selected].removeClass("OxSelected"); + } + if (self.selected == position) { + self.focused = false; + self.selected = -1; + } else { + Ox.print("pos", position) + self.focused = true; + self.selected = position; + that.titles[self.selected].addClass("OxSelected"); + that.menus[self.selected].showMenu(); + } } } @@ -1908,6 +1919,18 @@ requires }; + that.addMenuAfter = function() { + + }; + + that.addMenuBefore = function() { + + }; + + that.removeMenu = function() { + + }; + that.selectNextMenu = function() { if (self.selected < self.options.menus.length - 1) { clickTitle(self.selected + 1); @@ -2023,6 +2046,7 @@ requires function clickItem(position) { var item = that.items[position]; + Ox.print("clickItem", position, item.options("items").length) if (!item.options("items").length) { if (that.options("parent")) { that.options("parent").hideMenu().triggerEvent("click"); @@ -2040,6 +2064,7 @@ requires item.toggleTitle(); } } + closeMenu(); } function clickSelectedItem() { @@ -2050,6 +2075,11 @@ requires } } + function closeMenu() { + that.triggerEvent("click"); + that.hideMenu(); + } + function constructLine() { return $("").append( $("", { @@ -2309,6 +2339,14 @@ requires } + that.addItemAfter = function(item) { + + }; + + that.addItemBefore = function(item) { + + }; + that.hasEnabledItems = function() { var ret = false; $.each(that.items, function(i, item) { @@ -2347,6 +2385,10 @@ requires //that.triggerEvent("hide"); }; + that.removeItem = function() { + + }; + that.selectFirstItem = function() { selectNextItem(); }; @@ -2385,7 +2427,7 @@ requires key_down: selectNextItem, key_left: selectSupermenu, key_right: selectSubmenu, - key_escape: that.hideMenu, + key_escape: closeMenu, key_enter: clickSelectedItem }); setTimeout(function() { @@ -2503,18 +2545,6 @@ requires } } - that.insertItemAfter = function(item) { - - }; - - that.insertItemBefore = function(item) { - - }; - - that.removeItem = function() { - - }; - that.toggleChecked = function() { };