forked from 0x2620/oxjs
some redesign for better garbage collection of elements
This commit is contained in:
parent
01f02d9730
commit
1d09d19423
17 changed files with 129 additions and 101 deletions
|
|
@ -119,7 +119,7 @@ Ox.MainMenu = function(options, self) {
|
|||
|
||||
function removeMenu(position) {
|
||||
that.titles[position].remove();
|
||||
that.menus[position].removeElement();
|
||||
that.menus[position].remove();
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
|
|
|
|||
|
|
@ -200,11 +200,15 @@ Ox.Menu = function(options, self) {
|
|||
items.forEach(function(item) {
|
||||
var position;
|
||||
if ('id' in item) {
|
||||
that.items.push(Ox.MenuItem(Ox.extend(item, {
|
||||
maxWidth: self.options.maxWidth,
|
||||
menu: that,
|
||||
position: position = that.items.length
|
||||
})).data('position', position).appendTo(that.$content)); // fixme: jquery bug when passing {position: position}? does not return the object?;
|
||||
that.items.push(
|
||||
Ox.MenuItem(Ox.extend(item, {
|
||||
maxWidth: self.options.maxWidth,
|
||||
menu: that,
|
||||
position: position = that.items.length
|
||||
}))
|
||||
.data('position', position)
|
||||
.appendTo(that.$content)
|
||||
); // fixme: jquery bug when passing {position: position}? does not return the object?;
|
||||
if (item.items) {
|
||||
that.submenus[item.id] = Ox.Menu({
|
||||
element: that.items[position],
|
||||
|
|
@ -665,6 +669,14 @@ Ox.Menu = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
self.superRemove = that.remove;
|
||||
that.remove = function() {
|
||||
Ox.forEach(that.submenus, function(submenu) {
|
||||
submenu.remove();
|
||||
});
|
||||
self.superRemove();
|
||||
};
|
||||
|
||||
/*@
|
||||
removeItem <f> removeItem
|
||||
@*/
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Ox.MenuItem = function(options, self) {
|
|||
keyboard: parseKeyboard(options.keyboard || self.defaults.keyboard),
|
||||
title: Ox.toArray(options.title || self.defaults.title)
|
||||
}))
|
||||
.addClass('OxItem' + (self.options.disabled ? ' OxDisabled' : ''))
|
||||
.addClass('OxItem' + (self.options.disabled ? ' OxDisabled' : '') + ' MENUITEM')
|
||||
/*
|
||||
.attr({
|
||||
id: Ox.toCamelCase(self.options.menu.options('id') + '/' + self.options.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue