1
0
Fork 0
forked from 0x2620/oxjs

add unified Ox.Layer object for dialogs and menus

This commit is contained in:
rlx 2011-11-01 14:16:27 +00:00
commit 1720d2a184
5 changed files with 73 additions and 51 deletions

View file

@ -88,9 +88,6 @@ Ox.Menu = function(options, self) {
that.$bottom = $('<div>')
.addClass('OxBottom')
.appendTo(that.$element);
that.$layer = $('<div>')
.addClass(self.options.mainmenu ? 'OxMainMenuLayer' : 'OxMenuLayer')
.click(click);
function click(event) {
var item,
@ -161,6 +158,10 @@ Ox.Menu = function(options, self) {
}
}
function clickLayer() {
that.hideMenu();
}
function clickSelectedItem() {
// called on key.enter
if (self.options.selected > -1) {
@ -654,8 +655,8 @@ Ox.Menu = function(options, self) {
});
hideParent && self.options.parent.hideMenu(true);
}
that.$layer && that.$layer.hide();
that.hide().loseFocus().triggerEvent('hide');
that.$layer.hide();
return that;
};
@ -681,9 +682,6 @@ Ox.Menu = function(options, self) {
if (!that.is(':hidden')) {
return;
}
if (!self.options.parent && !that.$layer.parent().length) {
that.$layer.appendTo(Ox.UI.$body);
}
that.parent().length == 0 && that.appendTo(Ox.UI.$body);
that.css({
left: '-1000px',
@ -717,8 +715,11 @@ Ox.Menu = function(options, self) {
}
if (!self.options.parent) {
that.gainFocus();
that.$layer = Ox.Layer({type: 'menu'})
.css({top: self.options.mainmenu ? '20px' : 0})
.bindEvent({click: clickLayer})
.show();
}
that.$layer.show();
return that;
//that.triggerEvent('show');
};