diff --git a/core/core.js.php b/core/core.js.php index ac429c36..c8ce0f0a 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -224,18 +224,27 @@ core.start = function() { // Crée le cookie d'acceptation Google Analytics si l'ID a été saisie var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; + // l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation if( analytics.length > 0){ - document.cookie = "ZWII_COOKIE_GA_CONSENT=" + $("#googleAnalytics").prop("checked") + "" +";" + domain + ";" + path + ";" + samesite + ";" + expires; + // Traitement du retour de la checkbox + if ($("#googleAnalytics").is(":checked")) { + // L'URL du serveur faut TRUE + document.cookie = "ZWII_COOKIE_GA_CONSENT=" + "" + ";" + domain + ";" + path + ";" + samesite + ";" + expires; + } else { + document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires; + } + } - // Stocke lz cookie d'acceptation + // Stocke le cookie d'acceptation document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; }); /** * Suppression du cookie de consentement - */ - $('#footerCookies').bind('click', function(event) { + + $('#cookieConsentRefused').on('click', function() { + var samesite = "samesite=lax"; var getUrl = window.location; var domain = "domain=" + getUrl.host; @@ -244,8 +253,17 @@ core.start = function() { var e = new Date(); e.setFullYear(e.getFullYear() - 1); var expires = "expires=" + e.toUTCString(); - document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; + document.cookie = "ZWII_COOKIE_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires; + + // Désactiver le cookie GA + document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires; + + + + // fermer la fenêtre + $("#cookieConsent").fadeOut(); }); + */ /** * Fermeture de la popup des cookies @@ -254,6 +272,14 @@ core.start = function() { $(this).parents("#cookieConsent").fadeOut(); }); + /** + * Commande de gestion des cookies dans le footer + */ + + $("footer #footerCookies").on("click", function() { + $("#cookieConsent").removeClass("displayNone"); + }); + /** * Affiche / Cache le menu en mode responsive */ diff --git a/core/core.php b/core/core.php index e217235d..bbe2c319 100644 --- a/core/core.php +++ b/core/core.php @@ -1174,7 +1174,7 @@ class common { */ public function showAnalytics() { if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) && - $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true'.$_SERVER['PHP_SELF']) { + $this->getInput('ZWII_COOKIE_GA_CONSENT') === $_SERVER['PHP_SELF'] ) { echo '