ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,10 @@
define([], function () {
'use strict';
/**
* @deprecated since 1.11.0 - no more used
*/
return function (s) {
return s;
};
});
@@ -0,0 +1,10 @@
define([], function () {
'use strict';
/**
* @deprecated since 1.11.0 - no more used
*/
return function (originReturnData) {
return originReturnData;
};
});
@@ -0,0 +1,127 @@
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
/**
* Finds and executes scripts in a newly added element's body.
* Needed since innerHTML does not run scripts.
*/
define(['prCookieConsentApi', 'domReady!'], function (prCookieConsentApi) {
'use strict';
function BodyScripts()
{
this.execute = function (element, idPrefix) {
var scripts = this.collectScriptsFromChildren(element);
this.executeScripts(scripts, 0, idPrefix);
};
this.executeScripts = function (scripts, i, idPrefix) {
var self = this;
var script = scripts[i];
if (script.parentNode) {
script.parentNode.removeChild(script);
}
this.evalScript(scripts[i], idPrefix + '_' + i, function () {
if (i < scripts.length-1) {
self.executeScripts(scripts, ++i, idPrefix);
}
});
}
this.nodeName = function (elem, name) {
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
};
this.evalScript = function (elem, id, callback) {
var data = (elem.text || elem.textContent || elem.innerHTML || ''),
head = document.getElementsByTagName('head')[0] ||
document.documentElement;
var script = document.createElement('script');
script.type = "text/javascript";
if (id !== '') {
script.setAttribute('id', id);
}
if (elem.src !== '') {
script.src = elem.src;
head.appendChild(script);
// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;
} else {
try {
// doesn't work on ie...
script.appendChild(document.createTextNode(data));
} catch (e) {
// IE has funky script nodes
script.text = data;
}
head.appendChild(script);
callback();
}
};
this.collectScriptsFromChildren = function (node) {
var scripts = [],
children_nodes = node.childNodes,
child,
i;
if (children_nodes === undefined) {
return;
}
for (i = 0; i<children_nodes.length; i++) {
child = children_nodes[i];
if (this.nodeName(child, 'script') &&
(!child.type || child.type.toLowerCase() === 'text/javascript')
) {
scripts.push(child);
} else {
var newScripts = this.collectScriptsFromChildren(child);
for (var j = 0; j < newScripts.length; j++) {
scripts.push(newScripts[j]);
}
}
}
return scripts;
};
/**
* Active <script type="pr_cookie_category/..."> scripts.
*
* Allowed types are:
* - pr_cookie_category/all
* - pr_cookie_category/{{category_name}}
*
* @param {HTMLScriptElement} notActiveScript
*/
this.activatePrCookieCategoryScript = function (notActiveScript) {
var cookieCategory = notActiveScript.type.replace('pr_cookie_category/', '');
var isScriptAllowed = ('all' === cookieCategory)
? prCookieConsentApi.isAllCategoriesAllowed()
: prCookieConsentApi.isAllowedCategory(cookieCategory);
if (isScriptAllowed) {
var script = document.createElement('script');
script.type = 'text/javascript';
if (notActiveScript.getAttribute('id')) {
script.setAttribute('id', notActiveScript.getAttribute('id'));
}
if (notActiveScript.src) {
script.src = notActiveScript.src;
} else {
script.text = notActiveScript.text;
}
notActiveScript.replaceWith(script);
}
};
}
return new BodyScripts();
});
@@ -0,0 +1,231 @@
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
define([
'underscore',
'ko',
'jquery',
'uiComponent',
'prCookieConsentApi',
'uiRegistry',
'Magento_Ui/js/modal/modal',
'text!Plumrocket_CookieConsent/template/notice/modal/modal-bottom.html',
'text!Plumrocket_CookieConsent/template/notice/modal/modal-popup.html',
'mage/translate',
'mage/cookies',
], function (_, ko, $, Component, prCookieConsentApi, uiRegistry, modal, modalBottomTpl, modalPopupTpl) {
'use strict';
var DISPLAY_STYLE_POPUP = 'popup';
var DISPLAY_STYLE_WALL = 'wall';
var DISPLAY_STYLE_BOTTOM = 'bottom';
return Component.extend({
/**
* @type {{
* titleColor: string,
* textColor: string,
* backgroundColor: string,
* overlayBackgroundColor: string,
* overlayBlur: boolean,
* }}
*/
design: {},
initialize: function (config) {
this._super();
this.createModal = _.once(this.createModal);
},
autoOpen: function () {
this.createModal();
if (false === prCookieConsentApi.canManageCookie()) {
return;
}
if (! prCookieConsentApi.isOptIn() && ! this.isDisabled()) {
this.getModal().openModal();
}
this.addStyles(this.design);
this.addChangingStyleOnHover($('.pr-cookie-notice-btn.allow'), this.acceptButtonConfig);
this.addChangingStyleOnHover($('.pr-cookie-notice-btn.decline'), this.declineButtonConfig);
this.addChangingStyleOnHover($('.pr-cookie-setting-btn'), this.settingsButtonConfig);
},
allowAll: function () {
prCookieConsentApi.consent.allowAllCategories();
this.getModal().closeModal();
},
declineAll: function () {
prCookieConsentApi.consent.declineAll();
this.getModal().closeModal();
},
openSettings: function () {
uiRegistry.get('pr-cookie-settings-bar').getModal().openModal();
},
/**
* @return {String}
*/
getDisplayStyle: function () {
return this.displayStyle;
},
createModal: function () {
var self = this;
var options = {
buttons: [],
modalClass: 'pr-cookie-modal pr-cookie-modal-' + this.getDisplayStyle(),
};
switch (this.getDisplayStyle()) {
case DISPLAY_STYLE_BOTTOM:
options = _.extendOwn(options, {
customTpl: modalBottomTpl,
type: 'custom',
overlayClass: 'pr-cookie-overlay',
parentModalClass: '',
modalVisibleClass: 'show-without-overlay',
keyEventHandlers: {
escapeKey: function () {}
}
});
break;
case DISPLAY_STYLE_WALL:
options = _.extendOwn(options, {
popupTpl: modalPopupTpl,
type: 'popup',
clickableOverlay: false,
canClose: false,
title: this.noticeTitle,
keyEventHandlers: {
escapeKey: function () {}
},
opened: function () {
self.design.overlayBlur && self.overlayBlur.enable();
},
closed: function () {
self.design.overlayBlur && self.overlayBlur.disable();
}
});
break;
case DISPLAY_STYLE_POPUP:
options = _.extendOwn(options, {
popupTpl: modalPopupTpl,
type: 'popup',
clickableOverlay: false,
canClose: true,
title: this.noticeTitle,
modalCloseBtnHandler: this.disableNotice.bind(this),
keyEventHandlers: {
escapeKey: this.disableNotice.bind(this)
},
opened: function () {
self.design.overlayBlur && self.overlayBlur.enable();
},
closed: function () {
self.design.overlayBlur && self.overlayBlur.disable();
},
});
break;
}
this.modal = modal(options, document.getElementById('pr-cookie-notice'));
},
getModal: function () {
this.createModal();
return this.modal;
},
/**
* Check if notice was closed by customer this day
*
* @return {boolean}
*/
isDisabled: function () {
return 'close' === $.mage.cookies.get(this.statusCookieName);
},
/**
* Temporally disable notice
* Don't execute on "closed" event because customer might close popup by accepting cookie
*/
disableNotice: function () {
$.mage.cookies.set(this.statusCookieName, 'close', {lifetime: 86400}); // one day
this.getModal().closeModal();
},
/**
* @param {any} $button
* @param {Object} config
* @param {string} config.type
* @param {string} config.text_color
* @param {string} config.text_color_on_hover
* @param {string} config.background_color
* @param {string} config.background_color_on_hover
* @param {string} config.link_color
* @param {string} config.link_color_on_hover
*/
addChangingStyleOnHover: function ($button, config) {
$button.on({
mouseenter: function () {
$(this).css({
'background-color': (config.type === 'link') ? '' : config.background_color_on_hover,
'border-color': (config.type === 'link') ? '' : config.background_color_on_hover,
'color': (config.type === 'link') ? config.link_color_on_hover : config.text_color_on_hover
})
},
mouseleave: function () {
$(this).css({
'background-color': (config.type === 'link') ? '' : config.background_color,
'border-color': (config.type === 'link') ? '' : config.background_color,
'color': (config.type === 'link') ? config.link_color : config.text_color
});
}
});
},
/**
*
* @param {{titleColor, textColor, backgroundColor, overlayBackgroundColor}} design
*/
addStyles: function (design) {
if (design.titleColor) {
$('.pr-cookie-modal .modal-title').css({'color': design.titleColor});
}
if (design.textColor) {
$('.pr-cookie-notice-text').css({'color': design.textColor});
}
var background = document.querySelector('.pr-cookie-modal > .modal-inner-wrap');
if (design.backgroundColor && background) {
background.style.backgroundColor = design.backgroundColor;
}
var overlayBackground = document.querySelector('.pr-cookie-modal + .modals-overlay');
if (design.overlayBackgroundColor && overlayBackground) {
overlayBackground.style.backgroundColor = design.overlayBackgroundColor;
}
},
overlayBlur: {
enable: function () {
document.querySelector('.page-wrapper').classList.add('blur-mode');
},
disable: function () {
document.querySelector('.page-wrapper').classList.remove('blur-mode');
}
}
});
});
@@ -0,0 +1,302 @@
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
define([
'underscore',
'ko',
'jquery',
'uiComponent',
'prCookieConsentApi',
'uiRegistry',
'Magento_Ui/js/modal/modal',
'text!Plumrocket_CookieConsent/template/settings/modal/modal-slide.html',
'text!Plumrocket_CookieConsent/template/settings/modal/modal-popup.html',
'mage/translate'
], function (_, ko, $, Component, prCookieConsentApi, uiRegistry, modal, modalSlideTpl, modalPopupTpl) {
'use strict';
var DISPLAY_STYLE_ACCORDION_POPUP = 'accordions_popup';
return Component.extend({
acceptButtonLabel: '',
/**
* Contains selected categories to confirm
*/
selectedCategories: [],
initialize: function (config) {
this._super();
this.createModal = _.once(this.createModal);
this.isDetailView = ko.observable(false);
this.currentCategory = ko.observable('');
_.each(this.categories, function (category) {
if (prCookieConsentApi.isAllowedCategory(category.key) || this.isPreChecked(category.key)) {
this.selectedCategories.push(category.key);
}
category.categoryVisible = ko.observable(false);
category.detailVisible = ko.observable(true);
}.bind(this));
this.initOpenCookieSettingsLinks('pr-open-cookie-settings');
prCookieConsentApi.consent.addCallback(this.reset.bind(this));
},
reset: function () {
this.isDetailView(false)
var categories = [];
_.each(this.categories, function (category) {
categories.push(category.key);
category.categoryVisible(false);
category.detailVisible(true);
}.bind(this));
_.each(
document.getElementById('pr-cookie-setting-bar').querySelectorAll('input[type="checkbox"]'),
function (checkbox) {
var categoryKey = checkbox.name;
if (! categories.includes(categoryKey)) {
return;
}
var shouldBeChecked = prCookieConsentApi.isAllowedCategory(categoryKey)
|| this.isPreChecked(categoryKey);
if (Boolean(shouldBeChecked) !== Boolean(checkbox.checked)) {
checkbox.checked = ! checkbox.checked;
}
}.bind(this)
)
},
isAllowed: function (categoryKey) {
return prCookieConsentApi.isAllowedCategory(categoryKey) || this.isPreChecked(categoryKey);
},
isPreChecked: function (categoryKey) {
return ! prCookieConsentApi.isOptIn() && this.getCategoryByKey(categoryKey).is_pre_checked;
},
/**
* Save Choices
*/
confirmChosen: function () {
prCookieConsentApi.consent.set(this.selectedCategories);
this.closeNotice();
this.getModal().closeModal();
},
/**
* Toggle is allowed category in local variable, to save chooses - use "this.confirmChosen"
*
* @param uiClass
* @param {jQuery.Event} jQueryEvent
*/
toggleSelectedCategory: function (uiClass, jQueryEvent) {
/** @type {HTMLInputElement} input */
var input = jQueryEvent.target;
var categoryKey = input.name;
if (input.checked) {
if (! this.selectedCategories.includes(categoryKey)) {
this.selectedCategories.push(categoryKey);
}
} else {
this.selectedCategories = _.without(this.selectedCategories, categoryKey);
}
},
createModal: function () {
var options = {
buttons: [],
};
switch (this.displayStyle) {
case DISPLAY_STYLE_ACCORDION_POPUP:
options = _.extendOwn(options, {
popupTpl: modalPopupTpl,
type: 'popup',
modalClass: 'pr-cookie-details-modal',
canClose: false
});
break;
default:
options = _.extendOwn(options, {
slideTpl: modalSlideTpl,
type: 'slide',
modalClass: 'pr-cookie-left-bar'
});
}
this.modal = modal(options, document.getElementById('pr-cookie-setting-bar'));
this.addChangingStyleOnHover($('#pr-cookie-setting-bar .action.confirm'), this.confirmButtonConfig);
this.addChangingStyleOnHover($('#pr-cookie-setting-bar .action.allow'), this.acceptButtonConfig);
this.addChangingStyleOnHover($('#pr-cookie-setting-bar .action.decline'), this.declineButtonConfig);
},
getModal: function () {
this.createModal();
return this.modal;
},
closeNotice: function () {
uiRegistry.get('pr-cookie-notice').getModal().closeModal();
},
/**
* @param $button
* @param {{type, text_color, text_color_on_hover, background_color, background_color_on_hover}} config
*/
addChangingStyleOnHover: function ($button, config) {
$button.on({
mouseenter: function () {
$(this).css({
'background-color': null !== config.background_color_on_hover ? config.background_color_on_hover : '',
'border-color': null !== config.background_color_on_hover ? config.background_color_on_hover : '',
'color': null !== config.text_color_on_hover ? config.text_color_on_hover : ''
})
},
mouseleave: function () {
$(this).css({
'background-color': null !== config.background_color ? config.background_color : '',
'border-color': null !== config.background_color ? config.background_color : '',
'color': null !== config.text_color ? config.text_color : ''
});
}
});
},
allowAll: function () {
prCookieConsentApi.consent.allowAllCategories();
this.closeNotice();
this.getModal().closeModal();
},
declineAll: function () {
prCookieConsentApi.consent.declineAll();
this.closeNotice();
this.getModal().closeModal();
},
showCookieDetails: function (uiClass, jQueryEvent) {
this.currentCategory(jQueryEvent.target.dataset.categoryKey);
this.isDetailView(true);
},
hideCookieDetails: function () {
this.isDetailView(false);
},
/**
* Get category by key
*
* @param {string} categoryKey
* @return {{}}
*/
getCategoryByKey: function (categoryKey) {
return _.find(this.categories, function (category) {
return category.key === categoryKey;
});
},
/**
* Get category name by key
*
* @param {string} categoryKey
* @return {string}
*/
getCategoryNameByKey: function (categoryKey) {
var category = this.getCategoryByKey(categoryKey);
return category ? category.name : categoryKey;
},
/**
* @param {string} categoryKey
* @return {[]}
*/
getGroupedCookies: function (categoryKey) {
var firstPartyCookies = [];
var thirdPartyCookies = [];
var result = [];
this.cookies.forEach(function (cookie) {
if (cookie.category_key === categoryKey) {
if (cookie.type === 'first') {
firstPartyCookies.push(cookie);
} else {
thirdPartyCookies.push(cookie);
}
}
});
if (firstPartyCookies.length > 0) {
result.push(
{
name: $.mage.__('First party'),
cookies: firstPartyCookies,
checkThirdParty: thirdPartyCookies.length > 0
}
);
}
var groupdThirdPartyCookies = thirdPartyCookies.reduce(function (cookiesByDomain, cookie) {
if (!cookiesByDomain[cookie.domain]) {
cookiesByDomain[cookie.domain] = [];
}
cookiesByDomain[cookie.domain].push(cookie);
return cookiesByDomain;
}, {});
_.each(groupdThirdPartyCookies, function (cookiesWithSameDomain) {
result.push({
name: cookiesWithSameDomain[0].domainLabel,
cookies: cookiesWithSameDomain,
checkThirdParty: thirdPartyCookies.length > 0
});
});
return result;
},
/**
* @param {string} categoryKey
* @return {boolean}
*/
isCategoryHasCookie: function (categoryKey) {
return _.some(this.cookies, function (cookie) {
return cookie.category_key === categoryKey;
});
},
closeModal: function () {
this.getModal().closeModal();
},
/**
* Add event listener to show this component (Settings Panel)
*
* We have added this logic to component to avoid separate js file loading
*
* @param openSettingsClass
*/
initOpenCookieSettingsLinks(openSettingsClass) {
$('body').on('click', function (event) {
if (event.target.classList.contains(openSettingsClass)) {
this.getModal().openModal();
}
}.bind(this));
},
toggleAccordion: function () {
this.categoryVisible(!this.categoryVisible())
},
toggleAccordionCookieDetails: function (data) {
this.detailVisible(!this.detailVisible());
},
});
});
@@ -0,0 +1,37 @@
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
define([
'jquery',
'prCookieConsentApi'
], function ($, prCookieConsentApi) {
'use strict';
/**
* @param {{
* categoryKey: string
* }} config
*/
return function (config) {
function changeNoCookieDomain()
{
var youtubeNoCookieIframes = $('iframe').filter(function () {
return this.src.indexOf('youtube-nocookie.com') !== -1;
});
youtubeNoCookieIframes.each(function (index, iframe) {
iframe.src = iframe.src.replace('youtube-nocookie.com', 'youtube.com');
});
}
prCookieConsentApi.userScript.execute(
function () {
changeNoCookieDomain(config);
},
config.categoryKey
);
}
});