ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @package Plumrocket_ExtendedAdminUi
|
||||
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'Plumrocket_ExtendedAdminUi/js/lib/chosen.jquery.min'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
/**
|
||||
* Registry for all selects with class pr-chosen
|
||||
*/
|
||||
initializedSelects: [],
|
||||
|
||||
/**
|
||||
* @param {string} selector
|
||||
* @param {{enabled: boolean, allIndex: string}} dependConfig
|
||||
*/
|
||||
initializeChosen: function (selector, dependConfig) {
|
||||
var selects = this.getChosenSelects(selector);
|
||||
selects.forEach(function (select) {
|
||||
if (! this.isInitializedSelect(select)) {
|
||||
this.initializeSelect(select);
|
||||
this.initializeOptionDepends(select, dependConfig);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} selector
|
||||
* @returns {HTMLSelectElement[]}
|
||||
*/
|
||||
getChosenSelects: function (selector) {
|
||||
var result = $(selector);
|
||||
return result.length ? result.toArray() : [];
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
* @returns {boolean|number|*}
|
||||
*/
|
||||
initializeSelect: function (select) {
|
||||
if (!select instanceof HTMLElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isInitializedSelect(select)) {
|
||||
return this.getIndexOfRegisteredSelect(select);
|
||||
}
|
||||
|
||||
var enableSearch = true;
|
||||
if ('readonly' === select.getAttribute('readonly')) {
|
||||
enableSearch = false;
|
||||
}
|
||||
|
||||
$(select).chosen({
|
||||
'display_selected_options': true,
|
||||
'display_disabled_options': true,
|
||||
'hide_results_on_select': true,
|
||||
'group_search': enableSearch
|
||||
});
|
||||
|
||||
return this.initializedSelects.push(select.name);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
* @returns {number}
|
||||
*/
|
||||
getIndexOfRegisteredSelect: function (select) {
|
||||
return this.initializedSelects.indexOf(select.name);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isInitializedSelect: function (select) {
|
||||
return -1 !== this.getIndexOfRegisteredSelect(select);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
*/
|
||||
reinitializeSelect: function (select) {
|
||||
if (this.isInitializedSelect(select)) {
|
||||
$(select).chosen('destroy');
|
||||
this.initializedSelects.splice(this.getIndexOfRegisteredSelect(select), 1);
|
||||
this.initializeSelect(select);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
*/
|
||||
updateSelect: function (select) {
|
||||
this.initializeSelect(select);
|
||||
$(select).trigger('chosen:updated');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {HTMLSelectElement} select
|
||||
* @param {{enabled: boolean, allIndex: string}} dependConfig
|
||||
*/
|
||||
initializeOptionDepends: function (select, dependConfig) {
|
||||
if (! dependConfig.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initializeSelect(select);
|
||||
|
||||
var $select = $(select);
|
||||
|
||||
var initialValues = !$select.val() ? [] : $select.val();
|
||||
var initialShowToAllIndex = initialValues.indexOf(dependConfig.allIndex);
|
||||
|
||||
var chosenModel = this;
|
||||
$select.on('change', function () {
|
||||
var values = !$(this).val() ? [] : $(this).val();
|
||||
var showToAllIndex = values.indexOf(dependConfig.allIndex);
|
||||
|
||||
if (-1 !== initialShowToAllIndex) {
|
||||
if (-1 !== showToAllIndex && values.length > 1) {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
values.splice(showToAllIndex, 1);
|
||||
}
|
||||
$select.val(values);
|
||||
}
|
||||
} else {
|
||||
if (-1 !== showToAllIndex && values.length > 1) {
|
||||
$select.val([dependConfig.allIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$(this).val()) {
|
||||
$(this).val([dependConfig.allIndex]);
|
||||
}
|
||||
|
||||
initialValues = $(this).val() === null ? [] : $(this).val();
|
||||
initialShowToAllIndex = initialValues.indexOf(dependConfig.allIndex);
|
||||
chosenModel.updateSelect(select);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @package Plumrocket_ExtendedAdminUi
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated added for magento 2.2
|
||||
* for magento >= 2.3 please use their color picker
|
||||
* @link https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/ui-colorpicker.html
|
||||
*/
|
||||
define([
|
||||
'mage/translate',
|
||||
'Magento_Ui/js/form/element/abstract',
|
||||
'pickr',
|
||||
], function ($t, Abstract, Pickr) {
|
||||
'use strict';
|
||||
|
||||
return Abstract.extend({
|
||||
|
||||
defaults: {
|
||||
colorPickerConfig: {
|
||||
theme: 'monolith',
|
||||
useAsButton: false,
|
||||
comparison: false,
|
||||
swatches: [
|
||||
'rgba(244, 67, 54, 1)',
|
||||
'rgba(233, 30, 99, 0.95)',
|
||||
'rgba(156, 39, 176, 0.9)',
|
||||
'rgba(103, 58, 183, 0.85)',
|
||||
'rgba(63, 81, 181, 0.8)',
|
||||
'rgba(33, 150, 243, 0.75)',
|
||||
'rgba(3, 169, 244, 0.7)',
|
||||
'rgba(0, 188, 212, 0.7)',
|
||||
'rgba(0, 150, 136, 0.75)',
|
||||
'rgba(76, 175, 80, 0.8)',
|
||||
'rgba(139, 195, 74, 0.85)',
|
||||
'rgba(205, 220, 57, 0.9)',
|
||||
'rgba(255, 235, 59, 0.95)',
|
||||
'rgba(255, 193, 7, 1)'
|
||||
],
|
||||
|
||||
components: {
|
||||
|
||||
// Main components
|
||||
preview: true,
|
||||
opacity: true,
|
||||
hue: true,
|
||||
|
||||
// Input / output Options
|
||||
interaction: {
|
||||
hex: true,
|
||||
rgba: true,
|
||||
hsla: false,
|
||||
hsva: false,
|
||||
cmyk: false,
|
||||
input: true,
|
||||
clear: true,
|
||||
save: false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Invokes initialize method of parent class,
|
||||
* contains initialization logic
|
||||
*/
|
||||
initialize: function () {
|
||||
this._super();
|
||||
|
||||
this.colorPickerConfig.default = this.value() ? this.value() : null;
|
||||
this.colorPickerConfig.disabled = this.disabled();
|
||||
this.colorPickerConfig.el = '#' + this.uid + '_color_picker';
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
initColorPicker: function () {
|
||||
var self = this;
|
||||
var pickr = Pickr.create(self.colorPickerConfig);
|
||||
|
||||
pickr.on('change', function (color, instance) {
|
||||
if (null === color) {
|
||||
self.value('');
|
||||
} else {
|
||||
self.value(color.toHEXA().toString());
|
||||
}
|
||||
});
|
||||
|
||||
pickr.on('clear', function (instance) {
|
||||
self.value('');
|
||||
});
|
||||
|
||||
self.value.subscribe(function (newValue) {
|
||||
if (newValue === '') {
|
||||
pickr.setColor(null);
|
||||
} else {
|
||||
pickr.setColor(newValue);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @package Plumrocket_ExtendedAdminUi
|
||||
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
return {
|
||||
initialize: function (rowId) {
|
||||
var $grid = $('#' + rowId + ' > td.value .data-grid tbody');
|
||||
|
||||
this.waitMageInitialization($grid, function (rowId, $grid) {
|
||||
const $inherit = $('#' + rowId + '_inherit:checked');
|
||||
if ($inherit.length) {
|
||||
$inherit.click();
|
||||
}
|
||||
|
||||
let rowTemplate = $grid.find('tr:first-child').html();
|
||||
$grid.find('tr:first-child').remove();
|
||||
$grid.addClass('loaded');
|
||||
|
||||
this.initAddButton(rowId, $grid, rowTemplate);
|
||||
this.initRemoveButton($grid);
|
||||
}.bind(this, rowId, $grid))
|
||||
},
|
||||
initAddButton: function (rowId, $grid, template) {
|
||||
$('#' + rowId + ' > td.value > .add-row-value').on('click', function () {
|
||||
let name = 'row-value-' + Date.now();
|
||||
$grid.append('<tr>'+ template.split('_TMPNAME_').join(name) +'</tr>');
|
||||
return false;
|
||||
});
|
||||
},
|
||||
initRemoveButton: function ($grid) {
|
||||
$grid.on('click', '.remove-row-value', function () {
|
||||
$(this).parent().parent().remove();
|
||||
});
|
||||
},
|
||||
waitMageInitialization: function ($grid, callback) {
|
||||
let interval = setInterval(function () {
|
||||
if ($grid.find('*[data-mage-init]').length === 0) {
|
||||
callback();
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
||||
+6
File diff suppressed because one or more lines are too long
+3
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_Extension
|
||||
* @copyright Copyright (c) 2026 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
var __prinitparam = 'MzM5Njkw';
|
||||
Reference in New Issue
Block a user