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
|
||||
@*/
|
||||
that.checkItem = function(id) {
|
||||
var ids = id.split('_'),
|
||||
itemId = ids.pop(),
|
||||
menuId = ids.join('_');
|
||||
that.getMenu(menuId).checkItem(itemId);
|
||||
var ids = id.split('_');
|
||||
that.getMenu(ids.shift()).checkItem(ids.join('_'));
|
||||
return that;
|
||||
};
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ Ox.Menu = function(options, self) {
|
|||
toggled;
|
||||
that.hideMenu();
|
||||
if (!item.options('items').length) {
|
||||
if (that.options('parent')) {
|
||||
that.options('parent').hideMenu().triggerEvent('click');
|
||||
if (self.options.parent) {
|
||||
self.options.parent.hideMenu(true).triggerEvent('click');
|
||||
}
|
||||
if (item.options('checked') !== null) {
|
||||
if (item.options('group')) {
|
||||
|
@ -551,19 +551,27 @@ Ox.Menu = function(options, self) {
|
|||
checkItem <f>
|
||||
@*/
|
||||
that.checkItem = function(id) {
|
||||
var item = that.getItem(id);
|
||||
if (item.options('group')) {
|
||||
var position = getItemPositionById(id),
|
||||
toggled = self.optionGroups[item.options('group')].toggle(position);
|
||||
if (toggled.length) {
|
||||
toggled.forEach(function(pos) {
|
||||
that.items[pos].toggleChecked();
|
||||
//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')) {
|
||||
var position = getItemPositionById(id),
|
||||
toggled = self.optionGroups[item.options('group')].toggle(position);
|
||||
if (toggled.length) {
|
||||
toggled.forEach(function(pos) {
|
||||
that.items[pos].toggleChecked();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
item.options({
|
||||
checked: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
item.options({
|
||||
checked: true
|
||||
});
|
||||
that.submenus[ids.shift()].checkItem(ids.join('_'));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -571,7 +579,7 @@ Ox.Menu = function(options, self) {
|
|||
getItem <f>
|
||||
@*/
|
||||
that.getItem = function(id) {
|
||||
//Ox.print('id', id)
|
||||
//Ox.print('getItem id', id)
|
||||
var ids = id.split('_'),
|
||||
item;
|
||||
if (ids.length == 1) {
|
||||
|
@ -625,7 +633,7 @@ Ox.Menu = function(options, self) {
|
|||
hideMenu <f>
|
||||
() -> <f> Menu Object
|
||||
@*/
|
||||
that.hideMenu = function() {
|
||||
that.hideMenu = function(hideParent) {
|
||||
if (that.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
@ -644,10 +652,9 @@ Ox.Menu = function(options, self) {
|
|||
self.options.parent.options({
|
||||
selected: -1
|
||||
});
|
||||
hideParent && self.options.parent.hideMenu(true);
|
||||
}
|
||||
that.hide()
|
||||
.loseFocus()
|
||||
.triggerEvent('hide');
|
||||
that.hide().loseFocus().triggerEvent('hide');
|
||||
that.$layer.hide();
|
||||
return that;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue