Skip to content

Commit

Permalink
Merge pull request #123 from elisei/master
Browse files Browse the repository at this point in the history
Fix #122
  • Loading branch information
thomas-kl1 authored May 4, 2022
2 parents d528ef0 + 40d7d85 commit 5f9bcb4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
47 changes: 37 additions & 10 deletions view/frontend/web/js/view/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
}
});
});
6 changes: 3 additions & 3 deletions view/frontend/web/template/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<div class="popup content">
<strong data-bind="i18n: 'Cookie Disclosure'"></strong>
<div class="block-content">
<div data-bind="html: notificationText"></div>
<div data-bind="html: getPopupText()"></div>
<div class="actions-toolbar">
<div class="secondary">
<a class="action" data-bind="attr: {href: learnMore}, i18n: 'Read More'"></a>
<a class="action" data-bind="attr: {href: getPopupLink()}, i18n: 'Read More'"></a>
</div>
<div class="primary">
<button type="button" class="action primary" id="enhanced-privacy-popup-agree" data-bind="i18n: 'Accept'"></button>
<button type="button" class="action primary" id="enhanced-privacy-popup-agree" data-bind="i18n: 'Accept', click: acceptAllCookies"></button>
</div>
</div>
</div>
Expand Down

0 comments on commit 5f9bcb4

Please sign in to comment.