No need to use window.Cookies, just Cookies works.

This commit is contained in:
Fredrik Jonsson 2021-02-01 10:45:00 +01:00
commit e59dc13d4d
2 changed files with 6 additions and 6 deletions

View file

@ -2,10 +2,10 @@
'use strict'; 'use strict';
if (typeof window.Cookies !== 'undefined') { if (typeof Cookies !== 'undefined') {
const cookieconsent = document.querySelector('.cookieconsent'); 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'); cookieconsent.classList.add('js-cookieconsent-open');
} }
@ -25,10 +25,10 @@
cookie_buttons.forEach(function (button) { cookie_buttons.forEach(function (button) {
button.addEventListener('click', function () { button.addEventListener('click', function () {
if (button.getAttribute('data-consent') === 'true') { if (button.getAttribute('data-consent') === 'true') {
window.Cookies.set('cookieconsent', 'accept', cookie_options); Cookies.set('cookieconsent', 'accept', cookie_options);
} }
else { else {
window.Cookies.set('cookieconsent', 'decline', cookie_options); Cookies.set('cookieconsent', 'decline', cookie_options);
} }
cookieconsent.classList.remove('js-cookieconsent-open'); cookieconsent.classList.remove('js-cookieconsent-open');
}); });

View file

@ -16,13 +16,13 @@ _paq.push(['setTrackerUrl', matomoTrackingApiUrl]);
_paq.push(['setSiteId', idSite]); _paq.push(['setSiteId', idSite]);
_paq.push(['trackPageView']); _paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']); _paq.push(['enableLinkTracking']);
if (typeof window.Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') { if (typeof Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') {
_paq.push(['setConsentGiven']); _paq.push(['setConsentGiven']);
} }
var googleAnalytics = '{{ .Site.GoogleAnalytics }}'; var googleAnalytics = '{{ .Site.GoogleAnalytics }}';
if (cookieConsent) { if (cookieConsent) {
if (typeof window.Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') { if (typeof Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') {
window['ga-disable-' + googleAnalytics] = true; window['ga-disable-' + googleAnalytics] = true;
} }
} }