This commit is contained in:
2024-06-25 02:27:29 +03:00
parent 36e40a3035
commit 69c8e0e86c
50 changed files with 11388 additions and 10209 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module Action */ /** @module Action */
kit.PluginManager.register('Action', function(module, exports, require, global) { __PluginManager__.register('Action', function(require, exports, module, global) {
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module ActionCollection */ /** @module ActionCollection */
kit.PluginManager.register('ActionCollection', function(module, exports, require, global) { __PluginManager__.register('ActionCollection', function(require, exports, module, global) {
var Collection = require('Collection'); var Collection = require('Collection');
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module Viewer */ /** @module Viewer */
kit.PluginManager.register('Viewer', function(module, exports, require, global) { __PluginManager__.register('Viewer', function(require, exports, module, global) {
var Collection = require('Collection'); var Collection = require('Collection');
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module align */ /** @module align */
kit.PluginManager.register('align',function(module, exports, require) { __PluginManager__.register('align',function(require, exports, module) {
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -2,7 +2,7 @@
* @link https://animista.net/ * @link https://animista.net/
* @module animations * @module animations
**/ **/
kit.PluginManager.register('animations',function(module, exports, require, global) { __PluginManager__.register('animations',function(require, exports, module, global) {
/** /**
* @memberOf kit * @memberOf kit
+1 -1
View File
@@ -1,5 +1,5 @@
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); //(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
(function (global, factory) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) : typeof define === 'function' && define.amd ? define(factory) :
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module bsCore */ /** @module bsCore */
kit.PluginManager.register('bsCore', function(module, exports, require, global){ __PluginManager__.register('bsCore', function(require, exports, module, global){
/** /**
* @memberOf kit * @memberOf kit
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module bsToast */ /** @module bsToast */
kit.PluginManager.register('bsToast', function(module, exports, require){ __PluginManager__.register('bsToast', function(require, exports, module){
var bsCore = require('bsCore'); var bsCore = require('bsCore');
var var
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module bsToastService */ /** @module bsToastService */
kit.PluginManager.register('bsToastService', function(module, exports, require, global){ __PluginManager__.register('bsToastService', function(require, exports, module, global){
var support = require('support'); var support = require('support');
var bsToast = require('bsToast'); var bsToast = require('bsToast');
var Collection = require('Collection'); var Collection = require('Collection');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module chosen */ /** @module chosen */
kit.PluginManager.register('Chosen', function(module, exports, require, global) { __PluginManager__.register('Chosen', function(require, exports, module, global) {
var jQuery = require('jQuery'); var jQuery = require('jQuery');
/*! /*!
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('collapse', function(module, exports, require) { __PluginManager__.register('collapse', function(require, exports, module) {
var bsCore = require('bsCore'); var bsCore = require('bsCore');
/** /**
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module Collection */ /** @module Collection */
kit.PluginManager.register('Collection', function(module, exports, require, global) { __PluginManager__.register('Collection', function(require, exports, module, global) {
var support = require('support'); var support = require('support');
var valueEx = support.valueEx; var valueEx = support.valueEx;
+3 -4
View File
@@ -2,8 +2,7 @@
* @namespace kit * @namespace kit
* @module kit * @module kit
*/ */
var kit; window.kit = window.kit || {};
kit = window.kit = window.kit || {};
/** /**
* @typedef kit.service * @typedef kit.service
*/ */
@@ -17,7 +16,7 @@ kit.config = kit.config || {};
Object.assign(kit.config, { Object.assign(kit.config, {
debug: true, debug: true,
assetsPath: '/local/templater.dev/kit/assets', assetsPath: '/local/templater.dev/kit/assets',
requiredDependencies: ['bsCore', 'toolkit', 'support'], requiredDependencies: [],
autoloadPluginList: ['tooltip', 'support'], autoloadPluginList: ['tooltip'],
defaultPhoneMask: '+7 (999) 999-99-99', defaultPhoneMask: '+7 (999) 999-99-99',
}); });
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @module cookie * @module cookie
**/ **/
kit.PluginManager.register('cookie', function(module, exports, require){ __PluginManager__.register('cookie', function(require, exports, module){
var defaultConverter = { var defaultConverter = {
read: function (value) { read: function (value) {
+820 -615
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+425
View File
@@ -0,0 +1,425 @@
var __PluginManagerConfigHandler__ = function() {
var root = __pmConfig__.assetsPath;
return {
menu: {
path: root + '/menu',
module: '/menu.js',
css: [
'/menu.css'
],
type: 'HMD',
deps: ['lib', 'align', 'dataStructures', 'animations', 'userAction', 'Collection', 'support', 'ActionCollection', 'Action', 'Viewer']
},
lib: {
path: root + '/lib',
module: '/lib.js',
type: 'HMD',
},
align: {
path: root + '/align',
module: '/align.js',
type: 'HMD',
deps: ['support']
},
flexKit: {
path: root + '/flex-kit',
css: '/flex-kit.css'
},
support: {
path: root + '/support',
module: '/support.js',
type: 'HMD',
},
jqueryIniter: {
type: 'HMD',
handler: function(require, exports, module, global){
var J = function (){
var c = [];
J.queue.push(c);
c.push(['$', arguments]);
var J2 = function(){}
J2.ready = function (){
c.push(['ready', arguments]);
}
return J2
}
J.queue = [];
function JQueryIniter(){}
JQueryIniter.prototype.J = J;
JQueryIniter.prototype.hasJQuery = function(){
return window.hasOwnProperty('jQuery') && window.jQuery.hasOwnProperty('fn');
};
JQueryIniter.prototype.hasJQueryIniter = function(){
return window.hasOwnProperty('jQuery') && Object.is(window.jQuery, J);
};
JQueryIniter.prototype.onRegister = function(plugin){
if(!this.hasJQuery()){
(function(w){
w.$ = w.jQuery = J;
plugin.module.initer = J;
})(window);
}
};
JQueryIniter.prototype.onInstall = function(plugin){
var self = this;
(function(w){
var q = plugin.module.initer.queue;
if(self.hasJQueryIniter()){
w.$ = w.jQuery = plugin.module.exports;
for (var ch of q){
var root = w;
for (var c of ch){
root = root[c[0]].apply(c[0], c[1]);
}
}
}
})(window);
};
module.exports = new JQueryIniter();
},
},
jquery: {
path: root + '/jquery',
module: '/jquery.min.js',
type: 'UMD',
alias: ['$', 'jQuery'],
onRegister: function (plugin) {
console.log('reg jq');
var initer = kit.require('jqueryIniter');
initer.onRegister(plugin);
},
onInstall: function(plugin){
var initer = kit.require('jqueryIniter');
initer.onInstall(plugin);
},
},
popper: {
path: root + '/popper',
alias: 'popper.js',
module: '/popper.js',
type: 'HMD',
css: '/popper.css',
},
bsCore: {
path: root + '/bsCore',
module: '/bsCore.js',
type: 'HMD',
css: [
'/bsCore.css'
]
},
bsToast: {
path: root + '/bsToast',
module: '/bsToast.js',
type: 'HMD',
deps: ['bsCore'],
},
bsToastService: {
path: root + '/bsToastService',
module: '/bsToastService.js',
type: 'HMD',
css: [
'/bsToastService.css'
],
deps: ['bsToast', 'support', 'Collection'],
},
Tooltip: {
path: root + '/tooltip',
module: '/tooltip.js',
type: 'HMD',
css: '/tooltip.css',
onInstall: function (plugin) {
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return __pmGlobal__.Tooltip.getOrCreateInstance(tooltipTriggerEl, {sanitize: false});
});
},
deps: ['popper', 'bsCore'],
},
Tooltip2: {
path: root + '/tooltip2',
module: '/tooltip2.js',
type: 'HMD',
css: '/tooltip2.css',
onInstall: function (plugin) {
console.log('tt2 install');
document.addEventListener('mouseover', function (event) {
// console.log(event);
// console.log(event.target);
if (!(event.target && event.target.dataset.kitTooltip2 === 'autoload')) {
return;
}
// console.log(1);
if (kit.support.getNodeData(event.target, 'tooltip2')) {
return;
}
// console.log(2);
var tooltip = new __pmGlobal__.Tooltip2(event.target);
tooltip.run();
tooltip.show();
});
// var elements = [].slice.call(document.querySelectorAll('[data-kit-tooltip2="autoload"]'));
// elements.map(function (element) {
// var tooltip = new __pmGlobal__.Tooltip2(element);
// tooltip.run();
// console.log(tooltip);
// });
},
deps: ['Viewer', 'support', 'ActionCollection', 'Action', 'userAction', 'align', 'Collection', 'animations'],
},
Popover: {
path: root + '/popover',
module: '/popover.js',
type: 'HMD',
css: '/popover.css',
onInstall: function () {
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new __pmGlobal__.Popover(popoverTriggerEl);
});
},
deps: ['popper', 'bsCore', 'Tooltip'],
},
mask: {
path: root + '/mask',
module: '/mask.js',
type: 'HMD',
deps: ['jQuery'],
},
toolkit: {
path: root + '/toolkit',
module: '/toolkit.js',
type: 'HMD',
css: ['/toolkit.css'],
deps: ['jQuery', 'mask', 'support'],
},
Modal: {
path: root + '/modal',
module: '/modal.js',
type: 'HMD',
css: [
'/modal.css',
],
deps: ['bsCore'],
onRegister: function (plugin) {
plugin.onLoadConditionHandler = function (event) {
if (event.target && event.target.dataset && event.target.dataset.bsTarget && event.target.dataset.bsToggle === 'modal') {
kit.exec(plugin.id, function () {
var newEvent = new Event("click");
event.target.dispatchEvent(newEvent);
});
}
};
window.addEventListener('click', plugin.onLoadConditionHandler, false);
},
onInstall: function (plugin) {
if (plugin.onLoadConditionHandler) {
window.removeEventListener('click', plugin.onLoadConditionHandler, false);
}
},
},
collapse: {
path: root + '/collapse',
module: '/collapse.js',
type: 'HMD',
css: [
'/collapse.css',
],
deps: ['bsCore'],
},
datepicker: {
path: root + '/datepicker',
module: '/js/datepicker.js',
type: 'HMD',
css: [
'/css/datepicker.css',
],
deps: ['jQuery'],
},
cookie: {
path: root + '/cookie',
module: '/cookie.js',
type: 'HMD',
},
animations: {
path: root + '/animations',
css: '/animations.css',
module: '/animations.js',
type: 'HMD',
},
Collection: {
path: root + '/collection',
module: '/collection.js',
type: 'HMD',
deps: ['support'],
},
dataStructures: {
path: root + '/dataStructures',
module: '/dataStructures.js',
type: 'HMD',
},
userAction: {
path: root + '/userAction',
module: '/userAction.js',
type: 'HMD',
deps: ['support', 'ActionCollection', 'Action', 'Viewer'],
},
Viewer: {
path: root + '/Viewer',
module: '/Viewer.js',
type: 'HMD',
deps: ['Collection', 'support', 'ActionCollection', 'Action'],
},
ActionCollection: {
path: root + '/ActionCollection',
module: '/ActionCollection.js',
type: 'HMD',
deps: ['Collection', 'support', 'Action'],
},
Action: {
path: root + '/Action',
module: '/Action.js',
type: 'HMD',
deps: ['support'],
},
date: {
path: root + '/date',
module: '/date.js',
type: 'HMD',
deps: [],
},
testing: {
path: root + '/testing',
module: '/testing.js',
type: 'module',
deps: ['log'],
},
log: {
path: root + '/log',
module: '/log.js',
css: '/log.css',
type: 'HMD',
deps: ['support', 'Collection', 'lib']
},
fancybox: {
path: root + '/fancybox',
css: '/fancybox.css',
js: '/fancybox.umd.js',
},
lightGallery: {
path: root + '/lightGallery',
css: '/lightGallery.css',
js: '/lightGallery.js',
deps: ['jQuery'],
},
owlCarousel: {
path: root + '/owlCarousel',
css: '/owlCarousel.css',
js: '/owlCarousel.js',
deps: ['jQuery'],
},
Chosen: {
path: root + '/chosen',
css: '/chosen.css',
js: '/chosen.jquery.js',
deps: ['jQuery'],
},
makeCSSAnimations: {
path: root + '/makeCSSAnimations',
js: '/makeCSSAnimations.js',
deps: ['jQuery', 'support'],
},
mCustomScrollbar: {
path: root + '/mCustomScrollbar',
alias: 'malihu-custom-scrollbar-plugin',
js: '/mCustomScrollbar.js',
css: '/jquery.mCustomScrollbar.css',
deps: ['jQuery', 'jqueryMousewheel'],
onInstall: function (plugin) {
plugin.module.exports(kit.require('jQuery'));
}
},
jqueryMousewheel: {
path: root + '/jqueryMousewheel',
alias: 'jquery-mousewheel',
js: '/jquery.mousewheel.js',
deps: ['jQuery'],
onInstall: function (plugin) {
plugin.module.exports(kit.require('jQuery'));
}
},
jqueryLazy: {
path: root + '/jquery-lazy',
alias: 'jquery-lazy',
js: [
'/jquery.lazy.min.js',
'/jquery.lazy.plugins.min.js',
],
deps: ['jQuery'],
},
slickCarousel: {
path: root + '/slickCarousel',
alias: ['slick', 'slick-carousel'],
js: '/slick.min.js',
css: [
'/slick.css',
'/slick-theme.css',
],
deps: ['jQuery'],
},
mustache: {
path: root + '/mustache',
alias: ['mustache.js'],
js: '/mustache.js',
deps: [],
},
bxSlider: {
path: root + '/bxSlider',
module: '/jquery.bxslider.min.js',
css: [
'/jquery.bxslider.min.css',
],
type: 'import',
deps: ['jQuery'],
},
selectric: {
path: root + '/selectric',
module: '/jquery.selectric.min.js',
css: [
'/selectric.css',
],
type: 'import',
alias: ['jquerySelectric'],
deps: ['jQuery'],
},
jBox: {
path: root + '/jBox',
module: '/jBox.min.js',
css: [
'/jBox.min.css',
],
type: 'import',
deps: ['jQuery'],
},
intlTelInput: {
path: root + '/intl-tel-input',
module: '/js/intlTelInput.min.js',
css: [
'/css/intlTelInput.min.css',
],
type: 'import',
alias: ['intl-tel-input'],
},
autoComplete: {
path: root + '/autoComplete',
module: '/autoComplete.min.js',
css: [
'/css/autoComplete.css',
],
type: 'HMD',
},
};
};
File diff suppressed because one or more lines are too long
+730
View File
@@ -0,0 +1,730 @@
var kit;
kit = window.kit = window.kit || {};
kit.service = kit.service || {};
kit.config = kit.config || {};
(function(global){
var stateList = {
undefined: 0,
registered: 1,
loaded: 3,
installed: 4,
};
var moduleTypeList = {
loader: 'loader',
import: 'import',
};
/**
* @class PluginManager
* @param global
* @param plugins
* @memberOf kit
*/
var PluginManager = function(global, plugins = {}){
this.plugins = {};
this.global = global;
this.registerPlugins(plugins);
};
/**
*
* @type {kit.PluginManager|PluginManager}
* @private
*/
var __proto = PluginManager.prototype;
__proto.__checkState = function(pluginId, state){
return this.plugins.hasOwnProperty(pluginId) && this.plugins[pluginId].state >= state;
};
/**
* @param plugins
* @return {PluginManager}
*/
__proto.registerPlugins = function (plugins) {
if(Array.isArray(plugins)) {
plugins = Object.assign({}, plugins);
}
for (var pluginId in plugins) {
if(plugins.hasOwnProperty(pluginId)) {
this.register(pluginId, plugins[pluginId]);
}
}
return this;
};
/**
* @return {boolean}
*/
__proto.register = function (pluginId, config = {}) {
//console.warn('PluginManager.register: plugin ' + pluginId + ' ('+(this.plugins[pluginId]?this.plugins[pluginId].state:'0')+')');
var defaultPlugin = {
module: {
exports: {},
},
config: {
},
promise: new Promise(function(resolve, reject){resolve()}),
id: pluginId,
state: stateList.undefined,
stateInit: {
loading: false,
installing: false,
},
};
var plugin = this.__getPlugin(pluginId);
if(plugin) {
pluginId = plugin.id;
} else {
plugin = this.plugins[pluginId] = defaultPlugin;
}
/**
* @todo !!!
*/
if(
(this.__checkState(pluginId, stateList.installed) && typeof config.loader === 'function') ||
(
(plugin.stateInit.loading || this.__checkState(pluginId, stateList.loaded)) && typeof config === 'object'
)
) {
console.warn('PluginManager.register: plugin ' + pluginId + ' уже невозможно конфигурировать ('+plugin.state+')');
return false;
}
var loader;
if(typeof config === 'function') {
loader = config;
config = plugin.config;
config.loader = loader;
config.type = 'loader';
if(this.__checkState(pluginId, stateList.registered)) {
if(this.__checkState(pluginId, stateList.loaded)){
plugin.stateInit.installing = false;
}
//console.log(`PluginManager.register(${pluginId}): (${plugin.state} > ${stateList.registered})`);
plugin.state = stateList.registered;
if(plugin.config.autoRequire) {
this.require(pluginId);
}
}
}
if(typeof config === 'object') {
if(typeof config.onLoad !== 'function') {
config.onLoad = function(){};
}
if(typeof config.onInstall !== 'function') {
config.onInstall = function(){};
}
if(typeof config.onRegister !== 'function') {
config.onRegister = function(){};
}
if(typeof config.path !== 'string') {
config.path = '';
}
if(!config.hasOwnProperty('modulePath')) {
config.modulePath = config.path;
} else if(typeof config.modulePath !== 'string') {
config.modulePath = config.path;
}
if(typeof config.js === 'string') {
config.js = [config.js];
} else if(!Array.isArray(config.js)) {
config.js = [];
}
if(typeof config.css === 'string') {
config.css = [config.css];
} else if(!Array.isArray(config.css)) {
config.css = [];
}
if(typeof config.alias === 'string') {
config.alias = [config.alias];
} else if(!Array.isArray(config.alias)) {
config.alias = [];
}
config.loadJsAfterModule = !!config.loadJsAfterModule;
config.isSetTimestamp = config.hasOwnProperty('isSetTimestamp')?!!config.isSetTimestamp:true;
config.type = config.type || 'import'; //loader
if(typeof config.deps === 'string') {
config.deps = [config.deps];
} else if(!Array.isArray(config.deps)) {
config.deps = [];
}
} else {
console.warn('PluginManager.register: plugin ' + pluginId + ' is not a valid format');
return false;
}
Object.assign(plugin.config, config);
if(!this.__checkState(pluginId, stateList.registered)) {
plugin.state = stateList.registered;
plugin.config.onRegister(plugin);
var event = new CustomEvent("onRegister" + plugin.id + "Plugin", {
"detail": {plugin: plugin}
});
document.dispatchEvent(event);
}
return true;
};
/**
* @param pluginId
* @param callback
* @return {PluginManager}
*/
__proto.load = function (pluginId, callback) {
var self = this;
//console.log('PluginManager.load: plugin ' + pluginId + ' ('+(this.plugins[pluginId]?this.plugins[pluginId].state:'0')+')');
if(typeof callback !== 'function') {
callback = function(){};
}
var plugin = this.__getPlugin(pluginId);
if(plugin) {
pluginId = plugin.id;
}
if(!this.__checkState(pluginId, stateList.registered)) {
console.warn('kit.load: plugin ' + pluginId + ' is not register');
return this;
}
if(this.__checkState(pluginId, stateList.loaded)) {
//console.warn('PluginManager.load: plugin ' + pluginId + ' уже загружен');
callback();
return this;
}
if(plugin.stateInit.loading) {
//console.log('PluginManager.install: plugin ' + pluginId + ' уже грузится');
this.__exec(pluginId, callback);
return this;
}
plugin.stateInit.loading = true;
var configModule = plugin.config;
var stackPush = function (callbackPromise, argArr = []){
if(typeof plugin.promise === 'undefined') {
plugin.promise = callbackPromise.apply(this, argArr);
} else {
plugin.promise = plugin.promise.then(function(m){
return callbackPromise.apply(this, argArr);
});
}
}.bind(this);
var getModulePromise = (function () {
function getFileLoadNode(src) {
src = src.match(/^[^#?]*/)[0];
return document.querySelector('script[src^="'+src+'"]') ||
document.querySelector('link[href^="'+src+'"]') ||
document.querySelector('meta[property="kit:file-load"][content="'+src+'"]');
}
function loadScript(src, resolveCallback, rejectCallback) {
var originSrc = src;
src = String(src).split('?')[0];
if(typeof resolveCallback !== 'function'){
resolveCallback = function(){};
}
if(typeof rejectCallback !== 'function'){
rejectCallback = function(res){
console.warn(res.message, originSrc);
};
}
return new Promise(function(resolve, reject) {
var loadNode = getFileLoadNode(src);
if (loadNode) {
global.config.debug && console.warn(`Скрипт ${src} уже загружен`);
// self.__ready(resolve, [loadNode]);
resolve();
} else {
var script = document.createElement('script');
try {
var url = new URL(originSrc);
if(plugin.config.isSetTimestamp){
url.searchParams.append('__pm', (new Date()).getTime());
}
script.src = url.toString();
} catch (e) {
script.src = '' + src + '?__pm' + ((new Date()).getTime());
}
script.onload = function() {resolve(script);};
script.onerror = function() {reject(new Error(`Ошибка загрузки скрипта ${src}`));};
document.head.append(script);
}
}).then(resolveCallback, rejectCallback);
}
function syncLoadScriptList(list) {
return new Promise(function(resolve, reject) {
var i = 0;
var status = true;
var count = list.length;
var checkResolve = function(src, cond){
if(!cond) {
console.error(`Ошибка загрузки скрипта ${src}`)
}
status = status && cond;
i++;
if(i === count) {
resolve();
}
};
var syncPromise = new Promise(function(_resolve, _reject){_resolve();});
list.forEach(function(item, i, arr){
syncPromise.then(function(){
var src = configModule.path + item;
var loadNode = getFileLoadNode(src);
if(loadNode){
self.__ready(resolve, [src, true]);
// resolve(src, true);
} else {
var script = document.createElement('script');
script.src = '' + src + '?__pm' + (new Date()).getTime();
script.onload = () => checkResolve(src, true);
script.onerror = () => checkResolve(src, false);
document.head.append(script);
}
});
});
})
}
function loadStyle(src) {
return new Promise(function(resolve, reject) {
var loadNode = getFileLoadNode(src);
if(loadNode) {
global.config.debug && console.warn(`Стиль ${src} уже загружен`);
// self.__ready(resolve, [src]);
resolve();
} else {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = src + '?__pm' + (new Date()).getTime();
link.media = 'all';
document.head.append(link);
resolve(link);
}
});
}
var getImportPromise = function (){
if(configModule.module && configModule.type === 'import') {
return import(configModule.modulePath + configModule.module).then(function(m) {
m.__esModule = true;
plugin.module.exports = m;
}.bind(this), function(r){
console.error(r);
});
} else if(configModule.module && configModule.type === 'loader' && !(configModule.hasOwnProperty('loader') && typeof configModule.loader === 'function')) {
return loadScript(configModule.modulePath + configModule.module).then(function() {
}.bind(this));
}
return new Promise(function(resolve, reject){resolve();});
}.bind(this);
var getResPromise = function(){
var p = new Promise(function(resolve, reject){resolve();});
configModule.js.forEach(function(item, i, array){
if(Array.isArray(item)) {
p = p.then(function () {
return syncLoadScriptList(item);
});
} else {
p = p.then(function () {
return loadScript(configModule.path + item);
});
}
//loadScript(configModule.path + item);
});
return p;
}.bind(this);
var setSkipLoadPromise = function (depsPromise) {
var jsPromiseExists = true, importPromiseExists = true;
if(configModule.js.length === 0) {
jsPromiseExists = false;
}
if((!configModule.module && configModule.type === 'import') || (configModule.type === 'loader' && typeof configModule.loader === 'function')) {
importPromiseExists = false;
}
plugin.skipLoadPromise = !importPromiseExists && !jsPromiseExists && !depsPromise;
return plugin.skipLoadPromise;
}.bind(this);
configModule.css.forEach(function(item, i, array){
loadStyle(configModule.path + item);
});
var depsPromise = this.__getDepsPromise(this.depsCorrection(configModule.deps));
setSkipLoadPromise(depsPromise);
if(depsPromise) {
stackPush(function () {
return depsPromise;
});
}
if(configModule.loadJsAfterModule) {
stackPush(getImportPromise);
stackPush(getResPromise);
} else {
stackPush(getResPromise);
stackPush(getImportPromise);
}
this.__exec(pluginId, function(){
plugin.state = stateList.loaded;
plugin.skipLoadPromise = true;
configModule.onLoad.call(plugin.module.exports);
var event = new CustomEvent("onLoad" + plugin.id + "Plugin", {
"detail": {plugin: plugin}
});
document.dispatchEvent(event);
callback();
}.bind(this));
return plugin.promise;
}).bind(this);
getModulePromise();
return this;
};
/**
* @param pluginId
* @param callback
* @return {PluginManager}
*/
__proto.install = function(pluginId, callback){
//console.warn('PluginManager.install: plugin ' + pluginId + ' ('+(this.plugins[pluginId]?this.plugins[pluginId].state:'0')+')');
if(typeof callback !== 'function') {
callback = function(){};
}
var plugin = this.__getPlugin(pluginId);
if(plugin) {
pluginId = plugin.id;
}
var module = plugin.module;
if(!this.__checkState(pluginId, stateList.registered)) {
console.warn('PluginManager.install: plugin ' + pluginId + ' is not register');
return this;
}
if(this.__checkState(pluginId, stateList.installed)) {
callback();
return this;
}
if(plugin.stateInit.installing) {
//console.warn(`PluginManager.install(${pluginId}): уже устанавливается (${plugin.state}).`);
this.__exec(pluginId, callback);
return this;
}
plugin.stateInit.installing = true;
this.load(pluginId);
var installer = function(){
var setGlobalExtension = function (key, aliasList, data) {
if(data === undefined) {
return;
}
if(!this.global.hasOwnProperty(key)) {
this.global[key] = data;
}
if(Array.isArray(aliasList) && aliasList.length) {
aliasList.forEach(function (alias) {
setGlobalExtension(alias, [], data)
}.bind(this))
}
}.bind(this);
/**
* @todo !!!
*/
var returnData;
if(plugin.config.type === moduleTypeList.loader && typeof plugin.config.loader === 'function') {
// var returnData = plugin.config.loader.bind(module.exports).call(module.exports, module, module.exports, this.require.bind(this), global);
returnData = plugin.config.loader.bind(this.global).call(this.global, module, module.exports, this.require.bind(this), this.global);
if(returnData === undefined && module.exports){
returnData = module.exports;
}
setGlobalExtension(pluginId, plugin.config.alias, returnData);
} else if(plugin.config.type === moduleTypeList.import && typeof plugin.config.module === 'string') {
returnData = (typeof module.exports === 'object' && module.exports.default !== undefined)?module.exports.default:module.exports;
setGlobalExtension(pluginId, plugin.config.alias, returnData);
}
console.log(`%cPluginManager.install(${pluginId}): installed (${plugin.state} > ${stateList.installed}).`, "color: green;");
plugin.state = stateList.installed;
return true;
}.bind(this);
this.__exec(pluginId, function(){
if(!this.__checkState(pluginId, stateList.installed)) {
if(installer()){
plugin.config.onInstall.call(module.exports, plugin);
var event = new CustomEvent("onInstall" + plugin.id + "Plugin", {
"detail": {plugin: plugin}
});
document.dispatchEvent(event);
}
}
callback();
}.bind(this));
return this;
};
/**
* @name kitPluginManagerRequire
* @param {string} pluginId
* @param {callback} callback
* @return {boolean}
* @memberOf {kit}
*/
__proto.require = function (pluginId, callback) {
var plugin = this.__getPlugin(pluginId);
if(!plugin) {
console.warn('PluginManager.require: plugin ' + pluginId + ' not found ('+(this.plugins[pluginId]?this.plugins[pluginId].state:'0')+')');
return undefined;
}
pluginId = plugin.id;
var module = plugin.module;
if(!this.__checkState(pluginId, stateList.registered)) {
console.warn('PluginManager.require: plugin ' + pluginId + ' is not register');
return undefined;
}
if(typeof callback !== 'function') {
callback = function(){};
}
this.install(pluginId, callback);
return module.exports;
};
__proto.depsCorrection = function(deps){
if(!Array.isArray(deps) ) {
deps = [deps];
}
var correct = [];
deps.forEach(function(pluginId, i, arr) {
var realPlugin = this.__getPlugin(pluginId);
if(realPlugin === undefined) {
console.warn(`Plugin "${pluginId}" not registered!`);
return false;
}
correct.push(realPlugin.id);
}.bind(this));
return correct;
};
/**
* @memberOf kit
*/
__proto.exec = function (deps, callback, argArr = [], context = undefined) {
if(typeof deps === 'function') {
context = argArr;
argArr = callback;
callback = deps;
deps = [];
}
if(context === undefined) {
context = this;
}
deps = this.depsCorrection(deps);
if(typeof argArr === 'undefined') {
argArr = [];
}
deps = Array.from(new Set(deps.concat(global.config.requiredDependencies)));
if(typeof callback !== 'function') {
return undefined;
}
var depsPromise = this.__getDepsPromise(deps);
var getArgArr = function () {
if(argArr.length === 0) {
deps.forEach(function (pluginId) {
argArr.push(this.require(pluginId));
}.bind(this));
return argArr;
}
return argArr;
}.bind(this);
if(depsPromise) {
depsPromise.then(function(){
callback.apply(context, getArgArr());
});
} else {
callback.apply(context, getArgArr())
}
};
__proto.__exec = function (pluginId, callback, argArr = []) {
var plugin = this.plugins[pluginId];
var exec = function(_callback, argArr){
if(plugin.skipLoadPromise) {
_callback.apply(this, argArr);
} else {
plugin.promise = plugin.promise.then(function(){
_callback.apply(this, argArr);
}.bind(this));
}
}.bind(this);
exec(callback, argArr);
};
__proto.__getDepsPromise = function (pluginList) {
var skipPromise = true;
var promise = new Promise((resolve, reject)=>{
var i = 0;
var checkModule = function(){
if(++i === pluginList.length + 1) {
resolve();
}
};
checkModule();
pluginList.forEach(function(pluginId, i, array){
if(!this.__checkState(pluginId, stateList.registered)) {
checkModule();
return false;
}
this.install(pluginId, checkModule);
skipPromise = skipPromise && this.plugins[pluginId].skipLoadPromise;
}.bind(this));
});
return !skipPromise?promise:undefined;
};
/**
* @param {(string|string[])} deps
* @param {function} callback
* @memberOf kit
*/
__proto.ready = function(deps, callback = undefined) {
if(typeof deps === 'function') {
callback = deps;
deps = [];
}
this.__ready(this.exec, [deps, callback], this);
};
__proto.__ready = function(fn, args = [], context = window) {
context = context || this;
if (/complete|interactive|loaded/.test(document.readyState)) {
fn.apply(context, args);
} else {
document.addEventListener("DOMContentLoaded", function () {
fn.apply(context, args);
}.bind(this));
}
};
__proto.__getPlugin = function (pluginId) {
if(this.plugins.hasOwnProperty(pluginId)) {
return this.plugins[pluginId];
}
var _pluginId, alias;
for (_pluginId in this.plugins) {
if(this.plugins.hasOwnProperty(_pluginId) && this.plugins[_pluginId].config.alias.indexOf(pluginId) !== -1) {
return this.plugins[_pluginId];
}
}
var pluginIdLowerCase = pluginId.toLowerCase();
for (_pluginId in this.plugins) {
if(!this.plugins.hasOwnProperty(_pluginId)) {
continue;
}
if(pluginIdLowerCase === _pluginId.toLowerCase()) {
return this.plugins[_pluginId];
}
for(alias of this.plugins[_pluginId].config.alias) {
if(pluginIdLowerCase === alias.toLowerCase()) {
return this.plugins[_pluginId];
}
}
}
return undefined;
};
/**
* @class kitConfig
*/
var defaultConfig = {
version: '1.10',
assetsPath: '',
requiredDependencies: [],
autoloadPluginList: [],
debug: false,
defaultPhoneMask: '+7 (999) 999-99-99',
};
var script = document.currentScript;
if(script){
var path = script.src.split('?')[0];
defaultConfig.assetsPath = path.split('/').slice(0, -2).join('/');
}
var manager = new PluginManager(global);
manager.register('PluginManager', {
alias: 'pm',
type: moduleTypeList.loader,
loader: function(module, exports, require) {
return module.exports = manager;
}
});
manager.install('PluginManager');
manager.register('config', {
type: moduleTypeList.loader,
loader: function(module, exports, require, global) {
var config = global.config || {};
config = Object.assign({}, defaultConfig, config);
window.__pmConfig__ = global.config = config;
}
});
manager.install('config');
window.__PluginManager__ = manager;
global.ready = manager.ready.bind(manager);
global.exec = manager.exec.bind(manager);
global.require = manager.require.bind(manager);
/**
* @var __pmGlobal__
*/
window.__pmGlobal__ = global;
})(kit);
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module dataStructures */ /** @module dataStructures */
__PluginManager__.register('dataStructures', function(module, exports, require, global){ __PluginManager__.register('dataStructures', function(require, exports, module, global){
/** /**
+1 -1
View File
@@ -10,7 +10,7 @@
* *
* @module date * @module date
**/ **/
kit.PluginManager.register('date',function(module, exports, require, global) { __PluginManager__.register('date',function(require, exports, module, global) {
(function (global, factory) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('datepicker', function(module, exports, require, global){ __PluginManager__.register('datepicker', function(require, exports, module, global){
var $, jQuery; var $, jQuery;
jQuery = $ = require('jQuery'); jQuery = $ = require('jQuery');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module intlTelInput */ /** @module intlTelInput */
kit.PluginManager.register('intlTelInput', function(module, exports, require, global){ __PluginManager__.register('intlTelInput', function(require, exports, module, global){
/* /*
* International Telephone Input v19.5.7 * International Telephone Input v19.5.7
* https://github.com/jackocnr/intl-tel-input.git * https://github.com/jackocnr/intl-tel-input.git
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module jBox */ /** @module jBox */
kit.PluginManager.register('jBox', function(module, exports, require, global){ __PluginManager__.register('jBox', function(require, exports, module, global){
/** /**
+1 -1
View File
File diff suppressed because one or more lines are too long
+9365 -9541
View File
File diff suppressed because it is too large Load Diff
+2 -8
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module jqueryMousewheel */ /** @module jqueryMousewheel */
kit.PluginManager.register('jqueryMousewheel', function(module, exports, require, global){ __PluginManager__.register('jqueryMousewheel', function(require, exports, module, global){
var jQuery = require('jQuery'); var jQuery = require('jQuery');
/*! /*!
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module lib */ /** @module lib */
kit.PluginManager.register('lib',function(module, exports, require, global) { __PluginManager__.register('lib',function(require, exports, module, global) {
/** /**
* @memberOf kit * @memberOf kit
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module lightGallery */ /** @module lightGallery */
kit.PluginManager.register('lightGallery',function(module, exports, require, global) { __PluginManager__.register('lightGallery',function(require, exports, module, global) {
var $ = require('jQuery'); var $ = require('jQuery');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module log */ /** @module log */
__PluginManager__.register('log', function(module, exports, require, /** @param {kit}*/global){ __PluginManager__.register('log', function(require, exports, module, /** @param {kit}*/global){
var support = require('support'); var support = require('support');
var Collection = require('Collection'); var Collection = require('Collection');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module mCustomScrollbar */ /** @module mCustomScrollbar */
kit.PluginManager.register('mCustomScrollbar', function(module, exports, require, global){ __PluginManager__.register('mCustomScrollbar', function(require, exports, module, global){
var jQuery = require('jQuery'); var jQuery = require('jQuery');
/** /**
@@ -1,5 +1,5 @@
/** @module makeCSSAnimations */ /** @module makeCSSAnimations */
kit.PluginManager.register('makeCSSAnimations', function(module, exports, require, global) { __PluginManager__.register('makeCSSAnimations', function(require, exports, module, global) {
var support = require('support'); var support = require('support');
var $ = require('jQuery'); var $ = require('jQuery');
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('mask', function(module, exports, require){ __PluginManager__.register('mask', function(require, exports, module){
var $ = require('jQuery'); var $ = require('jQuery');
+1 -1
View File
@@ -1,7 +1,7 @@
/** @module menu */ /** @module menu */
//todo: instance, options, auto-options-by-node //todo: instance, options, auto-options-by-node
//ok: getChainActiveMenuDataList Скрытие меню открывающихся по клику / 3 depth базовый - след 2 //ok: getChainActiveMenuDataList Скрытие меню открывающихся по клику / 3 depth базовый - след 2
__PluginManager__.register('menu',function(module, exports, require, global) { __PluginManager__.register('menu',function(require, exports, module, global) {
var Collection = require('Collection'); var Collection = require('Collection');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module modal */ /** @module modal */
kit.PluginManager.register('modal', function(module, exports, require){ __PluginManager__.register('modal', function(require, exports, module){
var bsCore = require('bsCore'); var bsCore = require('bsCore');
var var
defineJQueryPlugin = bsCore.util.index.defineJQueryPlugin, defineJQueryPlugin = bsCore.util.index.defineJQueryPlugin,
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module mustache */ /** @module mustache */
kit.PluginManager.register('mustache', function(module, exports, require){ __PluginManager__.register('mustache', function(require, exports, module){
/*! /*!
* mustache.js - Logic-less {{mustache}} templates with JavaScript * mustache.js - Logic-less {{mustache}} templates with JavaScript
* http://github.com/janl/mustache.js * http://github.com/janl/mustache.js
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module owlCarousel */ /** @module owlCarousel */
kit.PluginManager.register('owlCarousel',function(module, exports, require, global) { __PluginManager__.register('owlCarousel',function(require, exports, module, global) {
var jQuery = require('jQuery'); var jQuery = require('jQuery');
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('popover',function(module, exports, require){ __PluginManager__.register('popover',function(require, exports, module){
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Bootstrap (v5.0.2): popover.js * Bootstrap (v5.0.2): popover.js
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('popper', function(module, exports, require){ __PluginManager__.register('popper', function(require, exports, module){
/** /**
* https://unpkg.com/@popperjs/core@2.9.3/dist/umd/popper.min.js * https://unpkg.com/@popperjs/core@2.9.3/dist/umd/popper.min.js
* @popperjs/core v2.9.3 - MIT License * @popperjs/core v2.9.3 - MIT License
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module support */ /** @module support */
__PluginManager__.register('support', function(module, exports, require, global){ __PluginManager__.register('support', function(require, exports, module, global){
window.pre = console.log; window.pre = console.log;
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module testing */ /** @module testing */
__PluginManager__.register('testing', function(module, exports, require, global){ __PluginManager__.register('testing', function(require, exports, module, global){
// var loggerService = require('loggerService'); // var loggerService = require('loggerService');
+1 -1
View File
@@ -1,4 +1,4 @@
kit.PluginManager.register('toolkit', function(module, exports, require, global) { __PluginManager__.register('toolkit', function(require, exports, module, global) {
var $ = require('jQuery'); var $ = require('jQuery');
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module Tooltip */ /** @module Tooltip */
kit.PluginManager.register('Tooltip',function(module, exports, require){ __PluginManager__.register('Tooltip',function(require, exports, module){
var Popper = require('popper'); var Popper = require('popper');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module Tooltip2 */ /** @module Tooltip2 */
kit.PluginManager.register('Tooltip2',function(module, exports, require, global){ __PluginManager__.register('Tooltip2',function(require, exports, module, global){
var Viewer = require('Viewer'); var Viewer = require('Viewer');
var support = require('support'); var support = require('support');
+1 -1
View File
@@ -1,5 +1,5 @@
/** @module userAction */ /** @module userAction */
kit.PluginManager.register('userAction', function(module, exports, require, global) { __PluginManager__.register('userAction', function(require, exports, module, global) {
var support = require('support'); var support = require('support');
var ActionCollection = require('ActionCollection'); var ActionCollection = require('ActionCollection');