mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
60 lines
112 KiB
JavaScript
60 lines
112 KiB
JavaScript
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){a(require("jquery"))}else{a(jQuery)}}}(function(i,e){
|
|
/*
|
|
* jsTree 3.0.3
|
|
* http://jstree.com/
|
|
*
|
|
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
|
|
*
|
|
* Licensed same as jquery - under the terms of the MIT License
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*/
|
|
/*
|
|
* if using jslint please allow for the jQuery global and use following options:
|
|
* jslint: browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
|
|
*/
|
|
if(i.jstree){return}var c=0,d=false,k=false,j=false,m=[],a=i("script:last").attr("src"),l=document,o=l.createElement("LI"),g,f;o.setAttribute("role","treeitem");g=l.createElement("I");g.className="jstree-icon jstree-ocl";o.appendChild(g);g=l.createElement("A");g.className="jstree-anchor";g.setAttribute("href","#");f=l.createElement("I");f.className="jstree-icon jstree-themeicon";g.appendChild(f);o.appendChild(g);g=f=null;i.jstree={version:"3.0.3",defaults:{plugins:[]},plugins:{},path:a&&a.indexOf("/")!==-1?a.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%]/g};i.jstree.create=function(s,p){var r=new i.jstree.core(++c),q=p;p=i.extend(true,{},i.jstree.defaults,p);if(q&&q.plugins){p.plugins=q.plugins}i.each(p.plugins,function(u,t){if(u!=="core"){r=r.plugin(t,p[t])}});r.init(s,p);return r};i.jstree.core=function(p){this._id=p;this._cnt=0;this._wrk=null;this._data={core:{themes:{name:false,dots:false,icons:false},selected:[],last_error:{},working:false,worker_queue:[]}}};i.jstree.reference=function(r){var p=null,q=null;if(r&&r.id){r=r.id}if(!q||!q.length){try{q=i(r)}catch(s){}}if(!q||!q.length){try{q=i("#"+r.replace(i.jstree.idregex,"\\$&"))}catch(s){}}if(q&&q.length&&(q=q.closest(".jstree")).length&&(q=q.data("jstree"))){p=q}else{i(".jstree").each(function(){var t=i(this).data("jstree");if(t&&t._model.data[r]){p=t;return false}})}return p};i.fn.jstree=function(q){var s=(typeof q==="string"),r=Array.prototype.slice.call(arguments,1),p=null;this.each(function(){var t=i.jstree.reference(this),u=s&&t?t[q]:null;p=s&&u?u.apply(t,r):null;if(!t&&!s&&(q===e||i.isPlainObject(q))){i(this).data("jstree",new i.jstree.create(this,q))}if((t&&!s)||q===true){p=t||false}if(p!==null&&p!==e){return false}});return p!==null&&p!==e?p:this};i.expr[":"].jstree=i.expr.createPseudo(function(p){return function(q){return i(q).hasClass("jstree")&&i(q).data("jstree")!==e}});i.jstree.defaults.core={data:false,strings:false,check_callback:false,error:i.noop,animation:200,multiple:true,themes:{name:false,url:false,dir:false,dots:true,icons:true,stripes:false,variant:false,responsive:false},expand_selected_onload:true,worker:true,force_text:false};i.jstree.core.prototype={plugin:function(r,q){var p=i.jstree.plugins[r];if(p){this._data[r]={};p.prototype=this;return new p(q,this)}return this},init:function(q,p){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:false}}},changed:[],force_full_redraw:false,redraw_timeout:false,default_state:{loaded:true,opened:false,selected:false,disabled:false}};this.element=i(q).addClass("jstree jstree-"+this._id);this.settings=p;this.element.bind("destroyed",i.proxy(this.teardown,this));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");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'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last'><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._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||24;this.trigger("loading");this.load_node("#")},destroy:function(p){if(!p){this.element.empty()}this.element.unbind("destroyed",this.teardown);this.teardown()},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(){this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty){document.selection.empty()}else{if(window.getSelection){var p=window.getSelection();try{p.removeAllRanges();p.collapse()}catch(q){}}}}).on("click.jstree",".jstree-ocl",i.proxy(function(p){this.toggle_node(p.target)},this)).on("click.jstree",".jstree-anchor",i.proxy(function(p){p.preventDefault();i(p.currentTarget).focus();this.activate_node(p.currentTarget,p)},this)).on("keydown.jstree",".jstree-anchor",i.proxy(function(p){if(p.target.tagName==="INPUT"){return true}var q=null;switch(p.which){case 13:case 32:p.type="click";i(p.currentTarget).trigger(p);break;case 37:p.preventDefault();if(this.is_open(p.currentTarget)){this.close_node(p.currentTarget)}else{q=this.get_prev_dom(p.currentTarget);if(q&&q.length){q.children(".jstree-anchor").focus()}}break;case 38:p.preventDefault();q=this.get_prev_dom(p.currentTarget);if(q&&q.length){q.children(".jstree-anchor").focus()}break;case 39:p.preventDefault();if(this.is_closed(p.currentTarget)){this.open_node(p.currentTarget,function(r){this.get_node(r,true).children(".jstree-anchor").focus()})}else{q=this.get_next_dom(p.currentTarget);if(q&&q.length){q.children(".jstree-anchor").focus()}}break;case 40:p.preventDefault();q=this.get_next_dom(p.currentTarget);if(q&&q.length){q.children(".jstree-anchor").focus()}break;case 46:p.preventDefault();q=this.get_node(p.currentTarget);if(q&&q.id&&q.id!=="#"){q=this.is_selected(q)?this.get_selected():q}break;case 113:p.preventDefault();q=this.get_node(p.currentTarget);
|
|
/*
|
|
if(o && o.id && o.id !== '#') {
|
|
// this.edit(o);
|
|
}
|
|
*/
|
|
break;default:break}},this)).on("load_node.jstree",i.proxy(function(t,s){if(s.status){if(s.node.id==="#"&&!this._data.core.loaded){this._data.core.loaded=true;this.trigger("loaded")}if(!this._data.core.ready&&!this.get_container_ul().find(".jstree-loading:eq(0)").length){this._data.core.ready=true;if(this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var r=[],q,p;for(q=0,p=this._data.core.selected.length;q<p;q++){r=r.concat(this._model.data[this._data.core.selected[q]].parents)}r=i.vakata.array_unique(r);for(q=0,p=r.length;q<p;q++){this.open_node(r[q],false,0)}}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}setTimeout(i.proxy(function(){this.trigger("ready")},this),0)}}},this)).on("init.jstree",i.proxy(function(){var p=this.settings.core.themes;this._data.core.themes.dots=p.dots;this._data.core.themes.stripes=p.stripes;this._data.core.themes.icons=p.icons;this.set_theme(p.name||"default",p.url);this.set_theme_variant(p.variant)},this)).on("loading.jstree",i.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)).on("blur.jstree",".jstree-anchor",i.proxy(function(p){i(p.currentTarget).filter(".jstree-hovered").mouseleave()},this)).on("focus.jstree",".jstree-anchor",i.proxy(function(p){this.element.find(".jstree-hovered").not(p.currentTarget).mouseleave();i(p.currentTarget).mouseenter()},this)).on("mouseenter.jstree",".jstree-anchor",i.proxy(function(p){this.hover_node(p.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",i.proxy(function(p){this.dehover_node(p.currentTarget)},this))},unbind:function(){this.element.off(".jstree");i(document).off(".jstree-"+this._id)},trigger:function(p,q){if(!q){q={}}q.instance=this;this.element.triggerHandler(p.replace(".jstree","")+".jstree",q)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children(".jstree-children:eq(0)")},get_string:function(q){var p=this.settings.core.strings;if(i.isFunction(p)){return p.call(this,q)}if(p&&p[q]){return p[q]}return q},_firstChild:function(p){p=p?p.firstChild:null;while(p!==null&&p.nodeType!==1){p=p.nextSibling}return p},_nextSibling:function(p){p=p?p.nextSibling:null;while(p!==null&&p.nodeType!==1){p=p.nextSibling}return p},_previousSibling:function(p){p=p?p.previousSibling:null;while(p!==null&&p.nodeType!==1){p=p.previousSibling}return p},get_node:function(r,p){if(r&&r.id){r=r.id}var s;try{if(this._model.data[r]){r=this._model.data[r]}else{if(((s=i(r,this.element)).length||(s=i("#"+r.replace(i.jstree.idregex,"\\$&"),this.element)).length)&&this._model.data[s.closest(".jstree-node").attr("id")]){r=this._model.data[s.closest(".jstree-node").attr("id")]}else{if((s=i(r,this.element)).length&&s.hasClass("jstree")){r=this._model.data["#"]}else{return false}}}if(p){r=r.id==="#"?this.element:i("#"+r.id.replace(i.jstree.idregex,"\\$&"),this.element)}return r}catch(q){return false}},get_path:function(v,t,s){v=v.parents?v:this.get_node(v);if(!v||v.id==="#"||!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(r,p){var q;r=this.get_node(r,true);if(r[0]===this.element[0]){q=this._firstChild(this.get_container_ul()[0]);return q?i(q):false}if(!r||!r.length){return false}if(p){q=this._nextSibling(r[0]);return q?i(q):false}if(r.hasClass("jstree-open")){q=this._firstChild(r.children(".jstree-children")[0]);return q?i(q):false}if((q=this._nextSibling(r[0]))!==null){return i(q)}return r.parentsUntil(".jstree",".jstree-node").next(".jstree-node").eq(0)},get_prev_dom:function(r,p){var q;r=this.get_node(r,true);if(r[0]===this.element[0]){q=this.get_container_ul()[0].lastChild;return q?i(q):false}if(!r||!r.length){return false}if(p){q=this._previousSibling(r[0]);return q?i(q):false}if((q=this._previousSibling(r[0]))!==null){r=i(q);while(r.hasClass("jstree-open")){r=r.children(".jstree-children:eq(0)").children(".jstree-node:last")}return r}q=r[0].parentNode.parentNode;return q&&q.className&&q.className.indexOf("jstree-node")!==-1?i(q):false},get_parent:function(p){p=this.get_node(p);if(!p||p.id==="#"){return false}return p.parent},get_children_dom:function(p){p=this.get_node(p,true);if(p[0]===this.element[0]){return this.get_container_ul().children(".jstree-node")}if(!p||!p.length){return false}return p.children(".jstree-children").children(".jstree-node")},is_parent:function(p){p=this.get_node(p);return p&&(p.state.loaded===false||p.children.length>0)},is_loaded:function(p){p=this.get_node(p);return p&&p.state.loaded},is_loading:function(p){p=this.get_node(p);return p&&p.state&&p.state.loading},is_open:function(p){p=this.get_node(p);return p&&p.state.opened},is_closed:function(p){p=this.get_node(p);return p&&this.is_parent(p)&&!p.state.opened},is_leaf:function(p){return !this.is_parent(p)},load_node:function(t,v){var q,p,s,r,u;if(i.isArray(t)){this._load_nodes(t.slice(),v);return true}t=this.get_node(t);if(!t){if(v){v.call(this,t,false)}return false}if(t.state.loaded){t.state.loaded=false;for(q=0,p=t.children_d.length;q<p;q++){for(s=0,r=t.parents.length;s<r;s++){this._model.data[t.parents[s]].children_d=i.vakata.array_remove_item(this._model.data[t.parents[s]].children_d,t.children_d[q])}if(this._model.data[t.children_d[q]].state.selected){u=true;this._data.core.selected=i.vakata.array_remove_item(this._data.core.selected,t.children_d[q])}delete this._model.data[t.children_d[q]]}t.children=[];t.children_d=[];if(u){this.trigger("changed",{action:"load_node",node:t,selected:this._data.core.selected})}}t.state.loading=true;this.get_node(t,true).addClass("jstree-loading");this._load_node(t,i.proxy(function(w){t=this._model.data[t.id];t.state.loading=false;t.state.loaded=w;var x=this.get_node(t,true);if(t.state.loaded&&!t.children.length&&x&&x.length&&!x.hasClass("jstree-leaf")){x.removeClass("jstree-closed jstree-open").addClass("jstree-leaf")}x.removeClass("jstree-loading");this.trigger("load_node",{node:t,status:w});if(v){v.call(this,t,w)}},this));return true},_load_nodes:function(q,x,u){var v=true,w=function(){this._load_nodes(q,x,true)},p=this._model.data,t,s;for(t=0,s=q.length;t<s;t++){if(p[q[t]]&&(!p[q[t]].state.loaded||!u)){if(!this.is_loading(q[t])){this.load_node(q[t],w)}v=false}}if(v){if(x&&!x.done){x.call(this,q);x.done=true}}},_load_node:function(r,u){var q=this.settings.core.data,p;if(!q){if(r.id==="#"){return this._append_html_data(r,this._data.core.original_container_html.clone(true),function(s){u.call(this,s)})}else{return u.call(this,false)}}if(i.isFunction(q)){return q.call(this,r,i.proxy(function(s){if(s===false){u.call(this,false)}this[typeof s==="string"?"_append_html_data":"_append_json_data"](r,typeof s==="string"?i(s):s,function(t){u.call(this,t)})},this))}if(typeof q==="object"){if(q.url){q=i.extend(true,{},q);if(i.isFunction(q.url)){q.url=q.url.call(this,r)}if(i.isFunction(q.data)){q.data=q.data.call(this,r)}return i.ajax(q).done(i.proxy(function(y,v,s){var w=s.getResponseHeader("Content-Type");if(w.indexOf("json")!==-1||typeof y==="object"){return this._append_json_data(r,y,function(t){u.call(this,t)})}if(w.indexOf("html")!==-1||typeof y==="string"){return this._append_html_data(r,i(y),function(t){u.call(this,t)})}this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:r.id,xhr:s})};this.settings.core.error.call(this,this._data.core.last_error);return u.call(this,false)},this)).fail(i.proxy(function(s){u.call(this,false);this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:r.id,xhr:s})};this.settings.core.error.call(this,this._data.core.last_error)},this))}p=(i.isArray(q)||i.isPlainObject(q))?JSON.parse(JSON.stringify(q)):q;if(r.id==="#"){return this._append_json_data(r,p,function(s){u.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:r.id})};this.settings.core.error.call(this,this._data.core.last_error);return u.call(this,false)}}if(typeof q==="string"){if(r.id==="#"){return this._append_html_data(r,i(q),function(s){u.call(this,s)})}else{this._data.core.last_error={error:"nodata",plugin:"core",id:"core_06",reason:"Could not load node",data:JSON.stringify({id:r.id})};this.settings.core.error.call(this,this._data.core.last_error);return u.call(this,false)}}return u.call(this,false)},_node_changed:function(p){p=this.get_node(p);if(p){this._model.changed.push(p.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(i.proxy(function(s,p){x=this._parse_model_from_html(i(p),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!=="#"){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(x,u,p){x=this.get_node(x);x.children=[];x.children_d=[];if(u.d){u=u.d;if(typeof u==="string"){u=JSON.parse(u)}}if(!i.isArray(u)){u=[u]}var r=null,s={df:this._model.default_state,dat:u,par:x.id,m:this._model.data,t_id:this._id,t_cnt:this._cnt,sel:this._data.core.selected},t=function(P,y){if(P.data){P=P.data}var K=P.dat,D=P.par,w=[],z=[],E=[],L=P.df,B=P.t_id,C=P.t_cnt,G=P.m,F=G[D],H=P.sel,N,J,I,M,O=function(X,R,Q){if(!Q){Q=[]}else{Q=Q.concat()}if(R){Q.unshift(R)}var S=X.id.toString(),V,T,Y,W,U={id:S,text:X.text||"",icon:X.icon!==y?X.icon:true,parent:R,parents:Q,children:X.children||[],children_d:X.children_d||[],data:X.data,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(V in L){if(L.hasOwnProperty(V)){U.state[V]=L[V]}}if(X&&X.data&&X.data.jstree&&X.data.jstree.icon){U.icon=X.data.jstree.icon}if(X&&X.data){U.data=X.data;if(X.data.jstree){for(V in X.data.jstree){if(X.data.jstree.hasOwnProperty(V)){U.state[V]=X.data.jstree[V]}}}}if(X&&typeof X.state==="object"){for(V in X.state){if(X.state.hasOwnProperty(V)){U.state[V]=X.state[V]}}}if(X&&typeof X.li_attr==="object"){for(V in X.li_attr){if(X.li_attr.hasOwnProperty(V)){U.li_attr[V]=X.li_attr[V]}}}if(!U.li_attr.id){U.li_attr.id=S}if(X&&typeof X.a_attr==="object"){for(V in X.a_attr){if(X.a_attr.hasOwnProperty(V)){U.a_attr[V]=X.a_attr[V]}}}if(X&&X.children&&X.children===true){U.state.loaded=false;U.children=[];U.children_d=[]}G[U.id]=U;for(V=0,T=U.children.length;V<T;V++){Y=O(G[U.children[V]],U.id,Q);W=G[Y];U.children_d.push(Y);if(W.children_d.length){U.children_d=U.children_d.concat(W.children_d)}}delete X.data;delete X.children;G[U.id].original=X;if(U.state.selected){E.push(U.id)}return U.id},A=function(X,R,Q){if(!Q){Q=[]}else{Q=Q.concat()}if(R){Q.unshift(R)}var S=false,V,T,Y,W,U;do{S="j"+B+"_"+(++C)}while(G[S]);U={id:false,text:typeof X==="string"?X:"",icon:typeof X==="object"&&X.icon!==y?X.icon:true,parent:R,parents:Q,children:[],children_d:[],data:null,state:{},li_attr:{id:false},a_attr:{href:"#"},original:false};for(V in L){if(L.hasOwnProperty(V)){U.state[V]=L[V]}}if(X&&X.id){U.id=X.id.toString()}if(X&&X.text){U.text=X.text}if(X&&X.data&&X.data.jstree&&X.data.jstree.icon){U.icon=X.data.jstree.icon}if(X&&X.data){U.data=X.data;if(X.data.jstree){for(V in X.data.jstree){if(X.data.jstree.hasOwnProperty(V)){U.state[V]=X.data.jstree[V]}}}}if(X&&typeof X.state==="object"){for(V in X.state){if(X.state.hasOwnProperty(V)){U.state[V]=X.state[V]}}}if(X&&typeof X.li_attr==="object"){for(V in X.li_attr){if(X.li_attr.hasOwnProperty(V)){U.li_attr[V]=X.li_attr[V]}}}if(U.li_attr.id&&!U.id){U.id=U.li_attr.id.toString()}if(!U.id){U.id=S}if(!U.li_attr.id){U.li_attr.id=U.id}if(X&&typeof X.a_attr==="object"){for(V in X.a_attr){if(X.a_attr.hasOwnProperty(V)){U.a_attr[V]=X.a_attr[V]}}}if(X&&X.children&&X.children.length){for(V=0,T=X.children.length;V<T;V++){Y=A(X.children[V],U.id,Q);W=G[Y];U.children.push(Y);if(W.children_d.length){U.children_d=U.children_d.concat(W.children_d)}}U.children_d=U.children_d.concat(U.children)}if(X&&X.children&&X.children===true){U.state.loaded=false;U.children=[];U.children_d=[]}delete X.data;delete X.children;U.original=X;G[U.id]=U;if(U.state.selected){E.push(U.id)}return U.id};if(K.length&&K[0].id!==y&&K[0].parent!==y){for(J=0,I=K.length;J<I;J++){if(!K[J].children){K[J].children=[]}G[K[J].id.toString()]=K[J]}for(J=0,I=K.length;J<I;J++){G[K[J].parent.toString()].children.push(K[J].id.toString());F.children_d.push(K[J].id.toString())}for(J=0,I=F.children.length;J<I;J++){N=O(G[F.children[J]],D,F.parents.concat());z.push(N);if(G[N].children_d.length){z=z.concat(G[N].children_d)}}for(J=0,I=F.parents.length;J<I;J++){G[F.parents[J]].children_d=G[F.parents[J]].children_d.concat(z)}M={cnt:C,mod:G,sel:H,par:D,dpc:z,add:E}}else{for(J=0,I=K.length;J<I;J++){N=A(K[J],D,F.parents.concat());if(N){w.push(N);z.push(N);if(G[N].children_d.length){z=z.concat(G[N].children_d)}}}F.children=w;F.children_d=z;for(J=0,I=F.parents.length;J<I;J++){G[F.parents[J]].children_d=G[F.parents[J]].children_d.concat(z)}M={cnt:C,mod:G,sel:H,par:D,dpc:z,add:E}}return M},q=function(z,E){this._cnt=z.cnt;this._model.data=z.mod;if(E){var B,A,y=z.add,D=z.sel,C=this._data.core.selected.slice(),w=this._model.data;if(D.length!==C.length||i.vakata.array_unique(D.concat(C)).length!==D.length){for(B=0,A=D.length;B<A;B++){if(i.inArray(D[B],y)===-1&&i.inArray(D[B],C)===-1){w[D[B]].state.selected=false}}for(B=0,A=C.length;B<A;B++){if(i.inArray(C[B],D)===-1){w[C[B]].state.selected=true}}}}if(z.add.length){this._data.core.selected=this._data.core.selected.concat(z.add)}this.trigger("model",{nodes:z.dpc,parent:z.par});if(z.par!=="#"){this._node_changed(z.par);this.redraw()}else{this.redraw(true)}if(z.add.length){this.trigger("changed",{action:"model",selected:this._data.core.selected})}p.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 = "+t.toString().replace(/return ([^;}]+)[\s;}]+$/,"postMessage($1);}")],{type:"text/javascript"}))}r=new window.Worker(this._wrk);r.onmessage=i.proxy(function(w){q.call(this,w.data,true);this._data.core.working=false;if(this._data.core.worker_queue.length){this._append_json_data.apply(this,this._data.core.worker_queue.shift())}},this);if(!this._data.core.working){this._data.core.working=true;r.postMessage(s)}else{this._data.core.worker_queue.push([x,u,p])}}catch(v){q.call(this,t(s),false)}}else{q.call(this,t(s),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=i.vakata.attributes(y,true);i.each(u,function(A,p){p=i.trim(p);if(!p.length){return true}v.li_attr[A]=p;if(A==="id"){v.id=p.toString()}});u=y.children("a").eq(0);if(u.length){u=i.vakata.attributes(u,true);i.each(u,function(A,p){p=i.trim(p);if(p.length){v.a_attr[A]=p}})}u=y.children("a:eq(0)").length?y.children("a:eq(0)").clone():y.clone();u.children("ins, i, ul").remove();u=u.html();u=i("<div />").html(u);v.text=this.settings.core.force_text?u.text():u.html();u=y.data();v.data=u?i.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){v.icon=v.state.icon}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(i.proxy(function(A,p){z=this._parse_model_from_html(i(p),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};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(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(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 p=this._model.force_full_redraw?this._model.data["#"].children.concat([]):this._model.changed.concat([]),t=document.createElement("UL"),s,r,q;for(r=0,q=p.length;r<q;r++){s=this.redraw_node(p[r],true,this._model.force_full_redraw);if(s&&this._model.force_full_redraw){t.appendChild(s)}}if(this._model.force_full_redraw){t.className=this.get_container_ul()[0].className;this.element.empty().append(t)}this._model.force_full_redraw=false;this._model.changed=[];this.trigger("redraw",{nodes:p})},redraw:function(p){if(p){this._model.force_full_redraw=true}this._redraw()},redraw_node:function(t,E,D){var x=this.get_node(t),B=false,p=false,q=false,y=false,v=false,u=false,C="",A=document,r=this._model.data,z=false,F=false,w=null;if(!x){return false}if(x.id==="#"){return this.redraw(true)}E=E||x.children.length===0;t=!document.querySelector?document.getElementById(x.id):this.element[0].querySelector("#"+("0123456789".indexOf(x.id[0])!==-1?"\\3"+x.id[0]+" "+x.id.substr(1).replace(i.jstree.idregex,"\\$&"):x.id.replace(i.jstree.idregex,"\\$&")));if(!t){E=true;if(!D){B=x.parent!=="#"?i("#"+x.parent.replace(i.jstree.idregex,"\\$&"),this.element)[0]:null;if(B!==null&&(!B||!r[x.parent].state.opened)){return false}p=i.inArray(x.id,B===null?r["#"].children:r[x.parent].children)}}else{t=i(t);if(!D){B=t.parent().parent()[0];if(B===this.element[0]){B=null}p=t.index()}if(!E&&x.children.length&&!t.children(".jstree-children").length){E=true}if(!E){q=t.children(".jstree-children")[0]}F=t.attr("aria-selected");z=t.children(".jstree-anchor")[0]===document.activeElement;t.remove()}t=o.cloneNode(true);C="jstree-node ";for(y in x.li_attr){if(x.li_attr.hasOwnProperty(y)){if(y==="id"){continue}if(y!=="class"){t.setAttribute(y,x.li_attr[y])}else{C+=x.li_attr[y]}}}if(F&&F!=="false"){t.setAttribute("aria-selected",true)}if(x.state.loaded&&!x.children.length){C+=" jstree-leaf"}else{C+=x.state.opened&&x.state.loaded?" jstree-open":" jstree-closed";t.setAttribute("aria-expanded",(x.state.opened&&x.state.loaded))}if(x.parent!==null&&r[x.parent].children[r[x.parent].children.length-1]===x.id){C+=" jstree-last"}t.id=x.id;t.className=C;C=(x.state.selected?" jstree-clicked":"")+(x.state.disabled?" jstree-disabled":"");for(v in x.a_attr){if(x.a_attr.hasOwnProperty(v)){if(v==="href"&&x.a_attr[v]==="#"){continue}if(v!=="class"){t.childNodes[1].setAttribute(v,x.a_attr[v])}else{C+=" "+x.a_attr[v]}}}if(C.length){t.childNodes[1].className="jstree-anchor "+C}if((x.icon&&x.icon!==true)||x.icon===false){if(x.icon===false){t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden"}else{if(x.icon.indexOf("/")===-1&&x.icon.indexOf(".")===-1){t.childNodes[1].childNodes[0].className+=" "+x.icon+" jstree-themeicon-custom"}else{t.childNodes[1].childNodes[0].style.backgroundImage="url("+x.icon+")";t.childNodes[1].childNodes[0].style.backgroundPosition="center center";t.childNodes[1].childNodes[0].style.backgroundSize="auto";t.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom"}}}if(this.settings.core.force_text){t.childNodes[1].appendChild(A.createTextNode(x.text))}else{t.childNodes[1].innerHTML+=x.text}if(E&&x.children.length&&x.state.opened&&x.state.loaded){u=A.createElement("UL");u.setAttribute("role","group");u.className="jstree-children";for(y=0,v=x.children.length;y<v;y++){u.appendChild(this.redraw_node(x.children[y],E,true))}t.appendChild(u)}if(q){t.appendChild(q)}if(!D){if(!B){B=this.element[0]}for(y=0,v=B.childNodes.length;y<v;y++){if(B.childNodes[y]&&B.childNodes[y].className&&B.childNodes[y].className.indexOf("jstree-children")!==-1){w=B.childNodes[y];break}}if(!w){w=A.createElement("UL");w.setAttribute("role","group");w.className="jstree-children";B.appendChild(w)}B=w;if(p<B.childNodes.length){B.insertBefore(t,B.childNodes[p])}else{B.appendChild(t)}if(z){t.childNodes[1].focus()}}if(x.state.opened&&!x.state.loaded){x.state.opened=false;setTimeout(i.proxy(function(){this.open_node(x.id,false,0)},this),0)}return t},open_node:function(u,w,s){var r,q,v,p;if(i.isArray(u)){u=u.slice();for(r=0,q=u.length;r<q;r++){this.open_node(u[r],w,s)}return true}u=this.get_node(u);if(!u||u.id==="#"){return false}s=s===e?this.settings.core.animation:s;if(!this.is_closed(u)){if(w){w.call(this,u,false)}return false}if(!this.is_loaded(u)){if(this.is_loading(u)){return setTimeout(i.proxy(function(){this.open_node(u,w,s)},this),500)}this.load_node(u,function(x,t){return t?this.open_node(x,w,s):(w?w.call(this,x,false):false)})}else{v=this.get_node(u,true);p=this;if(v.length){if(u.children.length&&!this._firstChild(v.children(".jstree-children")[0])){u.state.opened=true;this.redraw_node(u,true);v=this.get_node(u,true)}if(!s){this.trigger("before_open",{node:u});v[0].className=v[0].className.replace("jstree-closed","jstree-open");v[0].setAttribute("aria-expanded",true)}else{this.trigger("before_open",{node:u});v.children(".jstree-children").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",true).children(".jstree-children").stop(true,true).slideDown(s,function(){this.style.display="";p.trigger("after_open",{node:u})})}}u.state.opened=true;if(w){w.call(this,u,true)}if(!v.length){this.trigger("before_open",{node:u})}this.trigger("open_node",{node:u});if(!s||!v.length){this.trigger("after_open",{node:u})}}},_open_to:function(t){t=this.get_node(t);if(!t||t.id==="#"){return false}var r,q,s=t.parents;for(r=0,q=s.length;r<q;r+=1){if(r!=="#"){this.open_node(s[r],false,0)}}return i("#"+t.id.replace(i.jstree.idregex,"\\$&"),this.element)},close_node:function(u,s){var r,q,p,v;if(i.isArray(u)){u=u.slice();for(r=0,q=u.length;r<q;r++){this.close_node(u[r],s)}return true}u=this.get_node(u);if(!u||u.id==="#"){return false}if(this.is_closed(u)){return false}s=s===e?this.settings.core.animation:s;p=this;v=this.get_node(u,true);if(v.length){if(!s){v[0].className=v[0].className.replace("jstree-open","jstree-closed");v.attr("aria-expanded",false).children(".jstree-children").remove()}else{v.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(s,function(){this.style.display="";v.children(".jstree-children").remove();p.trigger("after_close",{node:u})})}}u.state.opened=false;this.trigger("close_node",{node:u});if(!s||!v.length){this.trigger("after_close",{node:u})}},toggle_node:function(r){var q,p;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.toggle_node(r[q])}return true}if(this.is_closed(r)){return this.open_node(r)}if(this.is_open(r)){return this.close_node(r)}},open_all:function(t,s,p){if(!t){t="#"}t=this.get_node(t);if(!t){return false}var u=t.id==="#"?this.get_container_ul():this.get_node(t,true),r,q,v;if(!u.length){for(r=0,q=t.children_d.length;r<q;r++){if(this.is_closed(this._model.data[t.children_d[r]])){this._model.data[t.children_d[r]].state.opened=true}}return this.trigger("open_all",{node:t})}p=p||u;v=this;u=this.is_closed(t)?u.find(".jstree-closed").addBack():u.find(".jstree-closed");u.each(function(){v.open_node(this,function(x,w){if(w&&this.is_parent(x)){this.open_all(x,s,p)}},s||0)});if(p.find(".jstree-closed").length===0){this.trigger("open_all",{node:this.get_node(p)})}},close_all:function(s,r){if(!s){s="#"}s=this.get_node(s);if(!s){return false}var t=s.id==="#"?this.get_container_ul():this.get_node(s,true),u=this,q,p;if(!t.length){for(q=0,p=s.children_d.length;q<p;q++){this._model.data[s.children_d[q]].state.opened=false}return this.trigger("close_all",{node:s})}t=this.is_open(s)?t.find(".jstree-open").addBack():t.find(".jstree-open");i(t.get().reverse()).each(function(){u.close_node(this,r||0)});this.trigger("close_all",{node:s})},is_disabled:function(p){p=this.get_node(p);return p&&p.state&&p.state.disabled},enable_node:function(r){var q,p;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.enable_node(r[q])}return true}r=this.get_node(r);if(!r||r.id==="#"){return false}r.state.disabled=false;this.get_node(r,true).children(".jstree-anchor").removeClass("jstree-disabled");this.trigger("enable_node",{node:r})},disable_node:function(r){var q,p;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.disable_node(r[q])}return true}r=this.get_node(r);if(!r||r.id==="#"){return false}r.state.disabled=true;this.get_node(r,true).children(".jstree-anchor").addClass("jstree-disabled");this.trigger("disable_node",{node:r})},activate_node:function(v,u){if(this.is_disabled(v)){return false}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);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(x||t[s]===w||t[s]===q){this.select_node(t[s],false,false,u)}else{this.deselect_node(t[s],false,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)})},hover_node:function(q){q=this.get_node(q,true);if(!q||!q.length||q.children(".jstree-hovered").length){return false}var r=this.element.find(".jstree-hovered"),p=this.element;if(r&&r.length){this.dehover_node(r)}q.children(".jstree-anchor").addClass("jstree-hovered");this.trigger("hover_node",{node:this.get_node(q)});setTimeout(function(){p.attr("aria-activedescendant",q[0].id);q.attr("aria-selected",true)},0)},dehover_node:function(p){p=this.get_node(p,true);if(!p||!p.length||!p.children(".jstree-hovered").length){return false}p.attr("aria-selected",false).children(".jstree-anchor").removeClass("jstree-hovered");this.trigger("dehover_node",{node:this.get_node(p)})},select_node:function(u,w,p,t){var v,s,q,r;if(i.isArray(u)){u=u.slice();for(s=0,q=u.length;s<q;s++){this.select_node(u[s],w,p,t)}return true}u=this.get_node(u);if(!u||u.id==="#"){return false}v=this.get_node(u,true);if(!u.state.selected){u.state.selected=true;this._data.core.selected.push(u.id);if(!p){v=this._open_to(u)}if(v&&v.length){v.children(".jstree-anchor").addClass("jstree-clicked")}this.trigger("select_node",{node:u,selected:this._data.core.selected,event:t});if(!w){this.trigger("changed",{action:"select_node",node:u,selected:this._data.core.selected,event:t})}}},deselect_node:function(s,u,r){var q,p,t;if(i.isArray(s)){s=s.slice();for(q=0,p=s.length;q<p;q++){this.deselect_node(s[q],u,r)}return true}s=this.get_node(s);if(!s||s.id==="#"){return false}t=this.get_node(s,true);if(s.state.selected){s.state.selected=false;this._data.core.selected=i.vakata.array_remove_item(this._data.core.selected,s.id);if(t.length){t.children(".jstree-anchor").removeClass("jstree-clicked")}this.trigger("deselect_node",{node:s,selected:this._data.core.selected,event:r});if(!u){this.trigger("changed",{action:"deselect_node",node:s,selected:this._data.core.selected,event:r})}}},select_all:function(s){var r=this._data.core.selected.concat([]),q,p;this._data.core.selected=this._model.data["#"].children_d.concat();for(q=0,p=this._data.core.selected.length;q<p;q++){if(this._model.data[this._data.core.selected[q]]){this._model.data[this._data.core.selected[q]].state.selected=true}}this.redraw(true);this.trigger("select_all",{selected:this._data.core.selected});if(!s){this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:r})}},deselect_all:function(s){var r=this._data.core.selected.concat([]),q,p;for(q=0,p=this._data.core.selected.length;q<p;q++){if(this._model.data[this._data.core.selected[q]]){this._model.data[this._data.core.selected[q]].state.selected=false}}this._data.core.selected=[];this.element.find(".jstree-clicked").removeClass("jstree-clicked");this.trigger("deselect_all",{selected:this._data.core.selected,node:r});if(!s){this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:r})}},is_selected:function(p){p=this.get_node(p);if(!p||p.id==="#"){return false}return p.state.selected},get_selected:function(p){return p?i.map(this._data.core.selected,i.proxy(function(q){return this.get_node(q)},this)):this._data.core.selected.slice()},get_top_selected:function(u){var t=this.get_selected(true),v={},s,r,q,p;for(s=0,r=t.length;s<r;s++){v[t[s].id]=t[s]}for(s=0,r=t.length;s<r;s++){for(q=0,p=t[s].children_d.length;q<p;q++){if(v[t[s].children_d[q]]){delete v[t[s].children_d[q]]}}}t=[];for(s in v){if(v.hasOwnProperty(s)){t.push(s)}}return u?i.map(t,i.proxy(function(w){return this.get_node(w)},this)):t},get_bottom_selected:function(s){var r=this.get_selected(true),t=[],q,p;for(q=0,p=r.length;q<p;q++){if(!r[q].children.length){t.push(r[q].id)}}return s?i.map(t,i.proxy(function(u){return this.get_node(u)},this)):t},get_state:function(){var q={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},
|
|
/*
|
|
'themes' : {
|
|
'name' : this.get_theme(),
|
|
'icons' : this._data.core.themes.icons,
|
|
'dots' : this._data.core.themes.dots
|
|
},
|
|
*/
|
|
selected:[]}},p;for(p in this._model.data){if(this._model.data.hasOwnProperty(p)){if(p!=="#"){if(this._model.data[p].state.opened){q.core.open.push(p)}if(this._model.data[p].state.selected){q.core.selected.push(p)}}}}return q},set_state:function(r,v){if(r){if(r.core){var q,u,p,s;if(r.core.open){if(!i.isArray(r.core.open)){delete r.core.open;this.set_state(r,v);return false}q=true;u=false;p=this;i.each(r.core.open.concat([]),function(w,t){u=p.get_node(t);if(u){if(p.is_loaded(t)){if(p.is_closed(t)){p.open_node(t,false,0)}if(r&&r.core&&r.core.open){i.vakata.array_remove_item(r.core.open,t)}}else{if(!p.is_loading(t)){p.open_node(t,i.proxy(function(y,x){if(!x&&r&&r.core&&r.core.open){i.vakata.array_remove_item(r.core.open,y.id)}this.set_state(r,v)},p),0)}q=false}}});if(q){delete r.core.open;this.set_state(r,v)}return false}if(r.core.scroll){if(r.core.scroll&&r.core.scroll.left!==e){this.element.scrollLeft(r.core.scroll.left)}if(r.core.scroll&&r.core.scroll.top!==e){this.element.scrollTop(r.core.scroll.top)}delete r.core.scroll;this.set_state(r,v);return false;
|
|
/*
|
|
if(state.core.themes) {
|
|
if(state.core.themes.name) {
|
|
this.set_theme(state.core.themes.name);
|
|
}
|
|
if(typeof state.core.themes.dots !== 'undefined') {
|
|
this[ state.core.themes.dots ? "show_dots" : "hide_dots" ]();
|
|
}
|
|
if(typeof state.core.themes.icons !== 'undefined') {
|
|
this[ state.core.themes.icons ? "show_icons" : "hide_icons" ]();
|
|
}
|
|
delete state.core.themes;
|
|
delete state.core.open;
|
|
this.set_state(state, callback);
|
|
return false;
|
|
}
|
|
*/
|
|
}if(r.core.selected){s=this;this.deselect_all();i.each(r.core.selected,function(w,t){s.select_node(t)});delete r.core.selected;this.set_state(r,v);return false}if(i.isEmptyObject(r.core)){delete r.core;this.set_state(r,v);return false}}if(i.isEmptyObject(r)){r=null;if(v){v.call(this)}this.trigger("set_state");return false}return true}return false},refresh:function(q,p){this._data.core.state=p===true?{}:this.get_state();if(p&&i.isFunction(p)){this._data.core.state=p.call(this,this._data.core.state)}this._cnt=0;this._model.data={"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:false}}};var r=this.get_container_ul()[0].className;if(!q){this.element.html("<ul class='"+r+"'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last'><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.load_node("#",function(u,t){if(t){this.get_container_ul()[0].className=r;this.set_state(i.extend(true,{},this._data.core.state),function(){this.trigger("refresh")})}this._data.core.state=null})},refresh_node:function(r){r=this.get_node(r);if(!r||r.id==="#"){return false}var t=[],p=[],q=this._data.core.selected.concat([]);p.push(r.id);if(r.state.opened===true){t.push(r.id)}this.get_node(r,true).find(".jstree-open").each(function(){t.push(this.id)});this._load_nodes(p,i.proxy(function(s){this.open_node(t,false,0);this.select_node(this._data.core.selected);this.trigger("refresh_node",{node:r,nodes:s})},this))},set_id:function(s,t){s=this.get_node(s);if(!s||s.id==="#"){return false}var r,q,p=this._model.data;t=t.toString();p[s.parent].children[i.inArray(s.id,p[s.parent].children)]=t;for(r=0,q=s.parents.length;r<q;r++){p[s.parents[r]].children_d[i.inArray(s.id,p[s.parents[r]].children_d)]=t}for(r=0,q=s.children.length;r<q;r++){p[s.children[r]].parent=t}for(r=0,q=s.children_d.length;r<q;r++){p[s.children_d[r]].parents[i.inArray(s.id,p[s.children_d[r]].parents)]=t}r=i.inArray(s.id,this._data.core.selected);if(r!==-1){this._data.core.selected[r]=t}r=this.get_node(s.id,true);if(r){r.attr("id",t)}delete p[s.id];s.id=t;p[t]=s;return true},get_text:function(p){p=this.get_node(p);return(!p||p.id==="#")?false:p.text},set_text:function(r,s){var q,p;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.set_text(r[q],s)}return true}r=this.get_node(r);if(!r||r.id==="#"){return false}r.text=s;if(this.get_node(r,true).length){this.redraw_node(r.id)}this.trigger("set_text",{obj:r,text:s});return true},get_json:function(t,q,u){t=this.get_node(t||"#");if(!t){return false}if(q&&q.flat&&!u){u=[]}var s={id:t.id,text:t.text,icon:this.get_icon(t),li_attr:t.li_attr,a_attr:t.a_attr,state:{},data:q&&q.no_data?false:t.data},r,p;if(q&&q.flat){s.parent=t.parent}else{s.children=[]}if(!q||!q.no_state){for(r in t.state){if(t.state.hasOwnProperty(r)){s.state[r]=t.state[r]}}}if(q&&q.no_id){delete s.id;if(s.li_attr&&s.li_attr.id){delete s.li_attr.id}}if(q&&q.flat&&t.id!=="#"){u.push(s)}if(!q||!q.no_children){for(r=0,p=t.children.length;r<p;r++){if(q&&q.flat){this.get_json(t.children[r],q,u)}else{s.children.push(this.get_json(t.children[r],q))}}}return q&&q.flat?u:(t.id==="#"?s.children:s)},create_node:function(u,p,w,x,v){if(u===null){u="#"}u=this.get_node(u);if(!u){return false}w=w===e?"last":w;if(!w.toString().match(/^(before|after)$/)&&!v&&!this.is_loaded(u)){return this.load_node(u,function(){this.create_node(u,p,w,x,true)})}if(!p){p={text:this.get_string("New node")}}if(p.text===e){p.text=this.get_string("New node")}var r,t,s,q;if(u.id==="#"){if(w==="before"){w="first"}if(w==="after"){w="last"}}switch(w){case"before":r=this.get_node(u.parent);w=i.inArray(u.id,r.children);u=r;break;case"after":r=this.get_node(u.parent);w=i.inArray(u.id,r.children)+1;u=r;break;case"inside":case"first":w=0;break;case"last":w=u.children.length;break;default:if(!w){w=0}break}if(w>u.children.length){w=u.children.length}if(!p.id){p.id=true}if(!this.check("create_node",p,u,w)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(p.id===true){delete p.id}p=this._parse_model_from_json(p,u.id,u.parents.concat());if(!p){return false}r=this.get_node(p);t=[];t.push(p);t=t.concat(r.children_d);this.trigger("model",{nodes:t,parent:u.id});u.children_d=u.children_d.concat(t);for(s=0,q=u.parents.length;s<q;s++){this._model.data[u.parents[s]].children_d=this._model.data[u.parents[s]].children_d.concat(t)}p=r;r=[];for(s=0,q=u.children.length;s<q;s++){r[s>=w?s+1:s]=u.children[s]}r[w]=p.id;u.children=r;this.redraw_node(u,true);if(x){x.call(this,this.get_node(p))}this.trigger("create_node",{node:this.get_node(p),parent:u.id,position:w});return p.id},rename_node:function(s,t){var r,q,p;if(i.isArray(s)){s=s.slice();for(r=0,q=s.length;r<q;r++){this.rename_node(s[r],t)}return true}s=this.get_node(s);if(!s||s.id==="#"){return false}p=s.text;if(!this.check("rename_node",s,this.get_parent(s),t)){this.settings.core.error.call(this,this._data.core.last_error);return false}this.set_text(s,t);this.trigger("rename_node",{node:s,text:t,old:p});return true},delete_node:function(s){var w,v,x,z,t,u,r,q,p,y;if(i.isArray(s)){s=s.slice();for(w=0,v=s.length;w<v;w++){this.delete_node(s[w])}return true}s=this.get_node(s);if(!s||s.id==="#"){return false}x=this.get_node(s.parent);z=i.inArray(s.id,x.children);y=false;if(!this.check("delete_node",s,x,z)){this.settings.core.error.call(this,this._data.core.last_error);return false}if(z!==-1){x.children=i.vakata.array_remove(x.children,z)}t=s.children_d.concat([]);t.push(s.id);for(q=0,p=t.length;q<p;q++){for(u=0,r=s.parents.length;u<r;u++){z=i.inArray(t[q],this._model.data[s.parents[u]].children_d);if(z!==-1){this._model.data[s.parents[u]].children_d=i.vakata.array_remove(this._model.data[s.parents[u]].children_d,z)}}if(this._model.data[t[q]].state.selected){y=true;z=i.inArray(t[q],this._data.core.selected);if(z!==-1){this._data.core.selected=i.vakata.array_remove(this._data.core.selected,z)}}}this.trigger("delete_node",{node:s,parent:x.id});if(y){this.trigger("changed",{action:"delete_node",node:s,selected:this._data.core.selected,parent:x.id})}for(q=0,p=t.length;q<p;q++){delete this._model.data[t[q]]}this.redraw_node(x,true);return true},check:function(p,t,s,v,r){t=t&&t.id?t:this.get_node(t);s=s&&s.id?s:this.get_node(s);var q=p.match(/^move_node|copy_node|create_node$/i)?s:t,u=this.settings.core.check_callback;if(p==="move_node"||p==="copy_node"){if((!r||!r.is_multi)&&(t.id===s.id||i.inArray(t.id,s.children)===v||i.inArray(s.id,t.children_d)!==-1)){this._data.core.last_error={error:"check",plugin:"core",id:"core_01",reason:"Moving parent inside child",data:JSON.stringify({chk:p,pos:v,obj:t&&t.id?t.id:false,par:s&&s.id?s.id:false})};return false}}if(q&&q.data){q=q.data}if(q&&q.functions&&(q.functions[p]===false||q.functions[p]===true)){if(q.functions[p]===false){this._data.core.last_error={error:"check",plugin:"core",id:"core_02",reason:"Node data prevents function: "+p,data:JSON.stringify({chk:p,pos:v,obj:t&&t.id?t.id:false,par:s&&s.id?s.id:false})}}return q.functions[p]}if(u===false||(i.isFunction(u)&&u.call(this,p,t,s,v,r)===false)||(u&&u[p]===false)){this._data.core.last_error={error:"check",plugin:"core",id:"core_03",reason:"User config for core.check_callback prevents function: "+p,data:JSON.stringify({chk:p,pos:v,obj:t&&t.id?t.id:false,par:s&&s.id?s.id:false})};return false}return true},last_error:function(){return this._data.core.last_error},move_node:function(y,A,t,r,z){var w,v,x,q,H,I,s,u,G,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)})}if(i.isArray(y)){y=y.reverse().slice();for(w=0,v=y.length;w<v;w++){this.move_node(y[w],A,t,r,z)}return true}y=y&&y.id?y:this.get_node(y);if(!y||y.id==="#"){return false}x=(y.parent||"#").toString();H=(!t.toString().match(/^(before|after)$/)||A.id==="#")?A:this.get_node(A.parent);I=y.instance?y.instance:(this._model.data[y.id]?this:i.jstree.reference(y.id));s=!I||!I._id||(this._id!==I._id);q=I&&I._id&&x&&I._model.data[x]&&I._model.data[x].children?i.inArray(y.id,I._model.data[x].children):-1;if(s){if(this.copy_node(y,A,t,r,z)){if(I){I.delete_node(y)}return true}return false}if(H.id==="#"){if(t==="before"){t="first"}if(t==="after"){t="last"}}switch(t){case"before":t=i.inArray(A.id,H.children);break;case"after":t=i.inArray(A.id,H.children)+1;break;case"inside":case"first":t=0;break;case"last":t=H.children.length;break;default:if(!t){t=0}break}if(t>H.children.length){t=H.children.length}if(!this.check("move_node",y,H,t,{core:true,is_multi:(I&&I._id&&I._id!==this._id),is_foreign:(!I||!I._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}if(y.parent===H.id){u=H.children.concat();G=i.inArray(y.id,u);if(G!==-1){u=i.vakata.array_remove(u,G);if(t>G){t--}}G=[];for(F=0,E=u.length;F<E;F++){G[F>=t?F+1:F]=u[F]}G[t]=y.id;H.children=G;this._node_changed(H.id);this.redraw(H.id==="#")}else{G=y.children_d.concat();G.push(y.id);for(F=0,E=y.parents.length;F<E;F++){u=[];B=I._model.data[y.parents[F]].children_d;for(D=0,C=B.length;D<C;D++){if(i.inArray(B[D],G)===-1){u.push(B[D])}}I._model.data[y.parents[F]].children_d=u}I._model.data[x].children=i.vakata.array_remove_item(I._model.data[x].children,y.id);for(F=0,E=H.parents.length;F<E;F++){this._model.data[H.parents[F]].children_d=this._model.data[H.parents[F]].children_d.concat(G)}u=[];for(F=0,E=H.children.length;F<E;F++){u[F>=t?F+1:F]=H.children[F]}u[t]=y.id;H.children=u;H.children_d.push(y.id);H.children_d=H.children_d.concat(y.children_d);y.parent=H.id;G=H.parents.concat();G.unshift(H.id);B=y.parents.length;y.parents=G;G=G.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,G)}this._node_changed(x);this._node_changed(H.id);this.redraw(x==="#"||H.id==="#")}if(r){r.call(this,y,H,t)}this.trigger("move_node",{node:y,parent:H.id,position:t,old_parent:x,old_position:q,is_multi:(I&&I._id&&I._id!==this._id),is_foreign:(!I||!I._id),old_instance:I,new_instance:this});return true},copy_node:function(v,B,D,E,C){var z,y,x,u,t,s,q,A,p,w,r;B=this.get_node(B);D=D===e?0:D;if(!B){return false}if(!D.toString().match(/^(before|after)$/)&&!C&&!this.is_loaded(B)){return this.load_node(B,function(){this.copy_node(v,B,D,E,true)})}if(i.isArray(v)){v=v.reverse().slice();for(z=0,y=v.length;z<y;z++){this.copy_node(v[z],B,D,E,C)}return true}v=v&&v.id?v:this.get_node(v);if(!v||v.id==="#"){return false}A=(v.parent||"#").toString();p=(!D.toString().match(/^(before|after)$/)||B.id==="#")?B:this.get_node(B.parent);w=v.instance?v.instance:(this._model.data[v.id]?this:i.jstree.reference(v.id));r=!w||!w._id||(this._id!==w._id);if(p.id==="#"){if(D==="before"){D="first"}if(D==="after"){D="last"}}switch(D){case"before":D=i.inArray(B.id,p.children);break;case"after":D=i.inArray(B.id,p.children)+1;break;case"inside":case"first":D=0;break;case"last":D=p.children.length;break;default:if(!D){D=0}break}if(D>p.children.length){D=p.children.length}if(!this.check("copy_node",v,p,D,{core:true,is_multi:(w&&w._id&&w._id!==this._id),is_foreign:(!w||!w._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false}q=w?w.get_json(v,{no_id:true,no_data:true,no_state:true}):v;if(!q){return false}if(q.id===true){delete q.id}q=this._parse_model_from_json(q,p.id,p.parents.concat());if(!q){return false}u=this.get_node(q);if(v&&v.state&&v.state.loaded===false){u.state.loaded=false}x=[];x.push(q);x=x.concat(u.children_d);this.trigger("model",{nodes:x,parent:p.id});for(t=0,s=p.parents.length;t<s;t++){this._model.data[p.parents[t]].children_d=this._model.data[p.parents[t]].children_d.concat(x)}x=[];for(t=0,s=p.children.length;t<s;t++){x[t>=D?t+1:t]=p.children[t]}x[D]=u.id;p.children=x;p.children_d.push(u.id);p.children_d=p.children_d.concat(u.children_d);this._node_changed(p.id);this.redraw(p.id==="#");if(E){E.call(this,u,p,D)}this.trigger("copy_node",{node:u,original:v,parent:p.id,position:D,old_parent:A,old_position:w&&w._id&&A&&w._model.data[A]&&w._model.data[A].children?i.inArray(v.id,w._model.data[A].children):-1,is_multi:(w&&w._id&&w._id!==this._id),is_foreign:(!w||!w._id),old_instance:w,new_instance:this});return u.id},cut:function(s){if(!s){s=this._data.core.selected.concat()}if(!i.isArray(s)){s=[s]}if(!s.length){return false}var p=[],t,r,q;for(r=0,q=s.length;r<q;r++){t=this.get_node(s[r]);if(t&&t.id&&t.id!=="#"){p.push(t)}}if(!p.length){return false}d=p;j=this;k="move_node";this.trigger("cut",{node:s})},copy:function(s){if(!s){s=this._data.core.selected.concat()}if(!i.isArray(s)){s=[s]}if(!s.length){return false}var p=[],t,r,q;for(r=0,q=s.length;r<q;r++){t=this.get_node(s[r]);if(t&&t.id&&t.id!=="#"){p.push(t)}}if(!p.length){return false}d=p;j=this;k="copy_node";this.trigger("copy",{node:s})},get_buffer:function(){return{mode:k,node:d,inst:j}},can_paste:function(){return k!==false&&d!==false},paste:function(p,q){p=this.get_node(p);if(!p||!k||!k.match(/^(copy_node|move_node)$/)||!d){return false}if(this[k](d,p,q)){this.trigger("paste",{parent:p.id,node:d,mode:k})}d=false;k=false;j=false},edit:function(p,x){p=this.get_node(p);if(!p){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}x=typeof x==="string"?x:p.text;this.set_text(p,"");p=this._open_to(p);var v=this._data.core.rtl,z=this.element.width(),y=p.children(".jstree-anchor"),B=i("<span>")
|
|
/*
|
|
oi = obj.children("i:visible"),
|
|
ai = a.children("i:visible"),
|
|
w1 = oi.width() * oi.length,
|
|
w2 = ai.width() * ai.length,
|
|
*/
|
|
,A=x,r=i("<div />",{css:{position:"absolute",top:"-200px",left:(v?"0px":"-1000px"),visibility:"hidden"}}).appendTo("body"),q=i("<input />",{value:A,"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:i.proxy(function(){var t=B.children(".jstree-rename-input"),s=t.val();if(s===""){s=A}r.remove();B.replaceWith(y);B.remove();this.set_text(p,A);if(this.rename_node(p,i("<div></div>").text(s)[this.settings.core.force_text?"text":"html"]())===false){this.set_text(p,A)}},this),keydown:function(t){var s=t.which;if(s===27){this.value=A}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){q.width(Math.min(r.text("pW"+this.value).width(),z))},keypress:function(s){if(s.which===13){return false}}}),u={fontFamily:y.css("fontFamily")||"",fontSize:y.css("fontSize")||"",fontWeight:y.css("fontWeight")||"",fontStyle:y.css("fontStyle")||"",fontStretch:y.css("fontStretch")||"",fontVariant:y.css("fontVariant")||"",letterSpacing:y.css("letterSpacing")||"",wordSpacing:y.css("wordSpacing")||""};B.attr("class",y.attr("class")).append(y.contents().clone()).append(q);y.replaceWith(B);r.css(u);q.css(u).width(Math.min(r.text("pW"+q[0].value).width(),z))[0].select()},set_theme:function(r,p){if(!r){return false}if(p===true){var q=this.settings.core.themes.dir;if(!q){q=i.jstree.path+"/themes"}p=q+"/"+r+"/style.css"}if(p&&i.inArray(p,m)===-1){i("head").append('<link rel="stylesheet" href="'+p+'" type="text/css" />');m.push(p)}if(this._data.core.themes.name){this.element.removeClass("jstree-"+this._data.core.themes.name)}this._data.core.themes.name=r;this.element.addClass("jstree-"+r);this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+r+"-responsive");this.trigger("set_theme",{theme:r})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(p){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=p;if(p){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")},hide_stripes:function(){this._data.core.themes.stripes=false;this.get_container_ul().removeClass("jstree-striped")},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")},hide_dots:function(){this._data.core.themes.dots=false;this.get_container_ul().addClass("jstree-no-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")},hide_icons:function(){this._data.core.themes.icons=false;this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){if(this._data.core.themes.icons){this.hide_icons()}else{this.show_icons()}},set_icon:function(t,r){var s,q,u,p;if(i.isArray(t)){t=t.slice();for(s=0,q=t.length;s<q;s++){this.set_icon(t[s],r)}return true}t=this.get_node(t);if(!t||t.id==="#"){return false}p=t.icon;t.icon=r;u=this.get_node(t,true).children(".jstree-anchor").children(".jstree-themeicon");if(r===false){this.hide_icon(t)}else{if(r===true){u.removeClass("jstree-themeicon-custom "+p).css("background","").removeAttr("rel")}else{if(r.indexOf("/")===-1&&r.indexOf(".")===-1){u.removeClass(p).css("background","");u.addClass(r+" jstree-themeicon-custom").attr("rel",r)}else{u.removeClass(p).css("background","");u.addClass("jstree-themeicon-custom").css("background","url('"+r+"') center center no-repeat").attr("rel",r)}}}return true},get_icon:function(p){p=this.get_node(p);return(!p||p.id==="#")?false:p.icon},hide_icon:function(r){var q,p;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.hide_icon(r[q])}return true}r=this.get_node(r);if(!r||r==="#"){return false}r.icon=false;this.get_node(r,true).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden");return true},show_icon:function(r){var q,p,s;if(i.isArray(r)){r=r.slice();for(q=0,p=r.length;q<p;q++){this.show_icon(r[q])}return true}r=this.get_node(r);if(!r||r==="#"){return false}s=this.get_node(r,true);r.icon=s.length?s.children(".jstree-anchor").children(".jstree-themeicon").attr("rel"):true;if(!r.icon){r.icon=true}s.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden");return true}};i.vakata={};i.vakata.attributes=function(q,r){q=i(q)[0];var p=r?{}:[];if(q&&q.attributes){i.each(q.attributes,function(t,s){if(i.inArray(s.nodeName.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])!==-1){return}if(s.nodeValue!==null&&i.trim(s.nodeValue)!==""){if(r){p[s.nodeName]=s.nodeValue}else{p.push(s.nodeName)}}})}return p};i.vakata.array_unique=function(t){var q=[],s,r,p;for(s=0,p=t.length;s<p;s++){for(r=0;r<=s;r++){if(t[s]===t[r]){break}}if(r===s){q.push(t[s])}}return q};i.vakata.array_remove=function(s,r,q){var p=s.slice((q||r)+1||s.length);s.length=r<0?s.length+r:r;s.push.apply(s,p);return s};i.vakata.array_remove_item=function(r,q){var p=i.inArray(q,r);return p!==-1?i.vakata.array_remove(r,p):r};var h=document.createElement("I");h.className="jstree-icon jstree-checkbox";i.jstree.defaults.checkbox={visible:true,three_state:true,whole_node:true,keep_selected_style:true,cascade:"",tie_selection:true};i.jstree.plugins.checkbox=function(p,q){this.bind=function(){q.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",i.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible;if(!this.settings.checkbox.keep_selected_style){this.element.addClass("jstree-checkbox-no-clicked")}if(this.settings.checkbox.tie_selection){this.element.addClass("jstree-checkbox-selection")}},this)).on("loading.jstree",i.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",i.proxy(function(){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(i.proxy(this._undetermined,this),50)},this))}if(!this.settings.checkbox.tie_selection){this.element.on("model.jstree",i.proxy(function(w,u){var r=this._model.data,v=r[u.parent],x=u.nodes,t,s;for(t=0,s=x.length;t<s;t++){r[x[t]].state.checked=(r[x[t]].original&&r[x[t]].original.state&&r[x[t]].original.state.checked);if(r[x[t]].state.checked){this._data.checkbox.selected.push(x[t])}}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1||this.settings.checkbox.cascade.indexOf("down")!==-1){this.element.on("model.jstree",i.proxy(function(C,z){var u=this._model.data,r=u[z.parent],B=z.nodes,G=[],D,A,x,w,v,y,F=this.settings.checkbox.cascade,E=this.settings.checkbox.tie_selection;if(F.indexOf("down")!==-1){if(r.state[E?"selected":"checked"]){for(A=0,x=B.length;A<x;A++){u[B[A]].state[E?"selected":"checked"]=true}this._data[E?"core":"checkbox"].selected=this._data[E?"core":"checkbox"].selected.concat(B)}else{for(A=0,x=B.length;A<x;A++){if(u[B[A]].state[E?"selected":"checked"]){for(w=0,v=u[B[A]].children_d.length;w<v;w++){u[u[B[A]].children_d[w]].state[E?"selected":"checked"]=true}this._data[E?"core":"checkbox"].selected=this._data[E?"core":"checkbox"].selected.concat(u[B[A]].children_d)}}}}if(F.indexOf("up")!==-1){for(A=0,x=r.children_d.length;A<x;A++){if(!u[r.children_d[A]].children.length){G.push(u[r.children_d[A]].parent)}}G=i.vakata.array_unique(G);for(w=0,v=G.length;w<v;w++){r=u[G[w]];while(r&&r.id!=="#"){D=0;for(A=0,x=r.children.length;A<x;A++){D+=u[r.children[A]].state[E?"selected":"checked"]}if(D===x){r.state[E?"selected":"checked"]=true;this._data[E?"core":"checkbox"].selected.push(r.id);y=this.get_node(r,true);if(y&&y.length){y.children(".jstree-anchor").addClass(E?"jstree-clicked":"jstree-checked")}}else{break}r=this.get_node(r.parent)}}}this._data[E?"core":"checkbox"].selected=i.vakata.array_unique(this._data[E?"core":"checkbox"].selected)},this)).on(this.settings.checkbox.tie_selection?"select_node.jstree":"check_node.jstree",i.proxy(function(A,y){var x=y.node,r=this._model.data,B=this.get_node(x.parent),u=this.get_node(x,true),z,v,C,w,E=this.settings.checkbox.cascade,D=this.settings.checkbox.tie_selection;if(E.indexOf("down")!==-1){this._data[D?"core":"checkbox"].selected=i.vakata.array_unique(this._data[D?"core":"checkbox"].selected.concat(x.children_d));for(z=0,v=x.children_d.length;z<v;z++){w=r[x.children_d[z]];w.state[D?"selected":"checked"]=true;if(w&&w.original&&w.original.state&&w.original.state.undetermined){w.original.state.undetermined=false}}}if(E.indexOf("up")!==-1){while(B&&B.id!=="#"){C=0;for(z=0,v=B.children.length;z<v;z++){C+=r[B.children[z]].state[D?"selected":"checked"]}if(C===v){B.state[D?"selected":"checked"]=true;this._data[D?"core":"checkbox"].selected.push(B.id);w=this.get_node(B,true);if(w&&w.length){w.children(".jstree-anchor").addClass(D?"jstree-clicked":"jstree-checked")}}else{break}B=this.get_node(B.parent)}}if(E.indexOf("down")!==-1&&u.length){u.find(".jstree-anchor").addClass(D?"jstree-clicked":"jstree-checked")}},this)).on(this.settings.checkbox.tie_selection?"deselect_all.jstree":"uncheck_all.jstree",i.proxy(function(x,v){var w=this.get_node("#"),r=this._model.data,u,s,t;for(u=0,s=w.children_d.length;u<s;u++){t=r[w.children_d[u]];if(t&&t.original&&t.original.state&&t.original.state.undetermined){t.original.state.undetermined=false}}},this)).on(this.settings.checkbox.tie_selection?"deselect_node.jstree":"uncheck_node.jstree",i.proxy(function(z,w){var v=w.node,r=this.get_node(v,true),x,u,y,B=this.settings.checkbox.cascade,A=this.settings.checkbox.tie_selection;if(v&&v.original&&v.original.state&&v.original.state.undetermined){v.original.state.undetermined=false}if(B.indexOf("down")!==-1){for(x=0,u=v.children_d.length;x<u;x++){y=this._model.data[v.children_d[x]];y.state[A?"selected":"checked"]=false;if(y&&y.original&&y.original.state&&y.original.state.undetermined){y.original.state.undetermined=false}}}if(B.indexOf("up")!==-1){for(x=0,u=v.parents.length;x<u;x++){y=this._model.data[v.parents[x]];y.state[A?"selected":"checked"]=false;if(y&&y.original&&y.original.state&&y.original.state.undetermined){y.original.state.undetermined=false}y=this.get_node(v.parents[x],true);if(y&&y.length){y.children(".jstree-anchor").removeClass(A?"jstree-clicked":"jstree-checked")}}}y=[];for(x=0,u=this._data[A?"core":"checkbox"].selected.length;x<u;x++){if((B.indexOf("down")===-1||i.inArray(this._data[A?"core":"checkbox"].selected[x],v.children_d)===-1)&&(B.indexOf("up")===-1||i.inArray(this._data[A?"core":"checkbox"].selected[x],v.parents)===-1)){y.push(this._data[A?"core":"checkbox"].selected[x])}}this._data[A?"core":"checkbox"].selected=i.vakata.array_unique(y);if(B.indexOf("down")!==-1&&r.length){r.find(".jstree-anchor").removeClass(A?"jstree-clicked":"jstree-checked")}},this))}if(this.settings.checkbox.cascade.indexOf("up")!==-1){this.element.on("delete_node.jstree",i.proxy(function(y,v){var r=this.get_node(v.parent),s=this._model.data,w,u,z,x,A=this.settings.checkbox.tie_selection;while(r&&r.id!=="#"){z=0;for(w=0,u=r.children.length;w<u;w++){z+=s[r.children[w]].state[A?"selected":"checked"]}if(z===u){r.state[A?"selected":"checked"]=true;this._data[A?"core":"checkbox"].selected.push(r.id);x=this.get_node(r,true);if(x&&x.length){x.children(".jstree-anchor").addClass(A?"jstree-clicked":"jstree-checked")}}else{break}r=this.get_node(r.parent)}},this)).on("move_node.jstree",i.proxy(function(B,z){var v=z.is_multi,A=z.old_parent,r=this.get_node(z.parent),u=this._model.data,s,C,y,w,x,D=this.settings.checkbox.tie_selection;if(!v){s=this.get_node(A);while(s&&s.id!=="#"){C=0;for(y=0,w=s.children.length;y<w;y++){C+=u[s.children[y]].state[D?"selected":"checked"]}if(C===w){s.state[D?"selected":"checked"]=true;this._data[D?"core":"checkbox"].selected.push(s.id);x=this.get_node(s,true);if(x&&x.length){x.children(".jstree-anchor").addClass(D?"jstree-clicked":"jstree-checked")}}else{break}s=this.get_node(s.parent)}}s=r;while(s&&s.id!=="#"){C=0;for(y=0,w=s.children.length;y<w;y++){C+=u[s.children[y]].state[D?"selected":"checked"]}if(C===w){if(!s.state[D?"selected":"checked"]){s.state[D?"selected":"checked"]=true;this._data[D?"core":"checkbox"].selected.push(s.id);x=this.get_node(s,true);if(x&&x.length){x.children(".jstree-anchor").addClass(D?"jstree-clicked":"jstree-checked")}}}else{if(s.state[D?"selected":"checked"]){s.state[D?"selected":"checked"]=false;this._data[D?"core":"checkbox"].selected=i.vakata.array_remove_item(this._data[D?"core":"checkbox"].selected,s.id);x=this.get_node(s,true);if(x&&x.length){x.children(".jstree-anchor").removeClass(D?"jstree-clicked":"jstree-checked")}}else{break}}s=this.get_node(s.parent)}},this))}};this._undetermined=function(){var w,u,r=this._model.data,v=this.settings.checkbox.tie_selection,y=this._data[v?"core":"checkbox"].selected,z=[],x=this;for(w=0,u=y.length;w<u;w++){if(r[y[w]]&&r[y[w]].parents){z=z.concat(r[y[w]].parents)}}this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var s=x.get_node(this),t;if(!s.state.loaded){if(s.original&&s.original.state&&s.original.state.undetermined&&s.original.state.undetermined===true){z.push(s.id);z=z.concat(s.parents)}}else{for(w=0,u=s.children_d.length;w<u;w++){t=r[s.children_d[w]];if(!t.state.loaded&&t.original&&t.original.state&&t.original.state.undetermined&&t.original.state.undetermined===true){z.push(t.id);z=z.concat(t.parents)}}}});z=i.vakata.array_unique(z);z=i.vakata.array_remove_item(z,"#");this.element.find(".jstree-undetermined").removeClass("jstree-undetermined");for(w=0,u=z.length;w<u;w++){if(!r[z[w]].state[v?"selected":"checked"]){y=this.get_node(z[w],true);if(y&&y.length){y.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined")}}}};this.redraw_node=function(w,r,v){w=q.redraw_node.call(this,w,r,v);if(w){var u,s,t=null;for(u=0,s=w.childNodes.length;u<s;u++){if(w.childNodes[u]&&w.childNodes[u].className&&w.childNodes[u].className.indexOf("jstree-anchor")!==-1){t=w.childNodes[u];break}}if(t){if(!this.settings.checkbox.tie_selection&&this._model.data[w.id].state.checked){t.className+=" jstree-checked"}t.insertBefore(h.cloneNode(false),t.childNodes[0])}}if(!v&&this.settings.checkbox.cascade.indexOf("undetermined")!==-1){if(this._data.checkbox.uto){clearTimeout(this._data.checkbox.uto)}this._data.checkbox.uto=setTimeout(i.proxy(this._undetermined,this),50)}return w};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")};this.toggle_checkboxes=function(){if(this._data.core.themes.checkboxes){this.hide_checkboxes()}else{this.show_checkboxes()}};this.is_undetermined=function(y){y=this.get_node(y);var x=this.settings.checkbox.cascade,w,u,v=this.settings.checkbox.tie_selection,z=this._data[v?"core":"checkbox"].selected,r=this._model.data;if(!y||y.state[v?"selected":"checked"]===true||x.indexOf("undetermined")===-1||(x.indexOf("down")===-1&&x.indexOf("up")===-1)){return false}if(!y.state.loaded&&y.original.state.undetermined===true){return true}for(w=0,u=y.children_d.length;w<u;w++){if(i.inArray(y.children_d[w],z)!==-1||(!r[y.children_d[w]].state.loaded&&r[y.children_d[w]].original.state.undetermined)){return true}}return false};this.activate_node=function(s,r){if(this.settings.checkbox.tie_selection&&(this.settings.checkbox.whole_node||i(r.target).hasClass("jstree-checkbox"))){r.ctrlKey=true}if(this.settings.checkbox.tie_selection||(!this.settings.checkbox.whole_node&&!i(r.target).hasClass("jstree-checkbox"))){return q.activate_node.call(this,s,r)}if(this.is_checked(s)){this.uncheck_node(s,r)}else{this.check_node(s,r)}this.trigger("activate_node",{node:this.get_node(s)})};this.check_node=function(v,u){if(this.settings.checkbox.tie_selection){return this.select_node(v,false,true,u)}var w,t,r,s;if(i.isArray(v)){v=v.slice();for(t=0,r=v.length;t<r;t++){this.check_node(v[t],u)}return true}v=this.get_node(v);if(!v||v.id==="#"){return false}w=this.get_node(v,true);if(!v.state.checked){v.state.checked=true;this._data.checkbox.selected.push(v.id);if(w&&w.length){w.children(".jstree-anchor").addClass("jstree-checked")}this.trigger("check_node",{node:v,selected:this._data.checkbox.selected,event:u})}};this.uncheck_node=function(u,t){if(this.settings.checkbox.tie_selection){return this.deselect_node(u,false,t)}var s,r,v;if(i.isArray(u)){u=u.slice();for(s=0,r=u.length;s<r;s++){this.uncheck_node(u[s],t)}return true}u=this.get_node(u);if(!u||u.id==="#"){return false}v=this.get_node(u,true);if(u.state.checked){u.state.checked=false;this._data.checkbox.selected=i.vakata.array_remove_item(this._data.checkbox.selected,u.id);if(v.length){v.children(".jstree-anchor").removeClass("jstree-checked")}this.trigger("uncheck_node",{node:u,selected:this._data.checkbox.selected,event:t})}};this.check_all=function(){if(this.settings.checkbox.tie_selection){return this.select_all()}var t=this._data.checkbox.selected.concat([]),s,r;this._data.checkbox.selected=this._model.data["#"].children_d.concat();for(s=0,r=this._data.checkbox.selected.length;s<r;s++){if(this._model.data[this._data.checkbox.selected[s]]){this._model.data[this._data.checkbox.selected[s]].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 t=this._data.checkbox.selected.concat([]),s,r;for(s=0,r=this._data.checkbox.selected.length;s<r;s++){if(this._model.data[this._data.checkbox.selected[s]]){this._model.data[this._data.checkbox.selected[s]].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:t})};this.is_checked=function(r){if(this.settings.checkbox.tie_selection){return this.is_selected(r)}r=this.get_node(r);if(!r||r.id==="#"){return false}return r.state.checked};this.get_checked=function(r){if(this.settings.checkbox.tie_selection){return this.get_selected(r)}return r?i.map(this._data.checkbox.selected,i.proxy(function(s){return this.get_node(s)},this)):this._data.checkbox.selected};this.get_top_checked=function(w){if(this.settings.checkbox.tie_selection){return this.get_top_selected(w)}var v=this.get_checked(true),x={},u,t,s,r;for(u=0,t=v.length;u<t;u++){x[v[u].id]=v[u]}for(u=0,t=v.length;u<t;u++){for(s=0,r=v[u].children_d.length;s<r;s++){if(x[v[u].children_d[s]]){delete x[v[u].children_d[s]]}}}v=[];for(u in x){if(x.hasOwnProperty(u)){v.push(u)}}return w?i.map(v,i.proxy(function(y){return this.get_node(y)},this)):v};this.get_bottom_checked=function(u){if(this.settings.checkbox.tie_selection){return this.get_bottom_selected(u)}var t=this.get_checked(true),v=[],s,r;for(s=0,r=t.length;s<r;s++){if(!t[s].children.length){v.push(t[s].id)}}return u?i.map(v,i.proxy(function(w){return this.get_node(w)},this)):v}};i.jstree.defaults.contextmenu={select_node:true,show_at_node:true,items:function(q,p){return{create:{separator_before:false,separator_after:true,_disabled:false,label:"Create",action:function(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);r.create_node(t,{},"last",function(u){setTimeout(function(){r.edit(u)},0)})}},rename:{separator_before:false,separator_after:false,_disabled:false,label:"Rename",action:function(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);r.edit(t)}},remove:{separator_before:false,icon:false,separator_after:false,_disabled:false,label:"Delete",action:function(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);if(r.is_selected(t)){r.delete_node(r.get_selected())}else{r.delete_node(t)}}},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(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);if(r.is_selected(t)){r.cut(r.get_selected())}else{r.cut(t)}}},copy:{separator_before:false,icon:false,separator_after:false,label:"Copy",action:function(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);if(r.is_selected(t)){r.copy(r.get_selected())}else{r.copy(t)}}},paste:{separator_before:false,icon:false,_disabled:function(r){return !i.jstree.reference(r.reference).can_paste()},separator_after:false,label:"Paste",action:function(s){var r=i.jstree.reference(s.reference),t=r.get_node(s.reference);r.paste(t)}}}}}}};i.jstree.plugins.contextmenu=function(p,q){this.bind=function(){q.bind.call(this);var r=0;this.element.on("contextmenu.jstree",".jstree-anchor",i.proxy(function(s){s.preventDefault();r=s.ctrlKey?s.timeStamp:0;if(!this.is_loading(s.currentTarget)){this.show_contextmenu(s.currentTarget,s.pageX,s.pageY,s)}},this)).on("click.jstree",".jstree-anchor",i.proxy(function(s){if(this._data.contextmenu.visible&&(!r||s.timeStamp-r>250)){i.vakata.context.hide()}},this));i(document).on("context_hide.vakata",i.proxy(function(){this._data.contextmenu.visible=false},this))};this.teardown=function(){if(this._data.contextmenu.visible){i.vakata.context.hide()}q.teardown.call(this)};this.show_contextmenu=function(u,B,z,v){u=this.get_node(u);if(!u||u.id==="#"){return false}var C=this.settings.contextmenu,w=this.get_node(u,true),A=w.children(".jstree-anchor"),r=false,t=false;if(C.show_at_node||B===e||z===e){r=A.offset();B=r.left;z=r.top+this._data.core.li_height}if(this.settings.contextmenu.select_node&&!this.is_selected(u)){this.activate_node(u,v)}t=C.items;if(i.isFunction(t)){t=t.call(this,u,i.proxy(function(s){this._show_contextmenu(u,B,z,s)},this))}if(i.isPlainObject(t)){this._show_contextmenu(u,B,z,t)}};this._show_contextmenu=function(u,r,w,t){var v=this.get_node(u,true),s=v.children(".jstree-anchor");i(document).one("context_show.vakata",i.proxy(function(z,y){var x="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";i(y.element).addClass(x)},this));this._data.contextmenu.visible=true;i.vakata.context.show(s,{x:r,y:w},t);this.trigger("show_contextmenu",{node:u,x:r,y:w})}};(function(q){var r=false,p={element:false,reference:false,position_x:0,position_y:0,items:[],html:"",is_visible:false};q.vakata.context={settings:{hide_onmouseleave:0,icons:true},_trigger:function(s){q(document).triggerHandler("context_"+s+".vakata",{reference:p.reference,element:p.element,position:{x:p.position_x,y:p.position_y}})},_execute:function(s){s=p.items[s];return s&&(!s._disabled||(q.isFunction(s._disabled)&&!s._disabled({item:s,reference:p.reference,element:p.element})))&&s.action?s.action.call(null,{item:s,reference:p.reference,element:p.element,position:{x:p.position_x,y:p.position_y}}):false},_parse:function(w,u){if(!w){return false}if(!u){p.html="";p.items=[]}var v="",s=false,t;if(u){v+="<ul>"}q.each(w,function(x,y){if(!y){return true}p.items.push(y);if(!s&&y.separator_before){v+="<li class='vakata-context-separator'><a href='#' "+(q.vakata.context.settings.icons?"":'style="margin-left:0px;"')+"> </a></li>"}s=false;v+="<li class='"+(y._class||"")+(y._disabled===true||(q.isFunction(y._disabled)&&y._disabled({item:y,reference:p.reference,element:p.element}))?" vakata-contextmenu-disabled ":"")+"' "+(y.shortcut?" data-shortcut='"+y.shortcut+"' ":"")+">";v+="<a href='#' rel='"+(p.items.length-1)+"'>";if(q.vakata.context.settings.icons){v+="<i ";if(y.icon){if(y.icon.indexOf("/")!==-1||y.icon.indexOf(".")!==-1){v+=" style='background:url(\""+y.icon+"\") center center no-repeat' "}else{v+=" class='"+y.icon+"' "}}v+="></i><span class='vakata-contextmenu-sep'> </span>"}v+=(q.isFunction(y.label)?y.label({item:x,reference:p.reference,element:p.element}):y.label)+(y.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+y.shortcut+'">'+(y.shortcut_label||"")+"</span>":"")+"</a>";if(y.submenu){t=q.vakata.context._parse(y.submenu,true);if(t){v+=t}}v+="</li>";if(y.separator_after){v+="<li class='vakata-context-separator'><a href='#' "+(q.vakata.context.settings.icons?"":'style="margin-left:0px;"')+"> </a></li>";s=true}});v=v.replace(/<li class\='vakata-context-separator'\><\/li\>$/,"");if(u){v+="</ul>"}if(!u){p.html=v;q.vakata.context._trigger("parse")}return v.length>10?v:false},_show_submenu:function(B){B=q(B);if(!B.length||!B.children("ul").length){return}var A=B.children("ul"),s=B.offset().left+B.outerWidth(),C=B.offset().top,t=A.width(),v=A.height(),u=q(window).width()+q(window).scrollLeft(),z=q(window).height()+q(window).scrollTop();if(r){B[s-(t+10+B.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left")}else{B[s+t+10>u?"addClass":"removeClass"]("vakata-context-right")}if(C+v+10>z){A.css("bottom","-1px")}A.show()},show:function(u,A,v){var t,B,F,E,G,z,s,D,C=true;if(p.element&&p.element.length){p.element.width("")}switch(C){case (!A&&!u):return false;case (!!A&&!!u):p.reference=u;p.position_x=A.x;p.position_y=A.y;break;case (!A&&!!u):p.reference=u;t=u.offset();p.position_x=t.left+u.outerHeight();p.position_y=t.top;break;case (!!A&&!u):p.position_x=A.x;p.position_y=A.y;break}if(!!u&&!v&&q(u).data("vakata_contextmenu")){v=q(u).data("vakata_contextmenu")}if(q.vakata.context._parse(v)){p.element.html(p.html)}if(p.items.length){B=p.element;F=p.position_x;E=p.position_y;G=B.width();z=B.height();s=q(window).width()+q(window).scrollLeft();D=q(window).height()+q(window).scrollTop();if(r){F-=B.outerWidth();if(F<q(window).scrollLeft()+20){F=q(window).scrollLeft()+20}}if(F+G+20>s){F=s-(G+20)}if(E+z+20>D){E=D-(z+20)}p.element.css({left:F,top:E}).show().find("a:eq(0)").focus().parent().addClass("vakata-context-hover");p.is_visible=true;q.vakata.context._trigger("show")}},hide:function(){if(p.is_visible){p.element.hide().find("ul").hide().end().find(":focus").blur();p.is_visible=false;q.vakata.context._trigger("hide")}}};q(function(){r=q("body").css("direction")==="rtl";var s=false;p.element=q("<ul class='vakata-context'></ul>");p.element.on("mouseenter","li",function(t){t.stopImmediatePropagation();if(q.contains(this,t.relatedTarget)){return}if(s){clearTimeout(s)}p.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();q(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover");q.vakata.context._show_submenu(this)}).on("mouseleave","li",function(t){if(q.contains(this,t.relatedTarget)){return}q(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(t){q(this).find(".vakata-context-hover").removeClass("vakata-context-hover");if(q.vakata.context.settings.hide_onmouseleave){s=setTimeout((function(u){return function(){q.vakata.context.hide()}}(this)),q.vakata.context.settings.hide_onmouseleave)}}).on("click","a",function(t){t.preventDefault();if(!q(this).blur().parent().hasClass("vakata-context-disabled")&&q.vakata.context._execute(q(this).attr("rel"))!==false){q.vakata.context.hide()}}).on("keydown","a",function(t){var u=null;switch(t.which){case 13:case 32:t.type="mouseup";t.preventDefault();q(t.currentTarget).trigger(t);break;case 37:if(p.is_visible){p.element.find(".vakata-context-hover").last().parents("li:eq(0)").find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus();t.stopImmediatePropagation();t.preventDefault()}break;case 38:if(p.is_visible){u=p.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();if(!u.length){u=p.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()}u.addClass("vakata-context-hover").children("a").focus();t.stopImmediatePropagation();t.preventDefault()}break;case 39:if(p.is_visible){p.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();t.stopImmediatePropagation();t.preventDefault()}break;case 40:if(p.is_visible){u=p.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();if(!u.length){u=p.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()}u.addClass("vakata-context-hover").children("a").focus();t.stopImmediatePropagation();t.preventDefault()}break;case 27:q.vakata.context.hide();t.preventDefault();break;default:break}}).on("keydown",function(u){u.preventDefault();var t=p.element.find(".vakata-contextmenu-shortcut-"+u.which).parent();if(t.parent().not(".vakata-context-disabled")){t.mouseup()}}).appendTo("body");q(document).on("mousedown",function(t){if(p.is_visible&&!q.contains(p.element[0],t.target)){q.vakata.context.hide()}}).on("context_show.vakata",function(u,t){p.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");if(r){p.element.addClass("vakata-context-rtl").css("direction","rtl")}p.element.find("ul").hide().end()})})}(i));i.jstree.defaults.dnd={copy:true,open_timeout:500,is_draggable:true,check_while_dragging:true,always_copy:false,inside_pos:0};i.jstree.plugins.dnd=function(p,q){this.bind=function(){q.bind.call(this);this.element.on("mousedown.jstree touchstart.jstree",".jstree-anchor",i.proxy(function(t){var s=this.get_node(t.target),r=this.is_selected(s)?this.get_selected().length:1;if(s&&s.id&&s.id!=="#"&&(t.which===1||t.type==="touchstart")&&(this.settings.dnd.is_draggable===true||(i.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,(r>1?this.get_selected(true):[s]))))){this.element.trigger("mousedown.jstree");return i.vakata.dnd.start(t,{jstree:true,origin:this,obj:this.get_node(s,true),nodes:r>1?this.get_selected():[s.id]},'<div id="jstree-dnd" class="jstree-'+this.get_theme()+(this.settings.core.themes.responsive?" jstree-dnd-responsive":"")+'"><i class="jstree-icon jstree-er"></i>'+(r>1?r+" "+this.get_string("nodes"):this.get_text(t.currentTarget,true))+'<ins class="jstree-copy" style="display:none;">+</ins></div>')}},this))}};i(function(){var s=false,r=false,q=false,p=i('<div id="jstree-marker"> </div>').hide().appendTo("body");i(document).bind("dnd_start.vakata",function(u,t){s=false}).bind("dnd_move.vakata",function(L,N){if(q){clearTimeout(q)}if(!N||!N.data||!N.data.jstree){return}if(N.event.target.id&&N.event.target.id==="jstree-marker"){return}var u=i.jstree.reference(N.event.target),x=false,M=false,v=false,I,D,K,E,J,F,C,B,A,z,G,H,y,w;if(u&&u._data&&u._data.dnd){p.attr("class","jstree-"+u.get_theme()+(u.settings.core.themes.responsive?" jstree-dnd-responsive":""));N.helper.children().attr("class","jstree-"+u.get_theme()+(u.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy:eq(0)")[N.data.origin&&(N.data.origin.settings.dnd.always_copy||(N.data.origin.settings.dnd.copy&&(N.event.metaKey||N.event.ctrlKey)))?"show":"hide"]();if((N.event.target===u.element[0]||N.event.target===u.get_container_ul()[0])&&u.get_container_ul().children().length===0){C=true;for(B=0,A=N.data.nodes.length;B<A;B++){C=C&&u.check((N.data.origin&&(N.data.origin.settings.dnd.always_copy||(N.data.origin.settings.dnd.copy&&(N.event.metaKey||N.event.ctrlKey)))?"copy_node":"move_node"),(N.data.origin&&N.data.origin!==u?N.data.origin.get_node(N.data.nodes[B]):N.data.nodes[B]),"#","last",{dnd:true,ref:u.get_node("#"),pos:"i",is_multi:(N.data.origin&&N.data.origin!==u),is_foreign:(!N.data.origin)});if(!C){break}}if(C){s={ins:u,par:"#",pos:"last"};p.hide();N.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok");return}}else{x=i(N.event.target).closest(".jstree-anchor");if(x&&x.length&&x.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")){M=x.offset();v=N.event.pageY-M.top;K=x.height();if(v<K/3){F=["b","i","a"]}else{if(v>K-K/3){F=["a","i","b"]}else{F=v>K/2?["i","a","b"]:["i","b","a"]}}i.each(F,function(O,t){switch(t){case"b":I=M.left-6;D=M.top;E=u.get_parent(x);J=x.parent().index();break;case"i":y=u.settings.dnd.inside_pos;w=u.get_node(x.parent());I=M.left-2;D=M.top+K/2+1;E=w.id;J=y==="first"?0:(y==="last"?w.children.length:Math.min(y,w.children.length));break;case"a":I=M.left-6;D=M.top+K;E=u.get_parent(x);J=x.parent().index()+1;break}
|
|
/*
|
|
// TODO: moving inside, but the node is not yet loaded?
|
|
// the check will work anyway, as when moving the node will be loaded first and checked again
|
|
if(v === 'i' && !ins.is_loaded(p)) { }
|
|
*/
|
|
C=true;for(B=0,A=N.data.nodes.length;B<A;B++){z=N.data.origin&&(N.data.origin.settings.dnd.always_copy||(N.data.origin.settings.dnd.copy&&(N.event.metaKey||N.event.ctrlKey)))?"copy_node":"move_node";G=J;if(z==="move_node"&&t==="a"&&(N.data.origin&&N.data.origin===u)&&E===u.get_parent(N.data.nodes[B])){H=u.get_node(E);if(G>i.inArray(N.data.nodes[B],H.children)){G-=1}}C=C&&((u&&u.settings&&u.settings.dnd&&u.settings.dnd.check_while_dragging===false)||u.check(z,(N.data.origin&&N.data.origin!==u?N.data.origin.get_node(N.data.nodes[B]):N.data.nodes[B]),E,G,{dnd:true,ref:u.get_node(x.parent()),pos:t,is_multi:(N.data.origin&&N.data.origin!==u),is_foreign:(!N.data.origin)}));if(!C){if(u&&u.last_error){r=u.last_error()}break}}if(C){if(t==="i"&&x.parent().is(".jstree-closed")&&u.settings.dnd.open_timeout){q=setTimeout((function(P,Q){return function(){P.open_node(Q)}}(u,x)),u.settings.dnd.open_timeout)}s={ins:u,par:E,pos:t==="i"&&y==="last"&&J===0&&!u.is_loaded(w)?"last":J};p.css({left:I+"px",top:D+"px"}).show();N.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok");r={};F=true;return false}});if(F===true){return}}}}s=false;N.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er");p.hide()}).bind("dnd_scroll.vakata",function(u,t){if(!t||!t.data||!t.data.jstree){return}p.hide();s=false;t.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er")}).bind("dnd_stop.vakata",function(x,w){if(q){clearTimeout(q)}if(!w||!w.data||!w.data.jstree){return}p.hide();var v,u,t=[];if(s){for(v=0,u=w.data.nodes.length;v<u;v++){t[v]=w.data.origin?w.data.origin.get_node(w.data.nodes[v]):w.data.nodes[v];if(w.data.origin){t[v].instance=w.data.origin}}s.ins[w.data.origin&&(w.data.origin.settings.dnd.always_copy||(w.data.origin.settings.dnd.copy&&(w.event.metaKey||w.event.ctrlKey)))?"copy_node":"move_node"](t,s.par,s.pos)}else{v=i(w.event.target).closest(".jstree");if(v.length&&r&&r.error&&r.error==="check"){v=v.jstree(true);if(v){v.settings.core.error.call(this,r)}}}}).bind("keyup keydown",function(u,t){t=i.vakata.dnd._get();if(t&&t.data&&t.data.jstree){t.helper.find(".jstree-copy:eq(0)")[t.data.origin&&(t.data.origin.settings.dnd.always_copy||(t.data.origin.settings.dnd.copy&&(u.metaKey||u.ctrlKey)))?"show":"hide"]()}})});(function(q){var p={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};q.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:50},_trigger:function(t,s){var r=q.vakata.dnd._get();r.event=s;q(document).triggerHandler("dnd_"+t+".vakata",r)},_get:function(){return{data:p.data,element:p.element,helper:p.helper}},_clean:function(){if(p.helper){p.helper.remove()}if(p.scroll_i){clearInterval(p.scroll_i);p.scroll_i=false}p={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};q(document).off("mousemove touchmove",q.vakata.dnd.drag);q(document).off("mouseup touchend",q.vakata.dnd.stop)},_scroll:function(t){if(!p.scroll_e||(!p.scroll_l&&!p.scroll_t)){if(p.scroll_i){clearInterval(p.scroll_i);p.scroll_i=false}return false}if(!p.scroll_i){p.scroll_i=setInterval(q.vakata.dnd._scroll,100);return false}if(t===true){return false}var s=p.scroll_e.scrollTop(),r=p.scroll_e.scrollLeft();p.scroll_e.scrollTop(s+p.scroll_t*q.vakata.dnd.settings.scroll_speed);p.scroll_e.scrollLeft(r+p.scroll_l*q.vakata.dnd.settings.scroll_speed);if(s!==p.scroll_e.scrollTop()||r!==p.scroll_e.scrollLeft()){q.vakata.dnd._trigger("scroll",p.scroll_e)}},start:function(t,s,r){if(t.type==="touchstart"&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]){t.pageX=t.originalEvent.changedTouches[0].pageX;t.pageY=t.originalEvent.changedTouches[0].pageY;t.target=document.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(p.is_drag){q.vakata.dnd.stop({})}try{t.currentTarget.unselectable="on";t.currentTarget.onselectstart=function(){return false};if(t.currentTarget.style){t.currentTarget.style.MozUserSelect="none"}}catch(u){}p.init_x=t.pageX;p.init_y=t.pageY;p.data=s;p.is_down=true;p.element=t.currentTarget;p.target=t.target;p.is_touch=t.type==="touchstart";if(r!==false){p.helper=q("<div id='vakata-dnd'></div>").html(r).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})}q(document).bind("mousemove touchmove",q.vakata.dnd.drag);q(document).bind("mouseup touchend",q.vakata.dnd.stop);return false},drag:function(y){if(y.type==="touchmove"&&y.originalEvent&&y.originalEvent.changedTouches&&y.originalEvent.changedTouches[0]){y.pageX=y.originalEvent.changedTouches[0].pageX;y.pageY=y.originalEvent.changedTouches[0].pageY;y.target=document.elementFromPoint(y.originalEvent.changedTouches[0].pageX-window.pageXOffset,y.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(!p.is_down){return}if(!p.is_drag){if(Math.abs(y.pageX-p.init_x)>(p.is_touch?q.vakata.dnd.settings.threshold_touch:q.vakata.dnd.settings.threshold)||Math.abs(y.pageY-p.init_y)>(p.is_touch?q.vakata.dnd.settings.threshold_touch:q.vakata.dnd.settings.threshold)){if(p.helper){p.helper.appendTo("body");p.helper_w=p.helper.outerWidth()}p.is_drag=true;q.vakata.dnd._trigger("start",y)}else{return}}var z=false,C=false,A=false,s=false,r=false,v=false,u=false,x=false,B=false,t=false;p.scroll_t=0;p.scroll_l=0;p.scroll_e=false;q(q(y.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return(/^auto|scroll$/).test(q(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var w=q(this),D=w.offset();if(this.scrollHeight>this.offsetHeight){if(D.top+w.height()-y.pageY<q.vakata.dnd.settings.scroll_proximity){p.scroll_t=1}if(y.pageY-D.top<q.vakata.dnd.settings.scroll_proximity){p.scroll_t=-1}}if(this.scrollWidth>this.offsetWidth){if(D.left+w.width()-y.pageX<q.vakata.dnd.settings.scroll_proximity){p.scroll_l=1}if(y.pageX-D.left<q.vakata.dnd.settings.scroll_proximity){p.scroll_l=-1}}if(p.scroll_t||p.scroll_l){p.scroll_e=q(this);return false}});if(!p.scroll_e){z=q(document);C=q(window);A=z.height();s=C.height();r=z.width();v=C.width();u=z.scrollTop();x=z.scrollLeft();if(A>s&&y.pageY-u<q.vakata.dnd.settings.scroll_proximity){p.scroll_t=-1}if(A>s&&s-(y.pageY-u)<q.vakata.dnd.settings.scroll_proximity){p.scroll_t=1}if(r>v&&y.pageX-x<q.vakata.dnd.settings.scroll_proximity){p.scroll_l=-1}if(r>v&&v-(y.pageX-x)<q.vakata.dnd.settings.scroll_proximity){p.scroll_l=1}if(p.scroll_t||p.scroll_l){p.scroll_e=z}}if(p.scroll_e){q.vakata.dnd._scroll(true)}if(p.helper){B=parseInt(y.pageY+q.vakata.dnd.settings.helper_top,10);t=parseInt(y.pageX+q.vakata.dnd.settings.helper_left,10);if(A&&B+25>A){B=A-50}if(r&&t+p.helper_w>r){t=r-(p.helper_w+2)}p.helper.css({left:t+"px",top:B+"px"})}q.vakata.dnd._trigger("move",y);return false},stop:function(r){if(r.type==="touchend"&&r.originalEvent&&r.originalEvent.changedTouches&&r.originalEvent.changedTouches[0]){r.pageX=r.originalEvent.changedTouches[0].pageX;r.pageY=r.originalEvent.changedTouches[0].pageY;r.target=document.elementFromPoint(r.originalEvent.changedTouches[0].pageX-window.pageXOffset,r.originalEvent.changedTouches[0].pageY-window.pageYOffset)}if(p.is_drag){q.vakata.dnd._trigger("stop",r)}else{if(r.type==="touchend"&&r.target===p.target){var s=setTimeout(function(){q(r.target).click()},100);q(r.target).one("click",function(){if(s){clearTimeout(s)}})}}q.vakata.dnd._clean();return false}}}(i));i.jstree.defaults.search={ajax:false,fuzzy:false,case_sensitive:false,show_only_matches:false,close_opened_onclear:true,search_leaves_only:false,search_callback:false};i.jstree.plugins.search=function(p,q){this.bind=function(){q.bind.call(this);this._data.search.str="";this._data.search.dom=i();this._data.search.res=[];this._data.search.opn=[];this.element.on("before_open.jstree",i.proxy(function(z,y){var u,t,x,w=this._data.search.res,v=[],A=i();if(w&&w.length){this._data.search.dom=i(this.element[0].querySelectorAll("#"+i.map(w,function(r){return"0123456789".indexOf(r[0])!==-1?"\\3"+r[0]+" "+r.substr(1).replace(i.jstree.idregex,"\\$&"):r.replace(i.jstree.idregex,"\\$&")}).join(", #")));this._data.search.dom.children(".jstree-anchor").addClass("jstree-search");if(this.settings.search.show_only_matches&&this._data.search.res.length){for(u=0,t=w.length;u<t;u++){v=v.concat(this.get_node(w[u]).parents)}v=i.vakata.array_remove_item(i.vakata.array_unique(v),"#");A=v.length?i(this.element[0].querySelectorAll("#"+i.map(v,function(r){return"0123456789".indexOf(r[0])!==-1?"\\3"+r[0]+" "+r.substr(1).replace(i.jstree.idregex,"\\$&"):r.replace(i.jstree.idregex,"\\$&")}).join(", #"))):i();this.element.find(".jstree-node").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last");A=A.add(this._data.search.dom);A.parentsUntil(".jstree").addBack().show().filter(".jstree-children").each(function(){i(this).children(".jstree-node:visible").eq(-1).addClass("jstree-last")})}}},this));if(this.settings.search.show_only_matches){this.element.on("search.jstree",function(s,r){if(r.nodes.length){i(this).find(".jstree-node").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last");r.nodes.parentsUntil(".jstree").addBack().show().filter(".jstree-children").each(function(){i(this).children(".jstree-node:visible").eq(-1).addClass("jstree-last")})}}).on("clear_search.jstree",function(s,r){if(r.nodes.length){i(this).find(".jstree-node").css("display","").filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last")}})}};this.search=function(y,A){if(y===false||i.trim(y.toString())===""){return this.clear_search()}y=y.toString();var B=this.settings.search,z=B.ajax?B.ajax:false,x=null,t=[],u=[],w,v;if(this._data.search.res.length){this.clear_search()}if(!A&&z!==false){if(i.isFunction(z)){return z.call(this,y,i.proxy(function(r){if(r&&r.d){r=r.d}this._load_nodes(!i.isArray(r)?[]:i.vakata.array_unique(r),function(){this.search(y,true)},true)},this))}else{z=i.extend({},z);if(!z.data){z.data={}}z.data.str=y;return i.ajax(z).fail(i.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(z)};this.settings.core.error.call(this,this._data.core.last_error)},this)).done(i.proxy(function(r){if(r&&r.d){r=r.d}this._load_nodes(!i.isArray(r)?[]:i.vakata.array_unique(r),function(){this.search(y,true)},true)},this))}}this._data.search.str=y;this._data.search.dom=i();this._data.search.res=[];this._data.search.opn=[];x=new i.vakata.search(y,true,{caseSensitive:B.case_sensitive,fuzzy:B.fuzzy});i.each(this._model.data,function(s,r){if(r.text&&((B.search_callback&&B.search_callback.call(this,y,r))||(!B.search_callback&&x.search(r.text).isMatch))&&(!B.search_leaves_only||(r.state.loaded&&r.children.length===0))){t.push(s);u=u.concat(r.parents)}});if(t.length){u=i.vakata.array_unique(u);this._search_open(u);this._data.search.dom=i(this.element[0].querySelectorAll("#"+i.map(t,function(r){return"0123456789".indexOf(r[0])!==-1?"\\3"+r[0]+" "+r.substr(1).replace(i.jstree.idregex,"\\$&"):r.replace(i.jstree.idregex,"\\$&")}).join(", #")));this._data.search.res=t;this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:y,res:this._data.search.res})};this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search");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});this._data.search.str="";this._data.search.res=[];this._data.search.opn=[];this._data.search.dom=i()};this._search_open=function(s){var r=this;i.each(s.concat([]),function(u,t){if(t==="#"){return true}try{t=i("#"+t.replace(i.jstree.idregex,"\\$&"),r.element)}catch(w){}if(t&&t.length){if(r.is_closed(t)){r._data.search.opn.push(t[0].id);r.open_node(t,function(){r._search_open(s)},0)}}})}};(function(p){p.vakata.search=function(v,t,A){A=A||{};if(A.fuzzy!==false){A.fuzzy=true}v=A.caseSensitive?v:v.toLowerCase();var x=A.location||0,y=A.distance||100,w=A.threshold||0.6,q=v.length,r,s,u,z;if(q>32){A.fuzzy=false}if(A.fuzzy){r=1<<(q-1);s=(function(){var B={},C=0;for(C=0;C<q;C++){B[v.charAt(C)]=0}for(C=0;C<q;C++){B[v.charAt(C)]|=1<<(q-C-1)}return B}());u=function(E,B){var D=E/q,C=Math.abs(x-B);if(!y){return C?1:D}return D+(C/y)}}z=function(O){O=A.caseSensitive?O:O.toLowerCase();if(v===O||O.indexOf(v)!==-1){return{isMatch:true,score:0}}if(!A.fuzzy){return{isMatch:false,score:1}}var J,I,N=O.length,F=w,H=O.indexOf(v,x),L,E,C=q+N,B,D,M,Q,P,G=1,K=[];if(H!==-1){F=Math.min(u(0,H),F);H=O.lastIndexOf(v,x+q);if(H!==-1){F=Math.min(u(0,H),F)}}H=-1;for(J=0;J<q;J++){L=0;E=C;while(L<E){if(u(J,x+E)<=F){L=E}else{C=E}E=Math.floor((C-L)/2+L)}C=E;D=Math.max(1,x-E+1);M=Math.min(x+E,N)+q;Q=new Array(M+2);Q[M+1]=(1<<J)-1;for(I=M;I>=D;I--){P=s[O.charAt(I-1)];if(J===0){Q[I]=((Q[I+1]<<1)|1)&P}else{Q[I]=((Q[I+1]<<1)|1)&P|(((B[I+1]|B[I])<<1)|1)|B[I+1]}if(Q[I]&r){G=u(J,I-1);if(G<=F){F=G;H=I-1;K.push(H);if(H>x){D=Math.max(1,2*x-H)}else{break}}}}if(u(J+1,x)>F){break}B=Q}return{isMatch:H>=0,score:G}};return t===true?{search:z}:z(t)}}(i));i.jstree.defaults.sort=function(q,p){return this.get_text(q)>this.get_text(p)?1:-1};i.jstree.plugins.sort=function(p,q){this.bind=function(){q.bind.call(this);this.element.on("model.jstree",i.proxy(function(s,r){this.sort(r.parent,true)},this)).on("rename_node.jstree create_node.jstree",i.proxy(function(s,r){this.sort(r.parent||r.node.parent,false);this.redraw_node(r.parent||r.node.parent,true)},this)).on("move_node.jstree copy_node.jstree",i.proxy(function(s,r){this.sort(r.parent,false);this.redraw_node(r.parent,true)},this))};this.sort=function(u,r){var t,s;u=this.get_node(u);if(u&&u.children&&u.children.length){u.children.sort(i.proxy(this.settings.sort,this));if(r){for(t=0,s=u.children_d.length;t<s;t++){this.sort(u.children_d[t],false)}}}}};var n=false;i.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:false,filter:false};i.jstree.plugins.state=function(p,q){this.bind=function(){q.bind.call(this);var r=i.proxy(function(){this.element.on(this.settings.state.events,i.proxy(function(){if(n){clearTimeout(n)}n=setTimeout(i.proxy(function(){this.save_state()},this),100)},this))},this);this.element.on("ready.jstree",i.proxy(function(t,s){this.element.one("restore_state.jstree",r);if(!this.restore_state()){r()}},this))};this.save_state=function(){var r={state:this.get_state(),ttl:this.settings.state.ttl,sec:+(new Date())};i.vakata.storage.set(this.settings.state.key,JSON.stringify(r))};this.restore_state=function(){var r=i.vakata.storage.get(this.settings.state.key);if(!!r){try{r=JSON.parse(r)}catch(s){return false}}if(!!r&&r.ttl&&r.sec&&+(new Date())-r.sec>r.ttl){return false}if(!!r&&r.state){r=r.state}if(!!r&&i.isFunction(this.settings.state.filter)){r=this.settings.state.filter.call(this,r)}if(!!r){this.element.one("set_state.jstree",function(u,t){t.instance.trigger("restore_state",{state:i.extend(true,{},r)})});this.set_state(r);return true}return false};this.clear_state=function(){return i.vakata.storage.del(this.settings.state.key)}};(function(p,q){p.vakata.storage={set:function(r,s){return window.localStorage.setItem(r,s)},get:function(r){return window.localStorage.getItem(r)},del:function(r){return window.localStorage.removeItem(r)}}}(i));i.jstree.defaults.types={"#":{},"default":{}};i.jstree.plugins.types=function(p,q){this.init=function(u,s){var t,r;if(s&&s.types&&s.types["default"]){for(t in s.types){if(t!=="default"&&t!=="#"&&s.types.hasOwnProperty(t)){for(r in s.types["default"]){if(s.types["default"].hasOwnProperty(r)&&s.types[t][r]===e){s.types[t][r]=s.types["default"][r]}}}}}q.init.call(this,u,s);this._model.data["#"].type="#"};this.refresh=function(s,r){q.refresh.call(this,s,r);this._model.data["#"].type="#"};this.bind=function(){this.element.on("model.jstree",i.proxy(function(x,w){var r=this._model.data,z=w.nodes,v=this.settings.types,u,s,y="default";for(u=0,s=z.length;u<s;u++){y="default";if(r[z[u]].original&&r[z[u]].original.type&&v[r[z[u]].original.type]){y=r[z[u]].original.type}if(r[z[u]].data&&r[z[u]].data.jstree&&r[z[u]].data.jstree.type&&v[r[z[u]].data.jstree.type]){y=r[z[u]].data.jstree.type}r[z[u]].type=y;if(r[z[u]].icon===true&&v[y].icon!==e){r[z[u]].icon=v[y].icon}}r["#"].type="#"},this));q.bind.call(this)};this.get_json=function(x,t,y){var w,s,r=this._model.data,v=t?i.extend(true,{},t,{no_id:false}):{},u=q.get_json.call(this,x,v,y);if(u===false){return false}if(i.isArray(u)){for(w=0,s=u.length;w<s;w++){u[w].type=u[w].id&&r[u[w].id]&&r[u[w].id].type?r[u[w].id].type:"default";if(t&&t.no_id){delete u[w].id;if(u[w].li_attr&&u[w].li_attr.id){delete u[w].li_attr.id}}}}else{u.type=u.id&&r[u.id]&&r[u.id].type?r[u.id].type:"default";if(t&&t.no_id){u=this._delete_ids(u)}}return u};this._delete_ids=function(t){if(i.isArray(t)){for(var s=0,r=t.length;s<r;s++){t[s]=this._delete_ids(t[s])}return t}delete t.id;if(t.li_attr&&t.li_attr.id){delete t.li_attr.id}if(t.children&&i.isArray(t.children)){t.children=this._delete_ids(t.children)}return t};this.check=function(z,u,x,A,y){if(q.check.call(this,z,u,x,A,y)===false){return false}u=u&&u.id?u:this.get_node(u);x=x&&x.id?x:this.get_node(x);var r=u&&u.id?i.jstree.reference(u.id):null,v,w,t,s;r=r&&r._model&&r._model.data?r._model.data:null;switch(z){case"create_node":case"move_node":case"copy_node":if(z!=="move_node"||i.inArray(u.id,x.children)===-1){v=this.get_rules(x);if(v.max_children!==e&&v.max_children!==-1&&v.max_children===x.children.length){this._data.core.last_error={error:"check",plugin:"types",id:"types_01",reason:"max_children prevents function: "+z,data:JSON.stringify({chk:z,pos:A,obj:u&&u.id?u.id:false,par:x&&x.id?x.id:false})};return false}if(v.valid_children!==e&&v.valid_children!==-1&&i.inArray(u.type,v.valid_children)===-1){this._data.core.last_error={error:"check",plugin:"types",id:"types_02",reason:"valid_children prevents function: "+z,data:JSON.stringify({chk:z,pos:A,obj:u&&u.id?u.id:false,par:x&&x.id?x.id:false})};return false}if(r&&u.children_d&&u.parents){w=0;for(t=0,s=u.children_d.length;t<s;t++){w=Math.max(w,r[u.children_d[t]].parents.length)}w=w-u.parents.length+1}if(w<=0||w===e){w=1}do{if(v.max_depth!==e&&v.max_depth!==-1&&v.max_depth<w){this._data.core.last_error={error:"check",plugin:"types",id:"types_03",reason:"max_depth prevents function: "+z,data:JSON.stringify({chk:z,pos:A,obj:u&&u.id?u.id:false,par:x&&x.id?x.id:false})};return false}x=this.get_node(x.parent);v=this.get_rules(x);w++}while(x)}break}return true};this.get_rules=function(s){s=this.get_node(s);if(!s){return false}var r=this.get_type(s,true);if(r.max_depth===e){r.max_depth=-1}if(r.max_children===e){r.max_children=-1}if(r.valid_children===e){r.valid_children=-1}return r};this.get_type=function(r,s){r=this.get_node(r);return(!r)?false:(s?i.extend({type:r.type},this.settings.types[r.type]):r.type)};this.set_type=function(y,w){var u,x,v,s,r;if(i.isArray(y)){y=y.slice();for(x=0,v=y.length;x<v;x++){this.set_type(y[x],w)}return true}u=this.settings.types;y=this.get_node(y);if(!u[w]||!y){return false}s=y.type;r=this.get_icon(y);y.type=w;if(r===true||(u[s]&&u[s].icon&&r===u[s].icon)){this.set_icon(y,u[w].icon!==e?u[w].icon:true)}return true}};i.jstree.defaults.unique={case_sensitive:false,duplicate:function(q,p){return q+" ("+p+")"}};i.jstree.plugins.unique=function(p,q){this.check=function(A,w,x,B,y){if(q.check.call(this,A,w,x,B,y)===false){return false}w=w&&w.id?w:this.get_node(w);x=x&&x.id?x:this.get_node(x);if(!x||!x.children){return true}var r=A==="rename_node"?B:w.text,z=[],C=this.settings.unique.case_sensitive,t=this._model.data,v,u;for(v=0,u=x.children.length;v<u;v++){z.push(C?t[x.children[v]].text:t[x.children[v]].text.toLowerCase())}if(!C){r=r.toLowerCase()}switch(A){case"delete_node":return true;case"rename_node":v=(i.inArray(r,z)===-1||(w.text&&w.text[C?"toString":"toLowerCase"]()===r));if(!v){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+r+" already exists. Preventing: "+A,data:JSON.stringify({chk:A,pos:B,obj:w&&w.id?w.id:false,par:x&&x.id?x.id:false})}}return v;case"create_node":v=(i.inArray(r,z)===-1);if(!v){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_04",reason:"Child with name "+r+" already exists. Preventing: "+A,data:JSON.stringify({chk:A,pos:B,obj:w&&w.id?w.id:false,par:x&&x.id?x.id:false})}}return v;case"copy_node":v=(i.inArray(r,z)===-1);if(!v){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_02",reason:"Child with name "+r+" already exists. Preventing: "+A,data:JSON.stringify({chk:A,pos:B,obj:w&&w.id?w.id:false,par:x&&x.id?x.id:false})}}return v;case"move_node":v=(w.parent===x.id||i.inArray(r,z)===-1);if(!v){this._data.core.last_error={error:"check",plugin:"unique",id:"unique_03",reason:"Child with name "+r+" already exists. Preventing: "+A,data:JSON.stringify({chk:A,pos:B,obj:w&&w.id?w.id:false,par:x&&x.id?x.id:false})}}return v}return true};this.create_node=function(A,u,C,D,B){if(!u||u.text===e){if(A===null){A="#"}A=this.get_node(A);if(!A){return q.create_node.call(this,A,u,C,D,B)}C=C===e?"last":C;if(!C.toString().match(/^(before|after)$/)&&!B&&!this.is_loaded(A)){return q.create_node.call(this,A,u,C,D,B)}if(!u){u={}}var y,r,z,x,w,t=this._model.data,E=this.settings.unique.case_sensitive,v=this.settings.unique.duplicate;r=y=this.get_string("New node");z=[];for(x=0,w=A.children.length;x<w;x++){z.push(E?t[A.children[x]].text:t[A.children[x]].text.toLowerCase())}x=1;while(i.inArray(E?r:r.toLowerCase(),z)!==-1){r=v.call(this,y,(++x)).toString()}u.text=r}return q.create_node.call(this,A,u,C,D,B)}};var b=document.createElement("DIV");b.setAttribute("unselectable","on");b.className="jstree-wholerow";b.innerHTML=" ";i.jstree.plugins.wholerow=function(p,q){this.bind=function(){q.bind.call(this);this.element.on("ready.jstree set_state.jstree",i.proxy(function(){this.hide_dots()},this)).on("init.jstree loading.jstree ready.jstree",i.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",i.proxy(function(s,r){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",i.proxy(function(v,u){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var t=false,s,r;for(s=0,r=u.selected.length;s<r;s++){t=this.get_node(u.selected[s],true);if(t&&t.length){t.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")}}},this)).on("open_node.jstree",i.proxy(function(s,r){this.get_node(r.node,true).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",i.proxy(function(s,r){this.get_node(r.node,true).children(".jstree-wholerow")[s.type==="hover_node"?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",i.proxy(function(s){s.preventDefault();var r=i.Event("contextmenu",{metaKey:s.metaKey,ctrlKey:s.ctrlKey,altKey:s.altKey,shiftKey:s.shiftKey,pageX:s.pageX,pageY:s.pageY});i(s.currentTarget).closest(".jstree-node").children(".jstree-anchor:eq(0)").trigger(r)},this)).on("click.jstree",".jstree-wholerow",function(s){s.stopImmediatePropagation();var r=i.Event("click",{metaKey:s.metaKey,ctrlKey:s.ctrlKey,altKey:s.altKey,shiftKey:s.shiftKey});i(s.currentTarget).closest(".jstree-node").children(".jstree-anchor:eq(0)").trigger(r).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",i.proxy(function(s){s.stopImmediatePropagation();var r=i.Event("click",{metaKey:s.metaKey,ctrlKey:s.ctrlKey,altKey:s.altKey,shiftKey:s.shiftKey});i(s.currentTarget).closest(".jstree-node").children(".jstree-anchor:eq(0)").trigger(r).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",i.proxy(function(r){r.stopImmediatePropagation();this.hover_node(r.currentTarget);return false},this)).on("mouseleave.jstree",".jstree-node",i.proxy(function(r){this.dehover_node(r.currentTarget)},this))};this.teardown=function(){if(this.settings.wholerow){this.element.find(".jstree-wholerow").remove()}q.teardown.call(this)};this.redraw_node=function(t,r,u){t=q.redraw_node.call(this,t,r,u);if(t){var s=b.cloneNode(true);if(i.inArray(t.id,this._data.core.selected)!==-1){s.className+=" jstree-wholerow-clicked"}t.insertBefore(s,t.childNodes[0])}return t}}})); |