@ -1,6 +1,7 @@
/ * C o p y r i g h t 2 0 1 5 S y l v a i n C a l a d o r < s y l v a i n . c a l a d o r @ a k r e t i o n . c o m >
/ * C o p y r i g h t 2 0 1 5 S y l v a i n C a l a d o r < s y l v a i n . c a l a d o r @ a k r e t i o n . c o m >
Copyright 2015 Javi Melendez < javi . melendez @ algios . com >
Copyright 2015 Javi Melendez < javi . melendez @ algios . com >
Copyright 2016 Antonio Espinosa < antonio . espinosa @ tecnativa . com >
Copyright 2016 Antonio Espinosa < antonio . espinosa @ tecnativa . com >
Copyright 2017 Thomas Binsfeld < thomas . binsfeld @ acsone . eu >
* License AGPL - 3.0 or later ( http : //www.gnu.org/licenses/agpl). */
* License AGPL - 3.0 or later ( http : //www.gnu.org/licenses/agpl). */
odoo . define ( 'web_environment_ribbon.ribbon' , function ( require ) {
odoo . define ( 'web_environment_ribbon.ribbon' , function ( require ) {
@ -10,7 +11,7 @@ var $ = require('jquery');
var Model = require ( 'web.Model' ) ;
var Model = require ( 'web.Model' ) ;
var core = require ( 'web.core' ) ;
var core = require ( 'web.core' ) ;
var model = new Model ( 'ir.config_parameter ' ) ;
var backend_ model = new Model ( 'web.environment.ribbon.backend ' ) ;
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
function validStrColour ( strToTest ) {
function validStrColour ( strToTest ) {
@ -30,27 +31,21 @@ core.bus.on('web_client_ready', null, function () {
var ribbon = $ ( '<div class="test-ribbon"/>' ) ;
var ribbon = $ ( '<div class="test-ribbon"/>' ) ;
$ ( 'body' ) . append ( ribbon ) ;
$ ( 'body' ) . append ( ribbon ) ;
ribbon . hide ( ) ;
ribbon . hide ( ) ;
model . call ( 'get_param' , [ 'ribbon.name' ] ) . then (
function ( name ) {
if ( name && name != 'False' ) {
ribbon . html ( name ) ;
// Get ribbon data from backend
backend_model . call ( 'get_environment_ribbon' ) . then (
function ( ribbon_data ) {
// Ribbon name
if ( ribbon_data . name && ribbon_data . name != 'False' ) {
ribbon . html ( ribbon_data . name ) ;
ribbon . show ( ) ;
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 ) ;
// Ribbon color
if ( ribbon_data . color && validStrColour ( ribbon_data . color ) ) {
ribbon . css ( 'color' , ribbon_data . color ) ;
}
}
}
) ;
// 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 ) ;
// Ribbon background color
if ( ribbon_data . background_color && validStrColour ( ribbon_data . background_color ) ) {
ribbon . css ( 'background-color' , ribbon_data . background_color ) ;
}
}
}
}
) ;
) ;