Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #122 #123

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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