diff --git a/build/css/ox.ui.classic.css b/build/css/ox.ui.classic.css index f13fe136..3027165a 100644 --- a/build/css/ox.ui.classic.css +++ b/build/css/ox.ui.classic.css @@ -100,6 +100,11 @@ 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))); +} + .OxThemeClassic .OxMenu { -moz-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.75); -webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.75); diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index 570a4372..09b2c63f 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -334,6 +334,53 @@ Menus ================================================================================ */ +.OxMainMenu { + z-index: 10; + -moz-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.75); + -webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.75); +} +.OxMainMenu.OxLarge { + height: 24px; + padding-left: 8px; +} +.OxMainMenu.OxMedium { + height: 20px; + padding-left: 6px; +} +.OxMainMenu.OxSmall { + height: 16px; + padding-left: 4px; +} +.OxMainMenu > .OxTitle { + float: left; + cursor: default; +} +.OxMainMenu.OxLarge > .OxTitle { + height: 21px; + padding-left: 8px; + padding-right: 8px; + padding-top: 3px; + font-size: 14px; +} +.OxMainMenu.OxMedium > .OxTitle { + height: 17px; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + font-size: 11px; +} +.OxMainMenu.OxSmall > .OxTitle { + height: 14px; + padding-left: 4px; + padding-right: 4px; + padding-top: 2px; + font-size: 9px; +} +.OxMainMenu .OxTitle.OxSelected { + background: rgb(48, 48, 48); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(80, 80, 80)), color-stop(1, rgb(48, 48, 48))); +} + .OxMenu { position: absolute; display: none; diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index e3b3df88..5e7926eb 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -799,7 +799,7 @@ requires ret = that.$element[v](args[0], args[1], args[2], args[3]); } if (v == "data") { - Ox.print("data ret", ret, $(ret)) + // Ox.print("data ret", ret, $(ret)) } // if the $element of an ox object was returned // then return the ox object instead @@ -905,12 +905,12 @@ requires /* triggerEvent(event, fn) or triggerEvent({event0: fn0, event1: fn1, ...}) */ - if (arguments.length == 1) { + if (Ox.isObject(arguments[0])) { $.each(arguments[0], function(event, fn) { - Ox.Event.trigger(event + "." + that.id, fn); + Ox.Event.trigger(event + "_" + that.id, fn); }); } else { - Ox.Event.trigger(arguments[0] + "." + that.id, arguments[1]); + Ox.Event.trigger(arguments[0] + "_" + that.id, arguments[1] || {}); } return that; } @@ -1162,15 +1162,14 @@ requires .options(options || {}) .addClass("OxTabbar"); - (function() { - Ox.ButtonGroup({ - selectable: true, - selected: self.options.selected, - size: "medium", - style: "tab", - values: self.options.values - }).appendTo(that); - })(); + Ox.ButtonGroup({ + group: true, + selectable: true, + selected: self.options.selected, + size: "medium", + style: "tab", + values: self.options.values + }).appendTo(that); return that; @@ -1308,10 +1307,8 @@ requires var self = self || {}, that = new Ox.Element("input", self) .defaults({ - buttonId: null, - //click: function() {}, disabled: false, - groupId: null, + group: false, selectable: false, selected: false, size: "medium", @@ -1362,10 +1359,9 @@ requires } } function click() { - if (self.options.selectable && !(self.options.groupId !== null && self.options.selected)) { + if (self.options.selectable && !(self.options.group && self.options.selected)) { that.toggleSelected(); } - Ox.print(self.options); if (self.options.values.length == 2) { Ox.print("2 values") that.options({ @@ -1379,9 +1375,10 @@ requires //Ox.print("setOption", option, value) Ox.print("OxButton onChange", key, value) if (key == "selected") { - if (value != that.hasClass("OxSelected")) { + if (value != that.hasClass("OxSelected")) { // fixme: neccessary? that.toggleClass("OxSelected"); } + that.triggerEvent(value ? "select" : "deselect", {}); } else if (key == "value") { Ox.print("OxButton onChange value", value) if (self.options.type == "image") { @@ -1391,7 +1388,7 @@ requires }); } else { that.val(value); - Ox.Event.trigger("change." + that.id, { + that.triggerEvent("change", { value: value }); } @@ -1406,7 +1403,6 @@ requires that.options({ selected: !self.options.selected }); - that.trigger("OxButtonToggle", self.options); } that.options("value", self.options.value); return that; @@ -1419,10 +1415,11 @@ requires */ Ox.ButtonGroup = function(options, self) { + var self = self || {}, that = new Ox.Element({}, self) .defaults({ - groupId: Ox.uid(), + group: false, selectable: false, selected: -1, size: "medium", @@ -1432,31 +1429,37 @@ requires }) .options(options || {}) .addClass("OxButtonGroup"); - (function() { - that.$buttons = []; - $.each(self.options.values, function(i, v) { - that.$buttons[i] = Ox.Button({ - buttonId: i, - groupId: self.options.groupId, - selectable: self.options.selectable, - selected: i == self.options.selected, - size: self.options.size, - style: self.options.style, - type: self.options.type, - value: v - }).appendTo(that); + self.position = {}; + + that.$buttons = []; + $.each(self.options.values, function(position, value) { + that.$buttons[position] = Ox.Button({ + group: self.options.group, + selectable: self.options.selectable, + selected: position == self.options.selected, + size: self.options.size, + style: self.options.style, + type: self.options.type, + value: value + }).appendTo(that); + self.position[that.$buttons.id] = position; + Ox.print("binding", "select_" + that.$buttons[position].id); + that.bindEvent("select_" + that.$buttons[position].id, select); + }); + + function select(event, data) { + console.log("event", event, "data", data) + var id = event.split("_")[1]; + Ox.print("OK") + if (self.options.selected > -1) { + that.$buttons[self.options.selected].toggleSelected(); + } + self.options.selected = self.position[id]; + that.triggerEvent("change", { + value: id }); - that.$element.bind("OxButtonToggle", function(e, data) { - if (data.groupId = self.options.groupId) { - if (data.selected) { - if (self.options.selected > -1) { - that.$buttons[self.options.selected].toggleSelected(); - } - self.options.selected = data.buttonId; - } - } - }); - })(); + } + return that; }; @@ -1785,11 +1788,11 @@ requires size: self.options.size }); - that.bindEvent("change." + that.$button.id, changeButton); - that.bindEvent("click." + that.$menu.id, clickMenu); + that.bindEvent("change_" + that.$button.id, changeButton); + that.bindEvent("click_" + that.$menu.id, clickMenu); function changeButton(event, data) { - that.triggerEvent("change." + that.id, data); + that.triggerEvent("change_" + that.id, data); } function clickButton() { @@ -1828,9 +1831,98 @@ requires var self = self || {}, that = new Ox.Bar({}, self) - .options + .defaults({ + menus: [], + size: "medium" + }) + .options(options || {}) + .addClass("OxMainMenu Ox" + Ox.toTitleCase(self.options.size)) // fixme: bar should accept small/medium/large + .click(click) + .mousemove(mousemove); - } + self.focused = false; + self.selected = -1; + that.titles = []; + that.menus = []; + + $.each(options.menus, function(position, menu) { + that.titles[position] = $("