Remove the hardcoded colors from the JS

The hardcoded colors green and red have been removed from the JS file.
The colors are now in the CSS file.
A new class tarteaucitronIsSelected is added to the main selected button ("Allow all" or "Deny all").
This commit is contained in:
Anthony Demurtas 2018-11-20 17:40:46 +01:00
parent 09c1de4548
commit 7c94cf65cc
2 changed files with 33 additions and 25 deletions

View File

@ -371,6 +371,14 @@ div#tarteaucitronServices {
padding: 15px 5px;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronLine.tarteaucitronIsAllowed {
border-color: #1B870B;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronLine.tarteaucitronIsDenied {
border-color: #9C1A1A;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine {
background: #333;
border: 3px solid #333;
@ -432,6 +440,22 @@ div#tarteaucitronServices {
border: 0;
}
#tarteaucitron #tarteaucitronServices #tarteaucitronAllAllowed.tarteaucitronIsSelected {
background-color: #1B870B;
opacity: 1;
}
#tarteaucitron #tarteaucitronServices #tarteaucitronAllDenied.tarteaucitronIsSelected {
background-color: #9C1A1A;
opacity: 1;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronLine.tarteaucitronIsAllowed .tarteaucitronAllow {
background-color: #1B870B;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronLine.tarteaucitronIsDenied .tarteaucitronDeny {
background-color: #9C1A1A;
}
#tarteaucitron #tarteaucitronServices .tarteaucitronLine .tarteaucitronName .tarteaucitronListCookies {
color: #333;
font-size: 12px;
@ -714,7 +738,7 @@ div.amazon_product {
}.tarteaucitronIsDenied .tarteaucitronDeny {
opacity: 1!important;
}
.tarteaucitronLine .tarteaucitronAllow, .tarteaucitronLine .tarteaucitronAllow {
.tarteaucitronLine .tarteaucitronAllow, .tarteaucitronLine .tarteaucitronDeny {
opacity: 0.4;
}

View File

@ -16,7 +16,7 @@ var scripts = document.getElementsByTagName('script'),
var tarteaucitron = {
"version": 20181023,
"version": 20181120,
"cdn": cdn,
"user": {},
"lang": {},
@ -672,13 +672,7 @@ var tarteaucitron = {
},
"color": function (key, status) {
"use strict";
var gray = '#808080',
greenDark = '#1B870B',
greenLight = '#E6FFE2',
redDark = '#9C1A1A',
redLight = '#FFE2E2',
yellowDark = '#FBDA26',
c = 'tarteaucitron',
var c = 'tarteaucitron',
nbDenied = 0,
nbPending = 0,
nbAllowed = 0,
@ -686,17 +680,9 @@ var tarteaucitron = {
index;
if (status === true) {
tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
} else if (status === false) {
tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
}
@ -717,16 +703,14 @@ var tarteaucitron = {
tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
if (nbDenied === 0 && nbPending === 0) {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '0.4');
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '1');
document.getElementById(c + 'AllDenied').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllAllowed').classList.add('tarteaucitronIsSelected');
} else if (nbAllowed === 0 && nbPending === 0) {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '0.4');
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '1');
tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
document.getElementById(c + 'AllAllowed').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllDenied').classList.add('tarteaucitronIsSelected');
} else {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '0.4');
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '0.4');
document.getElementById(c + 'AllDenied').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllAllowed').classList.remove('tarteaucitronIsSelected');
}
// close the alert if all service have been reviewed