From 40d7d859bb9797f9755ac2337e722b2ef5888732 Mon Sep 17 00:00:00 2001 From: elisei Date: Fri, 29 Apr 2022 20:14:37 -0300 Subject: [PATCH] Fix #122 --- view/frontend/web/js/view/popup.js | 47 +++++++++++++++++++------ view/frontend/web/template/message.html | 6 ++-- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/view/frontend/web/js/view/popup.js b/view/frontend/web/js/view/popup.js index b428ae3a..2a72fdc0 100644 --- a/view/frontend/web/js/view/popup.js +++ b/view/frontend/web/js/view/popup.js @@ -21,9 +21,7 @@ define([ "use strict"; return Component.extend({ - showPopUp: ko.observable(null), - popupText: ko.observable(null), - popupLink: ko.observable(null), + showPopUp: ko.observable(false), defaults: { template: "Opengento_Gdpr/message" @@ -33,16 +31,45 @@ define([ * Initialize component */ initialize() { + var self = this, + isBot = navigator.userAgent.toLowerCase().match( /.+?(?:bot|lighthouse)/ ); + this._super(); - this.showPopUp(!$.cookie(this.cookieName)); - this.popupText(this.notificationText); - this.popupLink(this.learnMore); + if (!window.localStorage.getItem(self.cookieName) && !isBot) { + self.showPopUp(true); + } + }, + + /** + * Get Popup Text + * @returns {string} + */ + getPopupText() { + var self = this; + + return self.notificationText; + }, + + /** + * Get Popup Link + * @returns {string} + */ + getPopupLink() { + var self = this; + + return self.learnMore; + }, + + /** + * Accept All Cookies + * @returns {void} + */ + acceptAllCookies() { + var self = this; - $(document).on("click", "#enhanced-privacy-popup-agree", function () { - this.showPopUp(false); - $.cookie(this.cookieName, 1); - }.bind(this)); + window.localStorage.setItem(self.cookieName, true, {}); + self.showPopUp(false); } }); }); diff --git a/view/frontend/web/template/message.html b/view/frontend/web/template/message.html index 1e2ae4f9..06ca70df 100644 --- a/view/frontend/web/template/message.html +++ b/view/frontend/web/template/message.html @@ -18,13 +18,13 @@