Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
elisei committed Apr 29, 2022
1 parent 0872942 commit f325aff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions view/frontend/web/js/view/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define([
"use strict";

return Component.extend({
showPopUp: ko.observable(null),
showPopUp: ko.observable(false),
popupText: ko.observable(null),
popupLink: ko.observable(null),

Expand All @@ -33,16 +33,27 @@ 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);
}

self.popupText(self.notificationText);
self.popupLink(self.learnMore);
},

/**
* Accept All Cookies
*/
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);
}
});
});
2 changes: 1 addition & 1 deletion view/frontend/web/template/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<a class="action" data-bind="attr: {href: learnMore}, 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 f325aff

Please sign in to comment.