This commit is contained in:
2021-11-18 20:48:04 +03:00
parent 4e9df6c81b
commit 5e7b4c6707
22 changed files with 1160 additions and 345 deletions
+11 -2
View File
@@ -113,7 +113,7 @@ kit.PluginManager.register('align',function(module, exports, require) {
/**
* @param node
* @param node {HTMLElement}
* @param axis
* @property start
* @property end
@@ -360,7 +360,15 @@ kit.PluginManager.register('align',function(module, exports, require) {
* @return {AlignCalc}
*/
AlignCalc.prototype.updateMetrics = function(){
var node = this.nodeMetricsLine.node;
var o = node.style.overflow, w = node.style.width, h = node.style.height;
node.style.overflow = 'hidden';
node.style.width = '';
node.style.height = '';
this.limiterMetricsLine.update();
node.style.overflow = o;
node.style.width = w;
node.style.height = h;
this.parentMetricsLine.update();
this.nodeMetricsLine.update();
return this;
@@ -568,7 +576,7 @@ kit.PluginManager.register('align',function(module, exports, require) {
this.reset(axis === 'horizontal', axis === 'vertical');
this.__setAdditionalStyles();
//todo
this.condition[axis].direction = direction;
this.condition[axis].align = align;
@@ -623,6 +631,7 @@ kit.PluginManager.register('align',function(module, exports, require) {
* @memberOf kit
*/
var align = {
AlignCalc: AlignCalc,
Class: AlignClass,
getInstance: function (node, parentNode) {
if(node instanceof HTMLElement && node.kit && node.kit.align) {
+7 -3
View File
@@ -1,3 +1,6 @@
/**
* @module cookie
**/
kit.PluginManager.register('cookie', function(module, exports, require){
var defaultConverter = {
@@ -96,9 +99,9 @@ kit.PluginManager.register('cookie', function(module, exports, require){
/**
* @class kitCookie
* @memberOf kit
*/
return Object.create(
var cookie = Object.create(
{
set: set,
get: get,
@@ -122,7 +125,8 @@ kit.PluginManager.register('cookie', function(module, exports, require){
attributes: { value: Object.freeze(defaultAttributes) },
converter: { value: Object.freeze(converter) }
}
)
);
return cookie;
}
module.exports = init(defaultConverter, { path: '/' });
+22 -16
View File
@@ -161,6 +161,7 @@ window.kit = window.kit || {};
* @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(){};
@@ -204,6 +205,7 @@ window.kit = window.kit || {};
var getModulePromise = (function () {
function loadScript(src, resolveCallback, rejectCallback) {
src = String(src).split('?')[0];
if(typeof resolveCallback !== 'function'){
resolveCallback = function(){};
}
@@ -213,16 +215,17 @@ window.kit = window.kit || {};
};
}
return new Promise(function(resolve, reject) {
var meta = document.querySelector('meta[name="'+src+'"]');
var script = document.querySelector('script[src^="'+src+'"]');
if (!script) {
if (script || meta) {
global.config.debug && console.warn(`Скрип ${src} уже загружен`);
self.__ready(resolve, [script]);
} else {
script = document.createElement('script');
script.src = '' + src + '?__pm' + (new Date()).getTime();
script.onload = () => resolve(script);
script.onerror = () => reject(new Error(`Ошибка загрузки скрипта ${src}`));
document.head.append(script);
} else {
global.config.debug && console.warn(`Скрип ${src} уже загружен`);
resolve(script);
}
}).then(resolveCallback, rejectCallback);
}
@@ -246,15 +249,16 @@ window.kit = window.kit || {};
list.forEach(function(item, i, arr){
syncPromise.then(function(){
var src = configModule.path + item;
var meta = document.querySelector('meta[name="'+src+'"]');
var script = document.querySelector('script[src^="'+src+'"]');
if (!script) {
if(meta || script){
self.__ready(resolve, [src, true]);
} else {
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);
} else {
checkResolve(src, true);
}
});
});
@@ -262,8 +266,12 @@ window.kit = window.kit || {};
}
function loadStyle(src) {
return new Promise(function(resolve, reject) {
var meta = document.querySelector('meta[name="'+src+'"]');
var link = document.querySelector('link[href^="'+src+'"]');
if (!link) {
if(link || meta) {
global.config.debug && console.warn(`Скрип ${src} уже загружен`);
self.__ready(resolve, [src]);
} else {
link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
@@ -271,9 +279,6 @@ window.kit = window.kit || {};
link.media = 'all';
document.head.append(link);
resolve(link);
} else {
global.config.debug && console.warn(`Скрип ${src} уже загружен`);
resolve(link);
}
});
}
@@ -563,14 +568,15 @@ window.kit = window.kit || {};
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)) {
// In case the document has finished parsing, document's readyState will
// be one of "complete", "interactive" or (non-standard) "loaded".
this.exec(deps, callback);
fn.apply(context, args);
} else {
// The document is not ready yet, so wait for the DOMContentLoaded event
document.addEventListener("DOMContentLoaded", function () {
this.exec(deps, callback);
fn.apply(context, args);
}.bind(this));
}
};
+18
View File
@@ -183,6 +183,24 @@ __PluginManager__.registerPlugins({
type: 'loader',
deps: ['support'],
},
date: {
path: __pmConfig__.assetsPath + '/date',
module: '/date.js',
type: 'loader',
deps: [],
},
testing: {
path: __pmConfig__.assetsPath + '/testing',
module: '/testing.js',
type: 'loader',
deps: ['Logger'],
},
Logger: {
path: __pmConfig__.assetsPath + '/logger',
module: '/logger.js',
css: '/logger.css',
type: 'loader',
},
});
+369
View File
@@ -0,0 +1,369 @@
/**
* date-php.js v1.7.15
* :-) date('Y-m-d', 1563148800000)
* This is a Javascript mimicking PHP datetime formatting function. It is very similar to PHP, has rich template
* characters, and enhances some template characters on the basis of the original.
*
* -- repository https://github.com/toviLau/date-php.git
*
* (c) 2019-2020 ToviLau. Released under the MIT License.
*
* @module date
**/
kit.PluginManager.register('date',function(module, exports, require, global) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.date = factory());
}(this, function () { 'use strict';
/**
* 补前导零(0)
* @param {number} str 字符
* @param {number} len 长度
* @param {string} placeholder 前导占位符
* @returns {string}
*/
function pad(str, len, placeholder) {
if ( placeholder === void 0 ) placeholder = '0';
str = '' + str;
if (str.length < len) {
return new Array(++len - str.length).join(placeholder) + str;
} else {
return str;
}
}var longDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var txt_ordin = {
1: 'st',
2: 'nd',
3: 'rd',
21: 'st',
22: 'nd',
23: 'rd',
31: 'st',
};
var txt_months = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var baseFigure = {
1: '一',
2: '二',
3: '三',
4: '四',
5: '五',
6: '六',
};
var lunarTime = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];
var ordinal = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
var lunarKe = Object.assign.apply(
Object, [ {},
{
0: '零',
7: '七',
} ].concat( baseFigure )
);
var weekDay = Object.assign.apply(
Object, [ {},
{
0: '日',
} ].concat( baseFigure )
);
var dateFigure = Object.assign.apply(
Object, [ {},
{
0: '〇', 7: '七', 8: '八', 9: '九', 10: '十',
20: '廿', 30: '卅',
} ].concat( baseFigure )
);
var lMonth = Object.assign.apply(
Object, [ {},
{
7: '七', 8: '八', 9: '九', 10: '十', 11: '冬', 12: '腊',
} ].concat( baseFigure )
);
// 取中文日期(廿七)
var textReplace = function (res) { return res.toString()
.split('')
.reverse()
.map(function (val, key) {
var v = Math.pow(10, key) * val;
return v ? dateFigure[v] : null;
})
.reverse()
.join(''); };
// 取中文日期2(例:一九八七)
var textReplace2 = function (succ) { return (succ + '').split('').map(function (res) { return dateFigure[res]; }).join(''); };
function defP(obj, key, val) {
Object.defineProperty(obj, key, {
get: function () { return val; },
});
}
/**
*
* 计算持续时长
* @param {String} fmt 模板字符串
* @param {Number} timestamp 时间戳
* @param {Boolean} ms 是否是 含有毫秒
* @return 相印时间
*/
function duration(fmt, timestamp, ms) {
if ( fmt === void 0 ) fmt = 'D天h:i:s';
if ( timestamp === void 0 ) timestamp = 0;
if ( ms === void 0 ) ms = true;
var conversion = {
y: 12,
m: 30.4375,
d: 24,
h: 60,
i: 60,
s: 1000,
v: 1000,
};
var tChars = {
y: function () { return tChars.Y(); }, // 当前剩余年数,
Y: function () { return Math.floor(tChars.M() / conversion.y); }, // 总剩余年数,
m: function () { return pad(tChars.n(), 2); }, // 当前剩余月数(有前导零)
n: function () { return tChars.M() % conversion.y; }, // 当前剩余月数(无前导零)
M: function () { return Math.floor(tChars.D() / conversion.m); }, // 总剩余月数
d: function () { return pad(tChars.j(), 2); }, // 当前剩余天数(有前导零)
j: function () { return Math.floor(tChars.D() % conversion.m); }, // 当前剩余天数(无前导零)。
D: function () { return Math.floor(tChars.H() / conversion.d); }, // 总剩余天数
h: function () { return pad(tChars.g(), 2); }, // 当前小时剩余数(有前导零)
g: function () { return Math.floor(tChars.H() % conversion.d); }, // 当前小时剩余数(无前导零)
H: function () { return Math.floor(tChars.I() / conversion.h); }, // 总剩余小时数
i: function () { return pad(Math.floor(tChars.I() % conversion.h),2); }, // 当前分钟剩余点数
I: function () { return Math.floor(tChars.S() / conversion.i); }, // 总剩余分钟数
s: function () { return pad(Math.floor(tChars.S() % conversion.i), 2); }, // 当前秒钟剩余点数
S: function () { return Math.floor(tChars.V() / conversion.s); }, // 总剩余秒数
v: function () { return pad(Math.floor(tChars.V() % conversion.s), 3); }, // 当前毫秒剩余数
V: function () { return ms ? new Date(timestamp)-0 : new Date(timestamp) * conversion.v; }, // 总剩余毫秒数
};
return fmt.replace(/(\\?([a-z]))/ig, function (res, key) {
var result = '';
if (res !== key) {
result = key;
} else {
if (tChars[key]) {
result = tChars[key]();
} else {
result = key.replace('\\', '');
}
}
return result;
});
}
/**
* 计算持续时间
* @param fmt
* @param timestamp1
* @param timestamp2
* @param ms
* @return 相印时间
*/
function countTime(fmt, timestamp1, timestamp2, ms) {
if ( fmt === void 0 ) fmt = 'D天h:i:s';
if ( timestamp1 === void 0 ) timestamp1 = 0;
if ( timestamp2 === void 0 ) timestamp2 = 0;
if ( ms === void 0 ) ms = true;
var count = new Date(timestamp1) - new Date(timestamp2) || 0;
return duration(fmt, Math.abs(count), ms);
}
var isDate = function (d) {
return new Date(d).toString() !== 'Invalid Date';
};
/**
* @memberOf kit
* @param fmt
* @param now
* @param ms
* @return {string}
*/
var date = function (fmt, now, ms) {
if ( fmt === void 0 ) fmt = 'Y-m-d';
if ( now === void 0 ) now = new Date;
if ( ms === void 0 ) ms = true;
now = isDate(this)
? this
: isDate(now)
? new Date(now)
: new Date;
if (ms === false) { now = new Date(now * 1000); }
if (!isDate(now)) { throw Error((function (D) {
return '' +
'参数2不正确,须传入 “日期时间对象”,或 “Unix时间戳” 或 “时间戳字符串”。\n可以参考以下值:\n' +
" \"" + D + "\"\n" +
" \"" + (D.toUTCString()) + "\"\n" +
" " + (D.getTime()) + " -- 推荐\n";
})(new Date())); }
// 模板字串替换函数
var tChars = {
// 日
d: function () { return pad(tChars.j(), 2); },
k: function () { return textReplace(tChars.j()); }, // 中文日(1.3.2+), PHP中无此功能
D: function () { return tChars.l().substr(0, 3); },
j: function () { return now.getDate(); },
lt: function () { return lunarTime[Math.floor((tChars.G() >= 23 ? 0 : tChars.G() + 1) / 2)]; },
lg: function () { return tChars.G() > 18 || tChars.G() < 5 ? Math.ceil((tChars.G() < 19 ? tChars.G() + 24 : tChars.G()) / 2) - 9 : ''; },
lG: function () { return ("" + (tChars.lg() ? baseFigure[tChars.lg()] + '更' : '')); },
lk: function () { return lunarKe[Math.floor(((tChars.U() + 60 * 60) % (60 * 60 * 2)) / 60 / 15)]; },
fh: function () { return (getFestival(tChars.Y() + tChars.m() + tChars.d()).cn || []).join(); },
lh: function () { return (getFestival(tChars.Y() + tChars.m() + tChars.d()).en || []).join(); },
l: function () { return longDays[tChars.w()]; },
N: function () { return tChars.w() === 0 ? 7 : tChars.w(); },
S: function () { return txt_ordin[tChars.j()] ? txt_ordin[tChars.j()] : 'th'; },
w: function () { return now.getDay(); },
K: function () { return weekDay[tChars.w()]; }, // 中文周(1.3.2+)
z: function () { return Math.ceil((now - new Date(tChars.Y() + '/1/1')) / (60 * 60 * 24 * 1e3)); },
// 周
W: function () {
var inYearDay = tChars.z(); // 当前年份中的第n天
var yDay = new Date(tChars.Y() + '1/1').getDay(); // 第一天周几
var diffDay = (yDay > 0) - 0;
return Math.ceil((inYearDay - yDay) / 7) + diffDay;
},
// 月
F: function () { return txt_months[tChars.n()]; },
f: function () { return textReplace(tChars.n()); }, // 中文月(1.3.2+), PHP中无此功能
m: function () { return pad(tChars.n(), 2); },
M: function () { return tChars.F().substr(0, 3); },
n: function () { return now.getMonth() + 1; },
t: function () {
var year = tChars.Y();
var nextMonth = tChars.n();
if (nextMonth === 12) {
year += 1;
nextMonth = 0;
}
return new Date(year, nextMonth, 0).getDate();
},
lq: function () { return Math.ceil((tChars.n() - 0) / 3); }, // 季度数字
lQ: function () { return baseFigure[tChars.lq()]; }, // 季度汉字(1.6.0+)
q: function () { return txt_ordin[tChars.lq()] ? tChars.lq() + '' + txt_ordin[tChars.lq()] : tChars.lq() + 'th'; }, // 季度英文缩写
Q: function () { return ordinal[tChars.lq() - 1]; }, // 李度英文(1.6.0+)
// 年
L: function () { return Number(tChars.Y() % 400 === 0 || (tChars.Y() % 100 !== 0 && tChars.Y() % 4 === 0)); },
o: function () {
var yearWeek = new Date(tChars.Y(), 0, 1).getDay();
var diffTime = 60 * 60 * 24 * 1000 * (7 - yearWeek);
var timestramp = yearWeek > 3 ? now.getTime() - diffTime : now.getTime();
return new Date(timestramp).getFullYear();
},
Y: function () { return now.getFullYear(); },
y: function () { return (tChars.Y() + '').slice(2); },
C: function () { return textReplace2(tChars.Y()); }, // 中文年(1.3.2+), PHP中无此功能
// 时间
a: function () { return tChars.G() > 11 ? 'pm' : 'am'; },
A: function () { return tChars.a().toUpperCase(); },
B: function () {
var off = (now.getTimezoneOffset() + 60) * 60;
var theSeconds = (tChars.G() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + off;
var beat = Math.floor(theSeconds / 86.4);
// beat > 1000 ? beat -= 1000 : beat += 1000
if (beat > 1000) { beat -= 1000; }
if (beat < 0) { beat += 1000; }
return pad(beat, 3);
},
g: function () { return tChars.G() % 12 || 12; },
G: function () { return now.getHours(); },
h: function () { return pad(tChars.g(), 2); },
H: function () { return pad(tChars.G(), 2); },
i: function () { return pad(now.getMinutes(), 2); },
s: function () { return pad(now.getSeconds(), 2); },
u: function () { return tChars.v() + pad(Math.floor(Math.random() * 1000), 3); },
v: function () { return (now.getTime() + '').substr(-3); },
// 时区
e: function () { return Intl.DateTimeFormat().resolvedOptions().timeZone; },
I: function () {
var DST = null;
for (var i = 0; i < 12; ++i) {
var d = new Date(tChars.Y(), i, 1);
var offset = d.getTimezoneOffset();
if (DST === null) { DST = offset; }
else if (offset < DST) {
DST = offset;
break;
} else if (offset > DST) { break; }
}
return (now.getTimezoneOffset() === DST) | 0;
},
O: function () { return (now.getTimezoneOffset() > 0 ? '-' : '+') + pad(Math.abs(now.getTimezoneOffset() / 60 * 100), 4); },
P: function () { return tChars.O().match(/[+-]?\d{2}/g).join(':'); },
T: function () {
var tz = now.toLocaleTimeString(navigator.language, { timeZoneName: 'short' }).split(/\s/);
return tz[tz.length - 1];
},
Z: function () { return -(now.getTimezoneOffset() * 60); },
// 完整日期时间
c: function () { return tChars.Y() + '-' + tChars.m() + '-' + tChars.d() + 'T' + tChars.h() + ':' + tChars.i() + ':' + tChars.s() + tChars.P(); },
r: function () { return now.toString(); },
U: function () { return Math.round(now.getTime() / 1000); },
};
if (fmt === 'json' || fmt === 'all' || fmt === -1 || fmt === '-1') {
var json = {};
Object.keys(tChars).forEach(function (res, idx) { return json[res] = tChars[res](); });
return json;
}
return fmt.replace(/\\?(([lf][a-z])|([a-z]))/ig, function (res, key) {
var result = '';
if (res !== key) {
result = key;
} else {
if (tChars[key]) {
result = tChars[key]();
} else {
result = key.replace('\\', '');
}
}
return result;
});
};
defP(Date.prototype, 'format', date);
defP(date, 'version', '1.7.15');
defP(date, 'description', function () { return (console.info('%cdate-php使用说明:\n' +
'已经废弃,查看使用说明请移步这里\nhttps://github.com/toviLau/date-php/blob/master/README.md'
, 'color:#c63'
)); });
date.duration = duration;
date.countTime = countTime;
return date;
}));
return module.exports;
});
+99
View File
@@ -0,0 +1,99 @@
:root {
--logger-color-emergency: hsl(0, 100%, 55%);
--logger-color-alert: hsl(192, 100%, 98%);
--logger-color-critical: hsl(0, 100%, 55%);
--logger-color-error: hsl(0, 100%, 55%);
--logger-color-warning: hsl(31, 100%, 55%);
--logger-color-notice: #909090;
--logger-color-info: hsl(205, 100%, 61%);
--logger-color-debug: #909090;
--logger-color-success: #8bc34a;
}
.kit-logger, #kit-logger {
margin: 0;
padding: 5px;
font-family: monospace;
background: hsla(0, 0%, 11%, 1);
color: #909090;
height: 100%;
overflow-y: scroll !important;
word-break: break-all;
display: block;
}
.kit-logger--fixed {
position: sticky;
bottom: 0;
height: 30vh;
}
bx_kit_log {
margin: 0;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-align-content: flex-start;
-ms-flex-line-pack: start;
align-content: flex-start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
white-space: pre-line;
font-size: 12px !important;
line-height: 14px !important;
}
bx_kit_log_value * {
color: inherit;
}
bx_kit_log_msg {
}
bx_kit_log_key {
min-width: 25px;
padding-right: 5px;
white-space: nowrap;
color: var(--logger-color-key, #909090);
}
bx_kit_log_key:empty {
display: none;
}
bx_kit_log_lvl {
min-width: 25px;
}
bx_kit_log_value {
flex: 1 0 0;
white-space: pre-wrap;
color: var(--logger-color-value, #c1c1c1);
}
bx_kit_log_value * {
font-size: inherit !important;
line-height: inherit !important;
color: inherit !important;
white-space: inherit !important;
}
.kit-logger-row--error {
--logger-color-key: var(--logger-color-error);
--logger-color-value: var(--logger-color-error);
}
.kit-logger-row--info {
--logger-color-key: var(--logger-color-info);
--logger-color-value: var(--logger-color-info);
}
.kit-logger-row--warning {
--logger-color-key: var(--logger-color-warning);
--logger-color-value: var(--logger-color-warning);
}
.kit-logger-row--success {
--logger-color-key: var(--logger-color-success);
--logger-color-value: var(--logger-color-success);
}
+159
View File
@@ -0,0 +1,159 @@
/** @module logger */
__PluginManager__.register('Logger', function(module, exports, require, global){
function makeNode(html = '') {
var nodeWrap = document.createElement('div');
nodeWrap.innerHTML = html;
var r = nodeWrap.firstElementChild;
r.remove();
return r;
}
var lightMap = [
{class: '', keys: []},
{class: 'text-danger', keys: []},
{class: 'text-secondary', keys: []},
];
var getLightClass = function(key) {
var addClass = '', ar;
for(var i=0; i < lightMap.length; i++){
ar = lightMap[i]['keys'];
addClass = ar.includes(String(key))?lightMap[i]['class']:addClass;
}
return addClass;
};
var collectionTemplater = '<div class="kit-logger kit-logger--fixed"></div>';
// function dump(value) {
// var rArray = [];
// if(value === null) {
// rArray[0] = 'null';
// } else {
// rArray[0] = String(typeof value);
// rArray[1] = emptyPHP(value)?'empty':'';
// }
// return rArray.join(' ');
// };
function getRowNode(level, key, value, opClass){
if(opClass) {
opClass = ' kit-logger-row--'+opClass;
}
var i = 0, lvlTemplate = '', setStyle = '';
level = Number(level);
key = String(key);
value = String(value);
for(i = 0; i < level; i++){
lvlTemplate += '<bx_kit_log_lvl></bx_kit_log_lvl>';
}
var result = '<bx_kit_log class="'+getLightClass(key)+opClass+'" style="'+setStyle+'">'+lvlTemplate+'<bx_kit_log_key class="">'+key+'</bx_kit_log_key><bx_kit_log_value class="text-log-value">'+value+'</bx_kit_log_value></bx_kit_log>';
return makeNode(result);
}
function args2array(arguments) {
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
return args;
}
/**
* @class Logger
* @memberOf kit
*/
var Logger = function() {
this.collection = undefined;
};
/**
* @param node {HTMLElement}
*/
Logger.prototype.setCollection = function (node) {
/**
* @type {HTMLElement}
*/
this.collection = node || document.getElementById('kit-logger') || document.querySelector('.kit-logger') || makeNode(collectionTemplater);
if(!this.collection.parentElement) {
document.body.appendChild(this.collection)
}
};
Logger.prototype.__row = function(message, lvl = 0, opClass = '') {
if (!this.collection) {
this.setCollection();
}
var log = this.collection;
var k = 0, j = 0, i = 0, m = 0, rowNode;
if(typeof message == 'object') {
for(k in message) {
log.appendChild(getRowNode(lvl, k, message[k], opClass));
if(typeof message[k] == 'object') {
for(j in message[k]) {
log.appendChild(getRowNode(lvl+1, j, message[k][j]));
if(typeof message[k][j] == 'object') {
for(i in message[k][j]) {
log.appendChild(getRowNode(lvl+2, i, message[k][j][i]));
if(typeof message[k][j][i] == 'object') {
for(m in message[k][j][i]) {
log.appendChild(getRowNode(lvl+3, m, message[k][j][i][m]));
}
}
}
}
}
}
}
} else {
log.appendChild(getRowNode(lvl, '', message, opClass));
}
log.scrollTop = log.scrollHeight;
};
Logger.prototype.__log = function(lvl, type, message, context){
lvl = Number(lvl);
var opClass = '';
if(arguments.length >= 2) opClass = type;
if(arguments.length >= 3)
this.__row(message, lvl, opClass);
if(arguments.length >= 4)
this.__row(context, lvl+1);
};
Logger.prototype.emergency = function (message, context) {
this.__log.apply(this, [0, 'emergency'].concat(args2array(arguments)));
};
Logger.prototype.alert = function (message, context) {
this.__log.apply(this, [0, 'alert'].concat(args2array(arguments)));
};
Logger.prototype.critical = function (message, context) {
this.__log.apply(this, [0, 'critical'].concat(args2array(arguments)));
};
Logger.prototype.error = function (message, context) {
this.__log.apply(this, [0, 'error'].concat(args2array(arguments)));
};
Logger.prototype.warning = function (message, context) {
this.__log.apply(this, [0, 'warning'].concat(args2array(arguments)));
};
Logger.prototype.notice = function (message, context) {
this.__log.apply(this, [0, 'notice'].concat(args2array(arguments)));
};
Logger.prototype.info = function (message, context) {
this.__log.apply(this, [0, 'info'].concat(args2array(arguments)));
};
Logger.prototype.debug = function (message, context) {
this.__log.apply(this, [0, 'debug'].concat(args2array(arguments)));
};
Logger.prototype.success = function (message, context) {
this.__log.apply(this, [0, 'success'].concat(args2array(arguments)));
};
Logger.prototype.log = function (lvl = 0, message = '', context, type) {
lvl = Number(lvl);
var opClass = '';
if(arguments.length >= 4) opClass = type;
if(arguments.length >= 2)
this.__row(message, lvl, opClass);
if(arguments.length >= 3)
this.__row(context, lvl+1, opClass);
};
return module.exports = Logger;
});
+316 -312
View File
@@ -121,12 +121,14 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
};
Menu.prototype.setPosition = function () {
//console.log('setPosition ' + this.id);
//console.log('setPosition', this.id);
if(!(this.getParent() instanceof Element)) {
console.warn('Menu.options.parent NOT instanceof Element');
return false;
}
if(!support.isA(this.align, align.Class)){
return;
}
this.node.style.position = 'absolute';
this.node.style.width = 'fit-content';
@@ -163,7 +165,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
*/
Menu.prototype.getParentMenu = function() {
var p = this.getParent();
if(p instanceof Element && p.hasOwnProperty('kit') && p.kit[MENU_ITEM_PLUGIN_NAME] instanceof MenuItemClass) {
if(p instanceof Element && p.hasOwnProperty('kit') && p.kit[MENU_ITEM_PLUGIN_NAME] instanceof MenuItem) {
return p.kit[MENU_ITEM_PLUGIN_NAME].getMenu();
}
};
@@ -181,9 +183,9 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
* @param options {kitMenuItemOptions}
* @return {MenuItem}
*/
Menu.prototype.addItem = function (options = {}) {
Menu.prototype.addItem = function (options = {}){
var id;
if(options instanceof MenuItemClass) {
if(options instanceof MenuItem) {
options.parentId = this.id;
id = options.options.id;
this.itemList[id] = options;
@@ -192,25 +194,26 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
options.id = support.uniqueId(8);
}
id = options.id;
this.itemList[id] = (new this.MenuItem(this.id)).setOptions(options).init();
this.itemList[id] = (new MenuItem(this.id)).setOptions(options).init();
}
return this.itemList[id];
};
Menu.prototype.addItemList = function(itemList = []){
var result = [];
itemList.forEach((function(element, index, array){
this.addItem(element);
result.push(this.addItem(element));
}).bind(this));
return this;
return result;
};
Menu.prototype.sortItems = function() {
this.itemList = Object.entries(this.itemList)
.sort(function(a, b){
return a[1].options.sort >>> 0 - b[1].options.sort >>> 0;
return Number(a[1].options.sort) - Number(b[1].options.sort);
})
.reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
};
Menu.prototype.render = function() {
//console.log('Menu: render');
//console.log('Menu: render', this.id);
this.sortItems();
this.node.innerHTML = '';
if(global.config.debug) {
@@ -334,315 +337,315 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
return this;
};
var MenuItemClass = function () {
function MenuItem(parentId) {
var _thisMenuItem = this;
this.parentId = Number(parentId);
this.node = Element;
this.bInit = false;
this.bActive = false;
this.child = null;
/**
* @class kit.menu.MenuItem
* @param parentId
*/
function MenuItem(parentId) {
var _thisMenuItem = this;
this.parentId = Number(parentId);
this.node = Element;
this.bInit = false;
this.bActive = false;
this.child = null;
/**
* @class kitMenuItemOptions
*/
this.options = {
id: '',
icon: libModule.svg.options,
arrow: libModule.svg.arrowMenu,
label: 'menu',
href: 'javascript:void(0);',
class: '',
sort: 500,
visible: true,
/** @type {kitMenuItemHandler} */
hover: this.defaultHoverHandler,
/** @type {kitMenuItemHandler} */
click: this.defaultClickHandler,
dblclick: this.defaultDblClickHandler,
};
/**
* @class kitMenuItemOptions
*/
this.options = {
id: '',
icon: libModule.svg.options,
arrow: libModule.svg.arrowMenu,
label: 'menu',
href: 'javascript:void(0);',
class: '',
sort: 500,
visible: true,
/** @type {kitMenuItemHandler} */
hover: this.defaultHoverHandler,
/** @type {kitMenuItemHandler} */
click: this.defaultClickHandler,
dblclick: this.defaultDblClickHandler,
};
this.handleEvent = function(event) {
event.stopPropagation();
switch(event.type) {
case 'mouseover':
this.options.hover(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
case 'click':
this.options.click(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
case 'dblclick':
this.options.dblclick(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
this.handleEvent = function(event) {
event.stopPropagation();
switch(event.type) {
case 'mouseover':
this.options.hover(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
case 'click':
this.options.click(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
case 'dblclick':
this.options.dblclick(event, _thisMenuItem, MenuList[_thisMenuItem.parentId]);
break;
}
};
this.createNode();
}
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultHoverHandler = function (event, menuItem, menu) {
console.log('hover: ' + menuItem.options.label);
};
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultClickHandler = function (event, menuItem, menu) {
console.log('click: ' + menuItem.options.label);
menu.hide();
};
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultDblClickHandler = function (event, menuItem, menu) {
console.log('dblclick: ' + menuItem.options.label);
};
MenuItem.prototype.getMenu = function () {
return MenuList[this.parentId];
};
MenuItem.prototype.getParent = function () {
if(MenuList[this.parentId] instanceof Menu) {
return MenuList[this.parentId].node;
}
return null;
};
MenuItem.prototype.getId = function () {
return this.options.id;
};
/**
* @returns HTMLElement
*/
MenuItem.prototype.getNode = function () {
return this.node;
};
MenuItem.prototype.createNode = function () {
this.node = document.createElement('a');
this.node.style.position = 'relative';
this.node.dataset.parentId = this.parentId;
this.node.kit = this.node.kit || {};
this.node.kit.menuItem = this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setLabel = function (content = '') {
this.options.label = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__label');
this.setContent(wrap, content);
return this;
};
/**
* @param href
* @returns {MenuItem}
*/
MenuItem.prototype.setHref = function (href = 'javascript:void(0);') {
this.options.href = href;
this.getNode().setAttribute('href', href);
return this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setIcon = function (content = '') {
this.options.icon = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__icon');
this.setContent(wrap, content);
return this;
};
/**
* @param sort int
* @returns {MenuItem}
*/
MenuItem.prototype.setSort = function (sort = 500) {
this.options.sort = Number(sort);
return this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setArrow = function (content = '') {
this.options.arrow = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__arrow');
this.setContent(wrap, content);
return this;
};
MenuItem.prototype.setId = function (id = '') {
if(id) {
this.options.id = id;
}
this.node.id = this.options.id;
return this;
};
MenuItem.prototype.setVisible = function (visible = true) {
this.options.visible = visible;
this.node.style.display = this.options.visible?'':'none';
return this;
};
/**
* @param {Menu} menu
* @return {MenuItem}
*/
MenuItem.prototype.setChild = function (menu) {
if(menu instanceof Menu) {
menu.setParent(this.node);
menu.init();
}
else if( Array.isArray(menu) ) {
var menuClass;
menuClass = new Menu();
menu.forEach(function (item, i) {
if(typeof item === 'object') {
menuClass.addItem(item);
}
});
menuClass.setParent(this.node);
menuClass.init();
}
return this;
};
MenuItem.prototype.addClass = function (addClass = '') {
if(addClass) {
this.node.classList.add(addClass);
}
return this;
};
/**
* @param options Object
* @return {MenuItem}
*/
MenuItem.prototype.setOptions = function (options = {}) {
/**
* @type {kitMenuItemOptions}
*/
this.options = Object.assign({}, this.options, options);
return this;
};
/**
* @return {MenuItem}
*/
MenuItem.prototype.render = function () {
this.setLabel(this.options.label);
this.setHref(this.options.href);
this.setId(this.options.id);
this.addClass(MENU_ITEM_CLASS);
this.addClass(this.options.class);
this.setChild(this.options.child);
this.setIcon(this.options.icon);
this.setArrow(this.options.arrow);
this.setVisible(this.options.visible);
this.setSort(this.options.sort);
return this;
};
MenuItem.prototype.init = function () {
if(this.bInit) {
return this;
}
this.render();
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
this.node.addEventListener('click', this, false);
this.node.addEventListener('dblclick', this, false);
this.bInit = true;
return this;
};
MenuItem.prototype.reInit = function () {
this.render();
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
this.node.addEventListener('click', this, false);
this.node.addEventListener('dblclick', this, false);
return this;
};
MenuItem.prototype.remove = function () {
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
var id = this.options.id;
//console.log('remove item' + id);
setTimeout((function(parentId, id){
return function() {
if(MenuList.hasOwnProperty(parentId) && MenuList[parentId].itemList.hasOwnProperty(id)) {
delete MenuList[parentId].itemList[id];
MenuList[parentId].init();
}
};
this.createNode();
})(this.parentId, this.options.id),0);
};
/**
* @param className
* @returns HTMLElement
*/
MenuItem.prototype.getNodeScopeElementByClassName = function(className = ''){
var wrap;
this.node && (wrap = this.node.querySelector(':scope > .' + className));
if(!wrap) {
wrap = document.createElement('div');
wrap.classList.add(className);
this.node.append(wrap);
}
return wrap;
};
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultHoverHandler = function (event, menuItem, menu) {
console.log('hover: ' + menuItem.options.label);
};
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultClickHandler = function (event, menuItem, menu) {
console.log('click: ' + menuItem.options.label);
menu.hide();
};
/**
* @param event {MouseEvent}
* @param menuItem {MenuItem}
* @param menu {Menu}
*/
MenuItem.prototype.defaultDblClickHandler = function (event, menuItem, menu) {
console.log('dblclick: ' + menuItem.options.label);
};
MenuItem.prototype.getMenu = function () {
return MenuList[this.parentId];
};
MenuItem.prototype.getParent = function () {
if(MenuList[this.parentId] instanceof Menu) {
return MenuList[this.parentId].node;
}
return null;
};
MenuItem.prototype.getId = function () {
return this.options.id;
};
/**
* @returns HTMLElement
*/
MenuItem.prototype.getNode = function () {
return this.node;
};
MenuItem.prototype.createNode = function () {
this.node = document.createElement('a');
this.node.style.position = 'relative';
this.node.dataset.parentId = this.parentId;
this.node.kit = this.node.kit || {};
this.node.kit.menuItem = this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setLabel = function (content = '') {
this.options.label = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__label');
this.setContent(wrap, content);
return this;
};
/**
* @param href
* @returns {MenuItem}
*/
MenuItem.prototype.setHref = function (href = 'javascript:void(0);') {
this.options.href = href;
this.getNode().setAttribute('href', href);
return this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setIcon = function (content = '') {
this.options.icon = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__icon');
this.setContent(wrap, content);
return this;
};
/**
* @param sort int
* @returns {MenuItem}
*/
MenuItem.prototype.setSort = function (sort = 500) {
this.options.sort = Number(sort);
return this;
};
/**
* @param content HTMLElement | string
* @returns {MenuItem}
*/
MenuItem.prototype.setArrow = function (content = '') {
this.options.arrow = content;
var wrap = this.getNodeScopeElementByClassName('kit-menu-item__arrow');
this.setContent(wrap, content);
return this;
};
MenuItem.prototype.setId = function (id = '') {
if(id) {
this.options.id = id;
}
this.node.id = this.options.id;
return this;
};
MenuItem.prototype.setVisible = function (visible = true) {
this.options.visible = visible;
this.node.style.display = this.options.visible?'':'none';
return this;
};
/**
* @param {Menu} menu
* @return {MenuItem}
*/
MenuItem.prototype.setChild = function (menu) {
if(menu instanceof Menu) {
menu.setParent(this.node);
menu.init();
}
else if( Array.isArray(menu) ) {
var menuClass;
menuClass = new Menu();
menu.forEach(function (item, i) {
if(typeof item === 'object') {
menuClass.addItem(item);
}
});
menuClass.setParent(this.node);
menuClass.init();
}
return this;
};
MenuItem.prototype.addClass = function (addClass = '') {
if(addClass) {
this.node.classList.add(addClass);
}
return this;
};
/**
* @param options Object
* @return {MenuItem}
*/
MenuItem.prototype.setOptions = function (options = {}) {
this.options = Object.assign({}, this.options, options);
return this;
};
/**
* @return {MenuItem}
*/
MenuItem.prototype.render = function () {
this.setLabel(this.options.label);
this.setHref(this.options.href);
this.setId(this.options.id);
this.addClass(MENU_ITEM_CLASS);
this.addClass(this.options.class);
this.setChild(this.options.child);
this.setIcon(this.options.icon);
this.setArrow(this.options.arrow);
this.setVisible(this.options.visible);
this.setSort(this.options.sort);
return this;
};
MenuItem.prototype.init = function () {
if(this.bInit) {
return this;
}
this.render();
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
this.node.addEventListener('click', this, false);
this.node.addEventListener('dblclick', this, false);
this.bInit = true;
return this;
};
MenuItem.prototype.reInit = function () {
this.render();
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
this.node.addEventListener('click', this, false);
this.node.addEventListener('dblclick', this, false);
return this;
};
MenuItem.prototype.remove = function () {
this.node.removeEventListener('click', this, false);
this.node.removeEventListener('dblclick', this, false);
var id = this.options.id;
//console.log('remove item' + id);
setTimeout((function(parentId, id){
return function() {
if(MenuList.hasOwnProperty(parentId) && MenuList[parentId].itemList.hasOwnProperty(id)) {
delete MenuList[parentId].itemList[id];
MenuList[parentId].init();
}
};
})(this.parentId, this.options.id),0);
};
/**
* @param className
* @returns HTMLElement
*/
MenuItem.prototype.getNodeScopeElementByClassName = function(className = ''){
var wrap;
this.node && (wrap = this.node.querySelector(':scope > .' + className));
if(!wrap) {
wrap = document.createElement('div');
wrap.classList.add(className);
this.node.append(wrap);
}
return wrap;
};
/**
* @param node HTMLElement
* @param content HTMLElement | string
* @param isText boolean
* @return boolean
*/
MenuItem.prototype.setContent = function(node, content, isText = false){
if(!(node instanceof Element)) {
return false;
}
while (node.firstChild) {
node.removeChild(node.firstChild);
}
if((content instanceof Element) || isText) {
node.append(content);
} else {
node.innerHTML = content;
}
return true;
};
return MenuItem;
}();
Menu.prototype.MenuItem = MenuItemClass;
/**
* @param node HTMLElement
* @param content HTMLElement | string
* @param isText boolean
* @return boolean
*/
MenuItem.prototype.setContent = function(node, content, isText = false){
if(!(node instanceof Element)) {
return false;
}
while (node.firstChild) {
node.removeChild(node.firstChild);
}
if((content instanceof Element) || isText) {
node.append(content);
} else {
node.innerHTML = content;
}
return true;
};
var getInstance = function(options = {}, items = []) {
@@ -786,6 +789,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
* @memberOf kit
*/
var menu = {
MenuItem: MenuItem,
Class: Menu,
getInstance: getInstance,
reInitAllMenu: reInitAllMenu,
+11
View File
@@ -52,6 +52,13 @@ __PluginManager__.register('support', function(module, exports, require, global)
val === 0 ||
val === false;
}
function emptyEx(val) {
return empty(val) ||
(isObject(val) && (function () {
for(v in val) return false;
return true;
})());
}
function typeOf(value) {
return typeof value;
}
@@ -105,6 +112,9 @@ __PluginManager__.register('support', function(module, exports, require, global)
}
}
};
function isA(o,c){
return null!=c&&"undefined"!=typeof Symbol&&c[Symbol.hasInstance]?!!c[Symbol.hasInstance](o):o instanceof c
}
/**
@@ -127,6 +137,7 @@ __PluginManager__.register('support', function(module, exports, require, global)
isElement,
getNode,
extend,
isA
};
return module.exports = support;
+32
View File
@@ -0,0 +1,32 @@
/** @module testing */
__PluginManager__.register('testing', function(module, exports, require, global){
/**
* @constructor
*/
function Unit() {
this.logger = new kit.Logger();
}
Unit.prototype.assertSame = function (expected, actual, message) {
if(expected === actual) {
this.logger.success({pass: message});
return true;
}
if(expected == actual) {
this.logger.warning({warn: message}, {expected: expected, actual: actual});
return false;
}
this.logger.error({fail: message}, {expected: expected, actual: actual});
return false;
};
/**
* @memberOf kit
*/
var testing = {
Unit,
};
return module.exports = testing;
});
+1 -2
View File
@@ -60,8 +60,7 @@ if($isHint) {
]);
}
?>
autocomplete="off"
><?
autocomplete="off"><?
if($isHint){
app()->service()->templater()->render('kit:field/hint', ['TITLE' => $arParams['HINT']]);
}
+43
View File
@@ -0,0 +1,43 @@
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?>
<?
if(\Bitrix\Main\Loader::includeModule('wt.core')) {
app()->service()->assets()->setPlugins([
'kit:config',
'kit:flex-kit',
'kit:core',
'kit:bsCore',
'kit:collapse',
'kit:site',
'kit:toolkit',
'kit:theme',
])->render();
}
$APPLICATION->ShowHead();
?>
<script>
kit.ready(['date', 'testing'], function () {
var nowClock = document.getElementsByClassName('date-time');
var unit = new kit.testing.Unit();
unit.logger.info(kit.date.version);
unit.logger.notice('<div class="date-time">--:--</div>');
unit.assertSame('2:00:02', kit.date.countTime('H:i:s', (3600 * 2 + 2) * 1000, 0, 1), 'countTime');
x = setInterval(function() {
for(let i=0; i<nowClock.length; i+=1){
nowClock[i].innerHTML=kit.date('Y-m-d H:i:s');
}
//clearInterval(x);
}, 1000);
});
</script>
<div class="kit-wrapper">
<div class="kit-logger"></div>
</div>
<?
?>
+13 -9
View File
@@ -1,13 +1,17 @@
<div style="display: flex; flex-direction: column; align-items: center;">
<a href="cheatsheet.php"><b>cheatsheet</b></a>
<a href="menu.php">Menu</a>
<a href="align.php">align</a>
<a href="templates.svg.php">templates.svg</a>
<a href="flex-kit.php">flex-kit</a>
<a href="card/block.php">card/block</a>
<a href="kit.Collection.php">kit.Collection</a>
<a href="userAction.php">userAction</a>
<a href="templater.php">templater</a>
<?php
$arFilesItems = glob(__DIR__ . '/*Test.php');
foreach ($arFilesItems as $file) {
$file = basename($file);
$clName = substr($file, 0, -8);
echo "<a href=\"$file\"><b>$clName</b></a>";
}
?>
</div>
+53
View File
@@ -0,0 +1,53 @@
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?>
<?
if(\Bitrix\Main\Loader::includeModule('wt.core')) {
app()->service()->assets()->setPlugins([
'kit:config',
'kit:flex-kit',
'kit:core',
'kit:bsCore',
'kit:collapse',
'kit:site',
'kit:toolkit',
'kit:theme',
])->render();
}
$APPLICATION->ShowHead();
?>
<script>
kit.ready(['date', 'logger'], function () {
var logger = new kit.Logger();
logger.error('Привет мир!');
logger.info('Привет мир!');
logger.warning('Привет мир!');
logger.success('Привет мир!');
logger.notice(kit.date('Y-m-d H:i:s'), {
test1: {
test1: kit.date('Y-m-d H:i:s'),
test2: kit.date('Y-m-d'),
test3: kit.date('H:i:s'),
},
test2: {
test1: kit.date('Y-m-d H:i:s'),
test2: kit.date('Y-m-d H:i:s'),
test3: kit.date('Y-m-d H:i:s'),
},
test3: {
test1: kit.date('Y-m-d H:i:s'),
test2: kit.date('Y-m-d H:i:s'),
test3: kit.date('Y-m-d H:i:s'),
},
});
});
</script>
<div class="kit-wrapper">
</div>
<?
?>
+6 -1
View File
@@ -239,7 +239,12 @@ kit.ready(['menu', 'animations'], function () {
window.i = 0;
menuBase.addItem({
label: 'Добавить сюда меню',
click: function(e, menuItem, menu) {
/**
* @param e {MouseEvent}
* @param menuItem {kit.menu.MenuItem}
* @param menu {kit.menu.Class}
* */
click: function(e, menuItem, menu) {
console.log('клик by ' + menuItem.options.label);
console.log(menu);
menu.addItem({