mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
+18
-13
@@ -100,7 +100,7 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
|
|
||||||
this.__aminationTrapHide = new AnimationTrap(this.node, function (options) {
|
this.__aminationTrapHide = new AnimationTrap(this.node, function (options) {
|
||||||
if(options.onHideBefore !== false) {
|
if(options.onHideBefore !== false) {
|
||||||
this.onHideBefore.eachCall();
|
this.onHideBefore.eachCall(window, options);
|
||||||
}
|
}
|
||||||
removeAnimation.call(this, this.animShowClass);
|
removeAnimation.call(this, this.animShowClass);
|
||||||
addAnimation.call(this, this.animHideClass);
|
addAnimation.call(this, this.animHideClass);
|
||||||
@@ -111,14 +111,14 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
this.node.classList.add('hide');
|
this.node.classList.add('hide');
|
||||||
this.node.classList.remove('show');
|
this.node.classList.remove('show');
|
||||||
if(options.onHide !== false) {
|
if(options.onHide !== false) {
|
||||||
this.onHide.eachCall();
|
this.onHide.eachCall(window, options);
|
||||||
}
|
}
|
||||||
this.node.style.display = 'none';
|
this.node.style.display = 'none';
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.__aminationTrapShow = new AnimationTrap(this.node, function (options = {}) {
|
this.__aminationTrapShow = new AnimationTrap(this.node, function (options = {}) {
|
||||||
if(options.onShowBefore !== false) {
|
if(options.onShowBefore !== false) {
|
||||||
this.onShowBefore.eachCall();
|
this.onShowBefore.eachCall(window, options);
|
||||||
}
|
}
|
||||||
this.node.classList.remove('hide');
|
this.node.classList.remove('hide');
|
||||||
this.node.classList.add('show');
|
this.node.classList.add('show');
|
||||||
@@ -132,7 +132,7 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
removeAnimation.call(this, this.animHideClass);
|
removeAnimation.call(this, this.animHideClass);
|
||||||
addAnimation.call(this, this.animShowClass);
|
addAnimation.call(this, this.animShowClass);
|
||||||
if(options.onShow !== false) {
|
if(options.onShow !== false) {
|
||||||
this.onShow.eachCall();
|
this.onShow.eachCall(window, options);
|
||||||
}
|
}
|
||||||
}.bind(this), function (options = {}) {
|
}.bind(this), function (options = {}) {
|
||||||
|
|
||||||
@@ -149,8 +149,8 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
|
|
||||||
var proto = Viewer.prototype;
|
var proto = Viewer.prototype;
|
||||||
proto.show = function(options = {}){
|
proto.show = function(options = {}){
|
||||||
|
//console.log('viewer show', this.node.kit.menu.id, options);
|
||||||
if(this.isShown()) {
|
if(this.isShown() && !options.force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,8 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
};
|
};
|
||||||
|
|
||||||
proto.hide = function(options = {}){
|
proto.hide = function(options = {}){
|
||||||
if(this.isHidden()) {
|
//console.log('viewer hide', this.node.kit.menu.id);
|
||||||
|
if(this.isHidden() && !options.force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,12 +199,16 @@ kit.PluginManager.register('Viewer', function(module, exports, require, global)
|
|||||||
return !this.isHidden();
|
return !this.isHidden();
|
||||||
};
|
};
|
||||||
proto.isHidden = function(){
|
proto.isHidden = function(){
|
||||||
var result = this.node.classList.contains('hide');
|
return this.__aminationTrapHide.active || this.__deferredHideID || this.node.classList.contains('hide') ||
|
||||||
result = result || getComputedStyle(this.node).display === 'none';
|
(getComputedStyle(this.node).display === 'none') ||
|
||||||
if(this.masterNode && this.activeMasterClass) {
|
(this.masterNode && this.activeMasterClass && !this.masterNode.classList.contains(this.activeMasterClass));
|
||||||
result = result || !this.masterNode.classList.contains(this.activeMasterClass);
|
|
||||||
}
|
// var result = this.node.classList.contains('hide');
|
||||||
return result || this.__aminationTrapHide.active || this.__deferredHideID;
|
// result = result || getComputedStyle(this.node).display === 'none';
|
||||||
|
// if(this.masterNode && this.activeMasterClass) {
|
||||||
|
// result = result || !this.masterNode.classList.contains(this.activeMasterClass);
|
||||||
|
// }
|
||||||
|
// return result || this.__aminationTrapHide.active || this.__deferredHideID;
|
||||||
};
|
};
|
||||||
proto.stop = function () {
|
proto.stop = function () {
|
||||||
this.__aminationTrapHide.stop();
|
this.__aminationTrapHide.stop();
|
||||||
|
|||||||
@@ -436,5 +436,21 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Метод извлекает все значения для данного ключа
|
||||||
|
* ключи оставляет исходные
|
||||||
|
* Значения в коллекци должны быть массиво подобные
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return {kit.Collection}
|
||||||
|
*/
|
||||||
|
Collection.prototype.pluck = function (key) {
|
||||||
|
return this.map(function (value) {
|
||||||
|
if(value instanceof Object && value.hasOwnProperty(key)){
|
||||||
|
return value[key];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
};
|
||||||
return module.exports = Collection;
|
return module.exports = Collection;
|
||||||
});
|
});
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
--col-span: 1;
|
--col-span: 1;
|
||||||
--line-clamp: 3;
|
--line-clamp: 3;
|
||||||
--line-clamp-height: 1.3em;
|
--line-clamp-height: 1.3em;
|
||||||
--width-wrapper: 800px;
|
--width-wrapper: 1200px;
|
||||||
--flex-aspect-ratio: 1;
|
--flex-aspect-ratio: 1;
|
||||||
--flex-line-count: 1;
|
--flex-line-count: 1;
|
||||||
--flex-col-count: 2;
|
--flex-col-count: 2;
|
||||||
|
|||||||
+50
-38
@@ -1,5 +1,6 @@
|
|||||||
/** @module menu */
|
/** @module menu */
|
||||||
//todo: instance, options, auto-options-by-node
|
//todo: instance, options, auto-options-by-node
|
||||||
|
//ok: getChainActiveMenuDataList Скрытие меню открывающихся по клику / 3 depth базовый - след 2
|
||||||
__PluginManager__.register('menu',function(module, exports, require, global) {
|
__PluginManager__.register('menu',function(module, exports, require, global) {
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +68,6 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
this.itemList = {};
|
this.itemList = {};
|
||||||
this.node = null;
|
this.node = null;
|
||||||
this.bInit = false;
|
this.bInit = false;
|
||||||
this.bActive = false;
|
|
||||||
this.options = defaultMenuOptions;
|
this.options = defaultMenuOptions;
|
||||||
this.createNode(); //с пула нужна базовая нода
|
this.createNode(); //с пула нужна базовая нода
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
@@ -100,15 +100,22 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Menu.prototype.hide = function () {
|
Menu.prototype.isActive = function () {
|
||||||
if(this.viewer) {
|
if(this.viewer) {
|
||||||
this.viewer.hide();
|
return this.viewer.isShown();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Menu.prototype.hide = function (options = {}) {
|
||||||
|
if(this.viewer) {
|
||||||
|
this.viewer.hide(options);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Menu.prototype.show = function () {
|
Menu.prototype.show = function (options = {}) {
|
||||||
if(this.viewer) {
|
if(this.viewer) {
|
||||||
this.viewer.show();
|
this.viewer.show(options);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -142,6 +149,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Menu.prototype.setPositionRecursive = function(){
|
Menu.prototype.setPositionRecursive = function(){
|
||||||
|
console.log('setPositionRecursive', this.id);
|
||||||
var list = getChainActiveMenuDataList(this.id);
|
var list = getChainActiveMenuDataList(this.id);
|
||||||
list.forEach(function (data) {
|
list.forEach(function (data) {
|
||||||
data.menu.setPosition();
|
data.menu.setPosition();
|
||||||
@@ -228,10 +236,6 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
//console.warn('Menu.setParent: Не удалось получить parent. ' + parentNode);
|
//console.warn('Menu.setParent: Не удалось получить parent. ' + parentNode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(this.viewer instanceof Viewer) {
|
|
||||||
this.bActive = this.viewer.isShown();
|
|
||||||
this.viewer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options.parent = parentNode;
|
this.options.parent = parentNode;
|
||||||
|
|
||||||
@@ -246,14 +250,18 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.prototype.init = function (setPositionRecursive = false) {
|
Menu.prototype.init = function () {
|
||||||
var self = this;
|
var self = this, isActiveBefore = this.isActive();
|
||||||
|
|
||||||
if(!(this.options.parent instanceof Element)) {
|
if(!(this.options.parent instanceof Element)) {
|
||||||
console.warn('Menu.init: Не установлен parent');
|
console.warn('Menu.init: Не установлен parent');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.viewer instanceof Viewer) {
|
||||||
|
this.viewer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
if(this.node.parentElement !== this.options.parent) {
|
if(this.node.parentElement !== this.options.parent) {
|
||||||
this.node.remove();
|
this.node.remove();
|
||||||
@@ -265,7 +273,6 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
}
|
}
|
||||||
this.align = new align.Class(this.node, this.options.parent);
|
this.align = new align.Class(this.node, this.options.parent);
|
||||||
|
|
||||||
|
|
||||||
if(this.actions instanceof ActionCollection) {
|
if(this.actions instanceof ActionCollection) {
|
||||||
this.actions.stop();
|
this.actions.stop();
|
||||||
}
|
}
|
||||||
@@ -275,6 +282,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
this.viewer = ua.viewer;
|
this.viewer = ua.viewer;
|
||||||
ua.viewer.onHideBefore.push(function () {
|
ua.viewer.onHideBefore.push(function () {
|
||||||
var list = getChainActiveMenuDataList(self.id);
|
var list = getChainActiveMenuDataList(self.id);
|
||||||
|
//console.log('скрыт', self.id, 'цепочка', (new kit.Collection(list)).pluck('id').toArray().join('-'));
|
||||||
list.shift();
|
list.shift();
|
||||||
list.reverse().forEach(function (data) {
|
list.reverse().forEach(function (data) {
|
||||||
if(data.menu.viewer) {
|
if(data.menu.viewer) {
|
||||||
@@ -283,23 +291,29 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
ua.viewer.onHide.push(function () {
|
ua.viewer.onHide.push(function () {
|
||||||
self.bActive = self.viewer.isShown();
|
|
||||||
});
|
});
|
||||||
ua.viewer.onShow.push(function () {
|
ua.viewer.onShow.push(function (options = {}) {
|
||||||
|
//pre('onShow arguments', self.id, arguments[0]);
|
||||||
self.setPosition.call(self);
|
self.setPosition.call(self);
|
||||||
self.bActive = self.viewer.isShown();
|
if(options.recursiveMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var list = getChainActiveMenuDataList(self.id);
|
||||||
|
//console.log('показан', self.id, 'цепочка', (new kit.Collection(list)).pluck('id').toArray().join('-'));
|
||||||
|
list.shift();
|
||||||
|
list.forEach(function (data) {
|
||||||
|
if(data.menu.viewer) {
|
||||||
|
data.menu.viewer.show({recursiveMode: true, force: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.actions = new ActionCollection([ua]);
|
this.actions = new ActionCollection([ua]);
|
||||||
this.actions.run();
|
this.actions.run();
|
||||||
|
|
||||||
if(this.bActive) {
|
if(this.isActive() || isActiveBefore) {
|
||||||
if(setPositionRecursive) {
|
this.show({force: true});
|
||||||
this.setPositionRecursive();
|
|
||||||
} else {
|
|
||||||
this.setPosition();
|
|
||||||
}
|
|
||||||
this.show();
|
|
||||||
} else {
|
} else {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
@@ -644,34 +658,31 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
return new Menu(options, items);
|
return new Menu(options, items);
|
||||||
};
|
};
|
||||||
var getActiveMenuDataList = function(){
|
var getActiveMenuDataList = function(){
|
||||||
var idList = [];
|
|
||||||
var dataList = [];
|
var idList = [], dataList = [], refList = [];
|
||||||
var refList = [];
|
|
||||||
function getParentId(id, element) {
|
function getParentId(id) {
|
||||||
if(!element) {
|
var parentId = false, menu = MenuList[id], parentMenu;
|
||||||
element = MenuList[id];
|
|
||||||
}
|
|
||||||
var parentId = false, parentMenu;
|
|
||||||
if(refList.hasOwnProperty(id) && refList[id].parentMenu) {
|
if(refList.hasOwnProperty(id) && refList[id].parentMenu) {
|
||||||
return refList[id].parentMenu.id;
|
return refList[id].parentMenu.id;
|
||||||
}
|
}
|
||||||
if(element) {
|
if(menu) {
|
||||||
refList[id] = refList[id] || {};
|
refList[id] = refList[id] || {};
|
||||||
parentMenu = refList[id].parentMenu = element.getParentMenu();
|
parentMenu = refList[id].parentMenu = menu.getParentMenu();
|
||||||
}
|
}
|
||||||
parentMenu && (parentId = parentMenu.id);
|
parentMenu && (parentId = parentMenu.id);
|
||||||
return parentId;
|
return parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuList.forEach(function(element){
|
MenuList.forEach(function(menu){
|
||||||
var pos, posId, id, parentId;
|
var pos, posId, id, parentId;
|
||||||
if(!((element instanceof Menu) && element.bInit && element.bActive)) {
|
if(!((menu instanceof Menu) && menu.isActive())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
id = element.id;
|
id = menu.id;
|
||||||
refList[id] = refList[id] || {};
|
refList[id] = refList[id] || {};
|
||||||
refList[id].menu = element;
|
refList[id].menu = menu;
|
||||||
parentId = getParentId(id, element);
|
parentId = getParentId(id);
|
||||||
var depth = function (id){
|
var depth = function (id){
|
||||||
return function() {
|
return function() {
|
||||||
var pid = refList[id].data.parentId;
|
var pid = refList[id].data.parentId;
|
||||||
@@ -725,13 +736,14 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
|
|||||||
if(data.id === id) {
|
if(data.id === id) {
|
||||||
depth = data.depth;
|
depth = data.depth;
|
||||||
}
|
}
|
||||||
if(depth === data.depth && data.id !== id) {
|
if(depth === data.depth && data.id !== id || depth > data.depth) {
|
||||||
depth = 0;
|
depth = 0;
|
||||||
}
|
}
|
||||||
if(depth) {
|
if(depth) {
|
||||||
result.push(data);
|
result.push(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//pre(id, (new Collection(result).pluck('id').toArray().join('-')));
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var reInitAllMenu = function(){
|
var reInitAllMenu = function(){
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/** @module support */
|
/** @module support */
|
||||||
__PluginManager__.register('support', function(module, exports, require, global){
|
__PluginManager__.register('support', function(module, exports, require, global){
|
||||||
|
|
||||||
|
window.pre = console.log;
|
||||||
|
|
||||||
var node = {
|
var node = {
|
||||||
isRelate: function (node, container = document) {
|
isRelate: function (node, container = document) {
|
||||||
return node === container || container.contains(node);
|
return node === container || container.contains(node);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" version="1.1" viewBox="0 0 960 960" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m960 0v728h-192v232l-78-59.7-227-172h-463v-728zm-96 91h-768v546h401l13.5 9.96 162 122v-132h192z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 225 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M 2 5 L 2 21 L 6 21 L 6 26.09375 L 7.625 24.78125 L 12.34375 21 L 22 21 L 22 5 Z M 4 7 L 20 7 L 20 19 L 11.65625 19 L 11.375 19.21875 L 8 21.90625 L 8 19 L 4 19 Z M 24 9 L 24 11 L 28 11 L 28 23 L 24 23 L 24 25.90625 L 20.34375 23 L 12.84375 23 L 10.34375 25 L 19.65625 25 L 26 30.09375 L 26 25 L 30 25 L 30 9 Z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 417 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="16" version="1.1" viewBox="0 0 960 640" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m480 192a131 128 0 0 1 131 128 131 128 0 0 1-131 128 131 128 0 0 1-131-128 131 128 0 0 1 131-128m0-192c218 0 405 133 480 320-75.5 187-262 320-480 320s-405-133-480-320c75.5-187 262-320 480-320m-385 320c72 143 221 235 385 235s313-91.3 385-235c-72-143-221-235-385-235s-313 91.3-385 235z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 413 B |
@@ -1,3 +1,3 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" version="1.1" viewBox="0 0 24 24">
|
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path style="fill:none;fill-opacity:1;stroke:currentColor;stroke-opacity:1" stroke-width="2.15306" d="m 20.555124,20.394896 c -0.272926,0.248113 -0.481403,0.393311 -1.050082,0.493988 L 8.0635534,20.878407 c 0,0 -0.5220735,0.07778 -0.823884,-0.190715 C 6.9610567,20.439851 7.0099581,19.93416 7.0099581,19.93416 L 8.9928389,9.3702865 13.396911,1.1133523 c 0.890464,0.049951 1.649319,0.7795542 1.649319,1.6914978 V 8.40884 l 6.101959,-0.062376 c 0.500086,0 0.967605,0.1796509 1.335528,0.5043388 0.344913,0.3043237 0.497853,0.7709927 0.414163,1.1621372 l -1.643149,9.15398 v 0 c -0.138497,0.494818 -0.373238,0.931277 -0.699607,1.227976 z M 1.254434,19.976604 3.2236276,9.2589025 H 4.8115658 L 2.8423724,19.976604 Z" />
|
<path d="m20.6 20.4c-0.273 0.248-0.481 0.393-1.05 0.494l-11.4-0.0105s-0.522 0.0778-0.824-0.191c-0.279-0.248-0.23-0.754-0.23-0.754l1.98-10.6 4.4-8.26c0.89 0.05 1.65 0.78 1.65 1.69v5.6l6.1-0.0624c0.5 0 0.968 0.18 1.34 0.504 0.345 0.304 0.498 0.771 0.414 1.16l-1.64 9.15c-0.138 0.495-0.373 0.931-0.7 1.23zm-19.3-0.418 1.97-10.7h1.59l-1.97 10.7z" stroke-width="2.15" style="fill:none;stroke:currentColor"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 824 B After Width: | Height: | Size: 515 B |
@@ -221,7 +221,25 @@ kit.ready(['collection'], function () {
|
|||||||
assertSame(x.indexKey('11'), 3, 'indexKey (string)');
|
assertSame(x.indexKey('11'), 3, 'indexKey (string)');
|
||||||
assertSame(x.indexKey('111'), -1, 'indexKey (-1)');
|
assertSame(x.indexKey('111'), -1, 'indexKey (-1)');
|
||||||
|
|
||||||
|
xOb = [
|
||||||
|
{
|
||||||
|
name: 'Igor',
|
||||||
|
age: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Max',
|
||||||
|
age: 19,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Nikita',
|
||||||
|
age: 18,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
x = new kit.Collection(xOb);
|
||||||
|
y = x.pluck('name');
|
||||||
|
assertSame(y.toArray().join('-'), 'Igor-Max-Nikita', 'pluck');
|
||||||
|
y = x.pluck('age');
|
||||||
|
assertSame(y.toArray().join('-'), '20-19-18', 'pluck с проверкой сохранения порядка');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user