Verified Commit 0b67c17f authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

streamlining and simplifications

parent 2755e85c
<div id="lap-cookies-banner"> <div id="lap-cookies-banner">
<div class="banner-text">{{ site.banner_text }}</div> <div class="banner-text">{{ site.banner_text }}</div>
<div class="banner-buttons"> <div class="banner-buttons">
<a class="btn lap-cookies-accept" href="">{{ site.banner_accept_text }}</a> <a class="btn lap-cookies-accept">{{ site.banner_accept_text }}</a>
<a class="btn lap-cookies-refuse" href="">{{ site.banner_refuse_text }}</a> <a class="btn lap-cookies-refuse">{{ site.banner_refuse_text }}</a>
<a class="btn lap-cookies-more" href="{{ site.path_policy }}">{{ site.banner_more_text }}</a> <a class="btn lap-cookies-more" href="{{ site.path_policy }}">{{ site.banner_more_text }}</a>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -87,30 +87,56 @@ function hasConsent() { ...@@ -87,30 +87,56 @@ function hasConsent() {
} }
} }
/* accept: accept the cookies */
function accept(cookieMgmt) {
// action
loadMatomo();
// cookie management
if (cookieMgmt) {
setCookie(settings.cookieName, 1);
}
// feedback
hideCookieBanner();
setResultText(true);
// style
$('.lap-cookies-accept').addClass('disabled');
$('.lap-cookies-refuse').removeClass('disabled');
}
/* accept: refuse the cookies */
function refuse(cookieMgmt) {
// action
clearCookies();
// cookie management
if (cookieMgmt) {
setCookie(settings.cookieName, 0);
}
// feedback
hideCookieBanner();
setResultText(false);
// style
$('.lap-cookies-refuse').addClass('disabled');
$('.lap-cookies-accept').removeClass('disabled');
}
$( document ).ready(function() { $( document ).ready(function() {
/* accept */ /* accept */
$('.lap-cookies-accept').click(function (e) { $('.lap-cookies-accept').click(function(e){
e.preventDefault(true); e.preventDefault(true);
setCookie(settings.cookieName, 1); accept();
hideCookieBanner();
$('.lap-cookies-accept').addClass('disabled');
$('.lap-cookies-refuse').removeClass('disabled');
$(this).blur();
loadMatomo();
setResultText(true);
}); });
/* refuse */ /* refuse */
$('.lap-cookies-refuse').click(function (e) { $('.lap-cookies-refuse').click(function(e){
e.preventDefault(true); e.preventDefault(true);
clearCookies(); refuse();
setCookie(settings.cookieName, 0);
hideCookieBanner();
$('.lap-cookies-refuse').addClass('disabled');
$('.lap-cookies-accept').removeClass('disabled');
$(this).blur();
setResultText(false);
}); });
// Detect if the visitor is a bot or not // Detect if the visitor is a bot or not
...@@ -125,17 +151,14 @@ $( document ).ready(function() { ...@@ -125,17 +151,14 @@ $( document ).ready(function() {
// Do nothing if it is a bot // Do nothing if it is a bot
// If DoNotTrack is activated, do nothing too // If DoNotTrack is activated, do nothing too
if (isBot || !isToTrack || !hasConsent()) { if (isBot || !isToTrack || !hasConsent()) {
hideCookieBanner(); refuse(false);
$('.lap-cookies-refuse').addClass('disabled');
clearCookies();
doNotTrack = true; doNotTrack = true;
} }
// User has already consent to use cookies to tracking // User has already consent to use cookies to tracking
if (doNotTrack == false) { if (doNotTrack == false) {
if (hasConsent() === true) { if (hasConsent() === true) {
$('.lap-cookies-accept').addClass('disabled'); accept(true);
loadMatomo();
} else if (hasConsent() === false) { } else if (hasConsent() === false) {
// If it's not a bot, no DoNotTrack and not already accept, so show banner // If it's not a bot, no DoNotTrack and not already accept, so show banner
showCookieBanner(); showCookieBanner();
......
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