From 8751b85cd234682a23cc52d885d8833e7824ea14 Mon Sep 17 00:00:00 2001 From: er314 <> Date: Wed, 12 Apr 2023 23:55:16 +0200 Subject: [PATCH 1/2] add capability to set messageTimout = 0, for not displaying the confirmation message (as most cookie banner systems do) --- PrivacyWire.module | 2 +- src/js/PrivacyWire.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PrivacyWire.module b/PrivacyWire.module index aa9a69c..23ec405 100644 --- a/PrivacyWire.module +++ b/PrivacyWire.module @@ -190,7 +190,7 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule $privacyWireSettings->dnt = ($this->respectDNT) ? "1" : "0"; $privacyWireSettings->bots = ($this->checkForBots) ? "1" : "0"; $privacyWireSettings->customFunction = ($this->wire('sanitizer')->text($this->trigger_custom_js_function)) ?? ""; - $privacyWireSettings->messageTimeout = ($this->messageTimeout && intval($this->messageTimeout) > 1) ? intval($this->messageTimeout) : 1500; + $privacyWireSettings->messageTimeout = (isset($this->messageTimeout) && intval($this->messageTimeout) >= 0) ? intval($this->messageTimeout) : 1500; $privacyWireSettings->consentByClass = ($this->detect_consents_by_class) ? "1" : "0"; $privacyWireSettings->cookieGroups = [ 'necessary' => $this->get("cookies_necessary_label{$this->lang}|cookies_necessary_label"), diff --git a/src/js/PrivacyWire.js b/src/js/PrivacyWire.js index 60f00f8..5f6f278 100644 --- a/src/js/PrivacyWire.js +++ b/src/js/PrivacyWire.js @@ -308,10 +308,12 @@ class PrivacyWire { } showMessage() { - this.elements.banner.wrapper.classList.add("show-message") - setTimeout(() => { - this.elements.banner.wrapper.classList.remove("show-message") - }, this.settings.messageTimeout) + if (this.settings.messageTimeout > 0) { + this.elements.banner.wrapper.classList.add("show-message") + setTimeout(() => { + this.elements.banner.wrapper.classList.remove("show-message") + }, this.settings.messageTimeout) + } } checkElementsWithRequiredConsent() { From f5c4b097aa444054270718978660e8555b5b9f56 Mon Sep 17 00:00:00 2001 From: er314 <> Date: Wed, 7 Jun 2023 22:40:56 +0200 Subject: [PATCH 2/2] [BREAKING] manual rendering mode : make ALL processing manual, so that ALL processing is performed exactly once --- render the banner 'choose' button only if there's MORE than 1 optional cookie type to choose from (if there's only 1 optional cookie type, then the button 'necessary yes/no' is enough to cover all possible choices) --- PrivacyWire.module | 2 +- PrivacyWireBanner.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PrivacyWire.module b/PrivacyWire.module index 23ec405..ca4034b 100644 --- a/PrivacyWire.module +++ b/PrivacyWire.module @@ -51,7 +51,6 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule } // 1. - 5. within initiatePrivacyWire method - $this->wire('page')->addHookBefore('render', $this, 'initiatePrivacyWire'); // 6. Render everything! /* @@ -59,6 +58,7 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule * The banner markup and consent window blueprint can be loaded anywhere, for example at the end of the body tag. */ if (!$this->render_manually) { + $this->wire('page')->addHookBefore('render', $this, 'initiatePrivacyWire'); // also disabled : allows full manual execution, more reliable as fully executed exactly once $this->wire('page')->addHookAfter('render', $this, 'render', ['priority' => 101]); } } diff --git a/PrivacyWireBanner.php b/PrivacyWireBanner.php index 1462ae7..ba39563 100644 --- a/PrivacyWireBanner.php +++ b/PrivacyWireBanner.php @@ -11,12 +11,14 @@ $showMarketingButton = (in_array("marketing", $module->cookie_groups)); $showExternalMediaButton = (in_array("external_media", $module->cookie_groups)); +// show the "choose" button if there is MORE than 1 optional cookie types to choose from +// (if there's only 1 optional cookie type, then the button "necessary yes/no" is enough to cover all possible choices) $showChooseButton = ( - $showFunctionalButton || - $showStatisticsButton || - $showMarketingButton || - $showExternalMediaButton -); + (int)$showFunctionalButton + + (int)$showStatisticsButton + + (int)$showMarketingButton + + (int)$showExternalMediaButton +) > 1; // Detailed Text for options banner