ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* @package Plumrocket_GlobalPrivacyControl
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://www.plumrocket.com)
|
||||
* @license https://www.plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head>
|
||||
<css src="Plumrocket_GlobalPrivacyControl::css/gpc.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceBlock name="head.additional">
|
||||
<block class="Plumrocket\GlobalPrivacyControl\Block\ComponentInit" name="pr.gpc.init" after="pr.cookie.cookie_service">
|
||||
<arguments>
|
||||
<argument name="template" xsi:type="string">Plumrocket_GlobalPrivacyControl::init.phtml</argument>
|
||||
<argument name="cspNonceViewModel" xsi:type="object">Plumrocket\Base\ViewModel\CspNonce</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceBlock>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block class="Magento\Framework\View\Element\Template" name="pr.gpc.opt_out_notification" ifconfig="pr_gpc/general/enabled">
|
||||
<arguments>
|
||||
<argument name="template" xsi:type="string">Plumrocket_GlobalPrivacyControl::opt_out_notification.phtml</argument>
|
||||
<argument name="cspNonceViewModel" xsi:type="object">Plumrocket\Base\ViewModel\CspNonce</argument>
|
||||
<argument name="optOutNotificationViewModel" xsi:type="object">Plumrocket\GlobalPrivacyControl\ViewModel\OptOutNotification</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @package Plumrocket_GlobalPrivacyControl
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
var config = {
|
||||
map: {
|
||||
'*': {
|
||||
'prGlobalPrivacyControlApi': 'Plumrocket_GlobalPrivacyControl/js/gpc-api-wrapper'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_GlobalPrivacyControl
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc.
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
|
||||
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
|
||||
$cspNonceViewModel = $block->getData('cspNonceViewModel');
|
||||
?>
|
||||
|
||||
<script <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
|
||||
var prGlobalPrivacyControlApi = {
|
||||
config: <?= /* @noEscape */ $block->getSerializedConfig() ?>,
|
||||
isApplicableForUser: false,
|
||||
isConfigured: false,
|
||||
configure: function () {
|
||||
const setConfigurationResult = (isApplicable) => {
|
||||
this.isApplicableForUser = isApplicable;
|
||||
this.isConfigured = true;
|
||||
if (isApplicable) {
|
||||
this.signalHandlers.processPendingHandlers();
|
||||
}
|
||||
document.dispatchEvent(new Event('pr-global-privacy-control-api:configured'));
|
||||
};
|
||||
|
||||
if (! this.config.canProcessSignal) {
|
||||
setConfigurationResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cache.get('isApplicableForUser')) {
|
||||
setConfigurationResult(this.cache.get('isApplicableForUser'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (! navigator.globalPrivacyControl) {
|
||||
setConfigurationResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! this.config.isGeotargetingEnabled) {
|
||||
this.cache.set('isApplicableForUser', true);
|
||||
setConfigurationResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
this.geotargeting.isApplicable()
|
||||
.then(result => {
|
||||
this.cache.set('isApplicableForUser', result);
|
||||
setConfigurationResult(result);
|
||||
})
|
||||
.catch(() => setConfigurationResult(true));
|
||||
},
|
||||
shouldApply: function () {
|
||||
if (! this.isConfigured) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.isApplicableForUser;
|
||||
},
|
||||
};
|
||||
|
||||
prGlobalPrivacyControlApi.geotargeting = {
|
||||
isApplicable: async function () {
|
||||
return fetch(prGlobalPrivacyControlApi.config.geotargetingApiEndpoint, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
}).then(r => r.json());
|
||||
}
|
||||
};
|
||||
|
||||
prGlobalPrivacyControlApi.signalHandlers = {
|
||||
handlers: [],
|
||||
addHandler: function (callback) {
|
||||
let handler = {callback: callback, executed: false}
|
||||
this.handlers.push(handler);
|
||||
|
||||
if (prGlobalPrivacyControlApi.isConfigured && prGlobalPrivacyControlApi.shouldApply()) {
|
||||
handler.callback();
|
||||
handler.executed = true;
|
||||
}
|
||||
},
|
||||
processPendingHandlers: function () {
|
||||
if (! prGlobalPrivacyControlApi.shouldApply()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set cookie to indicate signal was handled
|
||||
if (! prCookieService.get('pr-gpc-signal-handled')) {
|
||||
prCookieService.set('pr-gpc-signal-handled', true, {expires: null});
|
||||
}
|
||||
|
||||
this.handlers.forEach(function (handler) {
|
||||
if (false === handler.executed) {
|
||||
handler.callback();
|
||||
handler.executed = true;
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
prGlobalPrivacyControlApi.cache = {
|
||||
storageKey: 'pr_global_privacy_control_api_cache',
|
||||
get: function (key) {
|
||||
try {
|
||||
let raw = sessionStorage.getItem(this.storageKey);
|
||||
let cacheData = JSON.parse(raw);
|
||||
return cacheData.hasOwnProperty(key) ? cacheData[key] : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set: function (key, value) {
|
||||
try {
|
||||
let cacheData = JSON.parse(sessionStorage.getItem(this.storageKey) || '{}');
|
||||
cacheData[key] = value;
|
||||
sessionStorage.setItem(this.storageKey, JSON.stringify(cacheData));
|
||||
} catch (e) {}
|
||||
},
|
||||
};
|
||||
|
||||
prGlobalPrivacyControlApi.configure();
|
||||
</script>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_GlobalPrivacyControl
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc.
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
|
||||
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
|
||||
$cspNonceViewModel = $block->getData('cspNonceViewModel');
|
||||
|
||||
/** @var \Plumrocket\GlobalPrivacyControl\ViewModel\OptOutNotification $optOutNotificationViewModel */
|
||||
$optOutNotificationViewModel = $block->getData('optOutNotificationViewModel');
|
||||
?>
|
||||
|
||||
<?php if ($optOutNotificationViewModel->isEnabled()): ?>
|
||||
<div id="pr-gpc-notification-modal" style="display: none;">
|
||||
<?= $optOutNotificationViewModel->getNotificationHtml() ?>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
|
||||
{
|
||||
"#pr-gpc-notification-modal": {
|
||||
"Plumrocket_GlobalPrivacyControl/js/opt-out-notification": {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,111 @@
|
||||
.pr-gpc-notification-wrap{
|
||||
padding: 20px 30px;
|
||||
border-radius: 6px;
|
||||
background: #F0F6FC;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
#pr-gpc-notification-modal .pr-gpc-notification-wrap {
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pr-gpc-notification,
|
||||
.pr-gpc-notification-wrap p,
|
||||
.pr-gpc-notification-wrap span{
|
||||
color: #3E3E3E;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-wrap h2{
|
||||
margin: 0 0 18px 0;
|
||||
color: #1F1F1F;
|
||||
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pr-gpc-text-with-icon{
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.pr-gpc-text-with-icon img{
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-wrap p{
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
/* Popup styles */
|
||||
.pr-gpc-notification-modal._has-modal{
|
||||
overflow: initial;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup.modal-popup .modal-header{
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup .pr-gpc-notification-wrap > h2{
|
||||
margin: 0 0 14px 0;
|
||||
padding-bottom: 14px;
|
||||
border-bottom: 1px solid #EDEDED;
|
||||
color: #1F1F1F;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup .pr-gpc-notification-wrap,
|
||||
.pr-gpc-notification-popup .pr-gpc-notification-wrap p,
|
||||
.pr-gpc-notification-popup .pr-gpc-notification-wrap span{
|
||||
color: #3E3E3E;
|
||||
font-size: 13px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup .modal-inner-wrap{
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
max-width: 100%;
|
||||
width: auto;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #E7E7E7;
|
||||
box-shadow: 0px 5px 24.9px 0px rgba(0, 0, 0, 0.10);
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup .modal-footer{
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-popup .modal-footer .action.primary{
|
||||
padding: 8px 20px;
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
.pr-gpc-notification-backdrop.modals-overlay{
|
||||
background-color: transparent;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@media (min-width: 768px){
|
||||
.pr-gpc-notification-popup .modal-inner-wrap{
|
||||
right: auto;
|
||||
left: 33px;
|
||||
margin-bottom: 33px;
|
||||
width: 460px;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 792 B |
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @package Plumrocket_GlobalPrivacyControl
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
define([], function() {
|
||||
'use strict';
|
||||
|
||||
return window.prGlobalPrivacyControlApi;
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
});
|
||||
Reference in New Issue
Block a user