Verified Commit 037a8d9b authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

add functionality for analytics button

parent 57a11695
......@@ -13,7 +13,7 @@
<span></span>
</label>
<span class="checkbox-label">Necessary</span>
<label class="input-toggle">
<label class="input-toggle analytics">
<input id="checkbox-2" type="checkbox">
<span></span>
</label>
......
......@@ -52,7 +52,7 @@ function showBanner() {
*/
function hideBanner() {
var popup = $('#lap-cookies-banner');
popup.hide();
setTimeout(() => { popup.slideUp('slow'); }, 1200);
}
/*
......@@ -113,7 +113,6 @@ function accept() {
setCookie(settings.cookieName, 1);
// feedback
hideBanner();
setResultText(true);
// style
......@@ -122,6 +121,15 @@ function accept() {
$('input#checkbox-2')[0].checked = true;
}
function select_accept() {
if ($('input#checkbox-2')[0].checked === true) {
refuse(false);
} else {
accept();
}
}
/*
* accept: refuse the cookies
*/
......@@ -136,7 +144,6 @@ function refuse(doNotTrack) {
}
// feedback
hideBanner();
setResultText(false);
// style
......@@ -153,12 +160,20 @@ $(document).ready(function() {
$('.lap-cookies-accept').click(function(e) {
e.preventDefault(true);
accept();
hideBanner();
});
// refuse
$('.lap-cookies-refuse').click(function(e) {
e.preventDefault(true);
refuse(false);
hideBanner();
});
$('.analytics').click(function(e) {
e.preventDefault(true);
select_accept();
hideBanner();
});
// detect if the visitor is a bot or not
......@@ -174,12 +189,14 @@ $(document).ready(function() {
if (isBot || !isToTrack || hasConsent() === false) {
doNotTrack = true;
refuse(doNotTrack);
hideBanner();
}
if (doNotTrack === false) {
if (hasConsent() === true) {
// user has already given consent to use cookies to tracking
accept();
hideBanner();
} else if (hasConsent() === false || hasConsent() === null) {
// all other cases considered, show banner
showBanner();
......
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