diff --git a/.travis.yml b/.travis.yml index 6c94aa0..3e97fc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,32 @@ +sudo: required +dist: trusty +group: edge + language: node_js + +os: + - linux + node_js: + - '6' - '5' - '4' - '0.12' - '0.10' - 'iojs' + after_success: - npm run coveralls - npm run coverage-clean + before_deploy: - echo "Deploying to GitHub releases" - ls -al releases + deploy: provider: releases api_key: - secure: "x9nz3bvNesYVCesjj36yFYlYIAVykchBR4Ffzzysd4Tk1v+0eh0mRc9jmTzfF7xYsAjpKRCMGCjWG39aPwVG7rbs0EZDrXVxT7KObZ31HS9A1VWkOs/LKAlDrwjylx4umNswmVWAW+pVr9N431Be21+mZg4Xu8z6iDnLgHWxhK9n2IewKanPVV3pbB6hNVKpshnbYMraqwnJQE4gOVhBc2EBHUAUIhtVN1ntmRL76+trlpPFTzbhBVywf0TRvW4J67wYQO0was/qRww+wKmUvymD+7vk8P/23+uVi9pDpUix2TMZfyCPUG1PpQ0cZfIaaUg4POQD3hqFCJGeAgxZzIPEHOVd+TLF+B2eZjSMlTDyrVI2+JzVwx9SIPBkLgsRy1xNGFfMHXidJGOnkG9efv2artjkNblx3SGkx9EgAd1fsfM/epvggaJvW3rsU0AlRN9IKOeHToYVkWGJIJNjFGt1AL7a98SvtQ56xsXocUeLjLRnh14VFxZ22IeBRClOpyMGVLuTBy+m4hJMSB8JbjdBkJW45Ou6Pdswt5cW6WWXM1sepmxjttStp0FyiOr0qCkQfJsEEg1fYF0Rj7zNfUTFlRCX9+JWhQ/Lb61kEsBjqKc7/lPFOiKB/iLkQo+gQNb5ToaQMZIK0vmYf4gZZ6tkFkicbp8JjZu6mlNKdSE=" + secure: "MZfhBihMNxpAGUffDpp5u5KUfhJ6+g0PQ7h7lbTl19HBK9zCnvN5Go8xJYGCZQNj4Y2bGwsXokGN3PudIJwhTMX3LnOEoByoqWUPw5wUpeRlRO3B7v9GFYsJM2Y9/ZkjEmv0bFwkSC69OMcQeVOZET83ch8UYl7ftIXGp2iTDF8LLCtWjDWRfdQOkDrd44JO2DLIVc5sbpbT4jEklln09ZJBAlbKTTpAiAPXLVn9WqZWiWMlbWJVKczykLrvkTlAUAJlZpu+2yqFmGlCQzWS/Ksc/2z1cvFKbC1mkZdfm+g3SUX1CJtjOAJjc9iAdltbcU4VqkwgFHVDYAa9wKU18fNw5nsYECEHdQx42GU+cCnhTEzKKMJdWj+h+QgWeMgCyUncBWubNiiU2fI0QtC8LUs19IppQ0/nbFR7RihvtILiaxfcQ37E42PGzFFdP1JnmthEXN4g4FV8sTXOsTtxCPKSlpea65NJyQheztzhOyromohT06EtLSjpwtwUnKMJmBNvjWo48IlOI5QPqbSOuI/wT/Yow2JuJVr4rQj4VKNYSDFwKYdo+ltdgfSjbsfKCevCw1Ok1QLHYcdUfOolzLJzNkWemEtfC4hdEkBB0iz3paznGvE9IggqAXZyvZuwxxFhNSRiZPujhOu4GsCtu3UvlOv8wsUeHJ3s2A0f0Qs=" file_glob: true file: - 'releases/*.*' diff --git a/README.md b/README.md index 005da1e..2459b4f 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ console.log(node.getFirstChild().getPreviousSibling()); #### Events Usage Learn more: [Events](https://github.com/cheton/infinite-tree/wiki/Events) ```js +tree.on('click', function(event) { +}); tree.on('contentWillUpdate', function() { }); tree.on('contentDidUpdate', function() { @@ -122,6 +124,51 @@ tree.on('selectNode', function(node) { * [Functions: Node](https://github.com/cheton/infinite-tree/wiki/Functions:-Node) * [Events](https://github.com/cheton/infinite-tree/wiki/Events) +## FAQ + +#### How to attach click event listeners to nodes? + +Use event delegation [[1](http://javascript.info/tutorial/event-delegation), [2](http://davidwalsh.name/event-delegate)] + +```js +// JavaScript +var el = document.querySelector('#tree'); +var tree = new InfiniteTree(el, { /* options */ }); + +tree.on('click', function(event) { + event = event || window.event; + var target = event.target || event.srcElement; + + // do stuff with node + console.log(target); + + // Check if the target element contains a specific class + if (!hasClass(target, 'my-specific-class')) { + return; + } +}; + +// Checks if an element contains a specific class +var hasClass = function(el, className) { + if (!el) { + return false; + } + var classes = el.className.split(' '); + return (classes.indexOf(className) >= 0); +}; +``` + +Event delegation with jQuery: +```js +var el = document.querySelector('#tree'); +var tree = new InfiniteTree(el, { /* options */ }); + +// jQuery +$(tree.contentElement).on('click', 'your-event-selector', function() { + // do stuff with node +}); +``` + ## License Copyright (c) 2016 Cheton Wu diff --git a/dist/infinite-tree.js b/dist/infinite-tree.js index 245f2bc..5646608 100644 --- a/dist/infinite-tree.js +++ b/dist/infinite-tree.js @@ -1,4 +1,4 @@ -/*! infinite-tree v1.1.1 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ +/*! infinite-tree v1.2.0 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -162,43 +162,71 @@ return /******/ (function(modules) { // webpackBootstrap _this.draggableTarget = null; _this.droppableTarget = null; _this.contentListener = { - 'click': function click(e) { - var itemTarget = null; - var clickToggler = false; + 'click': function click(event) { + event = event || window.event; + + // Wrap stopPropagation that allows click event handler to stop execution + // by setting the cancelBubble property + var stopPropagation = event.stopPropagation; + event.stopPropagation = function () { + // Setting the cancelBubble property in browsers that don't support it doesn't hurt. + // Of course it doesn't actually cancel the bubbling, but the assignment itself is safe. + event.cancelBubble = true; + + if (stopPropagation) { + stopPropagation.call(event); + } + }; - if (e.target && e.currentTarget) { - itemTarget = e.target !== e.currentTarget ? e.target : null; - } else if (e.srcElement) { - // IE8 - itemTarget = e.srcElement; - } + // Call setTimeout(fn, 0) to re-queues the execution of subsequent calls, it allows the + // click event to bubble up to higher level event handlers before handling tree events. + setTimeout(function () { + // Stop execution if the cancelBubble property is set to true by higher level event handlers + if (event.cancelBubble === true) { + return; + } - while (itemTarget && itemTarget.parentElement !== _this.contentElement) { - if ((0, _helper.hasClass)(itemTarget, _this.options.togglerClass)) { - clickToggler = true; + // Emit 'click' event + _this.emit('click', event); + + // Stop execution if the cancelBubble property is set to true after emitting the click event + if (event.cancelBubble === true) { + return; } - itemTarget = itemTarget.parentElement; - } - if (!itemTarget) { - return; - } + var itemTarget = null; + var clickToggler = false; - var id = itemTarget.getAttribute(_this.options.nodeIdAttr); - var node = _this.getNodeById(id); + if (event.target && event.currentTarget) { + itemTarget = event.target !== event.currentTarget ? event.target : null; + } else if (event.srcElement) { + // IE8 + itemTarget = event.srcElement; + } - if (!node) { - return; - } + while (itemTarget && itemTarget.parentElement !== _this.contentElement) { + if ((0, _helper.hasClass)(itemTarget, _this.options.togglerClass)) { + clickToggler = true; + } + itemTarget = itemTarget.parentElement; + } - // Click on the toggler to open/close a tree node - if (clickToggler) { - _this.toggleNode(node); - return; - } + if (!itemTarget) { + return; + } + + var id = itemTarget.getAttribute(_this.options.nodeIdAttr); + var node = _this.getNodeById(id); + if (!node) { + return; + } + + // Click on the toggler to open/close a tree node + if (clickToggler) { + _this.toggleNode(node); + return; + } - // Use setTimeout(fn, 0) to re-queues the selectNode operation, it allows the click event to bubble up to higher level event handlers. - setTimeout(function () { _this.selectNode(node); // selectNode will re-render the tree }, 0); }, diff --git a/dist/infinite-tree.min.js b/dist/infinite-tree.min.js index 8790c66..c42cd1c 100644 --- a/dist/infinite-tree.min.js +++ b/dist/infinite-tree.min.js @@ -1,3 +1,3 @@ -/*! infinite-tree v1.1.1 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ -!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.InfiniteTree=factory():root.InfiniteTree=factory()}(this,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _infiniteTree=__webpack_require__(1),_infiniteTree2=_interopRequireDefault(_infiniteTree);module.exports=_infiniteTree2["default"]},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},_events=__webpack_require__(2),_events2=_interopRequireDefault(_events),_clusterize=__webpack_require__(3),_clusterize2=_interopRequireDefault(_clusterize),_flattree=__webpack_require__(4),_lookupTable=__webpack_require__(8),_lookupTable2=_interopRequireDefault(_lookupTable),_renderer=__webpack_require__(9),_helper=__webpack_require__(10),error=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];if(console&&console.error){var prefix="[InfiniteTree]";console.error.apply(console,[prefix].concat(args))}},ensureNodeInstance=function(node){return node?node instanceof _flattree.Node?!0:(error("The node must be a Node object."),!1):!1},InfiniteTree=function(_events$EventEmitter){function InfiniteTree(el,options){_classCallCheck(this,InfiniteTree);var _this=_possibleConstructorReturn(this,_events$EventEmitter.call(this));return _this.options={autoOpen:!1,droppable:!1,el:null,layout:"div",loadNodes:null,noDataClass:"infinite-tree-no-data",noDataText:"No data",nodeIdAttr:"data-id",rowRenderer:_renderer.defaultRowRenderer,selectable:!0,shouldSelectNode:null,togglerClass:"infinite-tree-toggler"},_this.state={openNodes:[],rootNode:null,selectedNode:null},_this.clusterize=null,_this.nodeTable=new _lookupTable2["default"],_this.nodes=[],_this.rows=[],_this.scrollElement=null,_this.contentElement=null,_this.draggableTarget=null,_this.droppableTarget=null,_this.contentListener={click:function(e){var itemTarget=null,clickToggler=!1;for(e.target&&e.currentTarget?itemTarget=e.target!==e.currentTarget?e.target:null:e.srcElement&&(itemTarget=e.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)(0,_helper.hasClass)(itemTarget,_this.options.togglerClass)&&(clickToggler=!0),itemTarget=itemTarget.parentElement;if(itemTarget){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);if(node)return clickToggler?void _this.toggleNode(node):void setTimeout(function(){_this.selectNode(node)},0)}},dragstart:function(e){_this.draggableTarget=e.target||e.srcElement},dragend:function(e){var _this$options$droppab=_this.options.droppable.hoverClass,hoverClass=void 0===_this$options$droppab?"":_this$options$droppab;_this.draggableTarget=null,_this.droppableTarget&&((0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null)},dragenter:function(e){var itemTarget=null;for(e.target&&e.currentTarget?itemTarget=e.target!==e.currentTarget?e.target:null:e.srcElement&&(itemTarget=e.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)itemTarget=itemTarget.parentElement;if(itemTarget&&_this.droppableTarget!==itemTarget){var _this$options$droppab2=_this.options.droppable,accept=_this$options$droppab2.accept,_this$options$droppab3=_this$options$droppab2.hoverClass,hoverClass=void 0===_this$options$droppab3?"":_this$options$droppab3;(0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null;var canDrop=!0;if("function"==typeof accept){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);canDrop=!!accept.call(_this,{type:"dragenter",draggableTarget:_this.draggableTarget,droppableTarget:itemTarget,node:node})}canDrop&&((0,_helper.addClass)(itemTarget,hoverClass),_this.droppableTarget=itemTarget)}},dragover:function(e){(0,_helper.preventDefault)(e)},drop:function drop(e){if((0,_helper.preventDefault)(e),_this.draggableTarget&&_this.droppableTarget){var _this$options$droppab4=_this.options.droppable,accept=_this$options$droppab4.accept,drop=_this$options$droppab4.drop,_this$options$droppab5=_this$options$droppab4.hoverClass,hoverClass=void 0===_this$options$droppab5?"":_this$options$droppab5,id=_this.droppableTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id),canDrop=!0;"function"==typeof accept&&(canDrop=!!accept.call(_this,{type:"drop",draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node})),canDrop&&"function"==typeof drop&&drop.call(_this,e,{draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node}),(0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null}}},(0,_helper.isDOMElement)(el)?options.el=el:options=el,_this.options=(0,_helper.extend)({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(console.error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),InfiniteTree.prototype.create=function(){this.options.el||error("The element option is not specified.");var tag=null;if(this.scrollElement=document.createElement("div"),"table"===this.options.layout){var tableElement=document.createElement("table");tableElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-table");var contentElement=document.createElement("tbody");tableElement.appendChild(contentElement),this.scrollElement.appendChild(tableElement),this.contentElement=contentElement,tag="tr"}else{var _contentElement=document.createElement("div");this.scrollElement.appendChild(_contentElement),this.contentElement=_contentElement,tag="div"}this.scrollElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-scroll"),this.contentElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-content"),this.options.el.appendChild(this.scrollElement),this.clusterize=new _clusterize2["default"]({tag:tag,rows:[],scrollElem:this.scrollElement,contentElem:this.contentElement,no_data_text:this.options.noDataText,no_data_class:this.options.noDataClass}),(0,_helper.addEventListener)(this.contentElement,"click",this.contentListener.click),this.options.droppable&&((0,_helper.addEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_helper.addEventListener)(document,"dragend",this.contentListener.dragend),(0,_helper.addEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_helper.addEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_helper.addEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_helper.addEventListener)(this.contentElement,"drop",this.contentListener.drop))},InfiniteTree.prototype.destroy=function(){for((0,_helper.removeEventListener)(this.contentElement,"click",this.contentListener),this.options.droppable&&((0,_helper.removeEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_helper.removeEventListener)(document,"dragend",this.contentListener.dragend),(0,_helper.removeEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_helper.removeEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_helper.removeEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_helper.removeEventListener)(this.contentElement,"drop",this.contentListener.drop)),this.clear(),this.clusterize&&(this.clusterize.destroy(!0),this.clusterize=null);this.contentElement.firstChild;)this.contentElement.removeChild(this.contentElement.firstChild);for(;this.scrollElement.firstChild;)this.scrollElement.removeChild(this.scrollElement.firstChild);if(this.options.el)for(var containerElement=this.options.el;containerElement.firstChild;)containerElement.removeChild(containerElement.firstChild);this.contentElement=null,this.scrollElement=null},InfiniteTree.prototype.addChildNodes=function(newNodes,index,parentNode){var _this2=this;if(newNodes=[].concat(newNodes||[]),0===newNodes.length)return!1;if("object"===("undefined"==typeof index?"undefined":_typeof(index))?(parentNode=index||this.state.rootNode,index=parentNode.children.length):parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;newNodes.forEach(function(newNode){newNode.parent=parentNode}),parentNode.children.splice.apply(parentNode.children,[index,0].concat(newNodes)),index=parentNode.children.indexOf(newNodes[0]);var deleteCount=parentNode.state.total,nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this2.options.rowRenderer(node,_this2.options)});if(parentNode===this.state.rootNode)this.nodes=nodes,this.rows=rows;else{var parentOffset=this.nodes.indexOf(parentNode);parentOffset>=0&&(this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.rows[parentOffset]=this.options.rowRenderer(parentNode,this.options))}return parentNode.children.slice(index).forEach(function(childNode){_this2.flattenNode(childNode).forEach(function(node){void 0!==node.id&&_this2.nodeTable.set(node.id,node)})}),this.update(),!0},InfiniteTree.prototype.appendChildNode=function(newNode,parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;var index=parentNode.children.length,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.clear=function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=null,this.state.selectedNode=null},InfiniteTree.prototype.closeNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)<0)return!1;if(this.state.selectedNode&&this.state.selectedNode!==node){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex+1,rangeTo=nodeIndex+node.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(node)}node.state.open=!1;var openNodes=this.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});this.state.openNodes=openNodes;for(var deleteCount=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return this.nodes.splice(nodeIndex+1,deleteCount),this.rows.splice(nodeIndex+1,deleteCount),this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.emit("closeNode",node),this.update(),!0},InfiniteTree.prototype.flattenChildNodes=function(parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return[];for(var list=[],node=parentNode.getFirstChild();node;)if(list.push(node),node.hasChildren())node=node.getFirstChild();else{for(;null===node.getNextSibling()&&node.parent!==parentNode;)node=node.getParent();node=node.getNextSibling()}return list},InfiniteTree.prototype.flattenNode=function(node){return[node].concat(this.flattenChildNodes(node))},InfiniteTree.prototype.getChildNodes=function(parentNode){return parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode)?parentNode.children:[]},InfiniteTree.prototype.getNodeById=function(id){var node=this.nodeTable.get(id);if(!node){if(node=this.nodes.filter(function(node){return node.id===id})[0],!node)return null;this.nodeTable.set(node.id,node)}return node},InfiniteTree.prototype.getOpenNodes=function(){return this.state.openNodes.slice()},InfiniteTree.prototype.getRootNode=function(){return this.state.rootNode},InfiniteTree.prototype.getSelectedNode=function(){return this.state.selectedNode},InfiniteTree.prototype.insertNodeAfter=function(newNode,referenceNode){if(!ensureNodeInstance(referenceNode))return!1;var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode)+1,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.insertNodeBefore=function(newNode,referenceNode){if(!ensureNodeInstance(referenceNode))return!1;var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode),newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.loadData=function(){var _this3=this,data=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.nodes=(0,_flattree.flatten)(data,{openAllNodes:this.options.autoOpen}),this.nodeTable.clear(),this.state.openNodes=this.nodes.filter(function(node){return node.hasChildren()&&node.state.open}),this.state.rootNode=function(){for(var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];node&&null!==node.parent;)node=node.parent;return node}(this.nodes.length>0?this.nodes[0]:null),this.state.selectedNode=null,this.state.rootNode&&this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)}),this.rows=this.nodes.map(function(node){return _this3.options.rowRenderer(node,_this3.options)}),this.update()},InfiniteTree.prototype.openNode=function(node){var _this4=this;if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)>=0)return!1;if(!node.hasChildren()&&node.loadOnDemand)return"function"!=typeof this.options.loadNodes?!1:node.state.loading===!0?!1:(node.state.loading=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update(),this.options.loadNodes(node,function(err,nodes){node.state.loading=!1,_this4.rows[nodeIndex]=_this4.options.rowRenderer(node,_this4.options),_this4.update(),err||nodes&&(nodes=[].concat(nodes||[]),0!==nodes.length&&(nodes.forEach(function(childNode){_this4.appendChildNode(childNode,node)}),node.hasChildren()&&_this4.openNode(node)))}),!1);node.state.open=!0;var openNodes=[node].concat(this.state.openNodes);this.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this4.options.rowRenderer(node,_this4.options)});return this.nodes.splice.apply(this.nodes,[nodeIndex+1,0].concat(nodes)),this.rows.splice.apply(this.rows,[nodeIndex+1,0].concat(rows)),this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),nodes.length>0&&!this.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this4.nodeTable.set(node.id,node)}),this.emit("openNode",node),this.update(),!0},InfiniteTree.prototype.removeChildNodes=function(parentNode){var _this5=this;if(!ensureNodeInstance(parentNode))return!1;if(0===parentNode.children.length)return!1;var parentNodeIndex=this.nodes.indexOf(parentNode);if(parentNodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=parentNodeIndex+1,rangeTo=parentNodeIndex+parentNode.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(parentNode)}parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),!function(){var childNodes=_this5.flattenChildNodes(parentNode);_this5.state.openNodes=_this5.state.openNodes.filter(function(node){return childNodes.indexOf(node)<0}),childNodes.forEach(function(node){_this5.nodeTable.unset(node.id)})}(),this.update(),!0},InfiniteTree.prototype.removeNode=function(node){var _this6=this;if(!ensureNodeInstance(node))return!1;var parentNode=node.parent;if(!parentNode)return!1;var nodeIndex=this.nodes.indexOf(node),parentNodeIndex=this.nodes.indexOf(parentNode);if(nodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex,rangeTo=nodeIndex+node.state.total+1;if(selectedIndex>=rangeFrom&&rangeTo>=selectedIndex){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();this.selectNode(selectedNode)}}parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),!function(){var nodes=_this6.flattenNode(node);_this6.state.openNodes=_this6.state.openNodes.filter(function(node){return nodes.indexOf(node)<0}),nodes.forEach(function(node){_this6.nodeTable.unset(node.id)})}(),this.update(),!0},InfiniteTree.prototype.scrollToNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return!1;if(!this.contentElement)return!1;var firstChild=this.contentElement.firstChild,rowHeight=firstChild&&firstChild.offsetHeight||0;return this.scrollTop(nodeIndex*rowHeight),!0},InfiniteTree.prototype.scrollTop=function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0},InfiniteTree.prototype.selectNode=function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],_options=this.options,selectable=_options.selectable,shouldSelectNode=_options.shouldSelectNode;if(!selectable)return!1;if("function"==typeof shouldSelectNode&&!shouldSelectNode(node))return!1;if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode,this.options),this.state.selectedNode=null,this.emit("selectNode",null),this.update(),!0}return!1}if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(_selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode,this.options)}return this.state.selectedNode!==node?(this.state.selectedNode=node,this.emit("selectNode",node)):(this.state.selectedNode=null,this.emit("selectNode",null)),this.update(),!0},InfiniteTree.prototype.toggleNode=function(node){this.state.openNodes.indexOf(node)>=0?this.closeNode(node):this.openNode(node)},InfiniteTree.prototype.toString=function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],traverse=function traverse(node){var s="[";if(node&&node.children)for(var _loop=function(i){var list=[];s+="{",Object.keys(node).forEach(function(key){var value=node[key];if("parent"!==key)return"children"===key?void list.push('"'+key+'":'+traverse(node.children[i])):void("string"==typeof value||"object"===("undefined"==typeof value?"undefined":_typeof(value))?list.push('"'+key+'":'+JSON.stringify(value)):list.push('"'+key+'":'+value))}),s+=list.join(","),s=s+"}"+(i===node.children.length-1?"":",")},i=0;i=0&&(this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update())}},InfiniteTree}(_events2["default"].EventEmitter);exports["default"]=InfiniteTree},function(module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified "error" event.')}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},function(module,exports,__webpack_require__){!function(name,definition){module.exports=definition()}("Clusterize",function(){"use strict";function on(evt,element,fnc){return element.addEventListener?element.addEventListener(evt,fnc,!1):element.attachEvent("on"+evt,fnc)}function off(evt,element,fnc){return element.removeEventListener?element.removeEventListener(evt,fnc,!1):element.detachEvent("on"+evt,fnc)}function isArray(arr){return"[object Array]"===Object.prototype.toString.call(arr)}function getStyle(prop,elem){return window.getComputedStyle?window.getComputedStyle(elem)[prop]:elem.currentStyle[prop]}var ie=function(){for(var v=3,el=document.createElement("b"),all=el.all||[];el.innerHTML="",all[0];);return v>4?v:document.documentMode}(),is_mac=navigator.platform.toLowerCase().indexOf("mac")+1,Clusterize=function(data){if(!(this instanceof Clusterize))return new Clusterize(data);var self=this,defaults={item_height:0,block_height:0,rows_in_block:50,rows_in_cluster:0,cluster_height:0,blocks_in_cluster:4,tag:null,content_tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{},scroll_top:0};self.options={};for(var option,options=["rows_in_block","blocks_in_cluster","show_no_data_row","no_data_class","no_data_text","keep_parity","tag","callbacks"],i=0;option=options[i];i++)self.options[option]="undefined"!=typeof data[option]&&null!=data[option]?data[option]:defaults[option];for(var elem,elems=["scroll","content"],i=0;elem=elems[i];i++)if(self[elem+"_elem"]=data[elem+"Id"]?document.getElementById(data[elem+"Id"]):data[elem+"Elem"],!self[elem+"_elem"])throw new Error("Error! Could not find "+elem+" element");self.content_elem.hasAttribute("tabindex")||self.content_elem.setAttribute("tabindex",0);var rows=isArray(data.rows)?data.rows:self.fetchMarkup(),cache={data:"",bottom:0},scroll_top=self.scroll_elem.scrollTop;self.exploreEnvironment(rows),self.insertToDOM(rows,cache),self.scroll_elem.scrollTop=scroll_top;var last_cluster=!1,scroll_debounce=0,pointer_events_set=!1,scrollEv=function(){is_mac&&(pointer_events_set||(self.content_elem.style.pointerEvents="none"),pointer_events_set=!0,clearTimeout(scroll_debounce),scroll_debounce=setTimeout(function(){self.content_elem.style.pointerEvents="auto",pointer_events_set=!1},50)),last_cluster!=(last_cluster=self.getClusterNum())&&self.insertToDOM(rows,cache),self.options.callbacks.scrollingProgress&&self.options.callbacks.scrollingProgress(self.getScrollProgress())},resize_debounce=0,resizeEv=function(){clearTimeout(resize_debounce),resize_debounce=setTimeout(self.refresh,100)};on("scroll",self.scroll_elem,scrollEv),on("resize",window,resizeEv),self.destroy=function(clean){off("scroll",self.scroll_elem,scrollEv),off("resize",window,resizeEv),self.html((clean?self.generateEmptyRow():rows).join(""))},self.refresh=function(){self.getRowsHeight(rows)&&self.update(rows)},self.update=function(new_rows){rows=isArray(new_rows)?new_rows:[];var scroll_top=self.scroll_elem.scrollTop;rows.length*self.options.item_height=ie&&!opts.tag&&(opts.tag=rows[0].match(/<([^>\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&this.html(rows[0]+rows[0]+rows[0]),opts.tag||(opts.tag=this.content_elem.children[0].tagName.toLowerCase()),this.getRowsHeight(rows))},getRowsHeight:function(rows){var opts=this.options,prev_item_height=opts.item_height;if(opts.cluster_height=0,rows.length){var nodes=this.content_elem.children;return opts.item_height=nodes[Math.floor(nodes.length/2)].offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem))||0),opts.block_height=opts.item_height*opts.rows_in_block,opts.rows_in_cluster=opts.blocks_in_cluster*opts.rows_in_block,opts.cluster_height=opts.blocks_in_cluster*opts.block_height,prev_item_height!=opts.item_height}},getClusterNum:function(){return this.options.scroll_top=this.scroll_elem.scrollTop,Math.floor(this.options.scroll_top/(this.options.cluster_height-this.options.block_height))||0},generateEmptyRow:function(){var opts=this.options;if(!opts.tag||!opts.show_no_data_row)return[];var td,empty_row=document.createElement(opts.tag),no_data_content=document.createTextNode(opts.no_data_text);return empty_row.className=opts.no_data_class,"tr"==opts.tag&&(td=document.createElement("td"),td.appendChild(no_data_content)),empty_row.appendChild(td||no_data_content), -[empty_row.outerHTML]},generate:function(rows,cluster_num){var opts=this.options,rows_len=rows.length;if(rows_lentop_offset&&rows_above++;for(var i=items_start;items_end>i;i++)rows[i]&&this_cluster_rows.push(rows[i]);return{top_offset:top_offset,bottom_offset:bottom_offset,rows_above:rows_above,rows:this_cluster_rows}},renderExtraTag:function(class_name,height){var tag=document.createElement(this.options.tag),clusterize_prefix="clusterize-";return tag.className=[clusterize_prefix+"extra-row",clusterize_prefix+class_name].join(" "),height&&(tag.style.height=height+"px"),tag.outerHTML},insertToDOM:function(rows,cache){var data=this.generate(rows,this.getClusterNum()),this_cluster_rows=data.rows.join(""),this_cluster_content_changed=this.checkChanges("data",this_cluster_rows,cache),only_bottom_offset_changed=this.checkChanges("bottom",data.bottom_offset,cache),callbacks=this.options.callbacks,layout=[];this_cluster_content_changed?(data.top_offset&&(this.options.keep_parity&&layout.push(this.renderExtraTag("keep-parity")),layout.push(this.renderExtraTag("top-space",data.top_offset))),layout.push(this_cluster_rows),data.bottom_offset&&layout.push(this.renderExtraTag("bottom-space",data.bottom_offset)),callbacks.clusterWillChange&&callbacks.clusterWillChange(),this.html(layout.join("")),"ol"==this.options.content_tag&&this.content_elem.setAttribute("start",data.rows_above),callbacks.clusterChanged&&callbacks.clusterChanged()):only_bottom_offset_changed&&(this.content_elem.lastChild.style.height=data.bottom_offset+"px")},html:function(data){var content_elem=this.content_elem;if(ie&&9>=ie&&"tr"==this.options.tag){var last,div=document.createElement("div");for(div.innerHTML=""+data+"
";last=content_elem.lastChild;)content_elem.removeChild(last);for(var rows_nodes=this.getChildNodes(div.firstChild.firstChild);rows_nodes.length;)content_elem.appendChild(rows_nodes.shift())}else content_elem.innerHTML=data},getChildNodes:function(tag){for(var child_nodes=tag.children,nodes=[],i=0,ii=child_nodes.length;ii>i;i++)nodes.push(child_nodes[i]);return nodes},checkChanges:function(type,value,cache){var changed=value!=cache[type];return cache[type]=value,changed}},Clusterize})},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0,exports.Node=exports.flatten=void 0;var _flatten=__webpack_require__(5),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(7),_node2=_interopRequireDefault(_node);exports.flatten=_flatten2["default"],exports.Node=_node2["default"]},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0;var _extend=__webpack_require__(6),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(7),_node2=_interopRequireDefault(_node),flatten=function flatten(){var nodes=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],options=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];nodes=[].concat(nodes);var flatten=[],stack=[],pool={lastChild:{}};options.openAllNodes=!!options.openAllNodes,options.openNodes=options.openNodes||[],options.throwOnError=!!options.throwOnError;var firstNode=nodes.length>0?nodes[0]:null,parentNode=firstNode?firstNode.parent:null;!parentNode||parentNode instanceof _node2["default"]||(parentNode=new _node2["default"](parentNode));var rootNode=parentNode||new _node2["default"]({label:"",parent:null,children:nodes,state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}});if(rootNode===parentNode)for(var subtotal=rootNode.state.total||0,p=rootNode;p;){var _p$state=p.state,path=_p$state.path,_p$state$total=_p$state.total,total=void 0===_p$state$total?0:_p$state$total;if(p.isLastChild()&&path&&(pool.lastChild[path]=!0),p.state.total=total-subtotal,p.state.total<0){if(options.throwOnError)throw new Error("The node might have been corrupted: id="+JSON.stringify(p.id)+", state="+JSON.stringify(p.state));console&&console.log("Error: The node might have been corrupted: id=%s, label=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),JSON.stringify(p.label),p.parent,p.children,JSON.stringify(p.state))}p=p.parent}for(stack.push([rootNode,rootNode.state.depth,0]);stack.length>0;)for(var _stack$pop=stack.pop(),current=_stack$pop[0],depth=_stack$pop[1],index=_stack$pop[2],_loop=function(){var node=current.children[index];node instanceof _node2["default"]||(node=new _node2["default"](node)),node.parent=current,node.children=node.children||[],node.parent.children[index]=node;var path=current.state.path+"."+index,open=node.hasChildren()&&function(){var openAllNodes=options.openAllNodes,openNodes=options.openNodes;return openAllNodes?!0:openNodes.indexOf(node)>=0?!0:openNodes.indexOf(node.id)>=0}(),prefixMask=function(prefix){for(var mask="";prefix.length>0;)prefix=prefix.replace(/\.\d+$/,""),mask=!prefix||pool.lastChild[prefix]?"0"+mask:"1"+mask;return mask}(path);node.isLastChild()&&(pool.lastChild[path]=!0),node.state=(0,_extend2["default"])({},node.state,{depth:depth+1,open:open,path:path,prefixMask:prefixMask,total:0});for(var parentDidOpen=!0,_p=node;null!==_p.parent;){if(_p.parent.state.open===!1){parentDidOpen=!1;break}_p=_p.parent}if(parentDidOpen){flatten.push(node);for(var _p2=node;null!==_p2.parent;)_p2.parent.state.total++,_p2=_p2.parent}++index,node.hasChildren()&&(stack.push([current,depth,index]),index=0,depth+=1,current=node)};index1?_len-1:0),_key=1;_len>_key;_key++)sources[_key-1]=arguments[_key];if(void 0===target||null===target)throw new TypeError("Cannot convert undefined or null to object");for(var output=Object(target),index=0;index0&&index>=0&&index0&&(node=this.children[0]),node},Node.prototype.getLastChild=function(){var node=null;return this.children.length>0&&(node=this.children[this.children.length-1]),node},Node.prototype.getNextSibling=function(){var node=null;if(this.parent){var index=this.parent.children.indexOf(this);index>=0&&index0&&index0},Node.prototype.isLastChild=function(){var hasNextSibling=this.getNextSibling();return!hasNextSibling},Node}();exports["default"]=Node},function(module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}exports.__esModule=!0;var LookupTable=function(){function LookupTable(){_classCallCheck(this,LookupTable),this.data={}}return LookupTable.prototype.clear=function(){this.data={}},LookupTable.prototype.get=function(key){return this.data[key]},LookupTable.prototype.has=function(key){return void 0!==this.data[key]},LookupTable.prototype.set=function(key,value){return this.data[key]=value,value},LookupTable.prototype.unset=function(key){void 0!==this.data[key]&&delete this.data[key]},LookupTable}();exports["default"]=LookupTable},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0,exports.defaultRowRenderer=void 0;var _helper=__webpack_require__(10),defaultRowRenderer=function(node,treeOptions){var id=node.id,name=node.name,_node$loadOnDemand=node.loadOnDemand,loadOnDemand=void 0===_node$loadOnDemand?!1:_node$loadOnDemand,children=node.children,state=node.state,droppable=treeOptions.droppable,depth=state.depth,open=state.open,path=state.path,total=state.total,_state$selected=state.selected,selected=void 0===_state$selected?!1:_state$selected,childrenLength=Object.keys(children).length,more=node.hasChildren(),togglerContent="";!more&&loadOnDemand&&(togglerContent="►"),more&&open&&(togglerContent="▼"),more&&!open&&(togglerContent="►");var toggler=(0,_helper.buildHTML)("a",togglerContent,{"class":function(){return!more&&loadOnDemand?(0,_helper.classNames)(treeOptions.togglerClass,"infinite-tree-closed"):more&&open?(0,_helper.classNames)(treeOptions.togglerClass):more&&!open?(0,_helper.classNames)(treeOptions.togglerClass,"infinite-tree-closed"):""}()}),title=(0,_helper.buildHTML)("span",(0,_helper.quoteattr)(name),{"class":(0,_helper.classNames)("infinite-tree-title")}),treeNode=(0,_helper.buildHTML)("div",toggler+title,{"class":"infinite-tree-node",style:"margin-left: "+18*depth+"px"});return(0,_helper.buildHTML)("div",treeNode,{"data-id":id,"data-expanded":more&&open,"data-depth":depth,"data-path":path,"data-selected":selected,"data-children":childrenLength,"data-total":total,"class":(0,_helper.classNames)("infinite-tree-item",{"infinite-tree-selected":selected}),droppable:droppable})};exports.defaultRowRenderer=defaultRowRenderer},function(module,exports){"use strict";exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},extend=function(target){for(var _len=arguments.length,sources=Array(_len>1?_len-1:0),_key=1;_len>_key;_key++)sources[_key-1]=arguments[_key];target=target||{};for(var index=0;index=0},addClass=function(el,className){if(!el)return"";if(!hasClass(el,className)){var classes=el.className.split(" ");el.className=classes.concat(className).join(" ")}return el.className},removeClass=function(el,className){if(!el)return"";if(hasClass(el,className)){var classes=el.className.split(" ");el.className=classes.filter(function(c){return c!==className}).join(" ")}return el.className},toggleClass=function(el,className){el&&(hasClass(el,className)?removeClass(el,className):addClass(el,className))},classNames=function classNames(){for(var _len2=arguments.length,args=Array(_len2),_key2=0;_len2>_key2;_key2++)args[_key2]=arguments[_key2];var classNames=[];return args.forEach(function(arg){Array.isArray(arg)?classNames=classNames.concat(arg):"object"===("undefined"==typeof arg?"undefined":_typeof(arg))?Object.keys(arg).forEach(function(className){var ok=arg[className];ok&&classNames.push(className)}):classNames.push(arg)}),classNames.join(" ")},isDOMElement=function(o){return"object"===("undefined"==typeof HTMLElement?"undefined":_typeof(HTMLElement))?o instanceof HTMLElement:o&&"object"===("undefined"==typeof o?"undefined":_typeof(o))&&1===o.nodeType&&"string"==typeof o.nodeName},isDOMNode=function(o){return"object"===("undefined"==typeof Node?"undefined":_typeof(Node))?o instanceof Node:o&&"object"===("undefined"==typeof o?"undefined":_typeof(o))&&"number"==typeof o.nodeType&&"string"==typeof o.nodeName},quoteattr=function(s,preserveCR){return preserveCR=preserveCR?" ":"\n",(""+s).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">").replace(/\r\n/g,preserveCR).replace(/[\r\n]/g,preserveCR)},buildHTML=function buildHTML(tag,html,attrs){switch(tag){case"select":if("object"===("undefined"==typeof html?"undefined":_typeof(html))){var options=html||{};html="";for(var value in options)options.hasOwnProperty(value)&&(html+=buildHTML("option",options[value]||"",{value:value}))}break;default:"object"===("undefined"==typeof html?"undefined":_typeof(html))&&(attrs=html,html=void 0)}var h="<"+tag;for(var attr in attrs)attrs.hasOwnProperty(attr)&&"undefined"!=typeof attrs[attr]&&(h+=" "+attr+'="'+quoteattr(attrs[attr])+'"');return h+="undefined"!=typeof html?">"+html+"":"/>"};exports.extend=extend,exports.preventDefault=preventDefault,exports.stopPropagation=stopPropagation,exports.dispatchEvent=dispatchEvent,exports.addEventListener=addEventListener,exports.removeEventListener=removeEventListener,exports.hasClass=hasClass,exports.addClass=addClass,exports.removeClass=removeClass,exports.toggleClass=toggleClass,exports.classNames=classNames,exports.isDOMElement=isDOMElement,exports.isDOMNode=isDOMNode,exports.quoteattr=quoteattr,exports.buildHTML=buildHTML}])}); \ No newline at end of file +/*! infinite-tree v1.2.0 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ +!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.InfiniteTree=factory():root.InfiniteTree=factory()}(this,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _infiniteTree=__webpack_require__(1),_infiniteTree2=_interopRequireDefault(_infiniteTree);module.exports=_infiniteTree2["default"]},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},_events=__webpack_require__(2),_events2=_interopRequireDefault(_events),_clusterize=__webpack_require__(3),_clusterize2=_interopRequireDefault(_clusterize),_flattree=__webpack_require__(4),_lookupTable=__webpack_require__(8),_lookupTable2=_interopRequireDefault(_lookupTable),_renderer=__webpack_require__(9),_helper=__webpack_require__(10),error=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];if(console&&console.error){var prefix="[InfiniteTree]";console.error.apply(console,[prefix].concat(args))}},ensureNodeInstance=function(node){return node?node instanceof _flattree.Node?!0:(error("The node must be a Node object."),!1):!1},InfiniteTree=function(_events$EventEmitter){function InfiniteTree(el,options){_classCallCheck(this,InfiniteTree);var _this=_possibleConstructorReturn(this,_events$EventEmitter.call(this));return _this.options={autoOpen:!1,droppable:!1,el:null,layout:"div",loadNodes:null,noDataClass:"infinite-tree-no-data",noDataText:"No data",nodeIdAttr:"data-id",rowRenderer:_renderer.defaultRowRenderer,selectable:!0,shouldSelectNode:null,togglerClass:"infinite-tree-toggler"},_this.state={openNodes:[],rootNode:null,selectedNode:null},_this.clusterize=null,_this.nodeTable=new _lookupTable2["default"],_this.nodes=[],_this.rows=[],_this.scrollElement=null,_this.contentElement=null,_this.draggableTarget=null,_this.droppableTarget=null,_this.contentListener={click:function(event){event=event||window.event;var stopPropagation=event.stopPropagation;event.stopPropagation=function(){event.cancelBubble=!0,stopPropagation&&stopPropagation.call(event)},setTimeout(function(){if(event.cancelBubble!==!0&&(_this.emit("click",event),event.cancelBubble!==!0)){var itemTarget=null,clickToggler=!1;for(event.target&&event.currentTarget?itemTarget=event.target!==event.currentTarget?event.target:null:event.srcElement&&(itemTarget=event.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)(0,_helper.hasClass)(itemTarget,_this.options.togglerClass)&&(clickToggler=!0),itemTarget=itemTarget.parentElement;if(itemTarget){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);if(node)return clickToggler?void _this.toggleNode(node):void _this.selectNode(node)}}},0)},dragstart:function(e){_this.draggableTarget=e.target||e.srcElement},dragend:function(e){var _this$options$droppab=_this.options.droppable.hoverClass,hoverClass=void 0===_this$options$droppab?"":_this$options$droppab;_this.draggableTarget=null,_this.droppableTarget&&((0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null)},dragenter:function(e){var itemTarget=null;for(e.target&&e.currentTarget?itemTarget=e.target!==e.currentTarget?e.target:null:e.srcElement&&(itemTarget=e.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)itemTarget=itemTarget.parentElement;if(itemTarget&&_this.droppableTarget!==itemTarget){var _this$options$droppab2=_this.options.droppable,accept=_this$options$droppab2.accept,_this$options$droppab3=_this$options$droppab2.hoverClass,hoverClass=void 0===_this$options$droppab3?"":_this$options$droppab3;(0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null;var canDrop=!0;if("function"==typeof accept){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);canDrop=!!accept.call(_this,{type:"dragenter",draggableTarget:_this.draggableTarget,droppableTarget:itemTarget,node:node})}canDrop&&((0,_helper.addClass)(itemTarget,hoverClass),_this.droppableTarget=itemTarget)}},dragover:function(e){(0,_helper.preventDefault)(e)},drop:function drop(e){if((0,_helper.preventDefault)(e),_this.draggableTarget&&_this.droppableTarget){var _this$options$droppab4=_this.options.droppable,accept=_this$options$droppab4.accept,drop=_this$options$droppab4.drop,_this$options$droppab5=_this$options$droppab4.hoverClass,hoverClass=void 0===_this$options$droppab5?"":_this$options$droppab5,id=_this.droppableTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id),canDrop=!0;"function"==typeof accept&&(canDrop=!!accept.call(_this,{type:"drop",draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node})),canDrop&&"function"==typeof drop&&drop.call(_this,e,{draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node}),(0,_helper.removeClass)(_this.droppableTarget,hoverClass),_this.droppableTarget=null}}},(0,_helper.isDOMElement)(el)?options.el=el:options=el,_this.options=(0,_helper.extend)({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(console.error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),InfiniteTree.prototype.create=function(){this.options.el||error("The element option is not specified.");var tag=null;if(this.scrollElement=document.createElement("div"),"table"===this.options.layout){var tableElement=document.createElement("table");tableElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-table");var contentElement=document.createElement("tbody");tableElement.appendChild(contentElement),this.scrollElement.appendChild(tableElement),this.contentElement=contentElement,tag="tr"}else{var _contentElement=document.createElement("div");this.scrollElement.appendChild(_contentElement),this.contentElement=_contentElement,tag="div"}this.scrollElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-scroll"),this.contentElement.className=(0,_helper.classNames)("infinite-tree","infinite-tree-content"),this.options.el.appendChild(this.scrollElement),this.clusterize=new _clusterize2["default"]({tag:tag,rows:[],scrollElem:this.scrollElement,contentElem:this.contentElement,no_data_text:this.options.noDataText,no_data_class:this.options.noDataClass}),(0,_helper.addEventListener)(this.contentElement,"click",this.contentListener.click),this.options.droppable&&((0,_helper.addEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_helper.addEventListener)(document,"dragend",this.contentListener.dragend),(0,_helper.addEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_helper.addEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_helper.addEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_helper.addEventListener)(this.contentElement,"drop",this.contentListener.drop))},InfiniteTree.prototype.destroy=function(){for((0,_helper.removeEventListener)(this.contentElement,"click",this.contentListener),this.options.droppable&&((0,_helper.removeEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_helper.removeEventListener)(document,"dragend",this.contentListener.dragend),(0,_helper.removeEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_helper.removeEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_helper.removeEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_helper.removeEventListener)(this.contentElement,"drop",this.contentListener.drop)),this.clear(),this.clusterize&&(this.clusterize.destroy(!0),this.clusterize=null);this.contentElement.firstChild;)this.contentElement.removeChild(this.contentElement.firstChild);for(;this.scrollElement.firstChild;)this.scrollElement.removeChild(this.scrollElement.firstChild);if(this.options.el)for(var containerElement=this.options.el;containerElement.firstChild;)containerElement.removeChild(containerElement.firstChild);this.contentElement=null,this.scrollElement=null},InfiniteTree.prototype.addChildNodes=function(newNodes,index,parentNode){var _this2=this;if(newNodes=[].concat(newNodes||[]),0===newNodes.length)return!1;if("object"===("undefined"==typeof index?"undefined":_typeof(index))?(parentNode=index||this.state.rootNode,index=parentNode.children.length):parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;newNodes.forEach(function(newNode){newNode.parent=parentNode}),parentNode.children.splice.apply(parentNode.children,[index,0].concat(newNodes)),index=parentNode.children.indexOf(newNodes[0]);var deleteCount=parentNode.state.total,nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this2.options.rowRenderer(node,_this2.options)});if(parentNode===this.state.rootNode)this.nodes=nodes,this.rows=rows;else{var parentOffset=this.nodes.indexOf(parentNode);parentOffset>=0&&(this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.rows[parentOffset]=this.options.rowRenderer(parentNode,this.options))}return parentNode.children.slice(index).forEach(function(childNode){_this2.flattenNode(childNode).forEach(function(node){void 0!==node.id&&_this2.nodeTable.set(node.id,node)})}),this.update(),!0},InfiniteTree.prototype.appendChildNode=function(newNode,parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;var index=parentNode.children.length,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.clear=function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=null,this.state.selectedNode=null},InfiniteTree.prototype.closeNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)<0)return!1;if(this.state.selectedNode&&this.state.selectedNode!==node){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex+1,rangeTo=nodeIndex+node.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(node)}node.state.open=!1;var openNodes=this.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});this.state.openNodes=openNodes;for(var deleteCount=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return this.nodes.splice(nodeIndex+1,deleteCount),this.rows.splice(nodeIndex+1,deleteCount),this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.emit("closeNode",node),this.update(),!0},InfiniteTree.prototype.flattenChildNodes=function(parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return[];for(var list=[],node=parentNode.getFirstChild();node;)if(list.push(node),node.hasChildren())node=node.getFirstChild();else{for(;null===node.getNextSibling()&&node.parent!==parentNode;)node=node.getParent();node=node.getNextSibling()}return list},InfiniteTree.prototype.flattenNode=function(node){return[node].concat(this.flattenChildNodes(node))},InfiniteTree.prototype.getChildNodes=function(parentNode){return parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode)?parentNode.children:[]},InfiniteTree.prototype.getNodeById=function(id){var node=this.nodeTable.get(id);if(!node){if(node=this.nodes.filter(function(node){return node.id===id})[0],!node)return null;this.nodeTable.set(node.id,node)}return node},InfiniteTree.prototype.getOpenNodes=function(){return this.state.openNodes.slice()},InfiniteTree.prototype.getRootNode=function(){return this.state.rootNode},InfiniteTree.prototype.getSelectedNode=function(){return this.state.selectedNode},InfiniteTree.prototype.insertNodeAfter=function(newNode,referenceNode){if(!ensureNodeInstance(referenceNode))return!1;var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode)+1,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.insertNodeBefore=function(newNode,referenceNode){if(!ensureNodeInstance(referenceNode))return!1;var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode),newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.loadData=function(){var _this3=this,data=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.nodes=(0,_flattree.flatten)(data,{openAllNodes:this.options.autoOpen}),this.nodeTable.clear(),this.state.openNodes=this.nodes.filter(function(node){return node.hasChildren()&&node.state.open}),this.state.rootNode=function(){for(var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];node&&null!==node.parent;)node=node.parent;return node}(this.nodes.length>0?this.nodes[0]:null),this.state.selectedNode=null,this.state.rootNode&&this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)}),this.rows=this.nodes.map(function(node){return _this3.options.rowRenderer(node,_this3.options)}),this.update()},InfiniteTree.prototype.openNode=function(node){var _this4=this;if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)>=0)return!1;if(!node.hasChildren()&&node.loadOnDemand)return"function"!=typeof this.options.loadNodes?!1:node.state.loading===!0?!1:(node.state.loading=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update(),this.options.loadNodes(node,function(err,nodes){node.state.loading=!1,_this4.rows[nodeIndex]=_this4.options.rowRenderer(node,_this4.options),_this4.update(),err||nodes&&(nodes=[].concat(nodes||[]),0!==nodes.length&&(nodes.forEach(function(childNode){_this4.appendChildNode(childNode,node)}),node.hasChildren()&&_this4.openNode(node)))}),!1);node.state.open=!0;var openNodes=[node].concat(this.state.openNodes);this.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this4.options.rowRenderer(node,_this4.options)});return this.nodes.splice.apply(this.nodes,[nodeIndex+1,0].concat(nodes)),this.rows.splice.apply(this.rows,[nodeIndex+1,0].concat(rows)),this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),nodes.length>0&&!this.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this4.nodeTable.set(node.id,node)}),this.emit("openNode",node),this.update(),!0},InfiniteTree.prototype.removeChildNodes=function(parentNode){var _this5=this;if(!ensureNodeInstance(parentNode))return!1;if(0===parentNode.children.length)return!1;var parentNodeIndex=this.nodes.indexOf(parentNode);if(parentNodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=parentNodeIndex+1,rangeTo=parentNodeIndex+parentNode.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(parentNode)}parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),!function(){var childNodes=_this5.flattenChildNodes(parentNode);_this5.state.openNodes=_this5.state.openNodes.filter(function(node){return childNodes.indexOf(node)<0}),childNodes.forEach(function(node){_this5.nodeTable.unset(node.id)})}(),this.update(),!0},InfiniteTree.prototype.removeNode=function(node){var _this6=this;if(!ensureNodeInstance(node))return!1;var parentNode=node.parent;if(!parentNode)return!1;var nodeIndex=this.nodes.indexOf(node),parentNodeIndex=this.nodes.indexOf(parentNode);if(nodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex,rangeTo=nodeIndex+node.state.total+1;if(selectedIndex>=rangeFrom&&rangeTo>=selectedIndex){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();this.selectNode(selectedNode)}}parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),!function(){var nodes=_this6.flattenNode(node);_this6.state.openNodes=_this6.state.openNodes.filter(function(node){return nodes.indexOf(node)<0}),nodes.forEach(function(node){_this6.nodeTable.unset(node.id)})}(),this.update(),!0},InfiniteTree.prototype.scrollToNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return!1;if(!this.contentElement)return!1;var firstChild=this.contentElement.firstChild,rowHeight=firstChild&&firstChild.offsetHeight||0;return this.scrollTop(nodeIndex*rowHeight),!0},InfiniteTree.prototype.scrollTop=function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0},InfiniteTree.prototype.selectNode=function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],_options=this.options,selectable=_options.selectable,shouldSelectNode=_options.shouldSelectNode;if(!selectable)return!1;if("function"==typeof shouldSelectNode&&!shouldSelectNode(node))return!1;if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode,this.options),this.state.selectedNode=null,this.emit("selectNode",null),this.update(),!0}return!1}if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return error("Invalid node index"),!1;if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(_selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode,this.options)}return this.state.selectedNode!==node?(this.state.selectedNode=node,this.emit("selectNode",node)):(this.state.selectedNode=null,this.emit("selectNode",null)),this.update(),!0},InfiniteTree.prototype.toggleNode=function(node){this.state.openNodes.indexOf(node)>=0?this.closeNode(node):this.openNode(node)},InfiniteTree.prototype.toString=function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],traverse=function traverse(node){var s="[";if(node&&node.children)for(var _loop=function(i){var list=[];s+="{",Object.keys(node).forEach(function(key){var value=node[key];if("parent"!==key)return"children"===key?void list.push('"'+key+'":'+traverse(node.children[i])):void("string"==typeof value||"object"===("undefined"==typeof value?"undefined":_typeof(value))?list.push('"'+key+'":'+JSON.stringify(value)):list.push('"'+key+'":'+value))}),s+=list.join(","),s=s+"}"+(i===node.children.length-1?"":",")},i=0;i=0&&(this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update())}},InfiniteTree}(_events2["default"].EventEmitter);exports["default"]=InfiniteTree},function(module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified "error" event.')}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},function(module,exports,__webpack_require__){!function(name,definition){module.exports=definition()}("Clusterize",function(){"use strict";function on(evt,element,fnc){return element.addEventListener?element.addEventListener(evt,fnc,!1):element.attachEvent("on"+evt,fnc)}function off(evt,element,fnc){return element.removeEventListener?element.removeEventListener(evt,fnc,!1):element.detachEvent("on"+evt,fnc)}function isArray(arr){return"[object Array]"===Object.prototype.toString.call(arr)}function getStyle(prop,elem){return window.getComputedStyle?window.getComputedStyle(elem)[prop]:elem.currentStyle[prop]}var ie=function(){for(var v=3,el=document.createElement("b"),all=el.all||[];el.innerHTML="",all[0];);return v>4?v:document.documentMode}(),is_mac=navigator.platform.toLowerCase().indexOf("mac")+1,Clusterize=function(data){if(!(this instanceof Clusterize))return new Clusterize(data);var self=this,defaults={item_height:0,block_height:0,rows_in_block:50,rows_in_cluster:0,cluster_height:0,blocks_in_cluster:4,tag:null,content_tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{},scroll_top:0};self.options={};for(var option,options=["rows_in_block","blocks_in_cluster","show_no_data_row","no_data_class","no_data_text","keep_parity","tag","callbacks"],i=0;option=options[i];i++)self.options[option]="undefined"!=typeof data[option]&&null!=data[option]?data[option]:defaults[option];for(var elem,elems=["scroll","content"],i=0;elem=elems[i];i++)if(self[elem+"_elem"]=data[elem+"Id"]?document.getElementById(data[elem+"Id"]):data[elem+"Elem"],!self[elem+"_elem"])throw new Error("Error! Could not find "+elem+" element");self.content_elem.hasAttribute("tabindex")||self.content_elem.setAttribute("tabindex",0);var rows=isArray(data.rows)?data.rows:self.fetchMarkup(),cache={data:"",bottom:0},scroll_top=self.scroll_elem.scrollTop;self.exploreEnvironment(rows),self.insertToDOM(rows,cache),self.scroll_elem.scrollTop=scroll_top;var last_cluster=!1,scroll_debounce=0,pointer_events_set=!1,scrollEv=function(){is_mac&&(pointer_events_set||(self.content_elem.style.pointerEvents="none"),pointer_events_set=!0,clearTimeout(scroll_debounce),scroll_debounce=setTimeout(function(){self.content_elem.style.pointerEvents="auto",pointer_events_set=!1},50)),last_cluster!=(last_cluster=self.getClusterNum())&&self.insertToDOM(rows,cache),self.options.callbacks.scrollingProgress&&self.options.callbacks.scrollingProgress(self.getScrollProgress())},resize_debounce=0,resizeEv=function(){clearTimeout(resize_debounce),resize_debounce=setTimeout(self.refresh,100)};on("scroll",self.scroll_elem,scrollEv),on("resize",window,resizeEv),self.destroy=function(clean){off("scroll",self.scroll_elem,scrollEv),off("resize",window,resizeEv),self.html((clean?self.generateEmptyRow():rows).join(""))},self.refresh=function(){self.getRowsHeight(rows)&&self.update(rows)},self.update=function(new_rows){rows=isArray(new_rows)?new_rows:[];var scroll_top=self.scroll_elem.scrollTop;rows.length*self.options.item_height=ie&&!opts.tag&&(opts.tag=rows[0].match(/<([^>\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&this.html(rows[0]+rows[0]+rows[0]),opts.tag||(opts.tag=this.content_elem.children[0].tagName.toLowerCase()),this.getRowsHeight(rows))},getRowsHeight:function(rows){var opts=this.options,prev_item_height=opts.item_height;if(opts.cluster_height=0,rows.length){var nodes=this.content_elem.children;return opts.item_height=nodes[Math.floor(nodes.length/2)].offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem))||0),opts.block_height=opts.item_height*opts.rows_in_block,opts.rows_in_cluster=opts.blocks_in_cluster*opts.rows_in_block,opts.cluster_height=opts.blocks_in_cluster*opts.block_height,prev_item_height!=opts.item_height}},getClusterNum:function(){return this.options.scroll_top=this.scroll_elem.scrollTop,Math.floor(this.options.scroll_top/(this.options.cluster_height-this.options.block_height))||0},generateEmptyRow:function(){var opts=this.options;if(!opts.tag||!opts.show_no_data_row)return[]; +var td,empty_row=document.createElement(opts.tag),no_data_content=document.createTextNode(opts.no_data_text);return empty_row.className=opts.no_data_class,"tr"==opts.tag&&(td=document.createElement("td"),td.appendChild(no_data_content)),empty_row.appendChild(td||no_data_content),[empty_row.outerHTML]},generate:function(rows,cluster_num){var opts=this.options,rows_len=rows.length;if(rows_lentop_offset&&rows_above++;for(var i=items_start;items_end>i;i++)rows[i]&&this_cluster_rows.push(rows[i]);return{top_offset:top_offset,bottom_offset:bottom_offset,rows_above:rows_above,rows:this_cluster_rows}},renderExtraTag:function(class_name,height){var tag=document.createElement(this.options.tag),clusterize_prefix="clusterize-";return tag.className=[clusterize_prefix+"extra-row",clusterize_prefix+class_name].join(" "),height&&(tag.style.height=height+"px"),tag.outerHTML},insertToDOM:function(rows,cache){var data=this.generate(rows,this.getClusterNum()),this_cluster_rows=data.rows.join(""),this_cluster_content_changed=this.checkChanges("data",this_cluster_rows,cache),only_bottom_offset_changed=this.checkChanges("bottom",data.bottom_offset,cache),callbacks=this.options.callbacks,layout=[];this_cluster_content_changed?(data.top_offset&&(this.options.keep_parity&&layout.push(this.renderExtraTag("keep-parity")),layout.push(this.renderExtraTag("top-space",data.top_offset))),layout.push(this_cluster_rows),data.bottom_offset&&layout.push(this.renderExtraTag("bottom-space",data.bottom_offset)),callbacks.clusterWillChange&&callbacks.clusterWillChange(),this.html(layout.join("")),"ol"==this.options.content_tag&&this.content_elem.setAttribute("start",data.rows_above),callbacks.clusterChanged&&callbacks.clusterChanged()):only_bottom_offset_changed&&(this.content_elem.lastChild.style.height=data.bottom_offset+"px")},html:function(data){var content_elem=this.content_elem;if(ie&&9>=ie&&"tr"==this.options.tag){var last,div=document.createElement("div");for(div.innerHTML=""+data+"
";last=content_elem.lastChild;)content_elem.removeChild(last);for(var rows_nodes=this.getChildNodes(div.firstChild.firstChild);rows_nodes.length;)content_elem.appendChild(rows_nodes.shift())}else content_elem.innerHTML=data},getChildNodes:function(tag){for(var child_nodes=tag.children,nodes=[],i=0,ii=child_nodes.length;ii>i;i++)nodes.push(child_nodes[i]);return nodes},checkChanges:function(type,value,cache){var changed=value!=cache[type];return cache[type]=value,changed}},Clusterize})},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0,exports.Node=exports.flatten=void 0;var _flatten=__webpack_require__(5),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(7),_node2=_interopRequireDefault(_node);exports.flatten=_flatten2["default"],exports.Node=_node2["default"]},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0;var _extend=__webpack_require__(6),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(7),_node2=_interopRequireDefault(_node),flatten=function flatten(){var nodes=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],options=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];nodes=[].concat(nodes);var flatten=[],stack=[],pool={lastChild:{}};options.openAllNodes=!!options.openAllNodes,options.openNodes=options.openNodes||[],options.throwOnError=!!options.throwOnError;var firstNode=nodes.length>0?nodes[0]:null,parentNode=firstNode?firstNode.parent:null;!parentNode||parentNode instanceof _node2["default"]||(parentNode=new _node2["default"](parentNode));var rootNode=parentNode||new _node2["default"]({label:"",parent:null,children:nodes,state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}});if(rootNode===parentNode)for(var subtotal=rootNode.state.total||0,p=rootNode;p;){var _p$state=p.state,path=_p$state.path,_p$state$total=_p$state.total,total=void 0===_p$state$total?0:_p$state$total;if(p.isLastChild()&&path&&(pool.lastChild[path]=!0),p.state.total=total-subtotal,p.state.total<0){if(options.throwOnError)throw new Error("The node might have been corrupted: id="+JSON.stringify(p.id)+", state="+JSON.stringify(p.state));console&&console.log("Error: The node might have been corrupted: id=%s, label=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),JSON.stringify(p.label),p.parent,p.children,JSON.stringify(p.state))}p=p.parent}for(stack.push([rootNode,rootNode.state.depth,0]);stack.length>0;)for(var _stack$pop=stack.pop(),current=_stack$pop[0],depth=_stack$pop[1],index=_stack$pop[2],_loop=function(){var node=current.children[index];node instanceof _node2["default"]||(node=new _node2["default"](node)),node.parent=current,node.children=node.children||[],node.parent.children[index]=node;var path=current.state.path+"."+index,open=node.hasChildren()&&function(){var openAllNodes=options.openAllNodes,openNodes=options.openNodes;return openAllNodes?!0:openNodes.indexOf(node)>=0?!0:openNodes.indexOf(node.id)>=0}(),prefixMask=function(prefix){for(var mask="";prefix.length>0;)prefix=prefix.replace(/\.\d+$/,""),mask=!prefix||pool.lastChild[prefix]?"0"+mask:"1"+mask;return mask}(path);node.isLastChild()&&(pool.lastChild[path]=!0),node.state=(0,_extend2["default"])({},node.state,{depth:depth+1,open:open,path:path,prefixMask:prefixMask,total:0});for(var parentDidOpen=!0,_p=node;null!==_p.parent;){if(_p.parent.state.open===!1){parentDidOpen=!1;break}_p=_p.parent}if(parentDidOpen){flatten.push(node);for(var _p2=node;null!==_p2.parent;)_p2.parent.state.total++,_p2=_p2.parent}++index,node.hasChildren()&&(stack.push([current,depth,index]),index=0,depth+=1,current=node)};index1?_len-1:0),_key=1;_len>_key;_key++)sources[_key-1]=arguments[_key];if(void 0===target||null===target)throw new TypeError("Cannot convert undefined or null to object");for(var output=Object(target),index=0;index0&&index>=0&&index0&&(node=this.children[0]),node},Node.prototype.getLastChild=function(){var node=null;return this.children.length>0&&(node=this.children[this.children.length-1]),node},Node.prototype.getNextSibling=function(){var node=null;if(this.parent){var index=this.parent.children.indexOf(this);index>=0&&index0&&index0},Node.prototype.isLastChild=function(){var hasNextSibling=this.getNextSibling();return!hasNextSibling},Node}();exports["default"]=Node},function(module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}exports.__esModule=!0;var LookupTable=function(){function LookupTable(){_classCallCheck(this,LookupTable),this.data={}}return LookupTable.prototype.clear=function(){this.data={}},LookupTable.prototype.get=function(key){return this.data[key]},LookupTable.prototype.has=function(key){return void 0!==this.data[key]},LookupTable.prototype.set=function(key,value){return this.data[key]=value,value},LookupTable.prototype.unset=function(key){void 0!==this.data[key]&&delete this.data[key]},LookupTable}();exports["default"]=LookupTable},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0,exports.defaultRowRenderer=void 0;var _helper=__webpack_require__(10),defaultRowRenderer=function(node,treeOptions){var id=node.id,name=node.name,_node$loadOnDemand=node.loadOnDemand,loadOnDemand=void 0===_node$loadOnDemand?!1:_node$loadOnDemand,children=node.children,state=node.state,droppable=treeOptions.droppable,depth=state.depth,open=state.open,path=state.path,total=state.total,_state$selected=state.selected,selected=void 0===_state$selected?!1:_state$selected,childrenLength=Object.keys(children).length,more=node.hasChildren(),togglerContent="";!more&&loadOnDemand&&(togglerContent="►"),more&&open&&(togglerContent="▼"),more&&!open&&(togglerContent="►");var toggler=(0,_helper.buildHTML)("a",togglerContent,{"class":function(){return!more&&loadOnDemand?(0,_helper.classNames)(treeOptions.togglerClass,"infinite-tree-closed"):more&&open?(0,_helper.classNames)(treeOptions.togglerClass):more&&!open?(0,_helper.classNames)(treeOptions.togglerClass,"infinite-tree-closed"):""}()}),title=(0,_helper.buildHTML)("span",(0,_helper.quoteattr)(name),{"class":(0,_helper.classNames)("infinite-tree-title")}),treeNode=(0,_helper.buildHTML)("div",toggler+title,{"class":"infinite-tree-node",style:"margin-left: "+18*depth+"px"});return(0,_helper.buildHTML)("div",treeNode,{"data-id":id,"data-expanded":more&&open,"data-depth":depth,"data-path":path,"data-selected":selected,"data-children":childrenLength,"data-total":total,"class":(0,_helper.classNames)("infinite-tree-item",{"infinite-tree-selected":selected}),droppable:droppable})};exports.defaultRowRenderer=defaultRowRenderer},function(module,exports){"use strict";exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},extend=function(target){for(var _len=arguments.length,sources=Array(_len>1?_len-1:0),_key=1;_len>_key;_key++)sources[_key-1]=arguments[_key];target=target||{};for(var index=0;index=0},addClass=function(el,className){if(!el)return"";if(!hasClass(el,className)){var classes=el.className.split(" ");el.className=classes.concat(className).join(" ")}return el.className},removeClass=function(el,className){if(!el)return"";if(hasClass(el,className)){var classes=el.className.split(" ");el.className=classes.filter(function(c){return c!==className}).join(" ")}return el.className},toggleClass=function(el,className){el&&(hasClass(el,className)?removeClass(el,className):addClass(el,className))},classNames=function classNames(){for(var _len2=arguments.length,args=Array(_len2),_key2=0;_len2>_key2;_key2++)args[_key2]=arguments[_key2];var classNames=[];return args.forEach(function(arg){Array.isArray(arg)?classNames=classNames.concat(arg):"object"===("undefined"==typeof arg?"undefined":_typeof(arg))?Object.keys(arg).forEach(function(className){var ok=arg[className];ok&&classNames.push(className)}):classNames.push(arg)}),classNames.join(" ")},isDOMElement=function(o){return"object"===("undefined"==typeof HTMLElement?"undefined":_typeof(HTMLElement))?o instanceof HTMLElement:o&&"object"===("undefined"==typeof o?"undefined":_typeof(o))&&1===o.nodeType&&"string"==typeof o.nodeName},isDOMNode=function(o){return"object"===("undefined"==typeof Node?"undefined":_typeof(Node))?o instanceof Node:o&&"object"===("undefined"==typeof o?"undefined":_typeof(o))&&"number"==typeof o.nodeType&&"string"==typeof o.nodeName},quoteattr=function(s,preserveCR){return preserveCR=preserveCR?" ":"\n",(""+s).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">").replace(/\r\n/g,preserveCR).replace(/[\r\n]/g,preserveCR)},buildHTML=function buildHTML(tag,html,attrs){switch(tag){case"select":if("object"===("undefined"==typeof html?"undefined":_typeof(html))){var options=html||{};html="";for(var value in options)options.hasOwnProperty(value)&&(html+=buildHTML("option",options[value]||"",{value:value}))}break;default:"object"===("undefined"==typeof html?"undefined":_typeof(html))&&(attrs=html,html=void 0)}var h="<"+tag;for(var attr in attrs)attrs.hasOwnProperty(attr)&&"undefined"!=typeof attrs[attr]&&(h+=" "+attr+'="'+quoteattr(attrs[attr])+'"');return h+="undefined"!=typeof html?">"+html+"":"/>"};exports.extend=extend,exports.preventDefault=preventDefault,exports.stopPropagation=stopPropagation,exports.dispatchEvent=dispatchEvent,exports.addEventListener=addEventListener,exports.removeEventListener=removeEventListener,exports.hasClass=hasClass,exports.addClass=addClass,exports.removeClass=removeClass,exports.toggleClass=toggleClass,exports.classNames=classNames,exports.isDOMElement=isDOMElement,exports.isDOMNode=isDOMNode,exports.quoteattr=quoteattr,exports.buildHTML=buildHTML}])}); \ No newline at end of file diff --git a/examples/classic/index.js b/examples/classic/index.js index 1e48662..6b247fd 100644 --- a/examples/classic/index.js +++ b/examples/classic/index.js @@ -70,6 +70,9 @@ const tree = new InfiniteTree(document.querySelector('#classic [data-id="tree"]' } }); +tree.on('click', (event) => { + console.log('click', event); +}); tree.on('contentWillUpdate', () => { console.log('contentWillUpdate'); }); diff --git a/examples/default/index.js b/examples/default/index.js index 8d6c97c..2a930e8 100644 --- a/examples/default/index.js +++ b/examples/default/index.js @@ -68,6 +68,9 @@ const tree = new InfiniteTree(document.querySelector('#default [data-id="tree"]' } }); +tree.on('click', (event) => { + console.log('click', event); +}); tree.on('contentWillUpdate', () => { console.log('contentWillUpdate'); }); diff --git a/examples/filebrowser/index.js b/examples/filebrowser/index.js index 7a46f28..b7ef8aa 100644 --- a/examples/filebrowser/index.js +++ b/examples/filebrowser/index.js @@ -40,6 +40,9 @@ const tree = new InfiniteTree(document.querySelector('#filebrowser [data-id="tre } }); +tree.on('click', (event) => { + console.log('click', event); +}); tree.on('contentWillUpdate', () => { console.log('contentWillUpdate'); }); diff --git a/package.json b/package.json index 6df7bce..d2ced69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "infinite-tree", - "version": "1.1.1", + "version": "1.2.0", "description": "A browser-ready tree library that can efficiently display a large amount of data using infinite scrolling.", "homepage": "https://github.com/cheton/infinite-tree", "main": "lib/index.js", @@ -11,7 +11,7 @@ "pack-examples": "npm run build-examples && zip -r examples.zip examples/{dist,vendor,*.html,*.css}", "test": "./babel-tap --coverage test/*.js", "dist": "webpack; BUILD_ENV=dist webpack", - "release": "mkdir -p releases; cp -f dist/infinite-tree.css releases/infinite-tree-${npm_package_version}.css; cp -f dist/infinite-tree.js releases/infinite-tree-${npm_package_version}.js; cp -f dist/infinite-tree.min.js releases/infinite-tree-${npm_package_version}.min.js", + "release": "mkdir -p releases; rm -f releases/*; cp -f dist/infinite-tree.css releases/infinite-tree-${npm_package_version}.css; cp -f dist/infinite-tree.js releases/infinite-tree-${npm_package_version}.js; cp -f dist/infinite-tree.min.js releases/infinite-tree-${npm_package_version}.min.js", "lint": "npm run eslint && npm run stylint", "eslint": "eslint ./src", "eslint:fix": "eslint --fix ./src", diff --git a/src/infinite-tree.js b/src/infinite-tree.js index 35beaa4..f36bcab 100644 --- a/src/infinite-tree.js +++ b/src/infinite-tree.js @@ -63,42 +63,70 @@ class InfiniteTree extends events.EventEmitter { droppableTarget = null; contentListener = { - 'click': (e) => { - let itemTarget = null; - let clickToggler = false; + 'click': (event) => { + event = event || window.event; + + // Wrap stopPropagation that allows click event handler to stop execution + // by setting the cancelBubble property + const stopPropagation = event.stopPropagation; + event.stopPropagation = function() { + // Setting the cancelBubble property in browsers that don't support it doesn't hurt. + // Of course it doesn't actually cancel the bubbling, but the assignment itself is safe. + event.cancelBubble = true; + + if (stopPropagation) { + stopPropagation.call(event); + } + }; - if (e.target && e.currentTarget) { - itemTarget = (e.target !== e.currentTarget) ? e.target : null; - } else if (e.srcElement) { // IE8 - itemTarget = e.srcElement; - } + // Call setTimeout(fn, 0) to re-queues the execution of subsequent calls, it allows the + // click event to bubble up to higher level event handlers before handling tree events. + setTimeout(() => { + // Stop execution if the cancelBubble property is set to true by higher level event handlers + if (event.cancelBubble === true) { + return; + } - while (itemTarget && itemTarget.parentElement !== this.contentElement) { - if (hasClass(itemTarget, this.options.togglerClass)) { - clickToggler = true; + // Emit 'click' event + this.emit('click', event); + + // Stop execution if the cancelBubble property is set to true after emitting the click event + if (event.cancelBubble === true) { + return; } - itemTarget = itemTarget.parentElement; - } - if (!itemTarget) { - return; - } + let itemTarget = null; + let clickToggler = false; - const id = itemTarget.getAttribute(this.options.nodeIdAttr); - const node = this.getNodeById(id); + if (event.target && event.currentTarget) { + itemTarget = (event.target !== event.currentTarget) ? event.target : null; + } else if (event.srcElement) { // IE8 + itemTarget = event.srcElement; + } - if (!node) { - return; - } + while (itemTarget && itemTarget.parentElement !== this.contentElement) { + if (hasClass(itemTarget, this.options.togglerClass)) { + clickToggler = true; + } + itemTarget = itemTarget.parentElement; + } - // Click on the toggler to open/close a tree node - if (clickToggler) { - this.toggleNode(node); - return; - } + if (!itemTarget) { + return; + } + + const id = itemTarget.getAttribute(this.options.nodeIdAttr); + const node = this.getNodeById(id); + if (!node) { + return; + } + + // Click on the toggler to open/close a tree node + if (clickToggler) { + this.toggleNode(node); + return; + } - // Use setTimeout(fn, 0) to re-queues the selectNode operation, it allows the click event to bubble up to higher level event handlers. - setTimeout(() => { this.selectNode(node); // selectNode will re-render the tree }, 0); },