jstree.min.js 138 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*!
  2. * jsTree 3.3.3
  3. * http://jstree.com/
  4. *此组件由jeeplus作者进行了深度定制
  5. * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
  6. *
  7. * Licensed same as jquery - under the terms of the MIT License
  8. * http://www.opensource.org/licenses/mit-license.php
  9. */
  10. /*!
  11. * if using jslint please allow for the jQuery global and use following options:
  12. * jslint: loopfunc: true, browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
  13. */
  14. var jstree_version="www.jeeplus.org";
  15. (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(g,e){
  16. if(g.jstree){return}if(jstree_version!="www.jeeplus.org"){return}var c=0,d=false,j=false,h=false,n=[],a=g("script:last").attr("src"),o=window.document;g.jstree={version:"3.3.3",defaults:{plugins:[]},plugins:{},path:a&&a.indexOf("/")!==-1?a.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:"#"};g.jstree.create=function(t,q){var s=new g.jstree.core(++c),r=q;q=g.extend(true,{},g.jstree.defaults,q);if(r&&r.plugins){q.plugins=r.plugins}g.each(q.plugins,function(v,u){if(v!=="core"){s=s.plugin(u,q[u])}});g(t).data("jstree",s);s.init(t,q);return s};g.jstree.destroy=function(){g(".jstree:jstree").jstree("destroy");g(o).off(".jstree")};g.jstree.core=function(q){this._id=q;this._cnt=0;this._wrk=null;this._data={core:{themes:{name:false,dots:false,icons:false,ellipsis:false},selected:[],last_error:{},working:false,worker_queue:[],focused:null}}};g.jstree.reference=function(s){var q=null,r=null;if(s&&s.id&&(!s.tagName||!s.nodeType)){s=s.id}if(!r||!r.length){try{r=g(s)}catch(t){}}if(!r||!r.length){try{r=g("#"+s.replace(g.jstree.idregex,"\\$&"))}catch(t){}}if(r&&r.length&&(r=r.closest(".jstree")).length&&(r=r.data("jstree"))){q=r}else{g(".jstree").each(function(){var u=g(this).data("jstree");if(u&&u._model.data[s]){q=u;return false}})}return q};g.fn.jstree=function(r){var t=(typeof r==="string"),s=Array.prototype.slice.call(arguments,1),q=null;if(r===true&&!this.length){return false}this.each(function(){var u=g.jstree.reference(this),v=t&&u?u[r]:null;q=t&&v?v.apply(u,s):null;if(!u&&!t&&(r===e||g.isPlainObject(r))){g.jstree.create(this,r)}if((u&&!t)||r===true){q=u||false}if(q!==null&&q!==e){return false}});return q!==null&&q!==e?q:this};g.expr.pseudos.jstree=g.expr.createPseudo(function(q){return function(r){return g(r).hasClass("jstree")&&g(r).data("jstree")!==e}});g.jstree.defaults.core={data:false,strings:false,check_callback:false,error:g.noop,animation:200,multiple:true,themes:{name:false,url:false,dir:false,dots:true,icons:true,ellipsis:false,stripes:false,variant:false,responsive:false},expand_selected_onload:true,worker:true,force_text:false,dblclick_toggle:true};g.jstree.core.prototype={plugin:function(s,r){var q=g.jstree.plugins[s];if(q){this._data[s]={};q.prototype=this;return new q(r,this)}return this},init:function(r,q){this._model={data:{},changed:[],force_full_redraw:false,redraw_timeout:false,default_state:{loaded:true,opened:false,selected:false,disabled:false}};this._model.data[g.jstree.root]={id:g.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:false}};this.element=g(r).addClass("jstree jstree-"+this._id);this.settings=q;this._data.core.ready=false;this._data.core.loaded=false;this._data.core.rtl=(this.element.css("direction")==="rtl");this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl");this.element.attr("role","tree");if(this.settings.core.multiple){this.element.attr("aria-multiselectable",true)}if(!this.element.attr("tabindex")){this.element.attr("tabindex","0")}this.bind();this.trigger("init");this._data.core.original_container_html=this.element.find(" > ul > li").clone(true);this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return this.nodeType===3&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove();this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>");this.element.attr("aria-activedescendant","j"+this._id+"_loading");this._data.core.li_height=this.get_container_ul().children("li").first().height()||24;this._data.core.node=this._create_prototype_node();this.trigger("loading");this.load_node(g.jstree.root)},destroy:function(q){if(this._wrk){try{window.URL.revokeObjectURL(this._wrk);this._wrk=null}catch(r){}}if(!q){this.element.empty()}this.teardown()},_create_prototype_node:function(){var r=o.createElement("LI"),s,q;r.setAttribute("role","treeitem");s=o.createElement("I");s.className="jstree-icon jstree-ocl";s.setAttribute("role","presentation");r.appendChild(s);
  17. s=o.createElement("A");s.className="jstree-anchor";s.setAttribute("href","#");s.setAttribute("tabindex","-1");q=o.createElement("I");q.className="jstree-icon jstree-themeicon";q.setAttribute("role","presentation");s.appendChild(q);r.appendChild(s);s=q=null;return r},teardown:function(){this.unbind();this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/ig,"")});this.element=null},bind:function(){var r="",q=null,s=0;this.element.on("dblclick.jstree",function(u){if(u.target.tagName&&u.target.tagName.toLowerCase()==="input"){return true}if(o.selection&&o.selection.empty){o.selection.empty()}else{if(window.getSelection){var t=window.getSelection();try{t.removeAllRanges();t.collapse()}catch(v){}}}}).on("mousedown.jstree",g.proxy(function(t){if(t.target===this.element[0]){t.preventDefault();s=+(new Date())}},this)).on("mousedown.jstree",".jstree-ocl",function(t){t.preventDefault()}).on("click.jstree",".jstree-ocl",g.proxy(function(t){this.toggle_node(t.target)},this)).on("dblclick.jstree",".jstree-anchor",g.proxy(function(t){if(t.target.tagName&&t.target.tagName.toLowerCase()==="input"){return true}if(this.settings.core.dblclick_toggle){this.toggle_node(t.target)}},this)).on("click.jstree",".jstree-anchor",g.proxy(function(t){t.preventDefault();if(t.currentTarget!==o.activeElement){g(t.currentTarget).focus()}this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",g.proxy(function(t){if(t.target.tagName&&t.target.tagName.toLowerCase()==="input"){return true}if(t.which!==32&&t.which!==13&&(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)){return true}var u=null;if(this._data.core.rtl){if(t.which===37){t.which=39}else{if(t.which===39){t.which=37}}}switch(t.which){case 32:if(t.ctrlKey){t.type="click";g(t.currentTarget).trigger(t)}break;case 13:t.type="click";g(t.currentTarget).trigger(t);break;case 37:t.preventDefault();if(this.is_open(t.currentTarget)){this.close_node(t.currentTarget)}else{u=this.get_parent(t.currentTarget);if(u&&u.id!==g.jstree.root){this.get_node(u,true).children(".jstree-anchor").focus()}}break;case 38:t.preventDefault();u=this.get_prev_dom(t.currentTarget);if(u&&u.length){u.children(".jstree-anchor").focus()}break;case 39:t.preventDefault();if(this.is_closed(t.currentTarget)){this.open_node(t.currentTarget,function(v){this.get_node(v,true).children(".jstree-anchor").focus()})}else{if(this.is_open(t.currentTarget)){u=this.get_node(t.currentTarget,true).children(".jstree-children")[0];if(u){g(this._firstChild(u)).children(".jstree-anchor").focus()}}}break;case 40:t.preventDefault();u=this.get_next_dom(t.currentTarget);if(u&&u.length){u.children(".jstree-anchor").focus()}break;case 106:this.open_all();break;case 36:t.preventDefault();u=this._firstChild(this.get_container_ul()[0]);if(u){g(u).children(".jstree-anchor").filter(":visible").focus()}break;case 35:t.preventDefault();this.element.find(".jstree-anchor").filter(":visible").last().focus();break;case 113:t.preventDefault();this.edit(t.currentTarget);break;default:break;
  18. }},this)).on("load_node.jstree",g.proxy(function(u,t){if(t.status){if(t.node.id===g.jstree.root&&!this._data.core.loaded){this._data.core.loaded=true;if(this._firstChild(this.get_container_ul()[0])){this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id)}this.trigger("loaded")}if(!this._data.core.ready){setTimeout(g.proxy(function(){if(this.element&&!this.get_container_ul().find(".jstree-loading").length){this._data.core.ready=true;if(this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var x=[],w,v;for(w=0,v=this._data.core.selected.length;w<v;w++){x=x.concat(this._model.data[this._data.core.selected[w]].parents)}x=g.vakata.array_unique(x);for(w=0,v=x.length;w<v;w++){this.open_node(x[w],false,0)}}this.trigger("changed",{"action":"ready","selected":this._data.core.selected})}this.trigger("ready")}},this),0)}}},this)).on("keypress.jstree",g.proxy(function(x){if(x.target.tagName&&x.target.tagName.toLowerCase()==="input"){return true}if(q){clearTimeout(q)}q=setTimeout(function(){r=""},500);var v=String.fromCharCode(x.which).toLowerCase(),u=this.element.find(".jstree-anchor").filter(":visible"),w=u.index(o.activeElement)||0,t=false;r+=v;if(r.length>1){u.slice(w).each(g.proxy(function(z,y){if(g(y).text().toLowerCase().indexOf(r)===0){g(y).focus();t=true;return false}},this));if(t){return}u.slice(0,w).each(g.proxy(function(z,y){if(g(y).text().toLowerCase().indexOf(r)===0){g(y).focus();t=true;return false}},this));if(t){return}}if(new RegExp("^"+v.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+"+$").test(r)){u.slice(w+1).each(g.proxy(function(z,y){if(g(y).text().toLowerCase().charAt(0)===v){g(y).focus();
  19. t=true;return false}},this));if(t){return}u.slice(0,w+1).each(g.proxy(function(z,y){if(g(y).text().toLowerCase().charAt(0)===v){g(y).focus();t=true;return false}},this));if(t){return}}},this)).on("init.jstree",g.proxy(function(){var t=this.settings.core.themes;this._data.core.themes.dots=t.dots;this._data.core.themes.stripes=t.stripes;this._data.core.themes.icons=t.icons;this._data.core.themes.ellipsis=t.ellipsis;this.set_theme(t.name||"default",t.url);this.set_theme_variant(t.variant)},this)).on("loading.jstree",g.proxy(function(){this[this._data.core.themes.dots?"show_dots":"hide_dots"]();this[this._data.core.themes.icons?"show_icons":"hide_icons"]();this[this._data.core.themes.stripes?"show_stripes":"hide_stripes"]();this[this._data.core.themes.ellipsis?"show_ellipsis":"hide_ellipsis"]()},this)).on("blur.jstree",".jstree-anchor",g.proxy(function(t){this._data.core.focused=null;g(t.currentTarget).filter(".jstree-hovered").mouseleave();this.element.attr("tabindex","0")},this)).on("focus.jstree",".jstree-anchor",g.proxy(function(u){var t=this.get_node(u.currentTarget);if(t&&t.id){this._data.core.focused=t.id}this.element.find(".jstree-hovered").not(u.currentTarget).mouseleave();g(u.currentTarget).mouseenter();this.element.attr("tabindex","-1")},this)).on("focus.jstree",g.proxy(function(){if(+(new Date())-s>500&&!this._data.core.focused){s=0;var t=this.get_node(this.element.attr("aria-activedescendant"),true);if(t){t.find("> .jstree-anchor").focus()}}},this)).on("mouseenter.jstree",".jstree-anchor",g.proxy(function(t){this.hover_node(t.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",g.proxy(function(t){this.dehover_node(t.currentTarget)},this))},unbind:function(){this.element.off(".jstree");g(o).off(".jstree-"+this._id)},trigger:function(q,r){if(!r){r={}}r.instance=this;this.element.triggerHandler(q.replace(".jstree","")+".jstree",r)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children(".jstree-children").first()},get_string:function(r){var q=this.settings.core.strings;if(g.isFunction(q)){return q.call(this,r)}if(q&&q[r]){return q[r]}return r},_firstChild:function(q){q=q?q.firstChild:null;while(q!==null&&q.nodeType!==1){q=q.nextSibling}return q},_nextSibling:function(q){q=q?q.nextSibling:null;while(q!==null&&q.nodeType!==1){q=q.nextSibling}return q},_previousSibling:function(q){q=q?q.previousSibling:null;while(q!==null&&q.nodeType!==1){q=q.previousSibling}return q},get_node:function(s,q){if(s&&s.id){s=s.id}var t;try{if(this._model.data[s]){s=this._model.data[s]}else{if(typeof s==="string"&&this._model.data[s.replace(/^#/,"")]){s=this._model.data[s.replace(/^#/,"")]}else{if(typeof s==="string"&&(t=g("#"+s.replace(g.jstree.idregex,"\\$&"),this.element)).length&&this._model.data[t.closest(".jstree-node").attr("id")]){s=this._model.data[t.closest(".jstree-node").attr("id")]}else{if((t=g(s,this.element)).length&&this._model.data[t.closest(".jstree-node").attr("id")]){s=this._model.data[t.closest(".jstree-node").attr("id")]}else{if((t=g(s,this.element)).length&&t.hasClass("jstree")){s=this._model.data[g.jstree.root]}else{return false}}}}}if(q){s=s.id===g.jstree.root?this.element:g("#"+s.id.replace(g.jstree.idregex,"\\$&"),this.element)}return s}catch(r){return false}},get_path:function(v,t,s){v=v.parents?v:this.get_node(v);if(!v||v.id===g.jstree.root||!v.parents){return false}var r,q,u=[];u.push(s?v.id:v.text);for(r=0,q=v.parents.length;r<q;r++){u.push(s?v.parents[r]:this.get_text(v.parents[r]))}u=u.reverse().slice(1);return t?u.join(t):u},get_next_dom:function(s,q){var r;s=this.get_node(s,true);if(s[0]===this.element[0]){r=this._firstChild(this.get_container_ul()[0]);while(r&&r.offsetHeight===0){r=this._nextSibling(r)}return r?g(r):false}if(!s||!s.length){return false}if(q){r=s[0];do{r=this._nextSibling(r)}while(r&&r.offsetHeight===0);return r?g(r):false}if(s.hasClass("jstree-open")){r=this._firstChild(s.children(".jstree-children")[0]);while(r&&r.offsetHeight===0){r=this._nextSibling(r)}if(r!==null){return g(r)}}r=s[0];do{r=this._nextSibling(r)}while(r&&r.offsetHeight===0);if(r!==null){return g(r)}return s.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first()},get_prev_dom:function(s,q){var r;s=this.get_node(s,true);if(s[0]===this.element[0]){r=this.get_container_ul()[0].lastChild;while(r&&r.offsetHeight===0){r=this._previousSibling(r)}return r?g(r):false}if(!s||!s.length){return false}if(q){r=s[0];do{r=this._previousSibling(r)}while(r&&r.offsetHeight===0);return r?g(r):false}r=s[0];do{r=this._previousSibling(r)}while(r&&r.offsetHeight===0);if(r!==null){s=g(r);while(s.hasClass("jstree-open")){s=s.children(".jstree-children").first().children(".jstree-node:visible:last")}return s}r=s[0].parentNode.parentNode;return r&&r.className&&r.className.indexOf("jstree-node")!==-1?g(r):false},get_parent:function(q){q=this.get_node(q);if(!q||q.id===g.jstree.root){return false}return q.parent},get_children_dom:function(q){q=this.get_node(q,true);
  20. if(q[0]===this.element[0]){return this.get_container_ul().children(".jstree-node")}if(!q||!q.length){return false}return q.children(".jstree-children").children(".jstree-node")},is_parent:function(q){q=this.get_node(q);return q&&(q.state.loaded===false||q.children.length>0)},is_loaded:function(q){q=this.get_node(q);return q&&q.state.loaded},is_loading:function(q){q=this.get_node(q);return q&&q.state&&q.state.loading},is_open:function(q){q=this.get_node(q);return q&&q.state.opened},is_closed:function(q){q=this.get_node(q);return q&&this.is_parent(q)&&!q.state.opened},is_leaf:function(q){return !this.is_parent(q)},load_node:function(u,w){var r,q,t,s,v;if(g.isArray(u)){this._load_nodes(u.slice(),w);return true}u=this.get_node(u);if(!u){if(w){w.call(this,u,false)}return false}if(u.state.loaded){u.state.loaded=false;for(t=0,s=u.parents.length;t<s;t++){this._model.data[u.parents[t]].children_d=g.vakata.array_filter(this._model.data[u.parents[t]].children_d,function(x){return g.inArray(x,u.children_d)===-1})}for(r=0,q=u.children_d.length;r<q;r++){if(this._model.data[u.children_d[r]].state.selected){v=true}delete this._model.data[u.children_d[r]]}if(v){this._data.core.selected=g.vakata.array_filter(this._data.core.selected,function(x){return g.inArray(x,u.children_d)===-1})}u.children=[];u.children_d=[];if(v){this.trigger("changed",{"action":"load_node","node":u,"selected":this._data.core.selected})}}u.state.failed=false;u.state.loading=true;this.get_node(u,true).addClass("jstree-loading").attr("aria-busy",true);this._load_node(u,g.proxy(function(y){u=this._model.data[u.id];u.state.loading=false;u.state.loaded=y;u.state.failed=!u.state.loaded;var C=this.get_node(u,true),B=0,z=0,x=this._model.data,A=false;for(B=0,z=u.children.length;B<z;B++){if(x[u.children[B]]&&!x[u.children[B]].state.hidden){A=true;break}}if(u.state.loaded&&C&&C.length){C.removeClass("jstree-closed jstree-open jstree-leaf");if(!A){C.addClass("jstree-leaf")}else{if(u.id!=="#"){C.addClass(u.state.opened?"jstree-open":"jstree-closed")}}}C.removeClass("jstree-loading").attr("aria-busy",false);this.trigger("load_node",{"node":u,"status":y});if(w){w.call(this,u,y)}},this));return true},_load_nodes:function(s,A,z,w){var q=true,y=function(){this._load_nodes(s,A,true)},t=this._model.data,x,u,v=[];for(x=0,u=s.length;x<u;x++){if(t[s[x]]&&((!t[s[x]].state.loaded&&!t[s[x]].state.failed)||(!z&&w))){if(!this.is_loading(s[x])){this.load_node(s[x],y)}q=false}}if(q){for(x=0,u=s.length;x<u;x++){if(t[s[x]]&&t[s[x]].state.loaded){v.push(s[x])}}if(A&&!A.done){A.call(this,v);A.done=true}}},load_all:function(u,w){if(!u){u=g.jstree.root}u=this.get_node(u);if(!u){return false}var t=[],q=this._model.data,v=q[u.id].children_d,s,r;if(u.state&&!u.state.loaded){t.push(u.id)}for(s=0,r=v.length;s<r;s++){if(q[v[s]]&&q[v[s]].state&&!q[v[s]].state.loaded){t.push(v[s])}}if(t.length){this._load_nodes(t,function(){this.load_all(u,w)})}else{if(w){w.call(this,u)}this.trigger("load_all",{"node":u})}},_load_node:function(v,w){var u=this.settings.core.data,r;var q=function q(){return this.nodeType!==3&&this.nodeType!==8};if(!u){if(v.id===g.jstree.root){return this._append_html_data(v,this._data.core.original_container_html.clone(true),function(s){w.call(this,s)})}else{return w.call(this,false)}}if(g.isFunction(u)){return u.call(this,v,g.proxy(function(s){if(s===false){w.call(this,false)}else{this[typeof s==="string"?"_append_html_data":"_append_json_data"](v,typeof s==="string"?g(g.parseHTML(s)).filter(q):s,function(t){w.call(this,t)})}},this))}if(typeof u==="object"){if(u.url){u=g.extend(true,{},u);if(g.isFunction(u.url)){u.url=u.url.call(this,v)}if(g.isFunction(u.data)){u.data=u.data.call(this,v)}return g.ajax(u).done(g.proxy(function(A,y,s){var z=s.getResponseHeader("Content-Type");if((z&&z.indexOf("json")!==-1)||typeof A==="object"){return this._append_json_data(v,A,function(t){w.call(this,t)})}if((z&&z.indexOf("html")!==-1)||typeof A==="string"){return this._append_html_data(v,g(g.parseHTML(A)).filter(q),function(t){w.call(this,t)})}this._data.core.last_error={"error":"ajax","plugin":"core","id":"core_04","reason":"Could not load node","data":JSON.stringify({"id":v.id,"xhr":s})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)},this)).fail(g.proxy(function(s){w.call(this,false);this._data.core.last_error={"error":"ajax","plugin":"core","id":"core_04","reason":"Could not load node","data":JSON.stringify({"id":v.id,"xhr":s})};this.settings.core.error.call(this,this._data.core.last_error)},this))}r=(g.isArray(u)||g.isPlainObject(u))?JSON.parse(JSON.stringify(u)):u;if(v.id===g.jstree.root){return this._append_json_data(v,r,function(s){w.call(this,s)})}else{this._data.core.last_error={"error":"nodata","plugin":"core","id":"core_05","reason":"Could not load node","data":JSON.stringify({"id":v.id})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)}}if(typeof u==="string"){if(v.id===g.jstree.root){return this._append_html_data(v,g(g.parseHTML(u)).filter(q),function(s){w.call(this,s)
  21. })}else{this._data.core.last_error={"error":"nodata","plugin":"core","id":"core_06","reason":"Could not load node","data":JSON.stringify({"id":v.id})};this.settings.core.error.call(this,this._data.core.last_error);return w.call(this,false)}}return w.call(this,false)},_node_changed:function(q){q=this.get_node(q);if(q){this._model.changed.push(q.id)}},_append_html_data:function(v,y,t){v=this.get_node(v);v.children=[];v.children_d=[];var B=y.is("ul")?y.children():y,A=v.id,D=[],z=[],r=this._model.data,q=r[A],C=this._data.core.selected.length,x,w,u;B.each(g.proxy(function(E,s){x=this._parse_model_from_html(g(s),A,q.parents.concat());if(x){D.push(x);z.push(x);if(r[x].children_d.length){z=z.concat(r[x].children_d)}}},this));q.children=D;q.children_d=z;for(w=0,u=q.parents.length;w<u;w++){r[q.parents[w]].children_d=r[q.parents[w]].children_d.concat(z)}this.trigger("model",{"nodes":z,"parent":A});if(A!==g.jstree.root){this._node_changed(A);this.redraw()}else{this.get_container_ul().children(".jstree-initial-node").remove();this.redraw(true)}if(this._data.core.selected.length!==C){this.trigger("changed",{"action":"model","selected":this._data.core.selected})}t.call(this,true)},_append_json_data:function(s,t,r,u){if(this.element===null){return}s=this.get_node(s);s.children=[];s.children_d=[];if(t.d){t=t.d;if(typeof t==="string"){t=JSON.parse(t)}}if(!g.isArray(t)){t=[t]}var z=null,x={"df":this._model.default_state,"dat":t,"par":s.id,"m":this._model.data,"t_id":this._id,"t_cnt":this._cnt,"sel":this._data.core.selected},q=function(R,A){if(R.data){R=R.data}var M=R.dat,F=R.par,w=[],B=[],G=[],N=R.df,D=R.t_id,E=R.t_cnt,I=R.m,H=I[F],J=R.sel,P,L,K,O,Q=function(Z,T,S){if(!S){S=[]}else{S=S.concat()}if(T){S.unshift(T)}var U=Z.id.toString(),X,V,aa,Y,W={id:U,text:Z.text||"",icon:Z.icon!==A?Z.icon:true,parent:T,parents:S,children:Z.children||[],children_d:Z.children_d||[],data:Z.data,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(X in N){if(N.hasOwnProperty(X)){W.state[X]=N[X]}}if(Z&&Z.data&&Z.data.jstree&&Z.data.jstree.icon){W.icon=Z.data.jstree.icon}if(W.icon===A||W.icon===null||W.icon===""){W.icon=true}if(Z&&Z.data){W.data=Z.data;if(Z.data.jstree){for(X in Z.data.jstree){if(Z.data.jstree.hasOwnProperty(X)){W.state[X]=Z.data.jstree[X]}}}}if(Z&&typeof Z.state==="object"){for(X in Z.state){if(Z.state.hasOwnProperty(X)){W.state[X]=Z.state[X]}}}if(Z&&typeof Z.li_attr==="object"){for(X in Z.li_attr){if(Z.li_attr.hasOwnProperty(X)){W.li_attr[X]=Z.li_attr[X]}}}if(!W.li_attr.id){W.li_attr.id=U}if(Z&&typeof Z.a_attr==="object"){for(X in Z.a_attr){if(Z.a_attr.hasOwnProperty(X)){W.a_attr[X]=Z.a_attr[X]}}}if(Z&&Z.children&&Z.children===true){W.state.loaded=false;W.children=[];W.children_d=[]}I[W.id]=W;for(X=0,V=W.children.length;X<V;X++){aa=Q(I[W.children[X]],W.id,S);Y=I[aa];W.children_d.push(aa);if(Y.children_d.length){W.children_d=W.children_d.concat(Y.children_d)}}delete Z.data;delete Z.children;I[W.id].original=Z;if(W.state.selected){G.push(W.id)}return W.id},C=function(Z,T,S){if(!S){S=[]}else{S=S.concat()}if(T){S.unshift(T)}var U=false,X,V,aa,Y,W;do{U="j"+D+"_"+(++E)}while(I[U]);W={id:false,text:typeof Z==="string"?Z:"",icon:typeof Z==="object"&&Z.icon!==A?Z.icon:true,parent:T,parents:S,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(X in N){if(N.hasOwnProperty(X)){W.state[X]=N[X]}}if(Z&&Z.id){W.id=Z.id.toString()}if(Z&&Z.text){W.text=Z.text}if(Z&&Z.data&&Z.data.jstree&&Z.data.jstree.icon){W.icon=Z.data.jstree.icon}if(W.icon===A||W.icon===null||W.icon===""){W.icon=true}if(Z&&Z.data){W.data=Z.data;if(Z.data.jstree){for(X in Z.data.jstree){if(Z.data.jstree.hasOwnProperty(X)){W.state[X]=Z.data.jstree[X]}}}}if(Z&&typeof Z.state==="object"){for(X in Z.state){if(Z.state.hasOwnProperty(X)){W.state[X]=Z.state[X]}}}if(Z&&typeof Z.li_attr==="object"){for(X in Z.li_attr){if(Z.li_attr.hasOwnProperty(X)){W.li_attr[X]=Z.li_attr[X]}}}if(W.li_attr.id&&!W.id){W.id=W.li_attr.id.toString()}if(!W.id){W.id=U}if(!W.li_attr.id){W.li_attr.id=W.id}if(Z&&typeof Z.a_attr==="object"){for(X in Z.a_attr){if(Z.a_attr.hasOwnProperty(X)){W.a_attr[X]=Z.a_attr[X]}}}if(Z&&Z.children&&Z.children.length){for(X=0,V=Z.children.length;X<V;X++){aa=C(Z.children[X],W.id,S);Y=I[aa];W.children.push(aa);if(Y.children_d.length){W.children_d=W.children_d.concat(Y.children_d)}}W.children_d=W.children_d.concat(W.children)}if(Z&&Z.children&&Z.children===true){W.state.loaded=false;W.children=[];W.children_d=[]}delete Z.data;delete Z.children;W.original=Z;I[W.id]=W;if(W.state.selected){G.push(W.id)}return W.id};if(M.length&&M[0].id!==A&&M[0].parent!==A){for(L=0,K=M.length;L<K;L++){if(!M[L].children){M[L].children=[]}I[M[L].id.toString()]=M[L]}for(L=0,K=M.length;L<K;L++){if(I[M[L].parent.toString()]){I[M[L].parent.toString()].children.push(M[L].id.toString())}else{console.log("IDΪ"+M[L].parent.toString()+"�Ľڵ㲻����!")}H.children_d.push(M[L].id.toString())}for(L=0,K=H.children.length;L<K;L++){P=Q(I[H.children[L]],F,H.parents.concat());
  22. B.push(P);if(I[P].children_d.length){B=B.concat(I[P].children_d)}}for(L=0,K=H.parents.length;L<K;L++){I[H.parents[L]].children_d=I[H.parents[L]].children_d.concat(B)}O={"cnt":E,"mod":I,"sel":J,"par":F,"dpc":B,"add":G}}else{for(L=0,K=M.length;L<K;L++){P=C(M[L],F,H.parents.concat());if(P){w.push(P);B.push(P);if(I[P].children_d.length){B=B.concat(I[P].children_d)}}}H.children=w;H.children_d=B;for(L=0,K=H.parents.length;L<K;L++){I[H.parents[L]].children_d=I[H.parents[L]].children_d.concat(B)}O={"cnt":E,"mod":I,"sel":J,"par":F,"dpc":B,"add":G}}if(typeof window==="undefined"||typeof window.document==="undefined"){postMessage(O)}else{return O}},y=function(B,G){if(this.element===null){return}this._cnt=B.cnt;var D,w=this._model.data;for(D in w){if(w.hasOwnProperty(D)&&w[D].state&&w[D].state.loading&&B.mod[D]){B.mod[D].state.loading=true}}this._model.data=B.mod;if(G){var C,A=B.add,F=B.sel,E=this._data.core.selected.slice();w=this._model.data;if(F.length!==E.length||g.vakata.array_unique(F.concat(E)).length!==F.length){for(D=0,C=F.length;D<C;D++){if(g.inArray(F[D],A)===-1&&g.inArray(F[D],E)===-1){w[F[D]].state.selected=false}}for(D=0,C=E.length;D<C;D++){if(g.inArray(E[D],F)===-1){w[E[D]].state.selected=true}}}}if(B.add.length){this._data.core.selected=this._data.core.selected.concat(B.add)}this.trigger("model",{"nodes":B.dpc,"parent":B.par});if(B.par!==g.jstree.root){this._node_changed(B.par);this.redraw()}else{this.redraw(true)}if(B.add.length){this.trigger("changed",{"action":"model","selected":this._data.core.selected})}r.call(this,true)};if(this.settings.core.worker&&window.Blob&&window.URL&&window.Worker){try{if(this._wrk===null){this._wrk=window.URL.createObjectURL(new window.Blob(["self.onmessage = "+q.toString()],{type:"text/javascript"}))}if(!this._data.core.working||u){this._data.core.working=true;z=new window.Worker(this._wrk);z.onmessage=g.proxy(function(w){y.call(this,w.data,true);try{z.terminate();z=null}catch(A){}if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}},this);if(!x.par){if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}}else{z.postMessage(x)}}else{this._data.core.worker_queue.push([s,t,r,true])}}catch(v){y.call(this,q(x),false);if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}else{this._data.core.working=false}}}else{y.call(this,q(x),false)}},_parse_model_from_html:function(y,r,q){if(!q){q=[]}else{q=[].concat(q)}if(r){q.unshift(r)}var z,x,s=this._model.data,v={id:false,text:false,icon:true,parent:r,parents:q,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false},w,u,t;for(w in this._model.default_state){if(this._model.default_state.hasOwnProperty(w)){v.state[w]=this._model.default_state[w]}}u=g.vakata.attributes(y,true);g.each(u,function(B,A){A=g.trim(A);if(!A.length){return true}v.li_attr[B]=A;if(B==="id"){v.id=A.toString()}});u=y.children("a").first();if(u.length){u=g.vakata.attributes(u,true);g.each(u,function(B,A){A=g.trim(A);if(A.length){v.a_attr[B]=A}})}u=y.children("a").first().length?y.children("a").first().clone():y.clone();u.children("ins, i, ul").remove();u=u.html();u=g("<div />").html(u);v.text=this.settings.core.force_text?u.text():u.html();u=y.data();v.data=u?g.extend(true,{},u):null;v.state.opened=y.hasClass("jstree-open");v.state.selected=y.children("a").hasClass("jstree-clicked");v.state.disabled=y.children("a").hasClass("jstree-disabled");if(v.data&&v.data.jstree){for(w in v.data.jstree){if(v.data.jstree.hasOwnProperty(w)){v.state[w]=v.data.jstree[w]}}}u=y.children("a").children(".jstree-themeicon");if(u.length){v.icon=u.hasClass("jstree-themeicon-hidden")?false:u.attr("rel")}if(v.state.icon!==e){v.icon=v.state.icon}if(v.icon===e||v.icon===null||v.icon===""){v.icon=true}u=y.children("ul").children("li");do{t="j"+this._id+"_"+(++this._cnt)}while(s[t]);v.id=v.li_attr.id?v.li_attr.id.toString():t;if(u.length){u.each(g.proxy(function(B,A){z=this._parse_model_from_html(g(A),v.id,q);x=this._model.data[z];v.children.push(z);if(x.children_d.length){v.children_d=v.children_d.concat(x.children_d)}},this));v.children_d=v.children_d.concat(v.children)}else{if(y.hasClass("jstree-closed")){v.state.loaded=false}}if(v.li_attr["class"]){v.li_attr["class"]=v.li_attr["class"].replace("jstree-closed","").replace("jstree-open","")}if(v.a_attr["class"]){v.a_attr["class"]=v.a_attr["class"].replace("jstree-clicked","").replace("jstree-disabled","")}s[v.id]=v;if(v.state.selected){this._data.core.selected.push(v.id)}return v.id},_parse_model_from_flat_json:function(y,r,q){if(!q){q=[]}else{q=q.concat()}if(r){q.unshift(r)}var t=y.id.toString(),s=this._model.data,A=this._model.default_state,w,u,z,x,v={id:t,text:y.text||"",icon:y.icon!==e?y.icon:true,parent:r,parents:q,children:y.children||[],children_d:y.children_d||[],data:y.data,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};
  23. for(w in A){if(A.hasOwnProperty(w)){v.state[w]=A[w]}}if(y&&y.data&&y.data.jstree&&y.data.jstree.icon){v.icon=y.data.jstree.icon}if(v.icon===e||v.icon===null||v.icon===""){v.icon=true}if(y&&y.data){v.data=y.data;if(y.data.jstree){for(w in y.data.jstree){if(y.data.jstree.hasOwnProperty(w)){v.state[w]=y.data.jstree[w]}}}}if(y&&typeof y.state==="object"){for(w in y.state){if(y.state.hasOwnProperty(w)){v.state[w]=y.state[w]}}}if(y&&typeof y.li_attr==="object"){for(w in y.li_attr){if(y.li_attr.hasOwnProperty(w)){v.li_attr[w]=y.li_attr[w]}}}if(!v.li_attr.id){v.li_attr.id=t}if(y&&typeof y.a_attr==="object"){for(w in y.a_attr){if(y.a_attr.hasOwnProperty(w)){v.a_attr[w]=y.a_attr[w]}}}if(y&&y.children&&y.children===true){v.state.loaded=false;v.children=[];v.children_d=[]}s[v.id]=v;for(w=0,u=v.children.length;w<u;w++){z=this._parse_model_from_flat_json(s[v.children[w]],v.id,q);x=s[z];v.children_d.push(z);if(x.children_d.length){v.children_d=v.children_d.concat(x.children_d)}}delete y.data;delete y.children;s[v.id].original=y;if(v.state.selected){this._data.core.selected.push(v.id)}return v.id},_parse_model_from_json:function(y,r,q){if(!q){q=[]}else{q=q.concat()}if(r){q.unshift(r)}var t=false,w,u,z,x,s=this._model.data,A=this._model.default_state,v;do{t="j"+this._id+"_"+(++this._cnt)}while(s[t]);v={id:false,text:typeof y==="string"?y:"",icon:typeof y==="object"&&y.icon!==e?y.icon:true,parent:r,parents:q,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(w in A){if(A.hasOwnProperty(w)){v.state[w]=A[w]}}if(y&&y.id){v.id=y.id.toString()}if(y&&y.text){v.text=y.text}if(y&&y.data&&y.data.jstree&&y.data.jstree.icon){v.icon=y.data.jstree.icon}if(v.icon===e||v.icon===null||v.icon===""){v.icon=true}if(y&&y.data){v.data=y.data;if(y.data.jstree){for(w in y.data.jstree){if(y.data.jstree.hasOwnProperty(w)){v.state[w]=y.data.jstree[w]}}}}if(y&&typeof y.state==="object"){for(w in y.state){if(y.state.hasOwnProperty(w)){v.state[w]=y.state[w]}}}if(y&&typeof y.li_attr==="object"){for(w in y.li_attr){if(y.li_attr.hasOwnProperty(w)){v.li_attr[w]=y.li_attr[w]}}}if(v.li_attr.id&&!v.id){v.id=v.li_attr.id.toString()}if(!v.id){v.id=t}if(!v.li_attr.id){v.li_attr.id=v.id}if(y&&typeof y.a_attr==="object"){for(w in y.a_attr){if(y.a_attr.hasOwnProperty(w)){v.a_attr[w]=y.a_attr[w]}}}if(y&&y.children&&y.children.length){for(w=0,u=y.children.length;w<u;w++){z=this._parse_model_from_json(y.children[w],v.id,q);x=s[z];v.children.push(z);if(x.children_d.length){v.children_d=v.children_d.concat(x.children_d)}}v.children_d=v.children_d.concat(v.children)}if(y&&y.children&&y.children===true){v.state.loaded=false;v.children=[];v.children_d=[]}delete y.data;delete y.children;v.original=y;s[v.id]=v;if(v.state.selected){this._data.core.selected.push(v.id)}return v.id},_redraw:function(){var q=this._model.force_full_redraw?this._model.data[g.jstree.root].children.concat([]):this._model.changed.concat([]),v=o.createElement("UL"),u,t,s,r=this._data.core.focused;for(t=0,s=q.length;t<s;t++){u=this.redraw_node(q[t],true,this._model.force_full_redraw);if(u&&this._model.force_full_redraw){v.appendChild(u)}}if(this._model.force_full_redraw){v.className=this.get_container_ul()[0].className;v.setAttribute("role","group");this.element.empty().append(v)}if(r!==null){u=this.get_node(r,true);if(u&&u.length&&u.children(".jstree-anchor")[0]!==o.activeElement){u.children(".jstree-anchor").focus()}else{this._data.core.focused=null}}this._model.force_full_redraw=false;this._model.changed=[];this.trigger("redraw",{"nodes":q})},redraw:function(q){if(q){this._model.force_full_redraw=true}this._redraw()},draw_children:function(t){var u=this.get_node(t),s=false,r=false,q=false,v=o;if(!u){return false}if(u.id===g.jstree.root){return this.redraw(true)}t=this.get_node(t,true);if(!t||!t.length){return false}t.children(".jstree-children").remove();t=t[0];if(u.children.length&&u.state.loaded){q=v.createElement("UL");q.setAttribute("role","group");q.className="jstree-children";for(s=0,r=u.children.length;s<r;s++){q.appendChild(this.redraw_node(u.children[s],true,true))}t.appendChild(q)}},redraw_node:function(B,G,r,J){var w=this.get_node(B),A=false,v=false,q=false,H=false,F=false,E=false,L="",K=o,C=this._model.data,I=false,z=false,M=null,x=0,D=0,y=false,u=false;if(!w){return false}if(w.id===g.jstree.root){return this.redraw(true)}G=G||w.children.length===0;B=!o.querySelector?o.getElementById(w.id):this.element[0].querySelector("#"+("0123456789".indexOf(w.id[0])!==-1?"\\3"+w.id[0]+" "+w.id.substr(1).replace(g.jstree.idregex,"\\$&"):w.id.replace(g.jstree.idregex,"\\$&")));if(!B){G=true;if(!r){A=w.parent!==g.jstree.root?g("#"+w.parent.replace(g.jstree.idregex,"\\$&"),this.element)[0]:null;if(A!==null&&(!A||!C[w.parent].state.opened)){return false}v=g.inArray(w.id,A===null?C[g.jstree.root].children:C[w.parent].children)}}else{B=g(B);if(!r){A=B.parent().parent()[0];if(A===this.element[0]){A=null}v=B.index()}if(!G&&w.children.length&&!B.children(".jstree-children").length){G=true
  24. }if(!G){q=B.children(".jstree-children")[0]}I=B.children(".jstree-anchor")[0]===o.activeElement;B.remove()}B=this._data.core.node.cloneNode(true);L="jstree-node ";for(H in w.li_attr){if(w.li_attr.hasOwnProperty(H)){if(H==="id"){continue}if(H!=="class"){B.setAttribute(H,w.li_attr[H])}else{L+=w.li_attr[H]}}}if(!w.a_attr.id){w.a_attr.id=w.id+"_anchor"}B.setAttribute("aria-selected",!!w.state.selected);B.setAttribute("aria-level",w.parents.length);B.setAttribute("aria-labelledby",w.a_attr.id);if(w.state.disabled){B.setAttribute("aria-disabled",true)}for(H=0,F=w.children.length;H<F;H++){if(!C[w.children[H]].state.hidden){y=true;break}}if(w.parent!==null&&C[w.parent]&&!w.state.hidden){H=g.inArray(w.id,C[w.parent].children);u=w.id;if(H!==-1){H++;for(F=C[w.parent].children.length;H<F;H++){if(!C[C[w.parent].children[H]].state.hidden){u=C[w.parent].children[H]}if(u!==w.id){break}}}}if(w.state.hidden){L+=" jstree-hidden"}if(w.state.loaded&&!y){L+=" jstree-leaf"}else{L+=w.state.opened&&w.state.loaded?" jstree-open":" jstree-closed";B.setAttribute("aria-expanded",(w.state.opened&&w.state.loaded))}if(u===w.id){L+=" jstree-last"}B.id=w.id;B.className=L;L=(w.state.selected?" jstree-clicked":"")+(w.state.disabled?" jstree-disabled":"");for(F in w.a_attr){if(w.a_attr.hasOwnProperty(F)){if(F==="href"&&w.a_attr[F]==="#"){continue}if(F!=="class"){B.childNodes[1].setAttribute(F,w.a_attr[F])}else{L+=" "+w.a_attr[F]}}}if(L.length){B.childNodes[1].className="jstree-anchor "+L}if((w.icon&&w.icon!==true)||w.icon===false){if(w.icon===false){B.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden"}else{if(w.icon.indexOf("/")===-1&&w.icon.indexOf(".")===-1){B.childNodes[1].childNodes[0].className+=" "+w.icon+" jstree-themeicon-custom"}else{B.childNodes[1].childNodes[0].style.backgroundImage='url("'+w.icon+'")';B.childNodes[1].childNodes[0].style.backgroundPosition="center center";B.childNodes[1].childNodes[0].style.backgroundSize="auto";B.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom"}}}if(this.settings.core.force_text){B.childNodes[1].appendChild(K.createTextNode(w.text))}else{B.childNodes[1].innerHTML+=w.text}if(G&&w.children.length&&(w.state.opened||J)&&w.state.loaded){E=K.createElement("UL");E.setAttribute("role","group");E.className="jstree-children";for(H=0,F=w.children.length;H<F;H++){E.appendChild(this.redraw_node(w.children[H],G,true))}B.appendChild(E)}if(q){B.appendChild(q)}if(!r){if(!A){A=this.element[0]}for(H=0,F=A.childNodes.length;H<F;H++){if(A.childNodes[H]&&A.childNodes[H].className&&A.childNodes[H].className.indexOf("jstree-children")!==-1){M=A.childNodes[H];break}}if(!M){M=K.createElement("UL");M.setAttribute("role","group");M.className="jstree-children";A.appendChild(M)}A=M;if(v<A.childNodes.length){A.insertBefore(B,A.childNodes[v])}else{A.appendChild(B)}if(I){x=this.element[0].scrollTop;D=this.element[0].scrollLeft;B.childNodes[1].focus();this.element[0].scrollTop=x;this.element[0].scrollLeft=D}}if(w.state.opened&&!w.state.loaded){w.state.opened=false;setTimeout(g.proxy(function(){this.open_node(w.id,false,0)},this),0)}return B},open_node:function(v,x,u){var s,r,w,q;if(g.isArray(v)){v=v.slice();for(s=0,r=v.length;s<r;s++){this.open_node(v[s],x,u)}return true}v=this.get_node(v);if(!v||v.id===g.jstree.root){return false}u=u===e?this.settings.core.animation:u;if(!this.is_closed(v)){if(x){x.call(this,v,false)}return false}if(!this.is_loaded(v)){if(this.is_loading(v)){return setTimeout(g.proxy(function(){this.open_node(v,x,u)},this),500)}this.load_node(v,function(y,t){return t?this.open_node(y,x,u):(x?x.call(this,y,false):false)})}else{w=this.get_node(v,true);q=this;if(w.length){if(u&&w.children(".jstree-children").length){w.children(".jstree-children").stop(true,true)}if(v.children.length&&!this._firstChild(w.children(".jstree-children")[0])){this.draw_children(v)}if(!u){this.trigger("before_open",{"node":v});w[0].className=w[0].className.replace("jstree-closed","jstree-open");w[0].setAttribute("aria-expanded",true)}else{this.trigger("before_open",{"node":v});w.children(".jstree-children").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",true).children(".jstree-children").stop(true,true).slideDown(u,function(){this.style.display="";if(q.element){q.trigger("after_open",{"node":v})}})}}v.state.opened=true;if(x){x.call(this,v,true)}if(!w.length){this.trigger("before_open",{"node":v})}this.trigger("open_node",{"node":v});if(!u||!w.length){this.trigger("after_open",{"node":v})}return true}},_open_to:function(t){t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}var r,q,s=t.parents;for(r=0,q=s.length;r<q;r+=1){if(r!==g.jstree.root){this.open_node(s[r],false,0)}}return g("#"+t.id.replace(g.jstree.idregex,"\\$&"),this.element)},close_node:function(v,u){var s,r,q,w;if(g.isArray(v)){v=v.slice();for(s=0,r=v.length;s<r;s++){this.close_node(v[s],u)}return true}v=this.get_node(v);if(!v||v.id===g.jstree.root){return false}if(this.is_closed(v)){return false
  25. }u=u===e?this.settings.core.animation:u;q=this;w=this.get_node(v,true);v.state.opened=false;this.trigger("close_node",{"node":v});if(!w.length){this.trigger("after_close",{"node":v})}else{if(!u){w[0].className=w[0].className.replace("jstree-open","jstree-closed");w.attr("aria-expanded",false).children(".jstree-children").remove();this.trigger("after_close",{"node":v})}else{w.children(".jstree-children").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded",false).children(".jstree-children").stop(true,true).slideUp(u,function(){this.style.display="";w.children(".jstree-children").remove();if(q.element){q.trigger("after_close",{"node":v})}})}}},toggle_node:function(s){var r,q;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.toggle_node(s[r])}return true}if(this.is_closed(s)){return this.open_node(s)}if(this.is_open(s)){return this.close_node(s)}},open_all:function(u,t,q){if(!u){u=g.jstree.root}u=this.get_node(u);if(!u){return false}var v=u.id===g.jstree.root?this.get_container_ul():this.get_node(u,true),s,r,w;if(!v.length){for(s=0,r=u.children_d.length;s<r;s++){if(this.is_closed(this._model.data[u.children_d[s]])){this._model.data[u.children_d[s]].state.opened=true}}return this.trigger("open_all",{"node":u})}q=q||v;w=this;v=this.is_closed(u)?v.find(".jstree-closed").addBack():v.find(".jstree-closed");v.each(function(){w.open_node(this,function(y,x){if(x&&this.is_parent(y)){this.open_all(y,t,q)}},t||0)});if(q.find(".jstree-closed").length===0){this.trigger("open_all",{"node":this.get_node(q)})}},close_all:function(t,s){if(!t){t=g.jstree.root}t=this.get_node(t);if(!t){return false}var u=t.id===g.jstree.root?this.get_container_ul():this.get_node(t,true),v=this,r,q;if(u.length){u=this.is_open(t)?u.find(".jstree-open").addBack():u.find(".jstree-open");g(u.get().reverse()).each(function(){v.close_node(this,s||0)})}for(r=0,q=t.children_d.length;r<q;r++){this._model.data[t.children_d[r]].state.opened=false}this.trigger("close_all",{"node":t})},is_disabled:function(q){q=this.get_node(q);return q&&q.state&&q.state.disabled},enable_node:function(s){var r,q;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.enable_node(s[r])}return true}s=this.get_node(s);if(!s||s.id===g.jstree.root){return false}s.state.disabled=false;this.get_node(s,true).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled",false);this.trigger("enable_node",{"node":s})},disable_node:function(s){var r,q;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.disable_node(s[r])}return true}s=this.get_node(s);if(!s||s.id===g.jstree.root){return false}s.state.disabled=true;this.get_node(s,true).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled",true);this.trigger("disable_node",{"node":s})},is_hidden:function(q){q=this.get_node(q);return q.state.hidden===true},hide_node:function(t,s){var r,q;if(g.isArray(t)){t=t.slice();for(r=0,q=t.length;r<q;r++){this.hide_node(t[r],true)}if(!s){this.redraw()}return true}t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}if(!t.state.hidden){t.state.hidden=true;this._node_changed(t.parent);if(!s){this.redraw()}this.trigger("hide_node",{"node":t})}},show_node:function(t,s){var r,q;if(g.isArray(t)){t=t.slice();for(r=0,q=t.length;r<q;r++){this.show_node(t[r],true)}if(!s){this.redraw()}return true}t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}if(t.state.hidden){t.state.hidden=false;this._node_changed(t.parent);if(!s){this.redraw()}this.trigger("show_node",{"node":t})}},hide_all:function(t){var r,q=this._model.data,s=[];for(r in q){if(q.hasOwnProperty(r)&&r!==g.jstree.root&&!q[r].state.hidden){q[r].state.hidden=true;s.push(r)}}this._model.force_full_redraw=true;if(!t){this.redraw()}this.trigger("hide_all",{"nodes":s});return s},show_all:function(t){var r,q=this._model.data,s=[];for(r in q){if(q.hasOwnProperty(r)&&r!==g.jstree.root&&q[r].state.hidden){q[r].state.hidden=false;s.push(r)}}this._model.force_full_redraw=true;if(!t){this.redraw()}this.trigger("show_all",{"nodes":s});return s},activate_node:function(v,u){if(this.is_disabled(v)){return false}if(!u||typeof u!=="object"){u={}}this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==e?this.get_node(this._data.core.last_clicked.id):null;if(this._data.core.last_clicked&&!this._data.core.last_clicked.state.selected){this._data.core.last_clicked=null}if(!this._data.core.last_clicked&&this._data.core.selected.length){this._data.core.last_clicked=this.get_node(this._data.core.selected[this._data.core.selected.length-1])}if(!this.settings.core.multiple||(!u.metaKey&&!u.ctrlKey&&!u.shiftKey)||(u.shiftKey&&(!this._data.core.last_clicked||!this.get_parent(v)||this.get_parent(v)!==this._data.core.last_clicked.parent))){if(!this.settings.core.multiple&&(u.metaKey||u.ctrlKey||u.shiftKey)&&this.is_selected(v)){this.deselect_node(v,false,u)}else{this.deselect_all(true);this.select_node(v,false,false,u);
  26. this._data.core.last_clicked=this.get_node(v)}}else{if(u.shiftKey){var w=this.get_node(v).id,q=this._data.core.last_clicked.id,t=this.get_node(this._data.core.last_clicked.parent).children,x=false,s,r;for(s=0,r=t.length;s<r;s+=1){if(t[s]===w){x=!x}if(t[s]===q){x=!x}if(!this.is_disabled(t[s])&&(x||t[s]===w||t[s]===q)){if(!this.is_hidden(t[s])){this.select_node(t[s],true,false,u)}}else{this.deselect_node(t[s],true,u)}}this.trigger("changed",{"action":"select_node","node":this.get_node(v),"selected":this._data.core.selected,"event":u})}else{if(!this.is_selected(v)){this.select_node(v,false,false,u)}else{this.deselect_node(v,false,u)}}}this.trigger("activate_node",{"node":this.get_node(v),"event":u})},hover_node:function(r){r=this.get_node(r,true);if(!r||!r.length||r.children(".jstree-hovered").length){return false}var s=this.element.find(".jstree-hovered"),q=this.element;if(s&&s.length){this.dehover_node(s)}r.children(".jstree-anchor").addClass("jstree-hovered");this.trigger("hover_node",{"node":this.get_node(r)});setTimeout(function(){q.attr("aria-activedescendant",r[0].id)},0)},dehover_node:function(q){q=this.get_node(q,true);if(!q||!q.length||!q.children(".jstree-hovered").length){return false}q.children(".jstree-anchor").removeClass("jstree-hovered");this.trigger("dehover_node",{"node":this.get_node(q)})},select_node:function(v,x,q,u){var w,t,r,s;if(g.isArray(v)){v=v.slice();for(t=0,r=v.length;t<r;t++){this.select_node(v[t],x,q,u)}return true}v=this.get_node(v);if(!v||v.id===g.jstree.root){return false}w=this.get_node(v,true);if(!v.state.selected){v.state.selected=true;this._data.core.selected.push(v.id);if(!q){w=this._open_to(v)}if(w&&w.length){w.attr("aria-selected",true).children(".jstree-anchor").addClass("jstree-clicked")}this.trigger("select_node",{"node":v,"selected":this._data.core.selected,"event":u});if(!x){this.trigger("changed",{"action":"select_node","node":v,"selected":this._data.core.selected,"event":u})}}},deselect_node:function(t,v,s){var r,q,u;if(g.isArray(t)){t=t.slice();for(r=0,q=t.length;r<q;r++){this.deselect_node(t[r],v,s)}return true}t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}u=this.get_node(t,true);if(t.state.selected){t.state.selected=false;this._data.core.selected=g.vakata.array_remove_item(this._data.core.selected,t.id);if(u.length){u.attr("aria-selected",false).children(".jstree-anchor").removeClass("jstree-clicked")}this.trigger("deselect_node",{"node":t,"selected":this._data.core.selected,"event":s});if(!v){this.trigger("changed",{"action":"deselect_node","node":t,"selected":this._data.core.selected,"event":s})}}},select_all:function(t){var s=this._data.core.selected.concat([]),r,q;this._data.core.selected=this._model.data[g.jstree.root].children_d.concat();for(r=0,q=this._data.core.selected.length;r<q;r++){if(this._model.data[this._data.core.selected[r]]){this._model.data[this._data.core.selected[r]].state.selected=true}}this.redraw(true);this.trigger("select_all",{"selected":this._data.core.selected});if(!t){this.trigger("changed",{"action":"select_all","selected":this._data.core.selected,"old_selection":s})}},deselect_all:function(t){var s=this._data.core.selected.concat([]),r,q;for(r=0,q=this._data.core.selected.length;r<q;r++){if(this._model.data[this._data.core.selected[r]]){this._model.data[this._data.core.selected[r]].state.selected=false}}this._data.core.selected=[];this.element.find(".jstree-clicked").removeClass("jstree-clicked").parent().attr("aria-selected",false);this.trigger("deselect_all",{"selected":this._data.core.selected,"node":s});if(!t){this.trigger("changed",{"action":"deselect_all","selected":this._data.core.selected,"old_selection":s})}},is_selected:function(q){q=this.get_node(q);if(!q||q.id===g.jstree.root){return false}return q.state.selected},get_selected:function(q){return q?g.map(this._data.core.selected,g.proxy(function(r){return this.get_node(r)},this)):this._data.core.selected.slice()},get_top_selected:function(v){var u=this.get_selected(true),w={},t,s,r,q;for(t=0,s=u.length;t<s;t++){w[u[t].id]=u[t]}for(t=0,s=u.length;t<s;t++){for(r=0,q=u[t].children_d.length;r<q;r++){if(w[u[t].children_d[r]]){delete w[u[t].children_d[r]]}}}u=[];for(t in w){if(w.hasOwnProperty(t)){u.push(t)}}return v?g.map(u,g.proxy(function(x){return this.get_node(x)},this)):u},get_bottom_selected:function(t){var s=this.get_selected(true),u=[],r,q;for(r=0,q=s.length;r<q;r++){if(!s[r].children.length){u.push(s[r].id)}}return t?g.map(u,g.proxy(function(v){return this.get_node(v)},this)):u},get_state:function(){var r={"core":{"open":[],"scroll":{"left":this.element.scrollLeft(),"top":this.element.scrollTop()},
  27. "selected":[]}},q;for(q in this._model.data){if(this._model.data.hasOwnProperty(q)){if(q!==g.jstree.root){if(this._model.data[q].state.opened){r.core.open.push(q)}if(this._model.data[q].state.selected){r.core.selected.push(q)
  28. }}}}return r},set_state:function(u,x){if(u){if(u.core){var s,w,r,v,q;if(u.core.open){if(!g.isArray(u.core.open)||!u.core.open.length){delete u.core.open;this.set_state(u,x)}else{this._load_nodes(u.core.open,function(t){this.open_node(t,false,0);delete u.core.open;this.set_state(u,x)})}return false}if(u.core.scroll){if(u.core.scroll&&u.core.scroll.left!==e){this.element.scrollLeft(u.core.scroll.left)}if(u.core.scroll&&u.core.scroll.top!==e){this.element.scrollTop(u.core.scroll.top)}delete u.core.scroll;this.set_state(u,x);return false}if(u.core.selected){v=this;this.deselect_all();g.each(u.core.selected,function(y,t){v.select_node(t,false,true)});delete u.core.selected;this.set_state(u,x);return false}for(q in u){if(u.hasOwnProperty(q)&&q!=="core"&&g.inArray(q,this.settings.plugins)===-1){delete u[q]}}if(g.isEmptyObject(u.core)){delete u.core;this.set_state(u,x);return false}}if(g.isEmptyObject(u)){u=null;if(x){x.call(this)}this.trigger("set_state");return false}return true}return false},refresh:function(r,q){this._data.core.state=q===true?{}:this.get_state();if(q&&g.isFunction(q)){this._data.core.state=q.call(this,this._data.core.state)}this._cnt=0;this._model.data={};this._model.data[g.jstree.root]={id:g.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:false}};this._data.core.selected=[];this._data.core.last_clicked=null;this._data.core.focused=null;var s=this.get_container_ul()[0].className;if(!r){this.element.html("<"+"ul class='"+s+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>");this.element.attr("aria-activedescendant","j"+this._id+"_loading")}this.load_node(g.jstree.root,function(u,t){if(t){this.get_container_ul()[0].className=s;if(this._firstChild(this.get_container_ul()[0])){this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id)}this.set_state(g.extend(true,{},this._data.core.state),function(){this.trigger("refresh")})}this._data.core.state=null})},refresh_node:function(t){t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}var u=[],q=[],r=this._data.core.selected.concat([]);q.push(t.id);if(t.state.opened===true){u.push(t.id)}this.get_node(t,true).find(".jstree-open").each(function(){q.push(this.id);u.push(this.id)});this._load_nodes(q,g.proxy(function(s){this.open_node(u,false,0);this.select_node(r);this.trigger("refresh_node",{"node":t,"nodes":s})},this),false,true)},set_id:function(u,v){u=this.get_node(u);if(!u||u.id===g.jstree.root){return false}var t,s,q=this._model.data,r=u.id;v=v.toString();q[u.parent].children[g.inArray(u.id,q[u.parent].children)]=v;for(t=0,s=u.parents.length;t<s;t++){q[u.parents[t]].children_d[g.inArray(u.id,q[u.parents[t]].children_d)]=v}for(t=0,s=u.children.length;t<s;t++){q[u.children[t]].parent=v}for(t=0,s=u.children_d.length;t<s;t++){q[u.children_d[t]].parents[g.inArray(u.id,q[u.children_d[t]].parents)]=v}t=g.inArray(u.id,this._data.core.selected);if(t!==-1){this._data.core.selected[t]=v}t=this.get_node(u.id,true);if(t){t.attr("id",v);if(this.element.attr("aria-activedescendant")===u.id){this.element.attr("aria-activedescendant",v)}}delete q[u.id];u.id=v;u.li_attr.id=v;q[v]=u;this.trigger("set_id",{"node":u,"new":u.id,"old":r});return true},get_text:function(q){q=this.get_node(q);return(!q||q.id===g.jstree.root)?false:q.text},set_text:function(s,t){var r,q;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.set_text(s[r],t)}return true}s=this.get_node(s);if(!s||s.id===g.jstree.root){return false}s.text=t;if(this.get_node(s,true).length){this.redraw_node(s.id)}this.trigger("set_text",{"obj":s,"text":t});return true},get_json:function(u,r,v){u=this.get_node(u||g.jstree.root);if(!u){return false}if(r&&r.flat&&!v){v=[]}var t={"id":u.id,"text":u.text,"icon":this.get_icon(u),"li_attr":g.extend(true,{},u.li_attr),"a_attr":g.extend(true,{},u.a_attr),"state":{},"data":r&&r.no_data?false:g.extend(true,{},u.data)},s,q;if(r&&r.flat){t.parent=u.parent}else{t.children=[]}if(!r||!r.no_state){for(s in u.state){if(u.state.hasOwnProperty(s)){t.state[s]=u.state[s]}}}else{delete t.state}if(r&&r.no_li_attr){delete t.li_attr}if(r&&r.no_a_attr){delete t.a_attr}if(r&&r.no_id){delete t.id;if(t.li_attr&&t.li_attr.id){delete t.li_attr.id}if(t.a_attr&&t.a_attr.id){delete t.a_attr.id}}if(r&&r.flat&&u.id!==g.jstree.root){v.push(t)}if(!r||!r.no_children){for(s=0,q=u.children.length;s<q;s++){if(r&&r.flat){this.get_json(u.children[s],r,v)}else{t.children.push(this.get_json(u.children[s],r))}}}return r&&r.flat?v:(u.id===g.jstree.root?t.children:t)},create_node:function(v,q,x,y,w){if(v===null){v=g.jstree.root}v=this.get_node(v);if(!v){return false}x=x===e?"last":x;if(!x.toString().match(/^(before|after)$/)&&!w&&!this.is_loaded(v)){return this.load_node(v,function(){this.create_node(v,q,x,y,true)
  29. })}if(!q){q={"text":this.get_string("New node")}}if(typeof q==="string"){q={"text":q}}if(q.text===e){q.text=this.get_string("New node")}var s,u,t,r;if(v.id===g.jstree.root){if(x==="before"){x="first"}if(x==="after"){x="last"}}switch(x){case"before":s=this.get_node(v.parent);x=g.inArray(v.id,s.children);v=s;break;case"after":s=this.get_node(v.parent);x=g.inArray(v.id,s.children)+1;v=s;break;case"inside":case"first":x=0;break;case"last":x=v.children.length;break;default:if(!x){x=0}break}if(x>v.children.length){x=v.children.length}if(!q.id){q.id=true}if(!this.check("create_node",q,v,x)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(q.id===true){delete q.id}q=this._parse_model_from_json(q,v.id,v.parents.concat());if(!q){return false}s=this.get_node(q);u=[];u.push(q);u=u.concat(s.children_d);this.trigger("model",{"nodes":u,"parent":v.id});v.children_d=v.children_d.concat(u);for(t=0,r=v.parents.length;t<r;t++){this._model.data[v.parents[t]].children_d=this._model.data[v.parents[t]].children_d.concat(u)}q=s;s=[];for(t=0,r=v.children.length;t<r;t++){s[t>=x?t+1:t]=v.children[t]}s[x]=q.id;v.children=s;this.redraw_node(v,true);if(y){y.call(this,this.get_node(q))}this.trigger("create_node",{"node":this.get_node(q),"parent":v.id,"position":x});return q.id},rename_node:function(t,u){var s,r,q;if(g.isArray(t)){t=t.slice();for(s=0,r=t.length;s<r;s++){this.rename_node(t[s],u)}return true}t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}q=t.text;if(!this.check("rename_node",t,this.get_parent(t),u)){this.settings.core.error.call(this,this._data.core.last_error);return false}this.set_text(t,u);this.trigger("rename_node",{"node":t,"text":u,"old":q});return true},delete_node:function(t){var x,w,y,B,u,v,s,r,q,z,A,C;if(g.isArray(t)){t=t.slice();for(x=0,w=t.length;x<w;x++){this.delete_node(t[x])}return true}t=this.get_node(t);if(!t||t.id===g.jstree.root){return false}y=this.get_node(t.parent);B=g.inArray(t.id,y.children);z=false;if(!this.check("delete_node",t,y,B)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(B!==-1){y.children=g.vakata.array_remove(y.children,B)}u=t.children_d.concat([]);u.push(t.id);for(v=0,s=t.parents.length;v<s;v++){this._model.data[t.parents[v]].children_d=g.vakata.array_filter(this._model.data[t.parents[v]].children_d,function(D){return g.inArray(D,u)===-1})}for(r=0,q=u.length;r<q;r++){if(this._model.data[u[r]].state.selected){z=true;break}}if(z){this._data.core.selected=g.vakata.array_filter(this._data.core.selected,function(D){return g.inArray(D,u)===-1})}this.trigger("delete_node",{"node":t,"parent":y.id});if(z){this.trigger("changed",{"action":"delete_node","node":t,"selected":this._data.core.selected,"parent":y.id})}for(r=0,q=u.length;r<q;r++){delete this._model.data[u[r]]}if(g.inArray(this._data.core.focused,u)!==-1){this._data.core.focused=null;A=this.element[0].scrollTop;C=this.element[0].scrollLeft;if(y.id===g.jstree.root){if(this._model.data[g.jstree.root].children[0]){this.get_node(this._model.data[g.jstree.root].children[0],true).children(".jstree-anchor").focus()}}else{this.get_node(y,true).children(".jstree-anchor").focus()}this.element[0].scrollTop=A;this.element[0].scrollLeft=C}this.redraw_node(y,true);return true},check:function(q,u,t,w,s){u=u&&u.id?u:this.get_node(u);t=t&&t.id?t:this.get_node(t);var r=q.match(/^move_node|copy_node|create_node$/i)?t:u,v=this.settings.core.check_callback;if(q==="move_node"||q==="copy_node"){if((!s||!s.is_multi)&&(u.id===t.id||(q==="move_node"&&g.inArray(u.id,t.children)===w)||g.inArray(t.id,u.children_d)!==-1)){this._data.core.last_error={"error":"check","plugin":"core","id":"core_01","reason":"Moving parent inside child","data":JSON.stringify({"chk":q,"pos":w,"obj":u&&u.id?u.id:false,"par":t&&t.id?t.id:false})};return false}}if(r&&r.data){r=r.data}if(r&&r.functions&&(r.functions[q]===false||r.functions[q]===true)){if(r.functions[q]===false){this._data.core.last_error={"error":"check","plugin":"core","id":"core_02","reason":"Node data prevents function: "+q,"data":JSON.stringify({"chk":q,"pos":w,"obj":u&&u.id?u.id:false,"par":t&&t.id?t.id:false})}}return r.functions[q]}if(v===false||(g.isFunction(v)&&v.call(this,q,u,t,w,s)===false)||(v&&v[q]===false)){this._data.core.last_error={"error":"check","plugin":"core","id":"core_03","reason":"User config for core.check_callback prevents function: "+q,"data":JSON.stringify({"chk":q,"pos":w,"obj":u&&u.id?u.id:false,"par":t&&t.id?t.id:false})};return false}return true},last_error:function(){return this._data.core.last_error},move_node:function(y,A,t,r,z,G,J){var w,v,x,q,I,K,s,u,H,F,E,D,C,B;A=this.get_node(A);t=t===e?0:t;if(!A){return false}if(!t.toString().match(/^(before|after)$/)&&!z&&!this.is_loaded(A)){return this.load_node(A,function(){this.move_node(y,A,t,r,true,false,J)})}if(g.isArray(y)){if(y.length===1){y=y[0]}else{for(w=0,v=y.length;w<v;w++){if((H=this.move_node(y[w],A,t,r,z,false,J))){A=H;t="after"}}this.redraw();return true}}y=y&&y.id?y:this.get_node(y);
  30. if(!y||y.id===g.jstree.root){return false}x=(y.parent||g.jstree.root).toString();I=(!t.toString().match(/^(before|after)$/)||A.id===g.jstree.root)?A:this.get_node(A.parent);K=J?J:(this._model.data[y.id]?this:g.jstree.reference(y.id));s=!K||!K._id||(this._id!==K._id);q=K&&K._id&&x&&K._model.data[x]&&K._model.data[x].children?g.inArray(y.id,K._model.data[x].children):-1;if(K&&K._id){y=K._model.data[y.id]}if(s){if((H=this.copy_node(y,A,t,r,z,false,J))){if(K){K.delete_node(y)}return H}return false}if(A.id===g.jstree.root){if(t==="before"){t="first"}if(t==="after"){t="last"}}switch(t){case"before":t=g.inArray(A.id,I.children);break;case"after":t=g.inArray(A.id,I.children)+1;break;case"inside":case"first":t=0;break;case"last":t=I.children.length;break;default:if(!t){t=0}break}if(t>I.children.length){t=I.children.length}if(!this.check("move_node",y,I,t,{"core":true,"origin":J,"is_multi":(K&&K._id&&K._id!==this._id),"is_foreign":(!K||!K._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}if(y.parent===I.id){u=I.children.concat();H=g.inArray(y.id,u);if(H!==-1){u=g.vakata.array_remove(u,H);if(t>H){t--}}H=[];for(F=0,E=u.length;F<E;F++){H[F>=t?F+1:F]=u[F]}H[t]=y.id;I.children=H;this._node_changed(I.id);this.redraw(I.id===g.jstree.root)}else{H=y.children_d.concat();H.push(y.id);for(F=0,E=y.parents.length;F<E;F++){u=[];B=K._model.data[y.parents[F]].children_d;for(D=0,C=B.length;D<C;D++){if(g.inArray(B[D],H)===-1){u.push(B[D])}}K._model.data[y.parents[F]].children_d=u}K._model.data[x].children=g.vakata.array_remove_item(K._model.data[x].children,y.id);for(F=0,E=I.parents.length;F<E;F++){this._model.data[I.parents[F]].children_d=this._model.data[I.parents[F]].children_d.concat(H)}u=[];for(F=0,E=I.children.length;F<E;F++){u[F>=t?F+1:F]=I.children[F]}u[t]=y.id;I.children=u;I.children_d.push(y.id);I.children_d=I.children_d.concat(y.children_d);y.parent=I.id;H=I.parents.concat();H.unshift(I.id);B=y.parents.length;y.parents=H;H=H.concat();for(F=0,E=y.children_d.length;F<E;F++){this._model.data[y.children_d[F]].parents=this._model.data[y.children_d[F]].parents.slice(0,B*-1);Array.prototype.push.apply(this._model.data[y.children_d[F]].parents,H)}if(x===g.jstree.root||I.id===g.jstree.root){this._model.force_full_redraw=true}if(!this._model.force_full_redraw){this._node_changed(x);this._node_changed(I.id)}if(!G){this.redraw()}}if(r){r.call(this,y,I,t)}this.trigger("move_node",{"node":y,"parent":I.id,"position":t,"old_parent":x,"old_position":q,"is_multi":(K&&K._id&&K._id!==this._id),"is_foreign":(!K||!K._id),"old_instance":K,"new_instance":this});return y.id},copy_node:function(x,z,s,r,y,D,G){var v,u,t,E,C,B,A,w,F,H,q;z=this.get_node(z);s=s===e?0:s;if(!z){return false}if(!s.toString().match(/^(before|after)$/)&&!y&&!this.is_loaded(z)){return this.load_node(z,function(){this.copy_node(x,z,s,r,true,false,G)})}if(g.isArray(x)){if(x.length===1){x=x[0]}else{for(v=0,u=x.length;v<u;v++){if((E=this.copy_node(x[v],z,s,r,y,true,G))){z=E;s="after"}}this.redraw();return true}}x=x&&x.id?x:this.get_node(x);if(!x||x.id===g.jstree.root){return false}w=(x.parent||g.jstree.root).toString();F=(!s.toString().match(/^(before|after)$/)||z.id===g.jstree.root)?z:this.get_node(z.parent);H=G?G:(this._model.data[x.id]?this:g.jstree.reference(x.id));q=!H||!H._id||(this._id!==H._id);if(H&&H._id){x=H._model.data[x.id]}if(z.id===g.jstree.root){if(s==="before"){s="first"}if(s==="after"){s="last"}}switch(s){case"before":s=g.inArray(z.id,F.children);break;case"after":s=g.inArray(z.id,F.children)+1;break;case"inside":case"first":s=0;break;case"last":s=F.children.length;break;default:if(!s){s=0}break}if(s>F.children.length){s=F.children.length}if(!this.check("copy_node",x,F,s,{"core":true,"origin":G,"is_multi":(H&&H._id&&H._id!==this._id),"is_foreign":(!H||!H._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}A=H?H.get_json(x,{no_id:true,no_data:true,no_state:true}):x;if(!A){return false}if(A.id===true){delete A.id}A=this._parse_model_from_json(A,F.id,F.parents.concat());if(!A){return false}E=this.get_node(A);if(x&&x.state&&x.state.loaded===false){E.state.loaded=false}t=[];t.push(A);t=t.concat(E.children_d);this.trigger("model",{"nodes":t,"parent":F.id});for(C=0,B=F.parents.length;C<B;C++){this._model.data[F.parents[C]].children_d=this._model.data[F.parents[C]].children_d.concat(t)}t=[];for(C=0,B=F.children.length;C<B;C++){t[C>=s?C+1:C]=F.children[C]}t[s]=E.id;F.children=t;F.children_d.push(E.id);F.children_d=F.children_d.concat(E.children_d);if(F.id===g.jstree.root){this._model.force_full_redraw=true}if(!this._model.force_full_redraw){this._node_changed(F.id)}if(!D){this.redraw(F.id===g.jstree.root)}if(r){r.call(this,E,F,s)}this.trigger("copy_node",{"node":E,"original":x,"parent":F.id,"position":s,"old_parent":w,"old_position":H&&H._id&&w&&H._model.data[w]&&H._model.data[w].children?g.inArray(x.id,H._model.data[w].children):-1,"is_multi":(H&&H._id&&H._id!==this._id),"is_foreign":(!H||!H._id),"old_instance":H,"new_instance":this});
  31. return E.id},cut:function(t){if(!t){t=this._data.core.selected.concat()}if(!g.isArray(t)){t=[t]}if(!t.length){return false}var q=[],u,s,r;for(s=0,r=t.length;s<r;s++){u=this.get_node(t[s]);if(u&&u.id&&u.id!==g.jstree.root){q.push(u)}}if(!q.length){return false}d=q;h=this;j="move_node";this.trigger("cut",{"node":t})},copy:function(t){if(!t){t=this._data.core.selected.concat()}if(!g.isArray(t)){t=[t]}if(!t.length){return false}var q=[],u,s,r;for(s=0,r=t.length;s<r;s++){u=this.get_node(t[s]);if(u&&u.id&&u.id!==g.jstree.root){q.push(u)}}if(!q.length){return false}d=q;h=this;j="copy_node";this.trigger("copy",{"node":t})},get_buffer:function(){return{"mode":j,"node":d,"inst":h}},can_paste:function(){return j!==false&&d!==false},paste:function(q,r){q=this.get_node(q);if(!q||!j||!j.match(/^(copy_node|move_node)$/)||!d){return false}if(this[j](d,q,r,false,false,false,h)){this.trigger("paste",{"parent":q.id,"node":d,"mode":j})}d=false;j=false;h=false},clear_buffer:function(){d=false;j=false;h=false;this.trigger("clear_buffer")},edit:function(r,z,C){var y,B,A,F,E,v,u,x,q,D=false;r=this.get_node(r);if(!r){return false}if(this.settings.core.check_callback===false){this._data.core.last_error={"error":"check","plugin":"core","id":"core_07","reason":"Could not edit node because of check_callback"};this.settings.core.error.call(this,this._data.core.last_error);return false}q=r;z=typeof z==="string"?z:r.text;this.set_text(r,"");r=this._open_to(r);q.text=z;y=this._data.core.rtl;B=this.element.width();this._data.core.focused=q.id;A=r.children(".jstree-anchor").focus();F=g("<span>");
  32. E=z;v=g("<"+"div />",{css:{"position":"absolute","top":"-200px","left":(y?"0px":"-1000px"),"visibility":"hidden"}}).appendTo("body");u=g("<"+"input />",{"value":E,"class":"jstree-rename-input","css":{"padding":"0","border":"1px solid silver","box-sizing":"border-box","display":"inline-block","height":(this._data.core.li_height)+"px","lineHeight":(this._data.core.li_height)+"px","width":"150px"},"blur":g.proxy(function(H){H.stopImmediatePropagation();H.preventDefault();var w=F.children(".jstree-rename-input"),t=w.val(),G=this.settings.core.force_text,s;if(t===""){t=E}v.remove();F.replaceWith(A);F.remove();E=G?E:g("<div></div>").append(g.parseHTML(E)).html();this.set_text(r,E);s=!!this.rename_node(r,G?g("<div></div>").text(t).text():g("<div></div>").append(g.parseHTML(t)).html());if(!s){this.set_text(r,E)}this._data.core.focused=q.id;setTimeout(g.proxy(function(){var I=this.get_node(q.id,true);if(I.length){this._data.core.focused=q.id;I.children(".jstree-anchor").focus()}},this),0);if(C){C.call(this,q,s,D)}u=null},this),"keydown":function(t){var s=t.which;if(s===27){D=true;this.value=E}if(s===27||s===13||s===37||s===38||s===39||s===40||s===32){t.stopImmediatePropagation()}if(s===27||s===13){t.preventDefault();this.blur()}},"click":function(s){s.stopImmediatePropagation()},"mousedown":function(s){s.stopImmediatePropagation()},"keyup":function(s){u.width(Math.min(v.text("pW"+this.value).width(),B))},"keypress":function(s){if(s.which===13){return false}}});x={fontFamily:A.css("fontFamily")||"",fontSize:A.css("fontSize")||"",fontWeight:A.css("fontWeight")||"",fontStyle:A.css("fontStyle")||"",fontStretch:A.css("fontStretch")||"",fontVariant:A.css("fontVariant")||"",letterSpacing:A.css("letterSpacing")||"",wordSpacing:A.css("wordSpacing")||""};F.attr("class",A.attr("class")).append(A.contents().clone()).append(u);A.replaceWith(F);v.css(x);u.css(x).width(Math.min(v.text("pW"+u[0].value).width(),B))[0].select();g(o).one("mousedown.jstree touchstart.jstree dnd_start.vakata",function(s){if(u&&s.target!==u){g(u).blur()}})},set_theme:function(s,q){if(!s){return false}if(q===true){var r=this.settings.core.themes.dir;if(!r){r=g.jstree.path+"/themes"}q=r+"/"+s+"/style.css"}if(q&&g.inArray(q,n)===-1){g("head").append("<"+'link rel="stylesheet" href="'+q+'" type="text/css" />');n.push(q)}if(this._data.core.themes.name){this.element.removeClass("jstree-"+this._data.core.themes.name)}this._data.core.themes.name=s;this.element.addClass("jstree-"+s);this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+s+"-responsive");this.trigger("set_theme",{"theme":s})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(q){if(this._data.core.themes.variant){this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)}this._data.core.themes.variant=q;if(q){this.element.addClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)}},get_theme_variant:function(){return this._data.core.themes.variant},show_stripes:function(){this._data.core.themes.stripes=true;this.get_container_ul().addClass("jstree-striped");this.trigger("show_stripes")},hide_stripes:function(){this._data.core.themes.stripes=false;this.get_container_ul().removeClass("jstree-striped");
  33. this.trigger("hide_stripes")},toggle_stripes:function(){if(this._data.core.themes.stripes){this.hide_stripes()}else{this.show_stripes()}},show_dots:function(){this._data.core.themes.dots=true;this.get_container_ul().removeClass("jstree-no-dots");this.trigger("show_dots")},hide_dots:function(){this._data.core.themes.dots=false;this.get_container_ul().addClass("jstree-no-dots");this.trigger("hide_dots")},toggle_dots:function(){if(this._data.core.themes.dots){this.hide_dots()}else{this.show_dots()}},show_icons:function(){this._data.core.themes.icons=true;this.get_container_ul().removeClass("jstree-no-icons");this.trigger("show_icons")},hide_icons:function(){this._data.core.themes.icons=false;this.get_container_ul().addClass("jstree-no-icons");this.trigger("hide_icons")},toggle_icons:function(){if(this._data.core.themes.icons){this.hide_icons()}else{this.show_icons()}},show_ellipsis:function(){this._data.core.themes.ellipsis=true;this.get_container_ul().addClass("jstree-ellipsis");this.trigger("show_ellipsis")},hide_ellipsis:function(){this._data.core.themes.ellipsis=false;this.get_container_ul().removeClass("jstree-ellipsis");this.trigger("hide_ellipsis")},toggle_ellipsis:function(){if(this._data.core.themes.ellipsis){this.hide_ellipsis()}else{this.show_ellipsis()}},set_icon:function(u,s){var t,r,v,q;if(g.isArray(u)){u=u.slice();for(t=0,r=u.length;t<r;t++){this.set_icon(u[t],s)}return true}u=this.get_node(u);if(!u||u.id===g.jstree.root){return false}q=u.icon;u.icon=s===true||s===null||s===e||s===""?true:s;v=this.get_node(u,true).children(".jstree-anchor").children(".jstree-themeicon");if(s===false){this.hide_icon(u)}else{if(s===true||s===null||s===e||s===""){v.removeClass("jstree-themeicon-custom "+q).css("background","").removeAttr("rel");if(q===false){this.show_icon(u)}}else{if(s.indexOf("/")===-1&&s.indexOf(".")===-1){v.removeClass(q).css("background","");v.addClass(s+" jstree-themeicon-custom").attr("rel",s);if(q===false){this.show_icon(u)}}else{v.removeClass(q).css("background","");v.addClass("jstree-themeicon-custom").css("background","url('"+s+"') center center no-repeat").attr("rel",s);if(q===false){this.show_icon(u)}}}}return true},get_icon:function(q){q=this.get_node(q);return(!q||q.id===g.jstree.root)?false:q.icon},hide_icon:function(s){var r,q;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.hide_icon(s[r])}return true}s=this.get_node(s);if(!s||s===g.jstree.root){return false}s.icon=false;this.get_node(s,true).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden");return true},show_icon:function(s){var r,q,t;if(g.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.show_icon(s[r])}return true}s=this.get_node(s);if(!s||s===g.jstree.root){return false}t=this.get_node(s,true);s.icon=t.length?t.children(".jstree-anchor").children(".jstree-themeicon").attr("rel"):true;if(!s.icon){s.icon=true}t.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden");return true}};g.vakata={};g.vakata.attributes=function(r,s){r=g(r)[0];var q=s?{}:[];if(r&&r.attributes){g.each(r.attributes,function(u,t){if(g.inArray(t.name.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])!==-1){return}if(t.value!==null&&g.trim(t.value)!==""){if(s){q[t.name]=t.value}else{q.push(t.name)}}})}return q};g.vakata.array_unique=function(v){var r=[],t,s,q,u={};for(t=0,q=v.length;t<q;t++){if(u[v[t]]===e){r.push(v[t]);u[v[t]]=true}}return r};g.vakata.array_remove=function(r,q){r.splice(q,1);return r};g.vakata.array_remove_item=function(s,r){var q=g.inArray(r,s);return q!==-1?g.vakata.array_remove(s,q):s};g.vakata.array_filter=function(u,r,q,t,s){if(u.filter){return u.filter(r,q)}t=[];for(s in u){if(~~s+""===s+""&&s>=0&&r.call(q,u[s],+s,u)){t.push(u[s])}}return t};g.jstree.plugins.changed=function(q,r){var s=[];this.trigger=function(w,x){var v,t;if(!x){x={}}if(w.replace(".jstree","")==="changed"){x.changed={selected:[],deselected:[]};var u={};for(v=0,t=s.length;v<t;v++){u[s[v]]=1}for(v=0,t=x.selected.length;v<t;v++){if(!u[x.selected[v]]){x.changed.selected.push(x.selected[v])}else{u[x.selected[v]]=2}}for(v=0,t=s.length;v<t;v++){if(u[s[v]]===1){x.changed.deselected.push(s[v])}}s=x.selected.slice()}r.trigger.call(this,w,x)};this.refresh=function(u,t){s=[];return r.refresh.apply(this,arguments)}};var f=o.createElement("I");f.className="jstree-icon jstree-checkbox";f.setAttribute("role","presentation");g.jstree.defaults.checkbox={visible:true,three_state:true,whole_node:true,keep_selected_style:true,cascade:"",tie_selection:true};g.jstree.plugins.checkbox=function(q,r){this.bind=function(){r.bind.call(this);this._data.checkbox.uto=false;this._data.checkbox.selected=[];if(this.settings.checkbox.three_state){this.settings.checkbox.cascade="up+down+undetermined"}this.element.on("init.jstree",g.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible;if(!this.settings.checkbox.keep_selected_style){this.element.addClass("jstree-checkbox-no-clicked")
  34. }if(this.settings.checkbox.tie_selection){this.element.addClass("jstree-checkbox-selection")}},this)).on("loading.jstree",g.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this));if(this.settings.checkbox.cascade.indexOf("undetermined")!==-1){this.element.on("changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",g.proxy(function(){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(g.proxy(this._undetermined,this),50)},this))}if(!this.settings.checkbox.tie_selection){this.element.on("model.jstree",g.proxy(function(x,v){var s=this._model.data,w=s[v.parent],y=v.nodes,u,t;for(u=0,t=y.length;u<t;u++){s[y[u]].state.checked=s[y[u]].state.checked||(s[y[u]].original&&s[y[u]].original.state&&s[y[u]].original.state.checked);if(s[y[u]].state.checked){this._data.checkbox.selected.push(y[u])}}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1||this.settings.checkbox.cascade.indexOf("down")!==-1){this.element.on("model.jstree",g.proxy(function(D,A){var v=this._model.data,u=v[A.parent],C=A.nodes,H=[],E,B,y,x,w,z,G=this.settings.checkbox.cascade,F=this.settings.checkbox.tie_selection;if(G.indexOf("down")!==-1){if(u.state[F?"selected":"checked"]){for(B=0,y=C.length;B<y;B++){v[C[B]].state[F?"selected":"checked"]=true}this._data[F?"core":"checkbox"].selected=this._data[F?"core":"checkbox"].selected.concat(C)}else{for(B=0,y=C.length;B<y;B++){if(v[C[B]].state[F?"selected":"checked"]){for(x=0,w=v[C[B]].children_d.length;x<w;x++){v[v[C[B]].children_d[x]].state[F?"selected":"checked"]=true}this._data[F?"core":"checkbox"].selected=this._data[F?"core":"checkbox"].selected.concat(v[C[B]].children_d)}}}}if(G.indexOf("up")!==-1){for(B=0,y=u.children_d.length;B<y;B++){if(!v[u.children_d[B]].children.length){H.push(v[u.children_d[B]].parent)}}H=g.vakata.array_unique(H);for(x=0,w=H.length;x<w;x++){u=v[H[x]];while(u&&u.id!==g.jstree.root){E=0;for(B=0,y=u.children.length;B<y;B++){E+=v[u.children[B]].state[F?"selected":"checked"]}if(E===y){u.state[F?"selected":"checked"]=true;this._data[F?"core":"checkbox"].selected.push(u.id);z=this.get_node(u,true);if(z&&z.length){z.attr("aria-selected",true).children(".jstree-anchor").addClass(F?"jstree-clicked":"jstree-checked")}}else{break}u=this.get_node(u.parent)}}}this._data[F?"core":"checkbox"].selected=g.vakata.array_unique(this._data[F?"core":"checkbox"].selected)},this)).on(this.settings.checkbox.tie_selection?"select_node.jstree":"check_node.jstree",g.proxy(function(C,A){var z=A.node,v=this._model.data,D=this.get_node(z.parent),w=this.get_node(z,true),B,x,E,y,H=this.settings.checkbox.cascade,G=this.settings.checkbox.tie_selection,u={},F=this._data[G?"core":"checkbox"].selected;for(B=0,x=F.length;B<x;B++){u[F[B]]=true}if(H.indexOf("down")!==-1){for(B=0,x=z.children_d.length;B<x;B++){u[z.children_d[B]]=true;y=v[z.children_d[B]];y.state[G?"selected":"checked"]=true;if(y&&y.original&&y.original.state&&y.original.state.undetermined){y.original.state.undetermined=false}}}if(H.indexOf("up")!==-1){while(D&&D.id!==g.jstree.root){E=0;for(B=0,x=D.children.length;B<x;B++){E+=v[D.children[B]].state[G?"selected":"checked"]}if(E===x){D.state[G?"selected":"checked"]=true;u[D.id]=true;y=this.get_node(D,true);if(y&&y.length){y.attr("aria-selected",true).children(".jstree-anchor").addClass(G?"jstree-clicked":"jstree-checked")}}else{break}D=this.get_node(D.parent)}}F=[];for(B in u){if(u.hasOwnProperty(B)){F.push(B)}}this._data[G?"core":"checkbox"].selected=F;if(H.indexOf("down")!==-1&&w.length){w.find(".jstree-anchor").addClass(G?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",true)}},this)).on(this.settings.checkbox.tie_selection?"deselect_all.jstree":"uncheck_all.jstree",g.proxy(function(y,w){var x=this.get_node(g.jstree.root),s=this._model.data,v,t,u;for(v=0,t=x.children_d.length;v<t;v++){u=s[x.children_d[v]];if(u&&u.original&&u.original.state&&u.original.state.undetermined){u.original.state.undetermined=false}}},this)).on(this.settings.checkbox.tie_selection?"deselect_node.jstree":"uncheck_node.jstree",g.proxy(function(B,y){var x=y.node,v=this.get_node(x,true),z,w,A,E=this.settings.checkbox.cascade,D=this.settings.checkbox.tie_selection,C=this._data[D?"core":"checkbox"].selected,u={};if(x&&x.original&&x.original.state&&x.original.state.undetermined){x.original.state.undetermined=false}if(E.indexOf("down")!==-1){for(z=0,w=x.children_d.length;z<w;z++){A=this._model.data[x.children_d[z]];A.state[D?"selected":"checked"]=false;if(A&&A.original&&A.original.state&&A.original.state.undetermined){A.original.state.undetermined=false}}}if(E.indexOf("up")!==-1){for(z=0,w=x.parents.length;z<w;z++){A=this._model.data[x.parents[z]];A.state[D?"selected":"checked"]=false;if(A&&A.original&&A.original.state&&A.original.state.undetermined){A.original.state.undetermined=false}A=this.get_node(x.parents[z],true);if(A&&A.length){A.attr("aria-selected",false).children(".jstree-anchor").removeClass(D?"jstree-clicked":"jstree-checked")
  35. }}}u={};for(z=0,w=C.length;z<w;z++){if((E.indexOf("down")===-1||g.inArray(C[z],x.children_d)===-1)&&(E.indexOf("up")===-1||g.inArray(C[z],x.parents)===-1)){u[C[z]]=true}}C=[];for(z in u){if(u.hasOwnProperty(z)){C.push(z)}}this._data[D?"core":"checkbox"].selected=C;if(E.indexOf("down")!==-1&&v.length){v.find(".jstree-anchor").removeClass(D?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",false)}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1){this.element.on("delete_node.jstree",g.proxy(function(z,w){var s=this.get_node(w.parent),u=this._model.data,x,v,A,y,B=this.settings.checkbox.tie_selection;while(s&&s.id!==g.jstree.root&&!s.state[B?"selected":"checked"]){A=0;for(x=0,v=s.children.length;x<v;x++){A+=u[s.children[x]].state[B?"selected":"checked"]}if(v>0&&A===v){s.state[B?"selected":"checked"]=true;this._data[B?"core":"checkbox"].selected.push(s.id);y=this.get_node(s,true);if(y&&y.length){y.attr("aria-selected",true).children(".jstree-anchor").addClass(B?"jstree-clicked":"jstree-checked")}}else{break}s=this.get_node(s.parent)}},this)).on("move_node.jstree",g.proxy(function(C,A){var w=A.is_multi,B=A.old_parent,s=this.get_node(A.parent),v=this._model.data,u,D,z,x,y,E=this.settings.checkbox.tie_selection;if(!w){u=this.get_node(B);while(u&&u.id!==g.jstree.root&&!u.state[E?"selected":"checked"]){D=0;for(z=0,x=u.children.length;z<x;z++){D+=v[u.children[z]].state[E?"selected":"checked"]}if(x>0&&D===x){u.state[E?"selected":"checked"]=true;this._data[E?"core":"checkbox"].selected.push(u.id);y=this.get_node(u,true);if(y&&y.length){y.attr("aria-selected",true).children(".jstree-anchor").addClass(E?"jstree-clicked":"jstree-checked")}}else{break}u=this.get_node(u.parent)}}u=s;while(u&&u.id!==g.jstree.root){D=0;for(z=0,x=u.children.length;z<x;z++){D+=v[u.children[z]].state[E?"selected":"checked"]}if(D===x){if(!u.state[E?"selected":"checked"]){u.state[E?"selected":"checked"]=true;this._data[E?"core":"checkbox"].selected.push(u.id);y=this.get_node(u,true);if(y&&y.length){y.attr("aria-selected",true).children(".jstree-anchor").addClass(E?"jstree-clicked":"jstree-checked")}}}else{if(u.state[E?"selected":"checked"]){u.state[E?"selected":"checked"]=false;this._data[E?"core":"checkbox"].selected=g.vakata.array_remove_item(this._data[E?"core":"checkbox"].selected,u.id);y=this.get_node(u,true);if(y&&y.length){y.attr("aria-selected",false).children(".jstree-anchor").removeClass(E?"jstree-clicked":"jstree-checked")}}else{break}}u=this.get_node(u.parent)}},this))}};this._undetermined=function(){if(this.element===null){return}var A,z,y,x,v={},w=this._model.data,C=this.settings.checkbox.tie_selection,D=this._data[C?"core":"checkbox"].selected,u=[],B=this;for(A=0,z=D.length;A<z;A++){if(w[D[A]]&&w[D[A]].parents){for(y=0,x=w[D[A]].parents.length;y<x;y++){if(v[w[D[A]].parents[y]]!==e){break}if(w[D[A]].parents[y]!==g.jstree.root){v[w[D[A]].parents[y]]=true;u.push(w[D[A]].parents[y])}}}}this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var s=B.get_node(this),t;if(!s.state.loaded){if(s.original&&s.original.state&&s.original.state.undetermined&&s.original.state.undetermined===true){if(v[s.id]===e&&s.id!==g.jstree.root){v[s.id]=true;u.push(s.id)}for(y=0,x=s.parents.length;y<x;y++){if(v[s.parents[y]]===e&&s.parents[y]!==g.jstree.root){v[s.parents[y]]=true;u.push(s.parents[y])}}}}else{for(A=0,z=s.children_d.length;A<z;A++){t=w[s.children_d[A]];if(!t.state.loaded&&t.original&&t.original.state&&t.original.state.undetermined&&t.original.state.undetermined===true){if(v[t.id]===e&&t.id!==g.jstree.root){v[t.id]=true;u.push(t.id)}for(y=0,x=t.parents.length;y<x;y++){if(v[t.parents[y]]===e&&t.parents[y]!==g.jstree.root){v[t.parents[y]]=true;u.push(t.parents[y])}}}}}});this.element.find(".jstree-undetermined").removeClass("jstree-undetermined");for(A=0,z=u.length;A<z;A++){if(!w[u[A]].state[C?"selected":"checked"]){D=this.get_node(u[A],true);if(D&&D.length){D.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined")}}}};this.redraw_node=function(z,s,w,y){z=r.redraw_node.apply(this,arguments);if(z){var v,t,u=null,x=null;for(v=0,t=z.childNodes.length;v<t;v++){if(z.childNodes[v]&&z.childNodes[v].className&&z.childNodes[v].className.indexOf("jstree-anchor")!==-1){u=z.childNodes[v];break}}if(u){if(!this.settings.checkbox.tie_selection&&this._model.data[z.id].state.checked){u.className+=" jstree-checked"}x=f.cloneNode(false);if(this._model.data[z.id].state.checkbox_disabled){x.className+=" jstree-checkbox-disabled"}u.insertBefore(x,u.childNodes[0])}}if(!w&&this.settings.checkbox.cascade.indexOf("undetermined")!==-1){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(g.proxy(this._undetermined,this),50)}return z};this.show_checkboxes=function(){this._data.core.themes.checkboxes=true;this.get_container_ul().removeClass("jstree-no-checkboxes")};this.hide_checkboxes=function(){this._data.core.themes.checkboxes=false;this.get_container_ul().addClass("jstree-no-checkboxes")
  36. };this.toggle_checkboxes=function(){if(this._data.core.themes.checkboxes){this.hide_checkboxes()}else{this.show_checkboxes()}};this.is_undetermined=function(z){z=this.get_node(z);var y=this.settings.checkbox.cascade,x,v,w=this.settings.checkbox.tie_selection,A=this._data[w?"core":"checkbox"].selected,u=this._model.data;if(!z||z.state[w?"selected":"checked"]===true||y.indexOf("undetermined")===-1||(y.indexOf("down")===-1&&y.indexOf("up")===-1)){return false}if(!z.state.loaded&&z.original.state.undetermined===true){return true}for(x=0,v=z.children_d.length;x<v;x++){if(g.inArray(z.children_d[x],A)!==-1||(!u[z.children_d[x]].state.loaded&&u[z.children_d[x]].original.state.undetermined)){return true}}return false};this.disable_checkbox=function(u){var t,s,v;if(g.isArray(u)){u=u.slice();for(t=0,s=u.length;t<s;t++){this.disable_checkbox(u[t])}return true}u=this.get_node(u);if(!u||u.id===g.jstree.root){return false}v=this.get_node(u,true);if(!u.state.checkbox_disabled){u.state.checkbox_disabled=true;if(v&&v.length){v.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-checkbox-disabled")}this.trigger("disable_checkbox",{"node":u})}};this.enable_checkbox=function(u){var t,s,v;if(g.isArray(u)){u=u.slice();for(t=0,s=u.length;t<s;t++){this.enable_checkbox(u[t])}return true}u=this.get_node(u);if(!u||u.id===g.jstree.root){return false}v=this.get_node(u,true);if(u.state.checkbox_disabled){u.state.checkbox_disabled=false;if(v&&v.length){v.children(".jstree-anchor").children(".jstree-checkbox").removeClass("jstree-checkbox-disabled")}this.trigger("enable_checkbox",{"node":u})}};this.activate_node=function(t,s){if(g(s.target).hasClass("jstree-checkbox-disabled")){return false}if(this.settings.checkbox.tie_selection&&(this.settings.checkbox.whole_node||g(s.target).hasClass("jstree-checkbox"))){s.ctrlKey=true}if(this.settings.checkbox.tie_selection||(!this.settings.checkbox.whole_node&&!g(s.target).hasClass("jstree-checkbox"))){return r.activate_node.call(this,t,s)}if(this.is_disabled(t)){return false}if(this.is_checked(t)){this.uncheck_node(t,s)}else{this.check_node(t,s)}this.trigger("activate_node",{"node":this.get_node(t)})};this.check_node=function(w,v){if(this.settings.checkbox.tie_selection){return this.select_node(w,false,true,v)}var x,u,s,t;if(g.isArray(w)){w=w.slice();for(u=0,s=w.length;u<s;u++){this.check_node(w[u],v)}return true}w=this.get_node(w);if(!w||w.id===g.jstree.root){return false}x=this.get_node(w,true);if(!w.state.checked){w.state.checked=true;this._data.checkbox.selected.push(w.id);if(x&&x.length){x.children(".jstree-anchor").addClass("jstree-checked")}this.trigger("check_node",{"node":w,"selected":this._data.checkbox.selected,"event":v})}};this.uncheck_node=function(v,u){if(this.settings.checkbox.tie_selection){return this.deselect_node(v,false,u)}var t,s,w;if(g.isArray(v)){v=v.slice();for(t=0,s=v.length;t<s;t++){this.uncheck_node(v[t],u)}return true}v=this.get_node(v);if(!v||v.id===g.jstree.root){return false}w=this.get_node(v,true);if(v.state.checked){v.state.checked=false;this._data.checkbox.selected=g.vakata.array_remove_item(this._data.checkbox.selected,v.id);if(w.length){w.children(".jstree-anchor").removeClass("jstree-checked")}this.trigger("uncheck_node",{"node":v,"selected":this._data.checkbox.selected,"event":u})}};this.check_all=function(){if(this.settings.checkbox.tie_selection){return this.select_all()}var u=this._data.checkbox.selected.concat([]),t,s;this._data.checkbox.selected=this._model.data[g.jstree.root].children_d.concat();for(t=0,s=this._data.checkbox.selected.length;t<s;t++){if(this._model.data[this._data.checkbox.selected[t]]){this._model.data[this._data.checkbox.selected[t]].state.checked=true}}this.redraw(true);this.trigger("check_all",{"selected":this._data.checkbox.selected})};this.uncheck_all=function(){if(this.settings.checkbox.tie_selection){return this.deselect_all()}var u=this._data.checkbox.selected.concat([]),t,s;for(t=0,s=this._data.checkbox.selected.length;t<s;t++){if(this._model.data[this._data.checkbox.selected[t]]){this._model.data[this._data.checkbox.selected[t]].state.checked=false}}this._data.checkbox.selected=[];this.element.find(".jstree-checked").removeClass("jstree-checked");this.trigger("uncheck_all",{"selected":this._data.checkbox.selected,"node":u})};this.is_checked=function(s){if(this.settings.checkbox.tie_selection){return this.is_selected(s)}s=this.get_node(s);if(!s||s.id===g.jstree.root){return false}return s.state.checked};this.get_checked=function(s){if(this.settings.checkbox.tie_selection){return this.get_selected(s)}return s?g.map(this._data.checkbox.selected,g.proxy(function(t){return this.get_node(t)},this)):this._data.checkbox.selected};this.get_top_checked=function(x){if(this.settings.checkbox.tie_selection){return this.get_top_selected(x)}var w=this.get_checked(true),y={},v,u,t,s;for(v=0,u=w.length;v<u;v++){y[w[v].id]=w[v]}for(v=0,u=w.length;v<u;v++){for(t=0,s=w[v].children_d.length;t<s;t++){if(y[w[v].children_d[t]]){delete y[w[v].children_d[t]]
  37. }}}w=[];for(v in y){if(y.hasOwnProperty(v)){w.push(v)}}return x?g.map(w,g.proxy(function(z){return this.get_node(z)},this)):w};this.get_bottom_checked=function(v){if(this.settings.checkbox.tie_selection){return this.get_bottom_selected(v)}var u=this.get_checked(true),w=[],t,s;for(t=0,s=u.length;t<s;t++){if(!u[t].children.length){w.push(u[t].id)}}return v?g.map(w,g.proxy(function(x){return this.get_node(x)},this)):w};this.load_node=function(x,z){var t,s,w,u,y,v;if(!g.isArray(x)&&!this.settings.checkbox.tie_selection){v=this.get_node(x);if(v&&v.state.loaded){for(t=0,s=v.children_d.length;t<s;t++){if(this._model.data[v.children_d[t]].state.checked){y=true;this._data.checkbox.selected=g.vakata.array_remove_item(this._data.checkbox.selected,v.children_d[t])}}}}return r.load_node.apply(this,arguments)};this.get_state=function(){var s=r.get_state.apply(this,arguments);if(this.settings.checkbox.tie_selection){return s}s.checkbox=this._data.checkbox.selected.slice();return s};this.set_state=function(t,v){var s=r.set_state.apply(this,arguments);if(s&&t.checkbox){if(!this.settings.checkbox.tie_selection){this.uncheck_all();var u=this;g.each(t.checkbox,function(x,w){u.check_node(w)})}delete t.checkbox;this.set_state(t,v);return false}return s};this.refresh=function(t,s){if(!this.settings.checkbox.tie_selection){this._data.checkbox.selected=[]}return r.refresh.apply(this,arguments)}};g.jstree.defaults.conditionalselect=function(){return true};g.jstree.plugins.conditionalselect=function(q,r){this.activate_node=function(t,s){if(this.settings.conditionalselect.call(this,this.get_node(t),s)){r.activate_node.call(this,t,s)}}};g.jstree.defaults.contextmenu={select_node:true,show_at_node:true,items:function(r,q){return{"create":{"separator_before":false,"separator_after":true,"_disabled":false,"label":"Create","action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);s.create_node(u,{},"last",function(v){setTimeout(function(){s.edit(v)},0)})}},"rename":{"separator_before":false,"separator_after":false,"_disabled":false,"label":"Rename",
  38. "action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);s.edit(u)}},"remove":{"separator_before":false,"icon":false,"separator_after":false,"_disabled":false,"label":"Delete","action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);if(s.is_selected(u)){s.delete_node(s.get_selected())}else{s.delete_node(u)}}},"ccp":{"separator_before":true,"icon":false,"separator_after":false,"label":"Edit","action":false,"submenu":{"cut":{"separator_before":false,"separator_after":false,"label":"Cut","action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);if(s.is_selected(u)){s.cut(s.get_top_selected())}else{s.cut(u)}}},"copy":{"separator_before":false,"icon":false,"separator_after":false,"label":"Copy","action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);if(s.is_selected(u)){s.copy(s.get_top_selected())}else{s.copy(u)}}},"paste":{"separator_before":false,"icon":false,"_disabled":function(s){return !g.jstree.reference(s.reference).can_paste()},"separator_after":false,"label":"Paste","action":function(t){var s=g.jstree.reference(t.reference),u=s.get_node(t.reference);s.paste(u)}}}}}}};g.jstree.plugins.contextmenu=function(q,r){this.bind=function(){r.bind.call(this);var s=0,v=null,u,t;this.element.on("contextmenu.jstree",".jstree-anchor",g.proxy(function(x,w){if(x.target.tagName.toLowerCase()==="input"){return}x.preventDefault();s=x.ctrlKey?+new Date():0;if(w||v){s=(+new Date())+10000}if(v){clearTimeout(v)}if(!this.is_loading(x.currentTarget)){this.show_contextmenu(x.currentTarget,x.pageX,x.pageY,x)}},this)).on("click.jstree",".jstree-anchor",g.proxy(function(w){if(this._data.contextmenu.visible&&(!s||(+new Date())-s>250)){g.vakata.context.hide()}s=0},this)).on("touchstart.jstree",".jstree-anchor",function(w){if(!w.originalEvent||!w.originalEvent.changedTouches||!w.originalEvent.changedTouches[0]){return}u=w.originalEvent.changedTouches[0].clientX;t=w.originalEvent.changedTouches[0].clientY;v=setTimeout(function(){g(w.currentTarget).trigger("contextmenu",true)},750)}).on("touchmove.vakata.jstree",function(w){if(v&&w.originalEvent&&w.originalEvent.changedTouches&&w.originalEvent.changedTouches[0]&&(Math.abs(u-w.originalEvent.changedTouches[0].clientX)>50||Math.abs(t-w.originalEvent.changedTouches[0].clientY)>50)){clearTimeout(v)}}).on("touchend.vakata.jstree",function(w){if(v){clearTimeout(v)}});
  39. g(o).on("context_hide.vakata.jstree",g.proxy(function(x,w){this._data.contextmenu.visible=false;
  40. g(w.reference).removeClass("jstree-context")},this))};this.teardown=function(){if(this._data.contextmenu.visible){g.vakata.context.hide()}r.teardown.call(this)};this.show_contextmenu=function(v,C,A,w){v=this.get_node(v);if(!v||v.id===g.jstree.root){return false}var D=this.settings.contextmenu,z=this.get_node(v,true),B=z.children(".jstree-anchor"),t=false,u=false;if(D.show_at_node||C===e||A===e){t=B.offset();C=t.left;A=t.top+this._data.core.li_height}if(this.settings.contextmenu.select_node&&!this.is_selected(v)){this.activate_node(v,w)}u=D.items;if(g.isFunction(u)){u=u.call(this,v,g.proxy(function(s){this._show_contextmenu(v,C,A,s)},this))}if(g.isPlainObject(u)){this._show_contextmenu(v,C,A,u)}};this._show_contextmenu=function(v,s,z,u){var w=this.get_node(v,true),t=w.children(".jstree-anchor");g(o).one("context_show.vakata.jstree",g.proxy(function(A,y){var x="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";g(y.element).addClass(x);t.addClass("jstree-context")},this));this._data.contextmenu.visible=true;g.vakata.context.show(t,{"x":s,"y":z},u);this.trigger("show_contextmenu",{"node":v,"x":s,"y":z})}};(function(r){var s=false,q={element:false,reference:false,position_x:0,position_y:0,items:[],html:"",is_visible:false};r.vakata.context={settings:{hide_onmouseleave:0,icons:true},_trigger:function(t){r(o).triggerHandler("context_"+t+".vakata",{"reference":q.reference,"element":q.element,"position":{"x":q.position_x,"y":q.position_y}})},_execute:function(t){t=q.items[t];return t&&(!t._disabled||(r.isFunction(t._disabled)&&!t._disabled({"item":t,"reference":q.reference,"element":q.element})))&&t.action?t.action.call(null,{"item":t,"reference":q.reference,"element":q.element,"position":{"x":q.position_x,"y":q.position_y}}):false},_parse:function(x,v){if(!x){return false}if(!v){q.html="";q.items=[]}var w="",t=false,u;if(v){w+="<"+"ul>"}r.each(x,function(y,z){if(!z){return true}q.items.push(z);if(!t&&z.separator_before){w+="<"+"li class='vakata-context-separator'><"+"a href='#' "+(r.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;<"+"/a><"+"/li>"}t=false;w+="<"+"li class='"+(z._class||"")+(z._disabled===true||(r.isFunction(z._disabled)&&z._disabled({"item":z,"reference":q.reference,"element":q.element}))?" vakata-contextmenu-disabled ":"")+"' "+(z.shortcut?" data-shortcut='"+z.shortcut+"' ":"")+">";w+="<"+"a href='#' rel='"+(q.items.length-1)+"' "+(z.title?"title='"+z.title+"'":"")+">";if(r.vakata.context.settings.icons){w+="<"+"i ";if(z.icon){if(z.icon.indexOf("/")!==-1||z.icon.indexOf(".")!==-1){w+=" style='background:url(\""+z.icon+"\") center center no-repeat' "}else{w+=" class='"+z.icon+"' "}}w+="><"+"/i><"+"span class='vakata-contextmenu-sep'>&#160;<"+"/span>"}w+=(r.isFunction(z.label)?z.label({"item":y,"reference":q.reference,"element":q.element}):z.label)+(z.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+z.shortcut+'">'+(z.shortcut_label||"")+"</span>":"")+"<"+"/a>";if(z.submenu){u=r.vakata.context._parse(z.submenu,true);if(u){w+=u}}w+="<"+"/li>";if(z.separator_after){w+="<"+"li class='vakata-context-separator'><"+"a href='#' "+(r.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;<"+"/a><"+"/li>";t=true}});w=w.replace(/<li class\='vakata-context-separator'\><\/li\>$/,"");if(v){w+="</ul>"}if(!v){q.html=w;r.vakata.context._trigger("parse")}return w.length>10?w:false},_show_submenu:function(u){u=r(u);if(!u.length||!u.children("ul").length){return}var A=u.children("ul"),z=u.offset().left,D=z+u.outerWidth(),C=u.offset().top,E=A.width(),v=A.height(),t=r(window).width()+r(window).scrollLeft(),B=r(window).height()+r(window).scrollTop();if(s){u[D-(E+10+u.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left")}else{u[D+E>t&&z>t-D?"addClass":"removeClass"]("vakata-context-right")}if(C+v+10>B){A.css("bottom","-1px")}if(u.hasClass("vakata-context-right")){if(z<E){A.css("margin-right",z-E)}}else{if(t-D<E){A.css("margin-left",t-D-E)}}A.show()},show:function(v,B,z){var u,C,G,F,H,A,t,E,D=true;if(q.element&&q.element.length){q.element.width("")}switch(D){case (!B&&!v):return false;case (!!B&&!!v):q.reference=v;q.position_x=B.x;q.position_y=B.y;break;case (!B&&!!v):q.reference=v;u=v.offset();q.position_x=u.left+v.outerHeight();q.position_y=u.top;break;case (!!B&&!v):q.position_x=B.x;q.position_y=B.y;break}if(!!v&&!z&&r(v).data("vakata_contextmenu")){z=r(v).data("vakata_contextmenu")}if(r.vakata.context._parse(z)){q.element.html(q.html)}if(q.items.length){q.element.appendTo("body");C=q.element;G=q.position_x;F=q.position_y;H=C.width();A=C.height();t=r(window).width()+r(window).scrollLeft();E=r(window).height()+r(window).scrollTop();if(s){G-=(C.outerWidth()-r(v).outerWidth());if(G<r(window).scrollLeft()+20){G=r(window).scrollLeft()+20}}if(G+H+20>t){G=t-(H+20)}if(F+A+20>E){F=E-(A+20)}q.element.css({"left":G,"top":F}).show().find("a").first().focus().parent().addClass("vakata-context-hover");q.is_visible=true;r.vakata.context._trigger("show")
  41. }},hide:function(){if(q.is_visible){q.element.hide().find("ul").hide().end().find(":focus").blur().end().detach();q.is_visible=false;r.vakata.context._trigger("hide")}}};r(function(){s=r("body").css("direction")==="rtl";var t=false;q.element=r("<ul class='vakata-context'></ul>");q.element.on("mouseenter","li",function(u){u.stopImmediatePropagation();if(r.contains(this,u.relatedTarget)){return}if(t){clearTimeout(t)}q.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();r(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover");r.vakata.context._show_submenu(this)}).on("mouseleave","li",function(u){if(r.contains(this,u.relatedTarget)){return}r(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(u){r(this).find(".vakata-context-hover").removeClass("vakata-context-hover");if(r.vakata.context.settings.hide_onmouseleave){t=setTimeout((function(v){return function(){r.vakata.context.hide()}}(this)),r.vakata.context.settings.hide_onmouseleave)}}).on("click","a",function(u){u.preventDefault();if(!r(this).blur().parent().hasClass("vakata-context-disabled")&&r.vakata.context._execute(r(this).attr("rel"))!==false){r.vakata.context.hide()}}).on("keydown","a",function(u){var v=null;switch(u.which){case 13:case 32:u.type="click";u.preventDefault();r(u.currentTarget).trigger(u);break;case 37:if(q.is_visible){q.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus();u.stopImmediatePropagation();u.preventDefault()}break;case 38:if(q.is_visible){v=q.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();if(!v.length){v=q.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()}v.addClass("vakata-context-hover").children("a").focus();u.stopImmediatePropagation();u.preventDefault()}break;case 39:if(q.is_visible){q.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children("a").focus();u.stopImmediatePropagation();u.preventDefault()}break;case 40:if(q.is_visible){v=q.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();if(!v.length){v=q.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()}v.addClass("vakata-context-hover").children("a").focus();u.stopImmediatePropagation();u.preventDefault()}break;case 27:r.vakata.context.hide();u.preventDefault();break;default:break}}).on("keydown",function(v){v.preventDefault();var u=q.element.find(".vakata-contextmenu-shortcut-"+v.which).parent();if(u.parent().not(".vakata-context-disabled")){u.click()}});r(o).on("mousedown.vakata.jstree",function(u){if(q.is_visible&&!r.contains(q.element[0],u.target)){r.vakata.context.hide()}}).on("context_show.vakata.jstree",function(v,u){q.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");if(s){q.element.addClass("vakata-context-rtl").css("direction","rtl")}q.element.find("ul").hide().end()})})}(g));g.jstree.defaults.dnd={copy:true,open_timeout:500,is_draggable:true,check_while_dragging:true,always_copy:false,inside_pos:0,drag_selection:true,touch:true,large_drop_target:false,large_drag_target:false,use_html5:false};var k,m;g.jstree.plugins.dnd=function(q,r){this.init=function(t,s){r.init.call(this,t,s);this.settings.dnd.use_html5=this.settings.dnd.use_html5&&("draggable" in o.createElement("span"))};this.bind=function(){r.bind.call(this);this.element.on(this.settings.dnd.use_html5?"dragstart.jstree":"mousedown.jstree touchstart.jstree",this.settings.dnd.large_drag_target?".jstree-node":".jstree-anchor",g.proxy(function(v){if(this.settings.dnd.large_drag_target&&g(v.target).closest(".jstree-node")[0]!==v.currentTarget){return true}if(v.type==="touchstart"&&(!this.settings.dnd.touch||(this.settings.dnd.touch==="selected"&&!g(v.currentTarget).closest(".jstree-node").children(".jstree-anchor").hasClass("jstree-clicked")))){return true}var u=this.get_node(v.target),t=this.is_selected(u)&&this.settings.dnd.drag_selection?this.get_top_selected().length:1,s=(t>1?t+" "+this.get_string("nodes"):this.get_text(v.currentTarget));if(this.settings.core.force_text){s=g.vakata.html.escape(s)}if(u&&u.id&&u.id!==g.jstree.root&&(v.which===1||v.type==="touchstart"||v.type==="dragstart")&&(this.settings.dnd.is_draggable===true||(g.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,(t>1?this.get_top_selected(true):[u]),v)))){k={"jstree":true,"origin":this,"obj":this.get_node(u,true),"nodes":t>1?this.get_top_selected():[u.id]};
  42. m=v.currentTarget;if(this.settings.dnd.use_html5){g.vakata.dnd._trigger("start",v,{"helper":g(),"element":m,"data":k})}else{this.element.trigger("mousedown.jstree");return g.vakata.dnd.start(v,k,'<div id="jstree-dnd" class="jstree-'+this.get_theme()+" jstree-"+this.get_theme()+"-"+this.get_theme_variant()+" "+(this.settings.core.themes.responsive?" jstree-dnd-responsive":"")+'"><i class="jstree-icon jstree-er"></i>'+s+'<ins class="jstree-copy" style="display:none;">+</ins></div>')}}},this));if(this.settings.dnd.use_html5){this.element.on("dragover.jstree",function(s){s.preventDefault();g.vakata.dnd._trigger("move",s,{"helper":g(),"element":m,"data":k});return false}).on("drop.jstree",g.proxy(function(s){s.preventDefault();g.vakata.dnd._trigger("stop",s,{"helper":g(),"element":m,"data":k});return false},this))}};this.redraw_node=function(x,s,y,w){x=r.redraw_node.apply(this,arguments);if(x&&this.settings.dnd.use_html5){if(this.settings.dnd.large_drag_target){x.setAttribute("draggable",true)}else{var v,t,u=null;for(v=0,t=x.childNodes.length;v<t;v++){if(x.childNodes[v]&&x.childNodes[v].className&&x.childNodes[v].className.indexOf("jstree-anchor")!==-1){u=x.childNodes[v];break}}if(u){u.setAttribute("draggable",true)}}}return x}};g(function(){var u=false,t=false,r=false,s=false,q=g('<div id="jstree-marker">&#160;</div>').hide();g(o).on("dnd_start.vakata.jstree",function(w,v){u=false;r=false;if(!v||!v.data||!v.data.jstree){return}q.appendTo("body")}).on("dnd_move.vakata.jstree",function(O,R){if(s){if(!R.event||R.event.type!=="dragover"||R.event.target!==r.target){clearTimeout(s)}}if(!R||!R.data||!R.data.jstree){return}if(R.event.target.id&&R.event.target.id==="jstree-marker"){return}r=R.event;var v=g.jstree.reference(R.event.target),z=false,Q=false,w=false,P,K,F,N,G,L,H,E,D,C,B,I,J,A,x,y,M;if(v&&v._data&&v._data.dnd){q.attr("class","jstree-"+v.get_theme()+(v.settings.core.themes.responsive?" jstree-dnd-responsive":""));y=R.data.origin&&(R.data.origin.settings.dnd.always_copy||(R.data.origin.settings.dnd.copy&&(R.event.metaKey||R.event.ctrlKey)));R.helper.children().attr("class","jstree-"+v.get_theme()+" jstree-"+v.get_theme()+"-"+v.get_theme_variant()+" "+(v.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy").first()[y?"show":"hide"]();if((R.event.target===v.element[0]||R.event.target===v.get_container_ul()[0])&&v.get_container_ul().children().length===0){E=true;for(D=0,C=R.data.nodes.length;D<C;D++){E=E&&v.check((R.data.origin&&(R.data.origin.settings.dnd.always_copy||(R.data.origin.settings.dnd.copy&&(R.event.metaKey||R.event.ctrlKey)))?"copy_node":"move_node"),(R.data.origin&&R.data.origin!==v?R.data.origin.get_node(R.data.nodes[D]):R.data.nodes[D]),g.jstree.root,"last",{"dnd":true,"ref":v.get_node(g.jstree.root),"pos":"i","origin":R.data.origin,"is_multi":(R.data.origin&&R.data.origin!==v),"is_foreign":(!R.data.origin)});if(!E){break}}if(E){u={"ins":v,"par":g.jstree.root,"pos":"last"};q.hide();R.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok");if(R.event.originalEvent&&R.event.originalEvent.dataTransfer){R.event.originalEvent.dataTransfer.dropEffect=y?"copy":"move"}return}}else{z=v.settings.dnd.large_drop_target?g(R.event.target).closest(".jstree-node").children(".jstree-anchor"):g(R.event.target).closest(".jstree-anchor");if(z&&z.length&&z.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")){Q=z.offset();w=(R.event.pageY!==e?R.event.pageY:R.event.originalEvent.pageY)-Q.top;N=z.outerHeight();if(w<N/3){H=["b","i","a"]}else{if(w>N-N/3){H=["a","i","b"]}else{H=w>N/2?["i","a","b"]:["i","b","a"]}}g.each(H,function(T,S){switch(S){case"b":K=Q.left-6;F=Q.top;G=v.get_parent(z);L=z.parent().index();break;case"i":A=v.settings.dnd.inside_pos;x=v.get_node(z.parent());K=Q.left-2;F=Q.top+N/2+1;G=x.id;L=A==="first"?0:(A==="last"?x.children.length:Math.min(A,x.children.length));break;case"a":K=Q.left-6;F=Q.top+N;G=v.get_parent(z);L=z.parent().index()+1;break}E=true;for(D=0,C=R.data.nodes.length;D<C;D++){B=R.data.origin&&(R.data.origin.settings.dnd.always_copy||(R.data.origin.settings.dnd.copy&&(R.event.metaKey||R.event.ctrlKey)))?"copy_node":"move_node";I=L;if(B==="move_node"&&S==="a"&&(R.data.origin&&R.data.origin===v)&&G===v.get_parent(R.data.nodes[D])){J=v.get_node(G);if(I>g.inArray(R.data.nodes[D],J.children)){I-=1}}E=E&&((v&&v.settings&&v.settings.dnd&&v.settings.dnd.check_while_dragging===false)||v.check(B,(R.data.origin&&R.data.origin!==v?R.data.origin.get_node(R.data.nodes[D]):R.data.nodes[D]),G,I,{"dnd":true,"ref":v.get_node(z.parent()),"pos":S,"origin":R.data.origin,"is_multi":(R.data.origin&&R.data.origin!==v),"is_foreign":(!R.data.origin)}));if(!E){if(v&&v.last_error){t=v.last_error()}break}}if(S==="i"&&z.parent().is(".jstree-closed")&&v.settings.dnd.open_timeout){s=setTimeout((function(U,V){return function(){U.open_node(V)}}(v,z)),v.settings.dnd.open_timeout)}if(E){M=v.get_node(G,true);if(!M.hasClass(".jstree-dnd-parent")){g(".jstree-dnd-parent").removeClass("jstree-dnd-parent");
  43. M.addClass("jstree-dnd-parent")}u={"ins":v,"par":G,"pos":S==="i"&&A==="last"&&L===0&&!v.is_loaded(x)?"last":L};q.css({"left":K+"px","top":F+"px"}).show();R.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok");if(R.event.originalEvent&&R.event.originalEvent.dataTransfer){R.event.originalEvent.dataTransfer.dropEffect=y?"copy":"move"}t={};H=true;return false}});if(H===true){return}}}}g(".jstree-dnd-parent").removeClass("jstree-dnd-parent");u=false;R.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er");if(R.event.originalEvent&&R.event.originalEvent.dataTransfer){R.event.originalEvent.dataTransfer.dropEffect="none"}q.hide()}).on("dnd_scroll.vakata.jstree",function(w,v){if(!v||!v.data||!v.data.jstree){return}q.hide();u=false;r=false;v.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er")}).on("dnd_stop.vakata.jstree",function(z,y){g(".jstree-dnd-parent").removeClass("jstree-dnd-parent");if(s){clearTimeout(s)}if(!y||!y.data||!y.data.jstree){return}q.hide().detach();var x,w,v=[];if(u){for(x=0,w=y.data.nodes.length;x<w;x++){v[x]=y.data.origin?y.data.origin.get_node(y.data.nodes[x]):y.data.nodes[x]}u.ins[y.data.origin&&(y.data.origin.settings.dnd.always_copy||(y.data.origin.settings.dnd.copy&&(y.event.metaKey||y.event.ctrlKey)))?"copy_node":"move_node"](v,u.par,u.pos,false,false,false,y.data.origin)}else{x=g(y.event.target).closest(".jstree");if(x.length&&t&&t.error&&t.error==="check"){x=x.jstree(true);if(x){x.settings.core.error.call(this,t)}}}r=false;u=false}).on("keyup.jstree keydown.jstree",function(w,v){v=g.vakata.dnd._get();if(v&&v.data&&v.data.jstree){if(w.type==="keyup"&&w.which===27){if(s){clearTimeout(s)}u=false;t=false;r=false;s=false;q.hide().detach();g.vakata.dnd._clean()}else{v.helper.find(".jstree-copy").first()[v.data.origin&&(v.data.origin.settings.dnd.always_copy||(v.data.origin.settings.dnd.copy&&(w.metaKey||w.ctrlKey)))?"show":"hide"]();if(r){r.metaKey=w.metaKey;r.ctrlKey=w.ctrlKey;g.vakata.dnd._trigger("move",r)}}}})});(function(r){r.vakata.html={div:r("<div />"),escape:function(s){return r.vakata.html.div.text(s).html()},strip:function(s){return r.vakata.html.div.empty().append(r.parseHTML(s)).text()}};var q={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};r.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:50},_trigger:function(u,t,s){if(s===e){s=r.vakata.dnd._get()}s.event=t;r(o).triggerHandler("dnd_"+u+".vakata",s)},_get:function(){return{"data":q.data,"element":q.element,"helper":q.helper}},_clean:function(){if(q.helper){q.helper.remove()}if(q.scroll_i){clearInterval(q.scroll_i);q.scroll_i=false}q={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};r(o).off("mousemove.vakata.jstree touchmove.vakata.jstree",r.vakata.dnd.drag);r(o).off("mouseup.vakata.jstree touchend.vakata.jstree",r.vakata.dnd.stop)},_scroll:function(u){if(!q.scroll_e||(!q.scroll_l&&!q.scroll_t)){if(q.scroll_i){clearInterval(q.scroll_i);q.scroll_i=false}return false}if(!q.scroll_i){q.scroll_i=setInterval(r.vakata.dnd._scroll,100);return false}if(u===true){return false}var t=q.scroll_e.scrollTop(),s=q.scroll_e.scrollLeft();q.scroll_e.scrollTop(t+q.scroll_t*r.vakata.dnd.settings.scroll_speed);q.scroll_e.scrollLeft(s+q.scroll_l*r.vakata.dnd.settings.scroll_speed);if(t!==q.scroll_e.scrollTop()||s!==q.scroll_e.scrollLeft()){r.vakata.dnd._trigger("scroll",q.scroll_e)}},start:function(u,t,s){if(u.type==="touchstart"&&u.originalEvent&&u.originalEvent.changedTouches&&u.originalEvent.changedTouches[0]){u.pageX=u.originalEvent.changedTouches[0].pageX;u.pageY=u.originalEvent.changedTouches[0].pageY;u.target=o.elementFromPoint(u.originalEvent.changedTouches[0].pageX-window.pageXOffset,u.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(q.is_drag){r.vakata.dnd.stop({})}try{u.currentTarget.unselectable="on";u.currentTarget.onselectstart=function(){return false};if(u.currentTarget.style){u.currentTarget.style.touchAction="none";u.currentTarget.style.msTouchAction="none";u.currentTarget.style.MozUserSelect="none"}}catch(v){}q.init_x=u.pageX;q.init_y=u.pageY;q.data=t;q.is_down=true;q.element=u.currentTarget;q.target=u.target;q.is_touch=u.type==="touchstart";if(s!==false){q.helper=r("<div id='vakata-dnd'></div>").html(s).css({"display":"block","margin":"0","padding":"0","position":"absolute","top":"-2000px","lineHeight":"16px","zIndex":"10000"})}r(o).on("mousemove.vakata.jstree touchmove.vakata.jstree",r.vakata.dnd.drag);r(o).on("mouseup.vakata.jstree touchend.vakata.jstree",r.vakata.dnd.stop);return false},drag:function(z){if(z.type==="touchmove"&&z.originalEvent&&z.originalEvent.changedTouches&&z.originalEvent.changedTouches[0]){z.pageX=z.originalEvent.changedTouches[0].pageX;
  44. z.pageY=z.originalEvent.changedTouches[0].pageY;z.target=o.elementFromPoint(z.originalEvent.changedTouches[0].pageX-window.pageXOffset,z.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(!q.is_down){return}if(!q.is_drag){if(Math.abs(z.pageX-q.init_x)>(q.is_touch?r.vakata.dnd.settings.threshold_touch:r.vakata.dnd.settings.threshold)||Math.abs(z.pageY-q.init_y)>(q.is_touch?r.vakata.dnd.settings.threshold_touch:r.vakata.dnd.settings.threshold)){if(q.helper){q.helper.appendTo("body");q.helper_w=q.helper.outerWidth()}q.is_drag=true;r(q.target).one("click.vakata",false);r.vakata.dnd._trigger("start",z)}else{return}}var A=false,D=false,B=false,t=false,s=false,x=false,v=false,y=false,C=false,u=false;q.scroll_t=0;q.scroll_l=0;q.scroll_e=false;r(r(z.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return(/^auto|scroll$/).test(r(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var w=r(this),E=w.offset();if(this.scrollHeight>this.offsetHeight){if(E.top+w.height()-z.pageY<r.vakata.dnd.settings.scroll_proximity){q.scroll_t=1}if(z.pageY-E.top<r.vakata.dnd.settings.scroll_proximity){q.scroll_t=-1}}if(this.scrollWidth>this.offsetWidth){if(E.left+w.width()-z.pageX<r.vakata.dnd.settings.scroll_proximity){q.scroll_l=1}if(z.pageX-E.left<r.vakata.dnd.settings.scroll_proximity){q.scroll_l=-1}}if(q.scroll_t||q.scroll_l){q.scroll_e=r(this);return false}});if(!q.scroll_e){A=r(o);D=r(window);B=A.height();t=D.height();s=A.width();x=D.width();v=A.scrollTop();y=A.scrollLeft();if(B>t&&z.pageY-v<r.vakata.dnd.settings.scroll_proximity){q.scroll_t=-1}if(B>t&&t-(z.pageY-v)<r.vakata.dnd.settings.scroll_proximity){q.scroll_t=1}if(s>x&&z.pageX-y<r.vakata.dnd.settings.scroll_proximity){q.scroll_l=-1}if(s>x&&x-(z.pageX-y)<r.vakata.dnd.settings.scroll_proximity){q.scroll_l=1}if(q.scroll_t||q.scroll_l){q.scroll_e=A}}if(q.scroll_e){r.vakata.dnd._scroll(true)}if(q.helper){C=parseInt(z.pageY+r.vakata.dnd.settings.helper_top,10);u=parseInt(z.pageX+r.vakata.dnd.settings.helper_left,10);if(B&&C+25>B){C=B-50}if(s&&u+q.helper_w>s){u=s-(q.helper_w+2)}q.helper.css({left:u+"px",top:C+"px"})}r.vakata.dnd._trigger("move",z);return false},stop:function(s){if(s.type==="touchend"&&s.originalEvent&&s.originalEvent.changedTouches&&s.originalEvent.changedTouches[0]){s.pageX=s.originalEvent.changedTouches[0].pageX;s.pageY=s.originalEvent.changedTouches[0].pageY;s.target=o.elementFromPoint(s.originalEvent.changedTouches[0].pageX-window.pageXOffset,s.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(q.is_drag){if(s.target!==q.target){r(q.target).off("click.vakata")}r.vakata.dnd._trigger("stop",s)}else{if(s.type==="touchend"&&s.target===q.target){var t=setTimeout(function(){r(s.target).click()},100);r(s.target).one("click",function(){if(t){clearTimeout(t)}})}}r.vakata.dnd._clean();return false}}}(g));g.jstree.defaults.massload=null;g.jstree.plugins.massload=function(q,r){this.init=function(t,s){this._data.massload={};r.init.call(this,t,s)};this._load_nodes=function(u,C,B,A){var D=this.settings.massload,t=JSON.stringify(u),v=[],w=this._model.data,z,y,x;if(!B){for(z=0,y=u.length;z<y;z++){if(!w[u[z]]||((!w[u[z]].state.loaded&&!w[u[z]].state.failed)||A)){v.push(u[z]);x=this.get_node(u[z],true);if(x&&x.length){x.addClass("jstree-loading").attr("aria-busy",true)}}}this._data.massload={};if(v.length){if(g.isFunction(D)){return D.call(this,v,g.proxy(function(F){var E,s;if(F){for(E in F){if(F.hasOwnProperty(E)){this._data.massload[E]=F[E]}}}for(E=0,s=u.length;E<s;E++){x=this.get_node(u[E],true);if(x&&x.length){x.removeClass("jstree-loading").attr("aria-busy",false)}}r._load_nodes.call(this,u,C,B,A)},this))}if(typeof D==="object"&&D&&D.url){D=g.extend(true,{},D);if(g.isFunction(D.url)){D.url=D.url.call(this,v)}if(g.isFunction(D.data)){D.data=D.data.call(this,v)}return g.ajax(D).done(g.proxy(function(H,G,s){var F,E;if(H){for(F in H){if(H.hasOwnProperty(F)){this._data.massload[F]=H[F]}}}for(F=0,E=u.length;F<E;F++){x=this.get_node(u[F],true);if(x&&x.length){x.removeClass("jstree-loading").attr("aria-busy",false)}}r._load_nodes.call(this,u,C,B,A)},this)).fail(g.proxy(function(s){r._load_nodes.call(this,u,C,B,A)},this))}}}return r._load_nodes.call(this,u,C,B,A)};this._load_node=function(u,w){var t=this._data.massload[u.id],s=null,v;if(t){s=this[typeof t==="string"?"_append_html_data":"_append_json_data"](u,typeof t==="string"?g(g.parseHTML(t)).filter(function(){return this.nodeType!==3}):t,function(x){w.call(this,x)});v=this.get_node(u.id,true);if(v&&v.length){v.removeClass("jstree-loading").attr("aria-busy",false)}delete this._data.massload[u.id];return s}return r._load_node.call(this,u,w)}};g.jstree.defaults.search={ajax:false,fuzzy:false,case_sensitive:false,show_only_matches:false,show_only_matches_children:false,close_opened_onclear:true,search_leaves_only:false,search_callback:false};g.jstree.plugins.search=function(q,r){this.bind=function(){r.bind.call(this);this._data.search.str="";
  45. this._data.search.dom=g();this._data.search.res=[];this._data.search.opn=[];this._data.search.som=false;this._data.search.smc=false;this._data.search.hdn=[];this.element.on("search.jstree",g.proxy(function(z,x){if(this._data.search.som&&x.res.length){var s=this._model.data,w,v,y=[],u,t;for(w=0,v=x.res.length;w<v;w++){if(s[x.res[w]]&&!s[x.res[w]].state.hidden){y.push(x.res[w]);y=y.concat(s[x.res[w]].parents);if(this._data.search.smc){for(u=0,t=s[x.res[w]].children_d.length;u<t;u++){if(s[s[x.res[w]].children_d[u]]&&!s[s[x.res[w]].children_d[u]].state.hidden){y.push(s[x.res[w]].children_d[u])}}}}}y=g.vakata.array_remove_item(g.vakata.array_unique(y),g.jstree.root);this._data.search.hdn=this.hide_all(true);this.show_node(y,true);this.redraw(true)}},this)).on("clear_search.jstree",g.proxy(function(t,s){if(this._data.search.som&&s.res.length){this.show_node(this._data.search.hdn,true);this.redraw(true)}},this))};this.search=function(D,F,w,y,v,z){if(D===false||g.trim(D.toString())===""){return this.clear_search()}y=this.get_node(y);y=y&&y.id?y.id:null;D=D.toString();var G=this.settings.search,E=G.ajax?G.ajax:false,x=this._model.data,C=null,t=[],u=[],B,A;if(this._data.search.res.length&&!v){this.clear_search()}if(w===e){w=G.show_only_matches}if(z===e){z=G.show_only_matches_children}if(!F&&E!==false){if(g.isFunction(E)){return E.call(this,D,g.proxy(function(s){if(s&&s.d){s=s.d}this._load_nodes(!g.isArray(s)?[]:g.vakata.array_unique(s),function(){this.search(D,true,w,y,v,z)})},this),y)}else{E=g.extend({},E);if(!E.data){E.data={}}E.data.str=D;if(y){E.data.inside=y}if(this._data.search.lastRequest){this._data.search.lastRequest.abort()}this._data.search.lastRequest=g.ajax(E).fail(g.proxy(function(){this._data.core.last_error={"error":"ajax","plugin":"search","id":"search_01","reason":"Could not load search parents","data":JSON.stringify(E)};this.settings.core.error.call(this,this._data.core.last_error)},this)).done(g.proxy(function(s){if(s&&s.d){s=s.d}this._load_nodes(!g.isArray(s)?[]:g.vakata.array_unique(s),function(){this.search(D,true,w,y,v,z)})},this));return this._data.search.lastRequest}}if(!v){this._data.search.str=D;this._data.search.dom=g();this._data.search.res=[];this._data.search.opn=[];this._data.search.som=w;this._data.search.smc=z}C=new g.vakata.search(D,true,{caseSensitive:G.case_sensitive,fuzzy:G.fuzzy});g.each(x[y?y:g.jstree.root].children_d,function(I,H){var s=x[H];if(s.text&&!s.state.hidden&&(!G.search_leaves_only||(s.state.loaded&&s.children.length===0))&&((G.search_callback&&G.search_callback.call(this,D,s))||(!G.search_callback&&C.search(s.text).isMatch))){t.push(H);u=u.concat(s.parents)}});if(t.length){u=g.vakata.array_unique(u);for(B=0,A=u.length;B<A;B++){if(u[B]!==g.jstree.root&&x[u[B]]&&this.open_node(u[B],null,0)===true){this._data.search.opn.push(u[B])}}if(!v){this._data.search.dom=g(this.element[0].querySelectorAll("#"+g.map(t,function(s){return"0123456789".indexOf(s[0])!==-1?"\\3"+s[0]+" "+s.substr(1).replace(g.jstree.idregex,"\\$&"):s.replace(g.jstree.idregex,"\\$&")}).join(", #")));this._data.search.res=t}else{this._data.search.dom=this._data.search.dom.add(g(this.element[0].querySelectorAll("#"+g.map(t,function(s){return"0123456789".indexOf(s[0])!==-1?"\\3"+s[0]+" "+s.substr(1).replace(g.jstree.idregex,"\\$&"):s.replace(g.jstree.idregex,"\\$&")}).join(", #"))));this._data.search.res=g.vakata.array_unique(this._data.search.res.concat(t))}this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:D,res:this._data.search.res,show_only_matches:w})};this.clear_search=function(){if(this.settings.search.close_opened_onclear){this.close_node(this._data.search.opn,0)}this.trigger("clear_search",{"nodes":this._data.search.dom,str:this._data.search.str,res:this._data.search.res});if(this._data.search.res.length){this._data.search.dom=g(this.element[0].querySelectorAll("#"+g.map(this._data.search.res,function(s){return"0123456789".indexOf(s[0])!==-1?"\\3"+s[0]+" "+s.substr(1).replace(g.jstree.idregex,"\\$&"):s.replace(g.jstree.idregex,"\\$&")}).join(", #")));this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search")}this._data.search.str="";this._data.search.res=[];this._data.search.opn=[];this._data.search.dom=g()};this.redraw_node=function(x,s,y,w){x=r.redraw_node.apply(this,arguments);if(x){if(g.inArray(x.id,this._data.search.res)!==-1){var v,t,u=null;for(v=0,t=x.childNodes.length;v<t;v++){if(x.childNodes[v]&&x.childNodes[v].className&&x.childNodes[v].className.indexOf("jstree-anchor")!==-1){u=x.childNodes[v];break}}if(u){u.className+=" jstree-search"}}}return x}};(function(q){q.vakata.search=function(w,u,B){B=B||{};B=q.extend({},q.vakata.search.defaults,B);if(B.fuzzy!==false){B.fuzzy=true}w=B.caseSensitive?w:w.toLowerCase();var y=B.location,z=B.distance,x=B.threshold,r=w.length,s,t,v,A;if(r>32){B.fuzzy=false}if(B.fuzzy){s=1<<(r-1);t=(function(){var C={},D=0;for(D=0;D<r;D++){C[w.charAt(D)]=0}for(D=0;D<r;D++){C[w.charAt(D)]|=1<<(r-D-1)
  46. }return C}());v=function(F,C){var E=F/r,D=Math.abs(y-C);if(!z){return D?1:E}return E+(D/z)}}A=function(P){P=B.caseSensitive?P:P.toLowerCase();if(w===P||P.indexOf(w)!==-1){return{isMatch:true,score:0}}if(!B.fuzzy){return{isMatch:false,score:1}}var K,J,O=P.length,G=x,I=P.indexOf(w,y),M,F,D=r+O,C,E,N,R,Q,H=1,L=[];if(I!==-1){G=Math.min(v(0,I),G);I=P.lastIndexOf(w,y+r);if(I!==-1){G=Math.min(v(0,I),G)}}I=-1;for(K=0;K<r;K++){M=0;F=D;while(M<F){if(v(K,y+F)<=G){M=F}else{D=F}F=Math.floor((D-M)/2+M)}D=F;E=Math.max(1,y-F+1);N=Math.min(y+F,O)+r;R=new Array(N+2);R[N+1]=(1<<K)-1;for(J=N;J>=E;J--){Q=t[P.charAt(J-1)];if(K===0){R[J]=((R[J+1]<<1)|1)&Q}else{R[J]=((R[J+1]<<1)|1)&Q|(((C[J+1]|C[J])<<1)|1)|C[J+1]}if(R[J]&s){H=v(K,J-1);if(H<=G){G=H;I=J-1;L.push(I);if(I>y){E=Math.max(1,2*y-I)}else{break}}}}if(v(K+1,y)>G){break}C=R}return{isMatch:I>=0,score:H}};return u===true?{"search":A}:A(u)};q.vakata.search.defaults={location:0,distance:100,threshold:0.6,fuzzy:false,caseSensitive:false}}(g));g.jstree.defaults.sort=function(r,q){return this.get_text(r)>this.get_text(q)?1:-1};g.jstree.plugins.sort=function(q,r){this.bind=function(){r.bind.call(this);this.element.on("model.jstree",g.proxy(function(t,s){this.sort(s.parent,true)},this)).on("rename_node.jstree create_node.jstree",g.proxy(function(t,s){this.sort(s.parent||s.node.parent,false);this.redraw_node(s.parent||s.node.parent,true)},this)).on("move_node.jstree copy_node.jstree",g.proxy(function(t,s){this.sort(s.parent,false);this.redraw_node(s.parent,true)},this))};this.sort=function(v,s){var u,t;v=this.get_node(v);if(v&&v.children&&v.children.length){v.children.sort(g.proxy(this.settings.sort,this));if(s){for(u=0,t=v.children_d.length;u<t;u++){this.sort(v.children_d[u],false)}}}}};var p=false;g.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree",ttl:false,filter:false};g.jstree.plugins.state=function(q,r){this.bind=function(){r.bind.call(this);var s=g.proxy(function(){this.element.on(this.settings.state.events,g.proxy(function(){if(p){clearTimeout(p)}p=setTimeout(g.proxy(function(){this.save_state()},this),100)},this));this.trigger("state_ready")},this);this.element.on("ready.jstree",g.proxy(function(u,t){this.element.one("restore_state.jstree",s);if(!this.restore_state()){s()}},this))};this.save_state=function(){var s={"state":this.get_state(),"ttl":this.settings.state.ttl,"sec":+(new Date())};g.vakata.storage.set(this.settings.state.key,JSON.stringify(s))};this.restore_state=function(){var s=g.vakata.storage.get(this.settings.state.key);if(!!s){try{s=JSON.parse(s)}catch(t){return false}}if(!!s&&s.ttl&&s.sec&&+(new Date())-s.sec>s.ttl){return false}if(!!s&&s.state){s=s.state}if(!!s&&g.isFunction(this.settings.state.filter)){s=this.settings.state.filter.call(this,s)}if(!!s){this.element.one("set_state.jstree",function(v,u){u.instance.trigger("restore_state",{"state":g.extend(true,{},s)})});this.set_state(s);return true}return false};this.clear_state=function(){return g.vakata.storage.del(this.settings.state.key)}};(function(q,r){q.vakata.storage={set:function(s,t){return window.localStorage.setItem(s,t)},get:function(s){return window.localStorage.getItem(s)},del:function(s){return window.localStorage.removeItem(s)}}}(g));g.jstree.defaults.types={"default":{}};g.jstree.defaults.types[g.jstree.root]={};g.jstree.plugins.types=function(q,r){this.init=function(v,t){var u,s;if(t&&t.types&&t.types["default"]){for(u in t.types){if(u!=="default"&&u!==g.jstree.root&&t.types.hasOwnProperty(u)){for(s in t.types["default"]){if(t.types["default"].hasOwnProperty(s)&&t.types[u][s]===e){t.types[u][s]=t.types["default"][s]}}}}}r.init.call(this,v,t);this._model.data[g.jstree.root].type=g.jstree.root};this.refresh=function(t,s){r.refresh.call(this,t,s);this._model.data[g.jstree.root].type=g.jstree.root};this.bind=function(){this.element.on("model.jstree",g.proxy(function(z,w){var s=this._model.data,y=w.nodes,B=this.settings.types,x,v,A="default",u;for(x=0,v=y.length;x<v;x++){A="default";if(s[y[x]].original&&s[y[x]].original.type&&B[s[y[x]].original.type]){A=s[y[x]].original.type}if(s[y[x]].data&&s[y[x]].data.jstree&&s[y[x]].data.jstree.type&&B[s[y[x]].data.jstree.type]){A=s[y[x]].data.jstree.type}s[y[x]].type=A;if(s[y[x]].icon===true&&B[A].icon!==e){s[y[x]].icon=B[A].icon}if(B[A].li_attr!==e&&typeof B[A].li_attr==="object"){for(u in B[A].li_attr){if(B[A].li_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(s[y[x]].li_attr[u]===e){s[y[x]].li_attr[u]=B[A].li_attr[u]}else{if(u==="class"){s[y[x]].li_attr["class"]=B[A].li_attr["class"]+" "+s[y[x]].li_attr["class"]}}}}}}if(B[A].a_attr!==e&&typeof B[A].a_attr==="object"){for(u in B[A].a_attr){if(B[A].a_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(s[y[x]].a_attr[u]===e){s[y[x]].a_attr[u]=B[A].a_attr[u]}else{if(u==="href"&&s[y[x]].a_attr[u]==="#"){s[y[x]].a_attr["href"]=B[A].a_attr["href"]}else{if(u==="class"){s[y[x]].a_attr["class"]=B[A].a_attr["class"]+" "+s[y[x]].a_attr["class"]
  47. }}}}}}}}s[g.jstree.root].type=g.jstree.root},this));r.bind.call(this)};this.get_json=function(y,u,z){var x,t,s=this._model.data,w=u?g.extend(true,{},u,{no_id:false}):{},v=r.get_json.call(this,y,w,z);if(v===false){return false}if(g.isArray(v)){for(x=0,t=v.length;x<t;x++){v[x].type=v[x].id&&s[v[x].id]&&s[v[x].id].type?s[v[x].id].type:"default";if(u&&u.no_id){delete v[x].id;if(v[x].li_attr&&v[x].li_attr.id){delete v[x].li_attr.id}if(v[x].a_attr&&v[x].a_attr.id){delete v[x].a_attr.id}}}}else{v.type=v.id&&s[v.id]&&s[v.id].type?s[v.id].type:"default";if(u&&u.no_id){v=this._delete_ids(v)}}return v};this._delete_ids=function(u){if(g.isArray(u)){for(var t=0,s=u.length;t<s;t++){u[t]=this._delete_ids(u[t])}return u}delete u.id;if(u.li_attr&&u.li_attr.id){delete u.li_attr.id}if(u.a_attr&&u.a_attr.id){delete u.a_attr.id}if(u.children&&g.isArray(u.children)){u.children=this._delete_ids(u.children)}return u};this.check=function(A,v,y,B,z){if(r.check.call(this,A,v,y,B,z)===false){return false}v=v&&v.id?v:this.get_node(v);y=y&&y.id?y:this.get_node(y);var s=v&&v.id?(z&&z.origin?z.origin:g.jstree.reference(v.id)):null,w,x,u,t;s=s&&s._model&&s._model.data?s._model.data:null;switch(A){case"create_node":case"move_node":case"copy_node":if(A!=="move_node"||g.inArray(v.id,y.children)===-1){w=this.get_rules(y);if(w.max_children!==e&&w.max_children!==-1&&w.max_children===y.children.length){this._data.core.last_error={"error":"check","plugin":"types","id":"types_01","reason":"max_children prevents function: "+A,"data":JSON.stringify({"chk":A,"pos":B,"obj":v&&v.id?v.id:false,"par":y&&y.id?y.id:false})};return false}if(w.valid_children!==e&&w.valid_children!==-1&&g.inArray((v.type||"default"),w.valid_children)===-1){this._data.core.last_error={"error":"check","plugin":"types","id":"types_02","reason":"valid_children prevents function: "+A,"data":JSON.stringify({"chk":A,"pos":B,"obj":v&&v.id?v.id:false,"par":y&&y.id?y.id:false})};return false}if(s&&v.children_d&&v.parents){x=0;for(u=0,t=v.children_d.length;u<t;u++){x=Math.max(x,s[v.children_d[u]].parents.length)}x=x-v.parents.length+1}if(x<=0||x===e){x=1}do{if(w.max_depth!==e&&w.max_depth!==-1&&w.max_depth<x){this._data.core.last_error={"error":"check","plugin":"types","id":"types_03","reason":"max_depth prevents function: "+A,"data":JSON.stringify({"chk":A,"pos":B,"obj":v&&v.id?v.id:false,"par":y&&y.id?y.id:false})};return false}y=this.get_node(y.parent);w=this.get_rules(y);x++}while(y)}break}return true};this.get_rules=function(t){t=this.get_node(t);if(!t){return false}var s=this.get_type(t,true);if(s.max_depth===e){s.max_depth=-1}if(s.max_children===e){s.max_children=-1}if(s.valid_children===e){s.valid_children=-1}return s};this.get_type=function(s,t){s=this.get_node(s);return(!s)?false:(t?g.extend({"type":s.type},this.settings.types[s.type]):s.type)};this.set_type=function(v,z){var s=this._model.data,D,x,w,B,C,u,y,A;if(g.isArray(v)){v=v.slice();for(x=0,w=v.length;x<w;x++){this.set_type(v[x],z)}return true}D=this.settings.types;v=this.get_node(v);if(!D[z]||!v){return false}y=this.get_node(v,true);if(y&&y.length){A=y.children(".jstree-anchor")}B=v.type;C=this.get_icon(v);v.type=z;if(C===true||!D[B]||(D[B].icon!==e&&C===D[B].icon)){this.set_icon(v,D[z].icon!==e?D[z].icon:true)}if(D[B]&&D[B].li_attr!==e&&typeof D[B].li_attr==="object"){for(u in D[B].li_attr){if(D[B].li_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(u==="class"){s[v.id].li_attr["class"]=(s[v.id].li_attr["class"]||"").replace(D[B].li_attr[u],"");if(y){y.removeClass(D[B].li_attr[u])}}else{if(s[v.id].li_attr[u]===D[B].li_attr[u]){s[v.id].li_attr[u]=null;if(y){y.removeAttr(u)}}}}}}}if(D[B]&&D[B].a_attr!==e&&typeof D[B].a_attr==="object"){for(u in D[B].a_attr){if(D[B].a_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(u==="class"){s[v.id].a_attr["class"]=(s[v.id].a_attr["class"]||"").replace(D[B].a_attr[u],"");if(A){A.removeClass(D[B].a_attr[u])}}else{if(s[v.id].a_attr[u]===D[B].a_attr[u]){if(u==="href"){s[v.id].a_attr[u]="#";if(A){A.attr("href","#")}}else{delete s[v.id].a_attr[u];if(A){A.removeAttr(u)}}}}}}}}if(D[z].li_attr!==e&&typeof D[z].li_attr==="object"){for(u in D[z].li_attr){if(D[z].li_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(s[v.id].li_attr[u]===e){s[v.id].li_attr[u]=D[z].li_attr[u];if(y){if(u==="class"){y.addClass(D[z].li_attr[u])}else{y.attr(u,D[z].li_attr[u])}}}else{if(u==="class"){s[v.id].li_attr["class"]=D[z].li_attr[u]+" "+s[v.id].li_attr["class"];if(y){y.addClass(D[z].li_attr[u])}}}}}}}if(D[z].a_attr!==e&&typeof D[z].a_attr==="object"){for(u in D[z].a_attr){if(D[z].a_attr.hasOwnProperty(u)){if(u==="id"){continue}else{if(s[v.id].a_attr[u]===e){s[v.id].a_attr[u]=D[z].a_attr[u];if(A){if(u==="class"){A.addClass(D[z].a_attr[u])}else{A.attr(u,D[z].a_attr[u])}}}else{if(u==="href"&&s[v.id].a_attr[u]==="#"){s[v.id].a_attr["href"]=D[z].a_attr["href"];if(A){A.attr("href",D[z].a_attr["href"])}}else{if(u==="class"){s[v.id].a_attr["class"]=D[z].a_attr["class"]+" "+s[v.id].a_attr["class"];if(A){A.addClass(D[z].a_attr[u])
  48. }}}}}}}}return true}};g.jstree.defaults.unique={case_sensitive:false,duplicate:function(r,q){return r+" ("+q+")"}};g.jstree.plugins.unique=function(q,r){this.check=function(B,x,y,C,z){if(r.check.call(this,B,x,y,C,z)===false){return false}x=x&&x.id?x:this.get_node(x);y=y&&y.id?y:this.get_node(y);if(!y||!y.children){return true}var t=B==="rename_node"?C:x.text,A=[],D=this.settings.unique.case_sensitive,u=this._model.data,w,v;for(w=0,v=y.children.length;w<v;w++){A.push(D?u[y.children[w]].text:u[y.children[w]].text.toLowerCase())}if(!D){t=t.toLowerCase()}switch(B){case"delete_node":return true;case"rename_node":w=(g.inArray(t,A)===-1||(x.text&&x.text[D?"toString":"toLowerCase"]()===t));if(!w){this._data.core.last_error={"error":"check","plugin":"unique","id":"unique_01","reason":"Child with name "+t+" already exists. Preventing: "+B,"data":JSON.stringify({"chk":B,"pos":C,"obj":x&&x.id?x.id:false,"par":y&&y.id?y.id:false})}}return w;case"create_node":w=(g.inArray(t,A)===-1);if(!w){this._data.core.last_error={"error":"check","plugin":"unique","id":"unique_04","reason":"Child with name "+t+" already exists. Preventing: "+B,"data":JSON.stringify({"chk":B,"pos":C,"obj":x&&x.id?x.id:false,"par":y&&y.id?y.id:false})}}return w;case"copy_node":w=(g.inArray(t,A)===-1);if(!w){this._data.core.last_error={"error":"check","plugin":"unique","id":"unique_02","reason":"Child with name "+t+" already exists. Preventing: "+B,"data":JSON.stringify({"chk":B,"pos":C,"obj":x&&x.id?x.id:false,"par":y&&y.id?y.id:false})}}return w;case"move_node":w=((x.parent===y.id&&(!z||!z.is_multi))||g.inArray(t,A)===-1);if(!w){this._data.core.last_error={"error":"check","plugin":"unique","id":"unique_03","reason":"Child with name "+t+" already exists. Preventing: "+B,"data":JSON.stringify({"chk":B,"pos":C,"obj":x&&x.id?x.id:false,"par":y&&y.id?y.id:false})}}return w}return true};this.create_node=function(B,v,D,E,C){if(!v||v.text===e){if(B===null){B=g.jstree.root}B=this.get_node(B);if(!B){return r.create_node.call(this,B,v,D,E,C)}D=D===e?"last":D;if(!D.toString().match(/^(before|after)$/)&&!C&&!this.is_loaded(B)){return r.create_node.call(this,B,v,D,E,C)}if(!v){v={}}var z,t,A,y,x,u=this._model.data,F=this.settings.unique.case_sensitive,w=this.settings.unique.duplicate;t=z=this.get_string("New node");A=[];for(y=0,x=B.children.length;y<x;y++){A.push(F?u[B.children[y]].text:u[B.children[y]].text.toLowerCase())}y=1;while(g.inArray(F?t:t.toLowerCase(),A)!==-1){t=w.call(this,z,(++y)).toString()}v.text=t}return r.create_node.call(this,B,v,D,E,C)}};var b=o.createElement("DIV");b.setAttribute("unselectable","on");b.setAttribute("role","presentation");b.className="jstree-wholerow";b.innerHTML="&#160;";g.jstree.plugins.wholerow=function(q,r){this.bind=function(){r.bind.call(this);this.element.on("ready.jstree set_state.jstree",g.proxy(function(){this.hide_dots()},this)).on("init.jstree loading.jstree ready.jstree",g.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",g.proxy(function(t,s){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",g.proxy(function(w,v){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var u=false,t,s;for(t=0,s=v.selected.length;t<s;t++){u=this.get_node(v.selected[t],true);if(u&&u.length){u.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")}}},this)).on("open_node.jstree",g.proxy(function(t,s){this.get_node(s.node,true).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",g.proxy(function(t,s){if(t.type==="hover_node"&&this.is_disabled(s.node)){return}this.get_node(s.node,true).children(".jstree-wholerow")[t.type==="hover_node"?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",g.proxy(function(t){if(this._data.contextmenu){t.preventDefault();var s=g.Event("contextmenu",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,pageX:t.pageX,pageY:t.pageY});g(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(s)}},this))
  49. .on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var s=g.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});g(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(s).focus()}).on("dblclick.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var s=g.Event("dblclick",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});g(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(s).focus()
  50. }).on("click.jstree",".jstree-leaf > .jstree-ocl",g.proxy(function(t){t.stopImmediatePropagation();var s=g.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});g(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(s).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",g.proxy(function(s){s.stopImmediatePropagation();if(!this.is_disabled(s.currentTarget)){this.hover_node(s.currentTarget)}return false},this)).on("mouseleave.jstree",".jstree-node",g.proxy(function(s){this.dehover_node(s.currentTarget)},this))};this.teardown=function(){if(this.settings.wholerow){this.element.find(".jstree-wholerow").remove()}r.teardown.call(this)};this.redraw_node=function(v,s,w,u){v=r.redraw_node.apply(this,arguments);if(v){var t=b.cloneNode(true);if(g.inArray(v.id,this._data.core.selected)!==-1){t.className+=" jstree-wholerow-clicked"}if(this._data.core.focused&&this._data.core.focused===v.id){t.className+=" jstree-wholerow-hovered"}v.insertBefore(t,v.childNodes[0])}return v}};if(o.registerElement&&Object&&Object.create){var i=Object.create(HTMLElement.prototype);i.createdCallback=function(){var r={core:{},plugins:[]},q;for(q in g.jstree.plugins){if(g.jstree.plugins.hasOwnProperty(q)&&this.attributes[q]){r.plugins.push(q);if(this.getAttribute(q)&&JSON.parse(this.getAttribute(q))){r[q]=JSON.parse(this.getAttribute(q))}}}for(q in g.jstree.defaults.core){if(g.jstree.defaults.core.hasOwnProperty(q)&&this.attributes[q]){r.core[q]=JSON.parse(this.getAttribute(q))||this.getAttribute(q)}}g(this).jstree(r)};try{o.registerElement("vakata-jstree",{prototype:i})}catch(l){}}}));