Antonio Espinosa
8 years ago
committed by
Dennis Sluijk
7 changed files with 124 additions and 147 deletions
-
20web_environment_ribbon/README.rst
-
22web_environment_ribbon/__init__.py
-
30web_environment_ribbon/__openerp__.py
-
38web_environment_ribbon/data/ribbon_data.xml
-
3web_environment_ribbon/static/src/css/ribbon.css
-
119web_environment_ribbon/static/src/js/ribbon.js
-
39web_environment_ribbon/view/base_view.xml
@ -1,20 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Copyright (C) 2015 Francesco OpenCode Apruzzese (<cescoap@gmail.com>) |
|||
# All Rights Reserved |
|||
# |
|||
# 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/>. |
|||
# |
|||
############################################################################## |
|||
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
|||
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
@ -1,24 +1,24 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
<odoo noupdate="1"> |
|||
|
|||
<!-- Add ribbon name default configuration parameter --> |
|||
<record id="default_ribbon_name" model="ir.config_parameter"> |
|||
<field name="key">ribbon.name</field> |
|||
<field name="value">TEST</field> |
|||
</record> |
|||
<!-- Add ribbon name default configuration parameter --> |
|||
<record id="default_ribbon_name" model="ir.config_parameter"> |
|||
<field name="key">ribbon.name</field> |
|||
<field name="value">TEST</field> |
|||
</record> |
|||
|
|||
<!-- Add ribbon color configuration parameter --> |
|||
<record id="set_ribbon_color" model="ir.config_parameter"> |
|||
<field name="key">ribbon.color</field> |
|||
<field name="value">#f0f0f0</field> |
|||
</record> |
|||
<!-- Add ribbon color configuration parameter --> |
|||
<record id="set_ribbon_color" model="ir.config_parameter"> |
|||
<field name="key">ribbon.color</field> |
|||
<field name="value">#f0f0f0</field> |
|||
</record> |
|||
|
|||
<!-- Add ribbon background color configuration parameter --> |
|||
<record id="set_ribbon_background_color" model="ir.config_parameter"> |
|||
<field name="key">ribbon.background.color</field> |
|||
<field name="value">rgba(255,0,0,.6)</field> |
|||
</record> |
|||
<!-- Add ribbon background color configuration parameter --> |
|||
<record id="set_ribbon_background_color" model="ir.config_parameter"> |
|||
<field name="key">ribbon.background.color</field> |
|||
<field name="value">rgba(255,0,0,.6)</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
|||
</odoo> |
@ -1,68 +1,61 @@ |
|||
/****************************************************************************** |
|||
Copyright (C) 2015 Akretion (http://www.akretion.com)
|
|||
@author Sylvain Calador <sylvain.calador@akretion.com> |
|||
|
|||
Copyright (C) 2016 Algi Open Source Solutions (http://www.algios.com)
|
|||
@author Javi Melendez <javi.melendez@algios.com> |
|||
|
|||
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_environment_ribbon = function(instance) { |
|||
|
|||
var ribbon = $(document).find('.test-ribbon'); |
|||
ribbon.hide(); |
|||
|
|||
var model = new instance.web.Model('ir.config_parameter'); |
|||
/* Copyright 2015 Sylvain Calador <sylvain.calador@akretion.com> |
|||
Copyright 2015 Javi Melendez <javi.melendez@algios.com> |
|||
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
|||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
|||
|
|||
odoo.define('web_environment_ribbon.ribbon', function(require) { |
|||
"use strict"; |
|||
|
|||
var $ = require('$'); |
|||
var Model = require('web.Model'); |
|||
var core = require('web.core'); |
|||
|
|||
var model = new Model('ir.config_parameter'); |
|||
|
|||
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
|
|||
function validStrColour(strToTest) { |
|||
if (strToTest === "") { return false; } |
|||
if (strToTest === "inherit") { return true; } |
|||
if (strToTest === "transparent") { return true; } |
|||
var image = document.createElement("img"); |
|||
image.style.color = "rgb(0, 0, 0)"; |
|||
image.style.color = strToTest; |
|||
if (image.style.color !== "rgb(0, 0, 0)") { return true; } |
|||
image.style.color = "rgb(255, 255, 255)"; |
|||
image.style.color = strToTest; |
|||
return image.style.color !== "rgb(255, 255, 255)"; |
|||
} |
|||
|
|||
var res = model.call('get_param', ['ribbon.name']).then( |
|||
function (name) { |
|||
if (name && name != 'False') { |
|||
ribbon.html(name); |
|||
ribbon.show(); |
|||
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(); |
|||
} |
|||
} |
|||
} |
|||
); |
|||
|
|||
// Get ribbon color from system parameters
|
|||
var res = 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
|
|||
var res = 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); |
|||
} |
|||
} |
|||
} |
|||
); |
|||
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
|
|||
function validStrColour(strToTest) { |
|||
if (strToTest === "") { return false; } |
|||
if (strToTest === "inherit") { return true; } |
|||
if (strToTest === "transparent") { return true; } |
|||
var image = document.createElement("img"); |
|||
image.style.color = "rgb(0, 0, 0)"; |
|||
image.style.color = strToTest; |
|||
if (image.style.color !== "rgb(0, 0, 0)") { return true; } |
|||
image.style.color = "rgb(255, 255, 255)"; |
|||
image.style.color = strToTest; |
|||
return image.style.color !== "rgb(255, 255, 255)"; |
|||
); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
}); // odoo.define
|
@ -1,21 +1,26 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
|||
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
<odoo> |
|||
|
|||
<!-- Load css for ribbons --> |
|||
<template id="assets_backend" name="ribbon_test assets" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<link rel="stylesheet" href="/web_environment_ribbon/static/src/css/ribbon.css"/> |
|||
<script type="text/javascript" src="/web_environment_ribbon/static/src/js/ribbon.js"/> |
|||
</xpath> |
|||
</template> |
|||
<!-- Load css for ribbons --> |
|||
<template id="assets_backend" name="ribbon_test assets" |
|||
inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<link rel="stylesheet" |
|||
href="/web_environment_ribbon/static/src/css/ribbon.css"/> |
|||
<script type="text/javascript" |
|||
src="/web_environment_ribbon/static/src/js/ribbon.js"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
<!-- Add ribbon to page --> |
|||
<template id="body_with_ribbon_test" name="ribbon_test web.webclient_bootstrap" inherit_id="web.webclient_bootstrap"> |
|||
<xpath expr="//div[@class='openerp openerp_webclient_container']" position="before"> |
|||
<div class="test-ribbon"/> |
|||
</xpath> |
|||
</template> |
|||
<!-- Add ribbon to page --> |
|||
<template id="body_with_ribbon_test" name="ribbon_test web.webclient_bootstrap" |
|||
inherit_id="web.webclient_bootstrap"> |
|||
<xpath expr="//div[@class='openerp openerp_webclient_container oe_webclient']" position="before"> |
|||
<div class="test-ribbon"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</data> |
|||
</openerp> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue