Ox.Menu: fix super binding, cosmetic changes

This commit is contained in:
rlx 2014-09-22 16:03:25 +02:00
parent 53e2126ec2
commit 498c5effa2

View file

@ -327,15 +327,17 @@ Ox.Menu = function(options, self) {
items.forEach(function(item) { items.forEach(function(item) {
var position; var position;
if ('id' in item) { if ('id' in item) {
position = that.items.length;
that.items.push( that.items.push(
Ox.MenuItem(Ox.extend(Ox.clone(item), { Ox.MenuItem(Ox.extend(Ox.clone(item), {
maxWidth: self.options.maxWidth, maxWidth: self.options.maxWidth,
menu: that, menu: that,
position: position = that.items.length position: position
})) }))
.data('position', position) .data('position', position)
// fixme: jquery bug when passing {position: position}? does not return the object?
.appendTo(that.$content) .appendTo(that.$content)
); // fixme: jquery bug when passing {position: position}? does not return the object?; );
if (item.items) { if (item.items) {
that.submenus[item.id] = Ox.Menu({ that.submenus[item.id] = Ox.Menu({
edge: 'right', edge: 'right',
@ -343,10 +345,7 @@ Ox.Menu = function(options, self) {
id: Ox.toCamelCase(self.options.id + '/' + item.id), id: Ox.toCamelCase(self.options.id + '/' + item.id),
items: item.items, items: item.items,
mainmenu: self.options.mainmenu, mainmenu: self.options.mainmenu,
offset: { offset: {left: 0, top: -4},
left: 0,
top: -4
},
parent: that, parent: that,
size: self.options.size size: self.options.size
}); });
@ -367,10 +366,7 @@ Ox.Menu = function(options, self) {
function renderLine() { function renderLine() {
return $('<tr>').append( return $('<tr>').append(
$('<td>', { $('<td>').addClass('OxLine').attr({colspan: 5})
'class': 'OxLine',
colspan: 5
})
); );
} }
@ -419,7 +415,7 @@ Ox.Menu = function(options, self) {
function renderSpace() { function renderSpace() {
return $('<tr>').append( return $('<tr>').append(
$('<td>', {'class': 'OxSpace', colspan: 5}) $('<td>').addClass('OxSpace').attr({colspan: 5})
); );
} }
@ -747,7 +743,7 @@ Ox.Menu = function(options, self) {
remove <f> remove remove <f> remove
() -> <o> remove menu () -> <o> remove menu
@*/ @*/
self.superRemove = that.remove; self.superRemove = that.remove.bind(that);
that.remove = function() { that.remove = function() {
Ox.forEach(that.submenus, function(submenu) { Ox.forEach(that.submenus, function(submenu) {
submenu.remove(); submenu.remove();