From e59dc13d4d532ba56fa0bd69675a325bbe92de72 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Mon, 1 Feb 2021 10:45:00 +0100 Subject: [PATCH] No need to use window.Cookies, just Cookies works. --- assets/js/cookieconsent.js | 8 ++++---- assets/js/tracking.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/js/cookieconsent.js b/assets/js/cookieconsent.js index 8f6e284..35f2735 100644 --- a/assets/js/cookieconsent.js +++ b/assets/js/cookieconsent.js @@ -2,10 +2,10 @@ 'use strict'; - if (typeof window.Cookies !== 'undefined') { + if (typeof Cookies !== 'undefined') { const cookieconsent = document.querySelector('.cookieconsent'); - if (typeof window.Cookies.get('cookieconsent') === 'undefined' && cookieconsent) { + if (typeof Cookies.get('cookieconsent') === 'undefined' && cookieconsent) { cookieconsent.classList.add('js-cookieconsent-open'); } @@ -25,10 +25,10 @@ cookie_buttons.forEach(function (button) { button.addEventListener('click', function () { if (button.getAttribute('data-consent') === 'true') { - window.Cookies.set('cookieconsent', 'accept', cookie_options); + Cookies.set('cookieconsent', 'accept', cookie_options); } else { - window.Cookies.set('cookieconsent', 'decline', cookie_options); + Cookies.set('cookieconsent', 'decline', cookie_options); } cookieconsent.classList.remove('js-cookieconsent-open'); }); diff --git a/assets/js/tracking.js b/assets/js/tracking.js index 16a4c25..edec20a 100644 --- a/assets/js/tracking.js +++ b/assets/js/tracking.js @@ -16,13 +16,13 @@ _paq.push(['setTrackerUrl', matomoTrackingApiUrl]); _paq.push(['setSiteId', idSite]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); -if (typeof window.Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') { +if (typeof Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') { _paq.push(['setConsentGiven']); } var googleAnalytics = '{{ .Site.GoogleAnalytics }}'; if (cookieConsent) { - if (typeof window.Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') { + if (typeof Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') { window['ga-disable-' + googleAnalytics] = true; } }