From 26dcbd7b09c11799eb1592f669e3c6c7c1c56807 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 1 May 2015 17:11:21 +0200 Subject: [PATCH] [ADD] web_hide_menu --- web_hide_menu/README.rst | 45 +++++ web_hide_menu/__init__.py | 20 +++ web_hide_menu/__openerp__.py | 41 +++++ web_hide_menu/data/ir_config_parameter.xml | 13 ++ web_hide_menu/static/description/icon.png | Bin 0 -> 3386 bytes .../static/src/css/web_hide_menu.css | 24 +++ web_hide_menu/static/src/js/web_hide_menu.js | 160 ++++++++++++++++++ web_hide_menu/views/templates.xml | 11 ++ 8 files changed, 314 insertions(+) create mode 100644 web_hide_menu/README.rst create mode 100644 web_hide_menu/__init__.py create mode 100644 web_hide_menu/__openerp__.py create mode 100644 web_hide_menu/data/ir_config_parameter.xml create mode 100644 web_hide_menu/static/description/icon.png create mode 100644 web_hide_menu/static/src/css/web_hide_menu.css create mode 100644 web_hide_menu/static/src/js/web_hide_menu.js create mode 100644 web_hide_menu/views/templates.xml diff --git a/web_hide_menu/README.rst b/web_hide_menu/README.rst new file mode 100644 index 00000000..d8b7dbad --- /dev/null +++ b/web_hide_menu/README.rst @@ -0,0 +1,45 @@ +Hide menus +========== + +This addon hides the top menu bar and the left menu bar. They become visible again when you move the mouse towards the border of the screen (the distance is configurable). Moving the mouse out of a menu causes it to disappear after a configurable delay. + +Configuration +============= + +To configure this module, you need to: + +* go to Settings / Technical / Parameters / System Parameters +* adjust `web_hide_menu.show_bar_treshold` to set the distance in pixels from the border from which the menu appears +* adjust `web_hide_menu.hide_delay` to set the amount of milliseconds after which the menu disappears if the mouse left it + +Known issues / Roadmap +====================== + +* This module heavily relies on mouse events, so it probably messes things up for touchscreens + +Credits +======= + +Contributors +------------ + +* Holger Brunn + +Icon +---- + +* http://commons.wikimedia.org/wiki/File:VisualEditor_-_Icon_-_Menu.svg +* http://commons.wikimedia.org/wiki/File:ProhibitionSign2.svg + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/web_hide_menu/__init__.py b/web_hide_menu/__init__.py new file mode 100644 index 00000000..faef9dac --- /dev/null +++ b/web_hide_menu/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## diff --git a/web_hide_menu/__openerp__.py b/web_hide_menu/__openerp__.py new file mode 100644 index 00000000..75795302 --- /dev/null +++ b/web_hide_menu/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "Hide menus", + "version": "1.0", + "author": "Therp BV", + "license": "AGPL-3", + "category": "Tools", + "summary": "Hide top and left menu bar", + "depends": [ + 'web', + ], + "data": [ + "data/ir_config_parameter.xml", + 'views/templates.xml', + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies": { + 'python': [], + }, +} diff --git a/web_hide_menu/data/ir_config_parameter.xml b/web_hide_menu/data/ir_config_parameter.xml new file mode 100644 index 00000000..9f2a543e --- /dev/null +++ b/web_hide_menu/data/ir_config_parameter.xml @@ -0,0 +1,13 @@ + + + + + web_hide_menu.show_bar_treshold + 10 + + + web_hide_menu.hide_delay + 10000 + + + diff --git a/web_hide_menu/static/description/icon.png b/web_hide_menu/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd538f1e75b8f77a06e430801a1ab733a22ab408 GIT binary patch literal 3386 zcmV-A4aM?_P)k$@PmNYwFXkr;oVbsV*$C?Fz`Y=Srq)k>{{w4K&=w4F+j zw*JJ5%2cau2eB$ei%pf1Y={97q#};C(~4~|iK6uvh*m)fi6Pnd`p13gB?z!ij`#t9>0xr!kx*N)X6M^v#j8||tFdP^GjB@`Cupih1v;*x9 zysw}Q{nOG7ZL{H{AdgoCtwZ%NHU#I}Fjc`tz;Ql*#V%lrf(;7RRlr+c01_ur{q}zo zxD*&a$Y0;;z>^AAMxZ5c0a*=)7Qkh|T;QyLyr3@uE4yLUP^q>-2V^aj#^727KLCmY zs>-_@SYg9$v*4Ya1f(9ug`n2aE25C>kORPq5G&b7RZS>pN2DB<@ao|G*du?bBX%C$k47Xr}10@Q^INHA{ zQ&8r>F&XHWqu`znsIAckKrjGtP1&e|GkqLvi-L^~YyzH*z<<+xVaC`n$YGL=cVLc!D;+r2hbG?yE{?!!Lk37a ze8qyNfU#)~W|M*?e}kuQ(&}l@qz*y{!88R6fD6)W?tKepRKUxF4#-*^0E_}7)6paf z7FWX7AnejnI1ji1n33jYAE|`r1`UvUm|($Xpu}URUjwd*!1^GXPYrN^(*D!Q9-H_S zm>hw>n?7iH34vI8BE5jo0W9oDbVgvl16Kn*hL4|J40rgdvKpXLL4#K# zz=lu%0`r!_D_I^c*&BtkfyXgB%W;6&5m=KpAb*Bq!`fOHmCi^yp=U9?vQ1kc*(^K1 z1J6~$FANQ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TaJ|5n-xY&I1zfQ5V7mHcYkj^`?FUv(^b literal 0 HcmV?d00001 diff --git a/web_hide_menu/static/src/css/web_hide_menu.css b/web_hide_menu/static/src/css/web_hide_menu.css new file mode 100644 index 00000000..8c34a2dd --- /dev/null +++ b/web_hide_menu/static/src/css/web_hide_menu.css @@ -0,0 +1,24 @@ +.openerp.openerp_webclient_container +{ + height: 100%; +} +.oe_leftbar +{ + display: block; + position: absolute; + left: 0px; + top: 0px; + bottom: 0px; + z-index: 100; +} +.openerp .oe_leftbar > div +{ + width: 100%; +} +#oe_main_menu_navbar +{ + position: absolute; + left: 0px; + right: 0px; + top: 0px; +} diff --git a/web_hide_menu/static/src/js/web_hide_menu.js b/web_hide_menu/static/src/js/web_hide_menu.js new file mode 100644 index 00000000..83b1479f --- /dev/null +++ b/web_hide_menu/static/src/js/web_hide_menu.js @@ -0,0 +1,160 @@ +//-*- coding: utf-8 -*- +//############################################################################ +// +// OpenERP, Open Source Management Solution +// This module copyright (C) 2015 Therp BV . +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +//############################################################################ + +openerp.web_hide_menu = function(instance) +{ + instance.web.WebClient.include({ + show_bar_treshold: 10, + hide_delay: 10000, + leftbar_hide_timeout_id: null, + main_menu_hide_timeout_id: null, + start: function() + { + var self = this; + return this._super.apply(this, arguments) + .then(function() + { + var addon_name = 'web_hide_menu', + parameters = _.map( + ['show_bar_treshold', 'hide_delay'], + function(a) { return addon_name + '.' + a }); + return (new openerp.web.Model('ir.config_parameter')) + .query(['key', 'value']) + .filter([['key', 'in', parameters]]) + .all() + .then(function(params) + { + _.each(params, function(param) + { + self[param.key.replace(addon_name + '.', '')] = + parseInt(param.value); + }); + }); + }) + .then(function() + { + self.$el + .bind('mousemove', _.bind(self.on_mousemove, self)); + }) + }, + show_application: function() + { + this._super.apply(this, arguments); + openerp.client.toggle_main_menu(false, this.hide_delay); + }, + toggle_bars: function(hide) + { + this.toggle_main_menu(hide); + this.toggle_left_bar(hide); + }, + toggle_menu_element(selector, timeout_id, show, delay) + { + if(this[timeout_id]) + { + clearTimeout(this[timeout_id]); + this[timeout_id] = null; + } + if(delay) + { + this[timeout_id] = setTimeout( + _.bind( + this.toggle_menu_element, this, + selector, timeout_id, show), + delay); + } + else + { + this.$(selector).toggle(show); + } + }, + toggle_main_menu: function(show, delay) + { + this.toggle_menu_element( + '#oe_main_menu_navbar', 'main_menu_hide_timeout_id', show, + delay); + }, + toggle_left_bar: function(show, delay) + { + this.toggle_menu_element( + '.oe_leftbar', 'leftbar_hide_timeout_id', show, delay); + }, + on_mousemove: function(e) + { + var on_main_menu = jQuery(e.srcElement) + .parents('#oe_main_menu_navbar').length > 0, + on_left_bar = jQuery(e.srcElement) + .parents('.oe_leftbar').length > 0; + if(on_left_bar && openerp.client.leftbar_hide_timeout_id) + { + clearTimeout(openerp.client.leftbar_hide_timeout_id); + openerp.client.leftbar_hide_timeout_id = null; + } + if(on_main_menu && openerp.client.main_menu_hide_timeout_id) + { + clearTimeout(openerp.client.main_menu_hide_timeout_id); + openerp.client.main_menu_hide_timeout_id = null; + } + if(!on_left_bar && !openerp.client.leftbar_hide_timeout_id) + { + this.toggle_left_bar(false, openerp.client.hide_delay); + } + if(!on_main_menu && !openerp.client.main_menu_hide_timeout_id) + { + this.toggle_main_menu(false); + } + if(e.pageX < this.show_bar_treshold) + { + this.toggle_left_bar(true); + } + if(e.pageY < this.show_bar_treshold) + { + this.toggle_main_menu(true); + } + }, + }); + instance.web.Menu.include({ + start: function() + { + this.on('menu_click', this, this.on_menu_click_with_action); + openerp.client.toggle_left_bar(false, openerp.client.hide_delay); + return this._super.apply(this, arguments); + }, + on_top_menu_click: function() + { + this.top_menu_click = true; + return this._super.apply(this, arguments); + }, + on_menu_click_with_action: function() + { + this.close_menu = !this.top_menu_click; + this.top_menu_click = false; + }, + open_menu: function() + { + this._super.apply(this, arguments); + if(this.close_menu) + { + openerp.client.toggle_left_bar(false); + } + this.close_menu = false; + }, + }); +} diff --git a/web_hide_menu/views/templates.xml b/web_hide_menu/views/templates.xml new file mode 100644 index 00000000..36f91537 --- /dev/null +++ b/web_hide_menu/views/templates.xml @@ -0,0 +1,11 @@ + + + + + +