Holger Brunn
10 years ago
8 changed files with 314 additions and 0 deletions
-
45web_hide_menu/README.rst
-
20web_hide_menu/__init__.py
-
41web_hide_menu/__openerp__.py
-
13web_hide_menu/data/ir_config_parameter.xml
-
BINweb_hide_menu/static/description/icon.png
-
24web_hide_menu/static/src/css/web_hide_menu.css
-
160web_hide_menu/static/src/js/web_hide_menu.js
-
11web_hide_menu/views/templates.xml
@ -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 <hbrunn@therp.nl> |
|||
|
|||
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. |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
@ -0,0 +1,41 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
{ |
|||
"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': [], |
|||
}, |
|||
} |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<record id="param_show_bar_treshold" model="ir.config_parameter"> |
|||
<field name="key">web_hide_menu.show_bar_treshold</field> |
|||
<field name="value">10</field> |
|||
</record> |
|||
<record id="param_hide_delay" model="ir.config_parameter"> |
|||
<field name="key">web_hide_menu.hide_delay</field> |
|||
<field name="value">10000</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
After Width: 100 | Height: 100 | Size: 3.3 KiB |
@ -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; |
|||
} |
@ -0,0 +1,160 @@ |
|||
//-*- coding: utf-8 -*-
|
|||
//############################################################################
|
|||
//
|
|||
// OpenERP, Open Source Management Solution
|
|||
// This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|||
//
|
|||
// 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 <http://www.gnu.org/licenses/>.
|
|||
//
|
|||
//############################################################################
|
|||
|
|||
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; |
|||
}, |
|||
}); |
|||
} |
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<template id="assets_backend" name="web_hide_menu assets" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<script type="text/javascript" src="/web_hide_menu/static/src/js/web_hide_menu.js"></script> |
|||
<link rel="stylesheet" href="/web_hide_menu/static/src/css/web_hide_menu.css"/> |
|||
</xpath> |
|||
</template> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue