From 142db4b9c92cce6cc25346d6ab2ee54e5e754c31 Mon Sep 17 00:00:00 2001 From: Sylvain GARANCHER Date: Fri, 16 Sep 2016 16:01:37 +0200 Subject: [PATCH] [IMP] Make web_environment_ribbon more generic By creating the ribbon div on the fly, this module doesn't depend anymore on the webclient structure. --- .../static/src/css/ribbon.css | 5 +- .../static/src/js/ribbon.js | 50 +++++++++---------- web_environment_ribbon/view/base_view.xml | 8 --- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/web_environment_ribbon/static/src/css/ribbon.css b/web_environment_ribbon/static/src/css/ribbon.css index 375ffee8..999c64f7 100644 --- a/web_environment_ribbon/static/src/css/ribbon.css +++ b/web_environment_ribbon/static/src/css/ribbon.css @@ -3,7 +3,7 @@ .test-ribbon{ width: 200px; - top: 50px; + top: 25px; left: -50px; text-align: center; line-height: 50px; @@ -14,10 +14,11 @@ -moz-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); - z-index: 1000; + z-index: 9999; position: fixed; box-shadow: 0 0 3px rgba(0,0,0,.3); background: rgba(255,0,0,.6); + pointer-events: none; } .test-ribbon b { diff --git a/web_environment_ribbon/static/src/js/ribbon.js b/web_environment_ribbon/static/src/js/ribbon.js index 68dbee33..90037f4e 100644 --- a/web_environment_ribbon/static/src/js/ribbon.js +++ b/web_environment_ribbon/static/src/js/ribbon.js @@ -27,35 +27,33 @@ function validStrColour(strToTest) { } core.bus.on('web_client_ready', null, function () { - var ribbon = $('.test-ribbon'); - // If ribbon is found in DOM - if (ribbon.length) { - ribbon.hide(); - model.call('get_param', ['ribbon.name']).then( - function (name) { - if (name && name != 'False') { - ribbon.html(name); - ribbon.show(); - } + var ribbon = $('
'); + $('body').append(ribbon); + ribbon.hide(); + model.call('get_param', ['ribbon.name']).then( + function (name) { + if (name && name != 'False') { + ribbon.html(name); + ribbon.show(); } - ); - // Get ribbon color from system parameters - model.call('get_param', ['ribbon.color']).then( - function (strColor) { - if (strColor && validStrColour(strColor)) { - ribbon.css('color', strColor); - } + } + ); + // Get ribbon color from system parameters + model.call('get_param', ['ribbon.color']).then( + function (strColor) { + if (strColor && validStrColour(strColor)) { + ribbon.css('color', strColor); } - ); - // Get ribbon background color from system parameters - model.call('get_param', ['ribbon.background.color']).then( - function (strBackgroundColor) { - if (strBackgroundColor && validStrColour(strBackgroundColor)) { - ribbon.css('background-color', strBackgroundColor); - } + } + ); + // Get ribbon background color from system parameters + model.call('get_param', ['ribbon.background.color']).then( + function (strBackgroundColor) { + if (strBackgroundColor && validStrColour(strBackgroundColor)) { + ribbon.css('background-color', strBackgroundColor); } - ); - } + } + ); }); }); // odoo.define diff --git a/web_environment_ribbon/view/base_view.xml b/web_environment_ribbon/view/base_view.xml index 464a71dd..f2a8d790 100644 --- a/web_environment_ribbon/view/base_view.xml +++ b/web_environment_ribbon/view/base_view.xml @@ -15,12 +15,4 @@ - - -