/** * jQuery asTree v0.3.2 * https://github.com/amazingSurge/jquery-asTree * * Copyright (c) amazingSurge * Released under the LGPL-3.0 license */ !function(e,t){if("function"==typeof define&&define.amd)define(["jquery"],t);else if("undefined"!=typeof exports)t(require("jquery"));else{var n={exports:{}};t(e.jQuery),e.jqueryAsTreeEs=n.exports}}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(e){return e&&e.__esModule?e:{default:e}}(e),i=function(){function e(e,t){for(var n=0;n'},branch:function(e){var t=this.branchContent(e);return'
'+this.toggler(e)+'
'+t+"
"},branchContent:function(e){return"object"===(void 0===e?"undefined":r(e))?e.name:e},leaf:function(e){return this.leafContent(e)},leafContent:function(e){return"object"===(void 0===e?"undefined":r(e))?e.name:e}}},s=function(){function e(n){t(this,e),this.tpl=n.tpl}return i(e,[{key:"getLeaf",value:function(e){return"
  • "+this.tpl.leaf(e)+"
  • "}},{key:"getBranch",value:function(e){return'
  • '+this.tpl.branch(e)+this.getTree(e.children)+"
  • "}},{key:"getNode",value:function(e){return e.children?this.getBranch(e):this.getLeaf(e)}},{key:"getTree",value:function(e,t){var n="",i=!0,r=!1,a=void 0;try{for(var s,l=e[Symbol.iterator]();!(i=(s=l.next()).done);i=!0){var o=s.value;n+=this.getNode(o)}}catch(e){r=!0,a=e}finally{try{!i&&l.return&&l.return()}finally{if(r)throw a}}return t?'":""}}]),e}(),l=function(){function e(n,i,r){t(this,e),this.$dom=n,this.api=r,null===i&&(i=!1),i?this.type="root":(this.selected=!1,this.hasChildren()?(this.type="branch",this.opened=this.isOpened()):this.type="leaf"),this.init()}return i(e,[{key:"init",value:function(){switch(this.type){case"root":this._children=this.$dom.get(0).children,this.level=0,this.parent=null,this.$parent=null;break;case"branch":case"leaf":var e=this.$dom.children("ul");e.length>0?this._children=e.get(0).children:this._children=[],this.$parent=this.$dom.parents("li.tree-branch").eq(0),0===this.$parent.length&&(this.$parent=this.$dom.parent()),this.parent=this.$parent.data("node"),this.level=this.parent.level+1}}},{key:"get",value:function(){return this.$dom}},{key:"position",value:function(){var e=[];return function t(n){e.push(n.$dom.index()+1),n.parent&&"root"!==n.parent.type&&t(n.parent)}(this),e.reverse()}},{key:"parents",value:function(){var e=[];return function t(n){null!==n.parent&&(e.push(n.parent),t(n.parent))}(this),e}},{key:"children",value:function(){for(var e=[],t=void 0,n=0;n")}return this}},{key:"append",value:function(e){"leaf"===this.type&&this.toBranch();var t=this.api.dataParser.getNode(e),n=$(t).appendTo(this.$dom.children("ul"));return"leaf"===this.type?this.api.attach(this.$dom,!1,this.api):this.api.attach(n,!1,this.api),this}},{key:"prepend",value:function(e){"leaf"===this.type&&this.toBranch();var t=this.api.dataParser.getNode(e),n=$(t).prependTo(this.$dom.children("ul"));return"leaf"===this.type?this.api.attach(this.$dom,!1,this.api):this.api.attach(n,!1,this.api),this}},{key:"after",value:function(e){var t=this.api.dataParser.getNode(e);this.$dom.after(t);var n=this.$dom.next();return this.api.attach(n,!1,this.api),this}},{key:"before",value:function(e){var t=this.api.dataParser.getNode(e);this.$dom.before(t);var n=this.$dom.prev();return this.api.attach(n,!1,this.api),this}},{key:"remove",value:function(){return this.$dom.remove(),this}}]),e}(),o=function(){function e(n){t(this,e),this.tpl=n.tpl}return i(e,[{key:"getLeaf",value:function(e){return e.html()}},{key:"getBranch",value:function(e){return e.children("div").html()}},{key:"renderTree",value:function(e,t,n){var i=this,r=void 0;if(t?(r=e,e.addClass("tree")):r=e.children("ul"),0!==r.length){e.addClass("tree-branch");!function(e){e.children("li").each(function(e,t){var r=$(t),a=i.tpl.branch(i.getBranch(r));r.children("div").replaceWith(a),i.renderTree(r,!1,n)})}(r)}}}]),e}(),h=function(){function e(i){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(this,e),this.$element=(0,n.default)(i),this.options=n.default.extend(!0,{},a,r),this.namespace=this.options.namespace,this.dataParser=new s(this.options),this.htmlParser=new o(this.options),this._init()}return i(e,[{key:"_init",value:function(){!0===this.options.dataFromHtml?this._createFromHtml():this._createFromData();var e="ul"===this.$element[0].nodeName.toLowerCase()?this.$element:this.$element.find("ul:first");this.root=e.data("node"),this.options.multiSelect?this.selected=[]:this.selected=null,this.autoOpen(),this.$element.on({click:n.default.proxy(this._click,this)}),this._trigger("ready")}},{key:"_trigger",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i1?t-1:0),r=1;r