define([ 'jquery', 'Magento_Ui/js/modal/modal', 'prCookieService', 'prGlobalPrivacyControlApi' ], function ($, modal, prCookieService, prGlobalPrivacyControlApi) { 'use strict'; $.widget('plumrocket.gpcOptOutNotification', { options: { cookieName: 'pr-gpc-notification-shown' }, /** * Widget initialization * @private */ _create: function () { var self = this; // Initialize modal options var modalOptions = { type: 'popup', innerScroll: true, modalClass: 'pr-gpc-notification-popup', overlayClass: 'pr-gpc-notification-backdrop modals-overlay', parentModalClass: 'pr-gpc-notification-modal _has-modal', buttons: [{ text: $.mage.__('OK'), class: 'action primary', click: function () { this.closeModal(); } }], closed: function () { self._setCookie(); } }; modal(modalOptions, $(this.element)); prGlobalPrivacyControlApi.signalHandlers.addHandler(this._showModal.bind(this)); }, _showModal: function () { if (prCookieService.get(this.options.cookieName)) { return; } setTimeout($.proxy(function () { $(this.element).modal('openModal'); }, this), 1000); }, /** * Set cookie to remember that notification was shown * @private */ _setCookie: function () { prCookieService.set(this.options.cookieName, '1', {expires: null}); } }); return $.plumrocket.gpcOptOutNotification; });