summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-12-13 11:58:21 +0100
committerFabien Meghazi <fme@openerp.com>2012-12-13 11:58:21 +0100
commit5bf6176b43caacdae2eecf391959d37a346d35b0 (patch)
treee67a3bc9ef7b12cb020f2b7fe7a80b66d41ce003 /addons/web/static/src
parent96231a7ddbd228cbc8e27040c974771e84d57d49 (diff)
[WIP] relflow
bzr revid: fme@openerp.com-20121213105821-i2f5o693fyljpc9n
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js22
-rw-r--r--addons/web/static/src/xml/base.xml17
2 files changed, 29 insertions, 10 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 56af4c9d564..00cff06b139 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -804,6 +804,7 @@ instance.web.Menu = instance.web.Widget.extend({
this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
this.data = {data:{children:[]}};
this.on("menu_loaded", this, function (menu_data) {
+ self.reflow();
// launch the fetch of needaction counters, asynchronous
if (!_.isEmpty(menu_data.all_menu_ids)) {
this.rpc("/web/menu/load_needaction", {menu_ids: menu_data.all_menu_ids}).done(function(r) {
@@ -811,7 +812,6 @@ instance.web.Menu = instance.web.Widget.extend({
});
}
});
-
},
start: function() {
this._super.apply(this, arguments);
@@ -829,7 +829,6 @@ instance.web.Menu = instance.web.Widget.extend({
var self = this;
this.data = {data: data};
this.renderElement();
- this.limit_entries();
// Hide toplevel item if there is only one
var $toplevel = this.$("li");
if($toplevel.length == 1) {
@@ -856,6 +855,25 @@ instance.web.Menu = instance.web.Widget.extend({
}
});
},
+ reflow: function() {
+ var self = this;
+ var $more_container = $('.oe_menu_more_container');
+ var $more = $('.oe_menu_more');
+ $more.find('li').before($more_container);
+ var $li = this.$el.find('> li').not($more_container).hide();
+ var remaining_space = self.$el.parent().width();
+ remaining_space -= self.$el.parent().children(':visible').not(this.$el).width();
+ //debugger
+ $li.each(function() {
+ remaining_space -= self.$el.children(':visible').width();
+ if ($(this).width() > remaining_space) {
+ return false;
+ }
+ $(this).show();
+ });
+ $li.filter(':hidden').appendTo($more);
+ $more_container.toggle(!!$more.children().length);
+ },
limit_entries: function() {
var maximum_visible_links = this.maximum_visible_links;
if (maximum_visible_links === 'auto') {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 576f179854d..cfaf2a2dc4f 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -348,16 +348,17 @@
<li t-foreach="widget.data.data.children" t-as="menu">
<t t-call="Menu.link"/>
</li>
+ <li t-foreach="widget.data.data.children" t-as="menu">
+ <t t-call="Menu.link"/>
+ </li>
+ <li class="oe_menu_more_container">
+ <span class="oe_topbar_item oe_menu_more_link oe_dropdown_toggle oe_dropdown_arrow">
+ More
+ <ul class="oe_menu_more oe_dropdown_menu"/>
+ </span>
+ </li>
</ul>
</t>
-<t t-name="Menu.more">
- <li class="oe_menu_more_container">
- <span class="oe_topbar_item oe_menu_more_link oe_dropdown_toggle oe_dropdown_arrow">
- More
- <ul class="oe_menu_more oe_dropdown_menu"/>
- </span>
- </li>
-</t>
<t t-name="Menu.secondary">
<div t-foreach="widget.data.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">
<t t-foreach="menu.children" t-as="menu">