From 5c0de71eb3e90e903bf2c435963ab67bdf519707 Mon Sep 17 00:00:00 2001 From: Rolux Date: Mon, 8 Feb 2010 20:12:00 +0530 Subject: [PATCH] some changes to events --- build/css/ox.ui.classic.css | 9 +++++++-- build/css/ox.ui.css | 2 ++ build/js/ox.ui.js | 35 +++++++++++++++++++---------------- demos/test/index.html | 4 ++-- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/build/css/ox.ui.classic.css b/build/css/ox.ui.classic.css index 3027165..5aaf4c3 100644 --- a/build/css/ox.ui.classic.css +++ b/build/css/ox.ui.classic.css @@ -17,6 +17,11 @@ Bars //background: -moz-linear-gradient(left top, left bottom, from(rgb(224, 224, 224)), to(rgb(192, 192, 192))); //background: -webkit-gradient(linear, left top, left bottom, from(rgb(224, 224, 224)), to(rgb(192, 192, 192))); } +.OxThemeClassic .OxBar.OxMainMenu { + background: -moz-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192)); + background: -webkit-gradient(linear, left top, left bottom, from(rgb(224, 224, 224)), to(rgb(192, 192, 192))); +} + /* ================================================================================ @@ -101,8 +106,8 @@ Menus */ .OxThemeClassic .OxMainMenu > .OxTitle.OxSelected { - background: -moz-linear-gradient(top, rgb(176, 176, 176), rgb(144, 144, 144)); - background: -webkit-gradient(linear, left top, left bottom, from(rgb(176, 176, 176)), to(rgb(144, 144, 144))); + background: -moz-linear-gradient(top, rgb(208, 208, 208), rgb(176, 176, 176)); + background: -webkit-gradient(linear, left top, left bottom, from(rgb(208, 208, 208)), to(rgb(176, 176, 176))); } .OxThemeClassic .OxMenu { diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index 0210927..f296630 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -391,6 +391,8 @@ Menus -moz-border-radius-bottomright: 4px; -webkit-border-bottom-left-radius: 4px; -webkit-border-bottom-right-radius: 4px; + -moz-user-select: none; + -webkit-user-select: none; } .OxMenu.OxRight { -moz-border-radius-topright: 4px; diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 19bc7c8..47ba5fe 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -907,10 +907,10 @@ requires */ if (Ox.isObject(arguments[0])) { $.each(arguments[0], function(event, fn) { - Ox.Event.trigger(event + "_" + that.id, fn); + Ox.Event.trigger(event + "_" + self.options.id, fn); }); } else { - Ox.Event.trigger(arguments[0] + "_" + that.id, arguments[1] || {}); + Ox.Event.trigger(arguments[0] + "_" + self.options.id, arguments[1] || {}); } return that; } @@ -1746,8 +1746,9 @@ requires size: "medium" }) .options(options) - .addClass("OxSelect Ox" + Ox.toTitleCase(self.options.size)), - selected; + .addClass("OxSelect Ox" + Ox.toTitleCase(self.options.size)); + self.buttonId = self.options.id + "_button" + self.menuId = self.options.id + "_menu", $.each(self.options.items, function(i, item) { self.options.items[i] = $.extend(self.options.items[i], { @@ -1755,14 +1756,14 @@ requires group: self.options.id, }); if (item.checked) { - selected = i; + self.selected = i; } }); that.$button = new Ox.Button($.extend(self.options, { - id: self.options.id, + id: self.buttonId, type: "text", // fixme: this shouldn't be necessary - value: self.options.items[selected].title + value: self.options.items[self.selected].title }), {}) .click(clickButton) .appendTo(that); @@ -1778,7 +1779,7 @@ requires that.$menu = new Ox.Menu({ element: that.$button, - id: self.options.id, + id: self.menuId, items: self.options.items, offset: { left: 8, @@ -1788,11 +1789,11 @@ requires size: self.options.size }); - that.bindEvent("change_" + that.$button.id, changeButton); - that.bindEvent("click_" + that.$menu.id, clickMenu); + that.bindEvent("change_" + self.buttonId, changeButton); + that.bindEvent("click_" + self.menuId + "_menu", clickMenu); function changeButton(event, data) { - that.triggerEvent("change_" + that.id, data); + that.triggerEvent("change", data); } function clickButton() { @@ -1846,6 +1847,7 @@ requires that.menus = []; $.each(options.menus, function(position, menu) { + var event = that.titles[position] = $("
") .addClass("OxTitle") .html(menu.title) @@ -1856,8 +1858,7 @@ requires mainmenu: that, size: self.options.size })); - Ox.print("binding", "click_" + that.menus[position].id) - that.bindEvent("click_" + that.menus[position].id, clickMenu); + that.bindEvent("click_" + that.menus[position].options("id"), clickMenu); }); function click(event) { @@ -2040,9 +2041,12 @@ requires Ox.print("...", position, item) if (!item.options("disabled")) { clickItem(position); + } else { + that.triggerEvent("click"); } + } else { + that.triggerEvent("click"); } - that.triggerEvent("click"); } function clickItem(position) { @@ -2056,8 +2060,7 @@ requires item.options({ checked: !item.options("checked") }); - Ox.Event.trigger("click_" + that.id, { - id: item.options("id"), + Ox.Event.trigger("click_" + item.options("id"), { value: item.options("title")[0] // fixme: value or title? }); } diff --git a/demos/test/index.html b/demos/test/index.html index 2caf3ff..eef2fb4 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -63,7 +63,7 @@ menus: [ { id: "oxjs", - title: "Ox.js", + title: "Oxjs", items: [ { id: "about", title: "About" }, {}, @@ -76,7 +76,7 @@ items: [ { id: "load", keyboard: "control o", title: "Open" }, { id: "save", keyboard: "control a", title: "Save" }, - { id: "save_ad", keyboard: "shift control s", title: "Save As..."} + { id: "save_as", keyboard: "shift control s", title: "Save As..."} ] }, {