fix bugs with deeply nested menus
This commit is contained in:
parent
e11a8e3a78
commit
ff0b83fa89
2 changed files with 26 additions and 21 deletions
|
@ -138,10 +138,8 @@ Ox.MainMenu = function(options, self) {
|
||||||
checkItem <f> checkItem
|
checkItem <f> checkItem
|
||||||
@*/
|
@*/
|
||||||
that.checkItem = function(id) {
|
that.checkItem = function(id) {
|
||||||
var ids = id.split('_'),
|
var ids = id.split('_');
|
||||||
itemId = ids.pop(),
|
that.getMenu(ids.shift()).checkItem(ids.join('_'));
|
||||||
menuId = ids.join('_');
|
|
||||||
that.getMenu(menuId).checkItem(itemId);
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,8 @@ Ox.Menu = function(options, self) {
|
||||||
toggled;
|
toggled;
|
||||||
that.hideMenu();
|
that.hideMenu();
|
||||||
if (!item.options('items').length) {
|
if (!item.options('items').length) {
|
||||||
if (that.options('parent')) {
|
if (self.options.parent) {
|
||||||
that.options('parent').hideMenu().triggerEvent('click');
|
self.options.parent.hideMenu(true).triggerEvent('click');
|
||||||
}
|
}
|
||||||
if (item.options('checked') !== null) {
|
if (item.options('checked') !== null) {
|
||||||
if (item.options('group')) {
|
if (item.options('group')) {
|
||||||
|
@ -551,7 +551,12 @@ Ox.Menu = function(options, self) {
|
||||||
checkItem <f>
|
checkItem <f>
|
||||||
@*/
|
@*/
|
||||||
that.checkItem = function(id) {
|
that.checkItem = function(id) {
|
||||||
var item = that.getItem(id);
|
//Ox.print('checkItem id', id)
|
||||||
|
var ids = id.split('_'),
|
||||||
|
item;
|
||||||
|
if (ids.length == 1) {
|
||||||
|
item = that.getItem(id);
|
||||||
|
Ox.print('checkItem', id, item, that.submenus)
|
||||||
if (item.options('group')) {
|
if (item.options('group')) {
|
||||||
var position = getItemPositionById(id),
|
var position = getItemPositionById(id),
|
||||||
toggled = self.optionGroups[item.options('group')].toggle(position);
|
toggled = self.optionGroups[item.options('group')].toggle(position);
|
||||||
|
@ -565,13 +570,16 @@ Ox.Menu = function(options, self) {
|
||||||
checked: true
|
checked: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
that.submenus[ids.shift()].checkItem(ids.join('_'));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
getItem <f>
|
getItem <f>
|
||||||
@*/
|
@*/
|
||||||
that.getItem = function(id) {
|
that.getItem = function(id) {
|
||||||
//Ox.print('id', id)
|
//Ox.print('getItem id', id)
|
||||||
var ids = id.split('_'),
|
var ids = id.split('_'),
|
||||||
item;
|
item;
|
||||||
if (ids.length == 1) {
|
if (ids.length == 1) {
|
||||||
|
@ -625,7 +633,7 @@ Ox.Menu = function(options, self) {
|
||||||
hideMenu <f>
|
hideMenu <f>
|
||||||
() -> <f> Menu Object
|
() -> <f> Menu Object
|
||||||
@*/
|
@*/
|
||||||
that.hideMenu = function() {
|
that.hideMenu = function(hideParent) {
|
||||||
if (that.is(':hidden')) {
|
if (that.is(':hidden')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -644,10 +652,9 @@ Ox.Menu = function(options, self) {
|
||||||
self.options.parent.options({
|
self.options.parent.options({
|
||||||
selected: -1
|
selected: -1
|
||||||
});
|
});
|
||||||
|
hideParent && self.options.parent.hideMenu(true);
|
||||||
}
|
}
|
||||||
that.hide()
|
that.hide().loseFocus().triggerEvent('hide');
|
||||||
.loseFocus()
|
|
||||||
.triggerEvent('hide');
|
|
||||||
that.$layer.hide();
|
that.$layer.hide();
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue