[IMP] decide whether to close the sidebar in a smarter way

pull/131/head
Holger Brunn 2015-05-01 17:57:51 +02:00
parent 2ae92c9212
commit 6289b681c8
1 changed files with 9 additions and 10 deletions

View File

@ -131,30 +131,29 @@ openerp.web_hide_menu = function(instance)
}, },
}); });
instance.web.Menu.include({ instance.web.Menu.include({
close_leftbar: false,
start: function() start: function()
{ {
this.on('menu_click', this, this.on_menu_click_with_action); this.on('menu_click', this, this.on_menu_click_with_action);
openerp.client.toggle_left_bar(false, openerp.client.hide_delay); openerp.client.toggle_left_bar(false, openerp.client.hide_delay);
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
}, },
on_top_menu_click: function() on_menu_click_with_action: function(menu, $element)
{ {
this.top_menu_click = true; //close if it's not a menu containing other menus
return this._super.apply(this, arguments); this.close_leftbar = (
}, $element.parents('#oe_main_menu_navbar').length == 0 &&
on_menu_click_with_action: function() $element.parent().children('ul').length == 0
{ );
this.close_menu = !this.top_menu_click;
this.top_menu_click = false;
}, },
open_menu: function() open_menu: function()
{ {
this._super.apply(this, arguments); this._super.apply(this, arguments);
if(this.close_menu) if(this.close_leftbar)
{ {
openerp.client.toggle_left_bar(false); openerp.client.toggle_left_bar(false);
} }
this.close_menu = false; this.close_leftbar = false;
}, },
}); });
} }