Commit 52211cc0 authored by rg's avatar rg

Synchro des boutons tout autoriser/interdire.

parent 06bc56bb
......@@ -203,10 +203,24 @@
setCookie(cookieName,response,cookieDuration);
}
var autoSelectButtons=function(consentOptions) {
consentOptions.forEach(function(e) {
var autoSelectButtons=function(options) {
var allAccepted=true;
var allDenied=true;
options.consent.forEach(function(e) {
if(!e.value)
allAccepted=false;
else
allDenied=false;
setButtonClass(e);
});
if(allAccepted)
$(options.buttonAcceptAll).addClass('selected');
else
$(options.buttonAcceptAll).removeClass('selected');
if(allDenied)
$(options.buttonDenyAll).addClass('selected');
else
$(options.buttonDenyAll).removeClass('selected');
}
var saveConsent=function(key,value) {
......@@ -219,7 +233,7 @@
}
list.push({"key": e.key,"value": e.value});
});
autoSelectButtons(consentOptions);
autoSelectButtons(options);
//saveCookieConsent(cookieName,consentOptions);
}
......@@ -234,7 +248,7 @@
}
var runCallbacks=function(consentOptions) {
/* Le cookie existe, on execute les callback */
/* La valeur est à true, on execute les callback */
consentOptions.forEach(function(e) {
runCallback(e);
});
......@@ -285,12 +299,12 @@
row=$('<div>').addClass('all-cookies-choice').appendTo(doc);
var buttonAcceptAll=$(document.createElement("button")).addClass('accept').html(locale.acceptAll).click(function() {
var buttonAcceptAll=options.buttonAcceptAll=$(document.createElement("button")).addClass('accept').html(locale.acceptAll).click(function() {
$(this).addClass('selected');
buttonDenyAll.removeClass('selected');
saveConsent(null,true);
}).appendTo(row);
var buttonDenyAll=$(document.createElement("button")).addClass('deny').html(locale.denyAll).click(function() {
var buttonDenyAll=options.buttonDenyAll=$(document.createElement("button")).addClass('deny').html(locale.denyAll).click(function() {
$(this).addClass('selected');
buttonAcceptAll.removeClass('selected');
saveConsent(null,false);
......@@ -300,10 +314,9 @@
saveCookieConsent(cookieName,consentOptions);
runCallbacks(consentOptions);
}).appendTo(row);
var buttonClose=$(document.createElement("button")).addClass('action-close').html(locale.close).click(function() {
//saveCookieConsent(cookieName,consentOptions);
doc.slideUp();
}).appendTo(row);
//var buttonClose=$(document.createElement("button")).addClass('action-close').html(locale.close).click(function() {
// doc.slideUp();
//}).appendTo(row);
/* Ajoute chaque ligne de demande de consentement */
consentOptions.forEach(function(e) {
......@@ -317,12 +330,14 @@
col=$('<div>').addClass('buttons');
e.accept=$(document.createElement("button")).addClass('accept').html(locale.accept).click(function() {
e.value=true;
setButtonClass(e);
//setButtonClass(e);
autoSelectButtons(options);
//saveCookieConsent(cookieName,consentOptions);
}).appendTo(col);
e.denied=$(document.createElement("button")).addClass('deny').html(locale.deny).click(function() {
e.value=false;
setButtonClass(e);
//setButtonClass(e);
autoSelectButtons(options);
//saveCookieConsent(cookieName,consentOptions);
}).appendTo(col);
......@@ -383,7 +398,7 @@
if(div===false) {
div=display(consentOptions,text,className,position,fixed);
}
autoSelectButtons(consentOptions);
autoSelectButtons(options);
div.slideDown("fast")
}
......@@ -393,7 +408,7 @@
var showMe=initConsentOptions(consentCookie,consentOptions);
if(showMe || forceDisplay) {
runCallbacks(consentOptions);
//runCallbacks(consentOptions);
if(delay) setTimeout(function() {show();},delay);
else show();
return true;
......@@ -402,4 +417,4 @@
}
return false;
};
})(jQuery);
\ No newline at end of file
})(jQuery);
......@@ -3,12 +3,12 @@
.rgpwhat button {line-height: 2.2em; margin-top: 2px; opacity: .9; color: white; background-color: #1BD2A4; border-radius: 5px; border: 0; padding: 0 20px; margin-left: 10px; opacity: 1; font-weight: bold;}
.rgpwhat button:hover {opacity: .7;}
.rgpwhat .consent-list {background-color: #111; padding: 1em; width: 100%;}
.rgpwhat .consent-list button {background-color: #500; margin-left: 10px;}
.rgpwhat .consent-list button.selected {background-color: #1BD2A4;}
.rgpwhat .consent-list button {background-color: #124; margin-left: 10px;}
.rgpwhat .consent-list button.selected {background-color: #4A90E2;}
.rgpwhat .consent-list .all-cookies-choice {width: 50%; margin: auto; display: inline-block;}
.rgpwhat .consent-list .all-cookies-choice .action-close {border-radius: 20px; line-height: .5em; padding: .5em; float: right; background-color: #555; color: white;}
.rgpwhat .consent-list .all-cookies-choice .action-close:hover {opacity: .5;}
.rgpwhat .consent-list .all-cookies-choice .validate {background-color: #1BD2A4;}
.rgpwhat .consent-list .all-cookies-choice .validate {background-color: #1BD2A4; float: right;}
.rgpwhat .consent-list .cookie-choice {width: 50%; margin: auto; display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid grey;}
.rgpwhat .consent-list .cookie-choice .explanations {text-align: left; flex: 2;}
.rgpwhat .consent-list .cookie-choice .explanations .title {font-size: 1.5em; font-weight: bold;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment