From 744be5db04bfccdf8d6745a4a3a253b2b95034de Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 19 Sep 2011 17:59:43 +0200 Subject: [PATCH] [ADD] Float menu (WIP) bzr revid: fme@openerp.com-20110919155943-fdx57kbr0q9a2ywe --- addons/web/static/src/css/base.css | 25 +++++++++++++++++++++---- addons/web/static/src/js/chrome.js | 17 +++++++++++++++-- addons/web/static/src/xml/base.xml | 18 ++++++++++++------ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 8ef299f9e1d..47bdacb02cb 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -288,11 +288,10 @@ label.error { color: #fff; } /* Secondary Menu */ -.openerp .oe_toggle_secondary_menu { +.openerp .secondary_menu .oe_toggle_secondary_menu { position: absolute; cursor: pointer; border-left: 1px solid #282828; - border-bottom: 1px solid #282828; width: 21px; height: 21px; left: 177px; @@ -304,10 +303,17 @@ label.error { font-size: 18px; line-height: 14px; } -.openerp .oe_toggle_secondary_menu.folded span.oe_menu_fold { +.openerp .secondary_menu.oe_folded .oe_toggle_secondary_menu { + position: initial; + border-left: none; + border-bottom: 1px solid #282828; + width: 21px; + height: 21px; +} +.openerp .secondary_menu.oe_folded .oe_toggle_secondary_menu span.oe_menu_fold { display: none; } -.openerp .oe_toggle_secondary_menu.unfolded span.oe_menu_unfold { +.openerp .secondary_menu.oe_unfolded .oe_toggle_secondary_menu span.oe_menu_unfold { display: none; } .openerp .secondary_menu { @@ -319,6 +325,17 @@ label.error { vertical-align: top; height: 100%; } +.openerp .secondary_menu.oe_folded { + width: 20px; + min-width: 20px; +} +.openerp .secondary_menu.oe_folded .oe_secondary_menu.active { + position: absolute; + background: #5A5858; + z-index: 100; + border: 2px solid white; + border-radius: 5px; +} .openerp .secondary_menu a { display: block; padding: 0 5px 2px 5px; diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index cfe4b02fb20..2f5e8e4427f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -779,6 +779,7 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ this.folded = false; }, start: function() { + this.$secondary_menu.addClass(this.folded ? 'oe_folded' : 'oe_unfolded'); this.rpc("/web/menu/load", {}, this.on_loaded); }, on_loaded: function(data) { @@ -789,6 +790,7 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ this.$secondary_menu.find('.oe_toggle_secondary_menu').click(this.on_toggle_fold); }, on_toggle_fold: function() { + this.$secondary_menu.toggleClass('oe_folded').toggleClass('oe_unfolded'); if (this.folded) { this.$secondary_menu.find('.oe_secondary_menu.active').show(); } else { @@ -796,12 +798,20 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ } this.folded = !this.folded; }, + do_show_secondary: function($secondary, $menu) { + if (this.folded) { + var css = $menu.position(); + $secondary.css(css); + } + $secondary.show(); + }, on_menu_click: function(ev, id) { id = id || 0; - var $menu, $parent, $secondary; + var $menu, $parent, $secondary, manual = false; if (id) { // We can manually activate a menu with it's id (for hash url mapping) + manual = true; $menu = this.$element.find('a[data-menu=' + id + ']'); if (!$menu.length) { $menu = this.$secondary_menu.find('a[data-menu=' + id + ']'); @@ -819,7 +829,6 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ } this.$secondary_menu.find('.oe_secondary_menu').hide().removeClass('active'); - $secondary.show(); if (id) { this.session.active_id = id; @@ -832,6 +841,10 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ $menu.addClass('active'); $secondary.addClass('active'); + if (!(this.folded && manual)) { + this.do_show_secondary($secondary, $menu, manual); + } + if (this.$secondary_menu.has($menu).length) { if ($menu.is('.submenu')) { //this.$secondary_menu.find('.submenu').removeClass('opened').next().hide(); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 28c0a7508ff..6d1ed16091e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -38,11 +38,17 @@ - - - -
-
+ + + + + + +
+ +
+
+
@@ -384,7 +390,7 @@ -
+
« »