1
0
Fork 0
forked from 0x2620/oxjs

some redesign for better garbage collection of elements

This commit is contained in:
j 2011-11-04 22:14:30 +00:00
commit 1d09d19423
17 changed files with 129 additions and 101 deletions

View file

@ -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) {

View file

@ -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
@*/

View file

@ -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)