diff --git a/.gitignore b/.gitignore index a2b3ae2a..8e5ec245 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /demo /jstree.sublime-project /jstree.sublime-workspace -/node_modules \ No newline at end of file +/node_modules +/site \ No newline at end of file diff --git a/bower.json b/bower.json index 19a67738..e4640aac 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jstree", - "version": "3.0.0", + "version": "3.0.0-beta", "main" : [ "./dist/jstree.min.js", "./dist/themes/default/style.min.css" diff --git a/dist/jstree.js b/dist/jstree.js index 00d6ae2a..b542de08 100644 --- a/dist/jstree.js +++ b/dist/jstree.js @@ -2477,7 +2477,8 @@ if(!pos.match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); }); } - if(!node) { node = this.get_string('New node'); } + if(!node) { node = { "text" : this.get_string('New node') }; } + if(node.text === undefined) { node.text = this.get_string('New node'); } var tmp, dpc, i, j; if(par.id === '#') { @@ -2507,7 +2508,9 @@ break; } if(pos > par.children.length) { pos = par.children.length; } + if(!node.id) { node.id = true; } if(!this.check("create_node", node, par, pos)) { return false; } + delete node.id; node = this._parse_model_from_json(node, par.id, par.parents.concat()); if(!node) { return false; } tmp = this.get_node(node); @@ -2528,7 +2531,7 @@ tmp[pos] = node.id; par.children = tmp; - this.redraw_node(par); + this.redraw_node(par, true); if(callback) { callback.call(this, this.get_node(node)); } /** * triggered when a node is created @@ -3030,7 +3033,7 @@ if(key === 27) { this.value = t; } - if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40) { + if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) { event.stopImmediatePropagation(); } if(key === 27 || key === 13) { @@ -3580,13 +3583,15 @@ this._undetermined = function () { var i, j, m = this._model.data, s = this._data.core.selected, p = [], t = this; for(i = 0, j = s.length; i < j; i++) { - p = p.concat(m[s[i]].parents); + if(m[s[i]] && m[s[i]].parents) { + p = p.concat(m[s[i]].parents); + } } // attempt for server side undetermined state this.element.find('.jstree-closed').not(':has(ul)') .each(function () { var tmp = t.get_node(this); - if(!tmp.state.loaded && tmp.original.state.undetermined === true) { + if(!tmp.state.loaded && tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) { p.push(tmp.id); p = p.concat(tmp.parents); } diff --git a/dist/jstree.min.js b/dist/jstree.min.js index 653e0e25..abd08cd4 100644 --- a/dist/jstree.min.js +++ b/dist/jstree.min.js @@ -1,4 +1,4 @@ -/*! jsTree - v3.0.0 - 2013-12-25 - (MIT) */ -(function(e){"use strict";"function"==typeof define&&define.amd?define("jstree",["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e,t){"use strict";if(!e.jstree){var n=0,r=0,a=!1,i=!1,s=!1,o=[],d=e("script:last").attr("src"),l=document,c=l.createElement("LI"),h,_;c.setAttribute("role","treeitem"),h=l.createElement("I"),h.className="jstree-icon jstree-ocl",c.appendChild(h),h=l.createElement("A"),h.className="jstree-anchor",h.setAttribute("href","#"),_=l.createElement("I"),_.className="jstree-icon jstree-themeicon",h.appendChild(_),c.appendChild(h),h=_=null,e.jstree={version:"3.0.0-alpha",defaults:{plugins:[]},plugins:{},path:d&&-1!==d.indexOf("/")?d.replace(/\/[^\/]+$/,""):""},e.jstree.create=function(t,r){var a=new e.jstree.core(++n),i=r;return r=e.extend(!0,{},e.jstree.defaults,r),i&&i.plugins&&(r.plugins=i.plugins),e.each(r.plugins,function(e,t){"core"!==e&&(a=a.plugin(t,r[t]))}),a.init(t,r),a},e.jstree.core=function(e){this._id=e,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[]}}},e.jstree.reference=function(n){if(n&&!e(n).length){n.id&&(n=n.id);var r=null;return e(".jstree").each(function(){var a=e(this).data("jstree");return a&&a._model.data[n]?(r=a,!1):t}),r}return e(n).closest(".jstree").data("jstree")},e.fn.jstree=function(n){var r="string"==typeof n,a=Array.prototype.slice.call(arguments,1),i=null;return this.each(function(){var s=e.jstree.reference(this),o=r&&s?s[n]:null;return i=r&&o?o.apply(s,a):null,s||r||n!==t&&!e.isPlainObject(n)||e(this).data("jstree",new e.jstree.create(this,n)),s&&!r&&(i=s),null!==i&&i!==t?!1:t}),null!==i&&i!==t?i:this},e.expr[":"].jstree=e.expr.createPseudo(function(n){return function(n){return e(n).hasClass("jstree")&&e(n).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1},expand_selected_onload:!0},e.jstree.core.prototype={plugin:function(t,n){var r=e.jstree.plugins[t];return r?(this._data[t]={},r.prototype=this,new r(n,this)):this},init:function(t,n){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=n,this.element.bind("destroyed",e.proxy(this.teardown,this)),this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),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(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html(""),this._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||18,this.trigger("loading"),this.load_node("#")},destroy:function(){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[^ ]*|$/gi,"")}),this.element=null},bind:function(){e.support.touch&&this.element.addTouch(),this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var e=window.getSelection();try{e.removeAllRanges(),e.collapse()}catch(t){}}}).on("click.jstree",".jstree-ocl",e.proxy(function(e){this.toggle_node(e.target)},this)).on("click.jstree",".jstree-anchor",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).focus(),this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",e.proxy(function(t){var n=null;switch(t.which){case 13:case 32:t.type="click",e(t.currentTarget).trigger(t);break;case 37:t.preventDefault(),this.is_open(t.currentTarget)?this.close_node(t.currentTarget):(n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 38:t.preventDefault(),n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 39:t.preventDefault(),this.is_closed(t.currentTarget)?this.open_node(t.currentTarget,function(e){this.get_node(e,!0).children(".jstree-anchor").focus()}):(n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 40:t.preventDefault(),n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 46:t.preventDefault(),n=this.get_node(t.currentTarget),n&&n.id&&"#"!==n.id&&(n=this.is_selected(n)?this.get_selected():n);break;case 113:t.preventDefault(),n=this.get_node(t.currentTarget);break;default:}},this)).on("load_node.jstree",e.proxy(function(t,n){if(n.status&&("#"!==n.node.id||this._data.core.loaded||(this._data.core.loaded=!0,this.trigger("loaded")),!this._data.core.ready&&!this.get_container_ul().find(".jstree-loading:eq(0)").length)){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var r=[],a,i;for(a=0,i=this._data.core.selected.length;i>a;a++)r=r.concat(this._model.data[this._data.core.selected[a]].parents);for(r=e.vakata.array_unique(r),a=0,i=r.length;i>a;a++)this.open_node(r[a],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this)).on("init.jstree",e.proxy(function(){var e=this.settings.core.themes;this._data.core.themes.dots=e.dots,this._data.core.themes.stripes=e.stripes,this._data.core.themes.icons=e.icons,this.set_theme(e.name||"default",e.url),this.set_theme_variant(e.variant)},this)).on("loading.jstree",e.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("focus.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseenter()},this)).on("blur.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseleave()},this)).on("mouseenter.jstree",".jstree-anchor",e.proxy(function(e){var t=this.element.find(".jstree-anchor:focus").not(".jstree-clicked");t&&t.length&&t[0]!==e.currentTarget&&t.blur(),this.hover_node(e.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),e(document).off(".jstree-"+this._id)},trigger:function(e,t){t||(t={}),t.instance=this,this.element.triggerHandler(e.replace(".jstree","")+".jstree",t)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children("ul:eq(0)")},get_string:function(t){var n=this.settings.core.strings;return e.isFunction(n)?n.call(this,t):n&&n[t]?n[t]:t},_firstChild:function(e){e=e?e.firstChild:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_nextSibling:function(e){e=e?e.nextSibling:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_previousSibling:function(e){e=e?e.previousSibling:null;while(null!==e&&1!==e.nodeType)e=e.previousSibling;return e},get_node:function(t,n){t&&t.id&&(t=t.id);var r;if(this._model.data[t])t=this._model.data[t];else if(((r=e(t,this.element)).length||(r=e("#"+t,this.element)).length)&&this._model.data[r.closest("li").attr("id")])t=this._model.data[r.closest("li").attr("id")];else{if(!(r=e(t,this.element)).length||!r.hasClass("jstree"))return!1;t=this._model.data["#"]}return n&&(t="#"===t.id?this.element:e(document.getElementById(t.id))),t},get_next_dom:function(t,n){var r;return t=this.get_node(t,!0),t[0]===this.element[0]?(r=this._firstChild(this.get_container_ul()[0]),r?e(r):!1):t&&t.length?n?(r=this._nextSibling(t[0]),r?e(r):!1):t.hasClass("jstree-open")?(r=this._firstChild(t.children("ul")[0]),r?e(r):!1):null!==(r=this._nextSibling(t[0]))?e(r):t.parentsUntil(".jstree","li").next("li").eq(0):!1},get_prev_dom:function(t,n){var r;if(t=this.get_node(t,!0),t[0]===this.element[0])return r=this.get_container_ul()[0].lastChild,r?e(r):!1;if(!t||!t.length)return!1;if(n)return r=this._previousSibling(t[0]),r?e(r):!1;if(null!==(r=this._previousSibling(t[0]))){t=e(r);while(t.hasClass("jstree-open"))t=t.children("ul:eq(0)").children("li:last");return t}return r=t[0].parentNode.parentNode,r&&"LI"===r.tagName?e(r):!1},get_parent:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.parent:!1},get_children_dom:function(e){return e=this.get_node(e,!0),e[0]===this.element[0]?this.get_container_ul().children("li"):e&&e.length?e.children("ul").children("li"):!1},is_parent:function(e){return e=this.get_node(e),e&&(e.state.loaded===!1||e.children.length)},is_loaded:function(e){return e=this.get_node(e),e&&e.state.loaded},is_loading:function(e){return e=this.get_node(e,!0),e&&e.hasClass("jstree-loading")},is_open:function(e){return e=this.get_node(e),e&&e.state.opened},is_closed:function(e){return e=this.get_node(e),e&&this.is_parent(e)&&!e.state.opened},is_leaf:function(e){return!this.is_parent(e)},load_node:function(t,n){var r,a;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.load_node(t[r],n);return!0}return(t=this.get_node(t))?(this.get_node(t,!0).addClass("jstree-loading"),this._load_node(t,e.proxy(function(e){t.state.loaded=e,this.get_node(t,!0).removeClass("jstree-loading"),this.trigger("load_node",{node:t,status:e}),n&&n.call(this,t,e)},this)),!0):(n.call(this,t,!1),!1)},_load_node:function(n,r){var a=this.settings.core.data;return a?e.isFunction(a)?a.call(this,n,e.proxy(function(t){return r.call(this,this["string"==typeof t?"_append_html_data":"_append_json_data"](n,"string"==typeof t?e(t):t))},this)):"object"==typeof a?a.url?(a=e.extend(!0,{},a),e.isFunction(a.url)&&(a.url=a.url.call(this,n)),e.isFunction(a.data)&&(a.data=a.data.call(this,n)),e.ajax(a).done(e.proxy(function(a,i,s){var o=s.getResponseHeader("Content-Type");return-1!==o.indexOf("json")?r.call(this,this._append_json_data(n,a)):-1!==o.indexOf("html")?r.call(this,this._append_html_data(n,e(a))):t},this)).fail(e.proxy(function(){r.call(this,!1)},this))):r.call(this,this._append_json_data(n,a)):"string"==typeof a?r.call(this,this._append_html_data(n,a)):r.call(this,!1):r.call(this,"#"===n.id?this._append_html_data(n,this._data.core.original_container_html.clone(!0)):!1)},_node_changed:function(e){e=this.get_node(e),e&&this._model.changed.push(e.id)},_append_html_data:function(t,n){t=this.get_node(t);var r=n.is("ul")?n.children():n,a=t.id,i=[],s=[],o=this._model.data,d=o[a],l=this._data.core.selected.length,c,h,_;for(r.each(e.proxy(function(t,n){c=this._parse_model_from_html(e(n),a,d.parents.concat()),c&&(i.push(c),s.push(c),o[c].children_d.length&&(s=s.concat(o[c].children_d)))},this)),d.children=i,d.children_d=s,h=0,_=d.parents.length;_>h;h++)o[d.parents[h]].children_d=o[d.parents[h]].children_d.concat(s);return this.trigger("model",{nodes:s,parent:a}),"#"!==a?(this._node_changed(a),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==l&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_append_json_data:function(n,r){n=this.get_node(n);var a=r,i=n.id,s=[],o=[],d=this._model.data,l=d[i],c=this._data.core.selected.length,h,_,u;if(e.isArray(a)||(a=[a]),a.length&&a[0].id!==t&&a[0].parent!==t){for(_=0,u=a.length;u>_;_++)a[_].children||(a[_].children=[]),d[a[_].id]=a[_];for(_=0,u=a.length;u>_;_++)d[a[_].parent].children.push(a[_].id),l.children_d.push(a[_].id);for(_=0,u=l.children.length;u>_;_++)this._parse_model_from_flat_json(d[l.children[_]],i,l.parents.concat())}else{for(_=0,u=a.length;u>_;_++)h=this._parse_model_from_json(a[_],i,l.parents.concat()),h&&(s.push(h),o.push(h),d[h].children_d.length&&(o=o.concat(d[h].children_d)));for(l.children=s,l.children_d=o,_=0,u=l.parents.length;u>_;_++)d[l.parents[_]].children_d=d[l.parents[_]].children_d.concat(o)}return this.trigger("model",{nodes:o,parent:i}),"#"!==i?(this._node_changed(i),this.redraw()):this.redraw(!0),this._data.core.selected.length!==c&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_parse_model_from_html:function(n,a,i){i=i?[].concat(i):[],a&&i.unshift(a);var s,o,d=this._model.data,l={id:!1,text:!1,icon:!0,parent:a,parents:i,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},c,h,_;for(c in this._model.default_state)this._model.default_state.hasOwnProperty(c)&&(l.state[c]=this._model.default_state[c]);if(h=e.vakata.attributes(n,!0),e.each(h,function(n,r){return r=e.trim(r),r.length?(l.li_attr[n]=r,"id"===n&&(l.id=r),t):!0}),h=n.children("a").eq(0),h.length&&(h=e.vakata.attributes(h,!0),e.each(h,function(t,n){n=e.trim(n),n.length&&(l.a_attr[t]=n)})),h=n.children("a:eq(0)").length?n.children("a:eq(0)").clone():n.clone(),h.children("ins, i, ul").remove(),h=h.html(),h=e("
").html(h),l.text=h.html(),h=n.data(),l.data=h?e.extend(!0,{},h):null,l.state.opened=n.hasClass("jstree-open"),l.state.selected=n.children("a").hasClass("jstree-clicked"),l.state.disabled=n.children("a").hasClass("jstree-disabled"),l.data&&l.data.jstree)for(c in l.data.jstree)l.data.jstree.hasOwnProperty(c)&&(l.state[c]=l.data.jstree[c]);h=n.children("a").children(".jstree-themeicon"),h.length&&(l.icon=h.hasClass("jstree-themeicon-hidden")?!1:h.attr("rel")),l.state.icon&&(l.icon=l.state.icon),h=n.children("ul").children("li");do _="j"+this._id+"_"+ ++r;while(d[_]);return l.id=l.li_attr.id||_,h.length?(h.each(e.proxy(function(t,n){s=this._parse_model_from_html(e(n),l.id,i),o=this._model.data[s],l.children.push(s),o.children_d.length&&(l.children_d=l.children_d.concat(o.children_d))},this)),l.children_d=l.children_d.concat(l.children)):n.hasClass("jstree-closed")&&(l.state.loaded=!1),d[l.id]=l,l.state.selected&&this._data.core.selected.push(l.id),l.id},_parse_model_from_flat_json:function(e,n,r){r=r?r.concat():[],n&&r.unshift(n);var a=e.id,i=this._model.data,s=this._model.default_state,o,d,l,c,h={id:a,text:e.text||"",icon:e.icon!==t?e.icon:!0,parent:n,parents:r,children:e.children||[],children_d:e.children_d||[],data:e.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(o in s)s.hasOwnProperty(o)&&(h.state[o]=s[o]);if(e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(h.icon=e.data.jstree.icon),e&&e.data&&(h.data=e.data,e.data.jstree))for(o in e.data.jstree)e.data.jstree.hasOwnProperty(o)&&(h.state[o]=e.data.jstree[o]);if(e&&"object"==typeof e.state)for(o in e.state)e.state.hasOwnProperty(o)&&(h.state[o]=e.state[o]);if(e&&"object"==typeof e.li_attr)for(o in e.li_attr)e.li_attr.hasOwnProperty(o)&&(h.li_attr[o]=e.li_attr[o]);if(h.li_attr.id||(h.li_attr.id=a),e&&"object"==typeof e.a_attr)for(o in e.a_attr)e.a_attr.hasOwnProperty(o)&&(h.a_attr[o]=e.a_attr[o]);for(e&&e.children&&e.children===!0&&(h.state.loaded=!1,h.children=[],h.children_d=[]),i[h.id]=h,o=0,d=h.children.length;d>o;o++)l=this._parse_model_from_flat_json(i[h.children[o]],h.id,r),c=i[l],h.children_d.push(l),c.children_d.length&&(h.children_d=h.children_d.concat(c.children_d));return delete e.data,delete e.children,i[h.id].original=e,h.state.selected&&this._data.core.selected.push(h.id),h.id},_parse_model_from_json:function(e,n,a){a=a?a.concat():[],n&&a.unshift(n);var i=!1,s,o,d,l,c=this._model.data,h=this._model.default_state,_;do i="j"+this._id+"_"+ ++r;while(c[i]);_={id:!1,text:"string"==typeof e?e:"",icon:"object"==typeof e&&e.icon!==t?e.icon:!0,parent:n,parents:a,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(s in h)h.hasOwnProperty(s)&&(_.state[s]=h[s]);if(e&&e.id&&(_.id=e.id),e&&e.text&&(_.text=e.text),e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(_.icon=e.data.jstree.icon),e&&e.data&&(_.data=e.data,e.data.jstree))for(s in e.data.jstree)e.data.jstree.hasOwnProperty(s)&&(_.state[s]=e.data.jstree[s]);if(e&&"object"==typeof e.state)for(s in e.state)e.state.hasOwnProperty(s)&&(_.state[s]=e.state[s]);if(e&&"object"==typeof e.li_attr)for(s in e.li_attr)e.li_attr.hasOwnProperty(s)&&(_.li_attr[s]=e.li_attr[s]);if(_.li_attr.id&&!_.id&&(_.id=_.li_attr.id),_.id||(_.id=i),_.li_attr.id||(_.li_attr.id=_.id),e&&"object"==typeof e.a_attr)for(s in e.a_attr)e.a_attr.hasOwnProperty(s)&&(_.a_attr[s]=e.a_attr[s]);if(e&&e.children&&e.children.length){for(s=0,o=e.children.length;o>s;s++)d=this._parse_model_from_json(e.children[s],_.id,a),l=c[d],_.children.push(d),l.children_d.length&&(_.children_d=_.children_d.concat(l.children_d));_.children_d=_.children_d.concat(_.children)}return e&&e.children&&e.children===!0&&(_.state.loaded=!1,_.children=[],_.children_d=[]),delete e.data,delete e.children,_.original=e,c[_.id]=_,_.state.selected&&this._data.core.selected.push(_.id),_.id},_redraw:function(){var e=this._model.force_full_redraw?this._model.data["#"].children.concat([]):this._model.changed.concat([]),t=document.createElement("UL"),n,r,a;for(r=0,a=e.length;a>r;r++)n=this.redraw_node(e[r],!0,this._model.force_full_redraw),n&&this._model.force_full_redraw&&t.appendChild(n);this._model.force_full_redraw&&(t.className=this.get_container_ul()[0].className,this.element.empty().append(t)),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:e})},redraw:function(e){e&&(this._model.force_full_redraw=!0),this._redraw()},redraw_node:function(t,n,r){var a=this.get_node(t),i=!1,s=!1,o=!1,d=!1,l=!1,h=!1,_="",u=document,g=this._model.data;if(!a)return!1;if("#"===a.id)return this.redraw(!0);if(n=n||0===a.children.length,t=u.getElementById(a.id))t=e(t),r||(i=t.parent().parent()[0],i===this.element[0]&&(i=null),s=t.index()),g[a.id].data=t.data(),n||!a.children.length||t.children("ul").length||(n=!0),n||(o=t.children("UL")[0]),t.remove();else if(n=!0,!r){if(i="#"!==a.parent?e("#"+a.parent,this.element)[0]:null,!(null===i||i&&g[a.parent].state.opened))return!1;s=e.inArray(a.id,null===i?g["#"].children:g[a.parent].children)}t=c.cloneNode(!0),_="jstree-node ";for(d in a.li_attr)if(a.li_attr.hasOwnProperty(d)){if("id"===d)continue;"class"!==d?c.setAttribute(d,a.li_attr[d]):_+=a.li_attr[d]}_+=!a.children.length&&a.state.loaded?" jstree-leaf":a.state.opened?" jstree-open":" jstree-closed",null!==a.parent&&g[a.parent].children[g[a.parent].children.length-1]===a.id&&(_+=" jstree-last"),t.id=a.id,t.className=_,_=(a.state.selected?" jstree-clicked":"")+(a.state.disabled?" jstree-disabled":"");for(l in a.a_attr)if(a.a_attr.hasOwnProperty(l)){if("href"===l&&"#"===a.a_attr[l])continue;"class"!==l?t.childNodes[1].setAttribute(l,a.a_attr[l]):_+=" "+a.a_attr[l]}if(_.length&&(t.childNodes[1].className="jstree-anchor "+_),a.icon&&a.icon!==!0&&(a.icon===!1?t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===a.icon.indexOf("/")?t.childNodes[1].childNodes[0].className+=" "+a.icon+" jstree-themeicon-custom":(t.childNodes[1].childNodes[0].style.backgroundImage="url("+a.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")),t.childNodes[1].appendChild(u.createTextNode(a.text)),a.data&&e.data(t,a.data),n&&a.children.length&&a.state.opened){for(h=u.createElement("UL"),h.setAttribute("role","group"),h.className="jstree-children",d=0,l=a.children.length;l>d;d++)h.appendChild(this.redraw_node(a.children[d],n,!0));t.appendChild(h)}return o&&t.appendChild(o),r||(i||(i=this.element[0]),i.getElementsByTagName("UL").length?i=i.getElementsByTagName("UL")[0]:(d=u.createElement("UL"),d.setAttribute("role","group"),d.className="jstree-children",i.appendChild(d),i=d),i.childNodes.length>s?i.insertBefore(t,i.childNodes[s]):i.appendChild(t)),t},open_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(i=0,s=n.length;s>i;i++)this.open_node(n[i],r,a);return!0}if(n=this.get_node(n),!n||"#"===n.id)return!1;if(a=a===t?this.settings.core.animation:a,!this.is_closed(n))return r&&r.call(this,n,!1),!1;if(this.is_loaded(n))o=this.get_node(n,!0),d=this,o.length&&(n.children.length&&!this._firstChild(o.children("ul")[0])&&(n.state.opened=!0,this.redraw_node(n,!0),o=this.get_node(n,!0)),a?o.children("ul").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").children("ul").stop(!0,!0).slideDown(a,function(){this.style.display="",d.trigger("after_open",{node:n})}):o[0].className=o[0].className.replace("jstree-closed","jstree-open")),n.state.opened=!0,r&&r.call(this,n,!0),this.trigger("open_node",{node:n}),a&&o.length||this.trigger("after_open",{node:n});else{if(this.is_loading(n))return setTimeout(e.proxy(function(){this.open_node(n,r,a)},this),500);this.load_node(n,function(e,t){return t?this.open_node(e,r,a):r?r.call(this,e,!1):!1})}},close_node:function(n,r){var a,i,s,o;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.close_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(r=r===t?this.settings.core.animation:r,s=this,o=this.get_node(n,!0),o.length&&(r?o.children("ul").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").children("ul").stop(!0,!0).slideUp(r,function(){this.style.display="",o.children("ul").remove(),s.trigger("after_close",{node:n})}):o[0].className=o[0].className.replace("jstree-open","jstree-closed")),n.state.opened=!1,this.trigger("close_node",{node:n}),r&&o.length||this.trigger("after_close",{node:n}),t):!1},toggle_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.toggle_node(n[r]);return!0}return this.is_closed(n)?this.open_node(n):this.is_open(n)?this.close_node(n):t},open_all:function(e,t,n){if(e||(e="#"),e=this.get_node(e),!e)return!1;var r="#"===e.id?this.get_container_ul():this.get_node(e,!0),a,i,s;if(!r.length){for(a=0,i=e.children_d.length;i>a;a++)this.is_closed(this._mode.data[e.children_d[a]])&&(this._mode.data[e.children_d[a]].state.opened=!0);return this.trigger("open_all",{node:e})}n=n||r,s=this,r=this.is_closed(e)?r.find("li.jstree-closed").addBack():r.find("li.jstree-closed"),r.each(function(){s.open_node(this,s.is_loaded(this)?!1:function(e){this.open_all(e,t,n)},t||0)}),0===n.find("li.jstree-closed").length&&this.trigger("open_all",{node:this.get_node(n)})},close_all:function(e,t){if(e||(e="#"),e=this.get_node(e),!e)return!1;var n="#"===e.id?this.get_container_ul():this.get_node(e,!0),r=this,a,i;if(!n.length){for(a=0,i=e.children_d.length;i>a;a++)this._mode.data[e.children_d[a]].state.opened=!1;return this.trigger("close_all",{node:e})}n=this.is_open(e)?n.find("li.jstree-open").addBack():n.find("li.jstree-open"),n.vakata_reverse().each(function(){r.close_node(this,t||0)}),this.trigger("close_all",{node:e})},is_disabled:function(e){return e=this.get_node(e),e&&e.state&&e.state.disabled},enable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.enable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!1,this.get_node(n,!0).children(".jstree-anchor").removeClass("jstree-disabled"),this.trigger("enable_node",{node:n}),t):!1},disable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.disable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!0,this.get_node(n,!0).children(".jstree-anchor").addClass("jstree-disabled"),this.trigger("disable_node",{node:n}),t):!1},activate_node:function(e,t){if(this.is_disabled(e))return!1;if(this.settings.core.multiple&&(t.metaKey||t.ctrlKey||t.shiftKey)&&(!t.shiftKey||this._data.core.last_clicked&&this.get_parent(e)&&this.get_parent(e)===this._data.core.last_clicked.parent))if(t.shiftKey){var n=this.get_node(e).id,r=this._data.core.last_clicked.id,a=this.get_node(this._data.core.last_clicked.parent).children,i=!1,s,o;for(s=0,o=a.length;o>s;s+=1)a[s]===n&&(i=!i),a[s]===r&&(i=!i),i||a[s]===n||a[s]===r?this.select_node(a[s]):this.deselect_node(a[s])}else this.is_selected(e)?this.deselect_node(e):this.select_node(e);else this.deselect_all(!0),this.select_node(e),this._data.core.last_clicked=this.get_node(e);this.trigger("activate_node",{node:this.get_node(e)})},hover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(e)}),t):!1},dehover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").removeClass("jstree-hovered"),this.trigger("dehover_node",{node:this.get_node(e)}),t):!1},select_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(s=0,o=n.length;o>s;s++)this.select_node(n[s],r,a);return!0}return n=this.get_node(n),n&&"#"!==n.id?(i=this.get_node(n,!0),n.state.selected||(n.state.selected=!0,this._data.core.selected.push(n.id),i.length&&(i.children(".jstree-anchor").addClass("jstree-clicked"),a||(d=this,i.parents(".jstree-closed").each(function(){d.open_node(this,!1,0)}))),this.trigger("select_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"select_node",node:n,selected:this._data.core.selected})),t):!1},deselect_node:function(n,r){var a,i,s;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.deselect_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(s=this.get_node(n,!0),n.state.selected&&(n.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(n.id,this._data.core.selected)),s.length&&s.children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"deselect_node",node:n,selected:this._data.core.selected})),t):!1},select_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(this._data.core.selected=this._model.data["#"].children_d.concat(),n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),e||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:t})},deselect_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked"),this.trigger("deselect_all",{selected:this._data.core.selected,node:t}),e||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:t})},is_selected:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.state.selected:!1},get_selected:function(){return this._data.core.selected},get_state:function(){var e={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},t;for(t in this._model.data)this._model.data.hasOwnProperty(t)&&"#"!==t&&(this._model.data[t].state.opened&&e.core.open.push(t),this._model.data[t].state.selected&&e.core.selected.push(t));return e},set_state:function(n,r){if(n){if(n.core){var a,i,s,o;return e.isArray(n.core.open)?(a=!0,i=!1,s=this,e.each(n.core.open.concat([]),function(t,r){i=document.getElementById(r),i&&(s.is_loaded(r)?(s.is_closed(r)&&s.open_node(r,!1,0),e.vakata.array_remove(n.core.open,e.inArray(r,n.core.open))):(s.is_loading(r)||s.open_node(r,e.proxy(function(){this.set_state(n)},s),0),a=!1))}),a&&(delete n.core.open,this.set_state(n,r)),!1):n.core.scroll?(n.core.scroll&&n.core.scroll.left!==t&&this.element.scrollLeft(n.core.scroll.left),n.core.scroll&&n.core.scroll.top!==t&&this.element.scrollTop(n.core.scroll.top),delete n.core.scroll,delete n.core.open,this.set_state(n,r),!1):n.core.selected?(o=this,this.deselect_all(),e.each(n.core.selected,function(e,t){o.select_node(t)}),delete n.core.selected,this.set_state(n,r),!1):e.isEmptyObject(n)?(r&&r.call(this),this.trigger("set_state"),!1):!0}return!0}return!1},refresh:function(){this._data.core.state=this.get_state(),this.load_node("#",function(t,n){n&&this.set_state(e.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")}),this._data.core.state=null})},get_text:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.text:!1},set_text:function(t,n){var r,a,i,s;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_text(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.text=n,i=this.get_node(t,!0),i.length&&(i=i.children(".jstree-anchor:eq(0)"),s=i.children("I").clone(),i.html(n).prepend(s),this.trigger("set_text",{obj:t,text:n})),!0):!1},get_json:function(e,t){if(e=this.get_node(e||"#"),!e)return!1;var n={id:e.id,text:e.text,icon:this.get_icon(e),li_attr:e.li_attr,a_attr:e.a_attr,state:{},data:t&&t.no_data?!1:this.get_node(e,!0).length?this.get_node(e,!0).data():e.data,children:[]},r,a;if(!t||!t.no_state)for(r in e.state)e.state.hasOwnProperty(r)&&(n.state[r]=e.state[r]);if(t&&t.no_id&&n.li_attr&&n.li_attr.id&&(delete n.li_attr.id,delete n.id),!t||!t.no_children)for(r=0,a=e.children.length;a>r;r++)n.children.push(this.get_json(e.children[r],t));return"#"===e.id?n.children:n},create_node:function(n,r,a,i,s){if(n=this.get_node(n),!n)return!1;if(a=a===t?"last":a,!a.match(/^(before|after)$/)&&!s&&!this.is_loaded(n))return this.load_node(n,function(){this.create_node(n,r,a,i,!0)});r||(r=this.get_string("New node"));var o,d,l,c;switch("#"===n.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"after":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"inside":case"first":a=0;break;case"last":a=n.children.length;break;default:a||(a=0)}if(a>n.children.length&&(a=n.children.length),!this.check("create_node",r,n,a))return!1;if(r=this._parse_model_from_json(r,n.id,n.parents.concat()),!r)return!1;for(o=this.get_node(r),d=[],d.push(r),d=d.concat(o.children_d),this.trigger("model",{nodes:d,parent:n.id}),n.children_d=n.children_d.concat(d),l=0,c=n.parents.length;c>l;l++)this._model.data[n.parents[l]].children_d=this._model.data[n.parents[l]].children_d.concat(d);for(r=o,o=[],l=0,c=n.children.length;c>l;l++)o[l>=a?l+1:l]=n.children[l];return o[a]=r.id,n.children=o,this.redraw_node(n),i&&i.call(this,this.get_node(r)),this.trigger("create_node",{node:this.get_node(r),parent:n.id,position:a}),r.id},rename_node:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.rename_node(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(i=t.text,this.check("rename_node",t,this.get_parent(t),n)?(this.set_text(t,n),this.trigger("rename_node",{node:t,text:n,old:i}),!0):!1):!1},delete_node:function(t){var n,r,a,i,s,o,d,l,c,h;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.delete_node(t[n]);return!0}if(t=this.get_node(t),!t||"#"===t.id)return!1;if(a=this.get_node(t.parent),i=e.inArray(t.id,a.children),h=!1,!this.check("delete_node",t,a,i))return!1;for(a.children=e.vakata.array_remove(a.children,i),s=t.children_d.concat([]),s.push(t.id),l=0,c=s.length;c>l;l++){for(o=0,d=t.parents.length;d>o;o++)this._model.data[t.parents[o]].children_d=e.vakata.array_remove(this._model.data[t.parents[o]].children_d,e.inArray(s[l],this._model.data[t.parents[o]].children_d));this._model.data[s[l]].state.selected&&(h=!0,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(s[l],this._data.core.selected)))}return this.trigger("delete_node",{node:t,parent:a.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:a.id}),delete this._model.data[t.id],this.redraw_node(a,!0),!0 -},check:function(t,n,r,a){n=n&&n.id?n:this.get_node(n),r=r&&r.id?r:this.get_node(r);var i=t.match(/^move_node|copy_node|create_node$/i)?r:n,s=this.settings.core.check_callback;return"move_node"!==t||n.id!==r.id&&e.inArray(n.id,r.children)!==a&&-1===e.inArray(r.id,n.children_d)?(i=this.get_node(i,!0),i.length&&(i=i.data("jstree")),i&&i.functions&&(i.functions[t]===!1||i.functions[t]===!0)?i.functions[t]:s===!1||e.isFunction(s)&&s.call(this,t,n,r,a)===!1||s&&s[t]===!1?!1:!0):!1},move_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m,v,j;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.move_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.move_node(n,r,a,i,!0)});switch(l=""+n.parent,c=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,h=this._model.data[n.id]?this:e.jstree.reference(n.id),_=this._id!==h._id,"#"===c.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,c.children);break;case"after":a=e.inArray(r.id,c.children)+1;break;case"inside":case"first":a=0;break;case"last":a=c.children.length;break;default:a||(a=0)}if(a>c.children.length&&(a=c.children.length),!this.check("move_node",n,c,a))return!1;if(_||n.parent!==c.id){for(g=n.children_d.concat(),g.push(n.id),f=0,p=n.parents.length;p>f;f++){for(u=[],j=h._model.data[n.parents[f]].children_d,m=0,v=j.length;v>m;m++)-1===e.inArray(j[m],g)&&u.push(j[m]);h._model.data[n.parents[f]].children_d=u}for(h._model.data[l].children=e.vakata.array_remove(h._model.data[l].children,e.inArray(n.id,h._model.data[l].children)),f=0,p=c.parents.length;p>f;f++)this._model.data[c.parents[f]].children_d=this._model.data[c.parents[f]].children_d.concat(g);for(u=[],f=0,p=c.children.length;p>f;f++)u[f>=a?f+1:f]=c.children[f];u[a]=n.id,c.children=u,c.children_d.push(n.id),c.children_d=c.children_d.concat(n.children_d),n.parent=c.id,g=c.parents.concat(),g.push(c.id),n.parents=g,_?(h.delete_node(n.id),this._node_changed(c.id),this.redraw("#"===c.id)):(this._node_changed(l),this._node_changed(c.id),this.redraw("#"===l||"#"===c.id))}else{for(u=c.children.concat(),g=e.inArray(n.id,u),-1!==g&&(u=e.vakata.array_remove(u,g),a>g&&a--),g=[],f=0,p=u.length;p>f;f++)g[f>=a?f+1:f]=u[f];g[a]=n.id,c.children=g,this._node_changed(c.id),this.redraw("#"===c.id)}return i&&i.call(this,n,c,a),this.trigger("move_node",{node:n,parent:c.id,position:a,old_parent:l,is_multi:_,old_instance:h,new_instance:this}),!0},copy_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.copy_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.copy_node(n,r,a,i,!0)});switch(g=""+n.parent,f=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,p=this._model.data[n.id]?this:e.jstree.reference(n.id),m=this._id!==p._id,"#"===f.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,f.children);break;case"after":a=e.inArray(r.id,f.children)+1;break;case"inside":case"first":a=0;break;case"last":a=f.children.length;break;default:a||(a=0)}if(a>f.children.length&&(a=f.children.length),!this.check("copy_node",n,f,a))return!1;if(u=p.get_json(n,{no_id:!0,no_data:!0,no_state:!0}),!u)return!1;if(u=this._parse_model_from_json(u,f.id,f.parents.concat()),!u)return!1;for(c=this.get_node(u),l=[],l.push(u),l=l.concat(c.children_d),this.trigger("model",{nodes:l,parent:f.id}),h=0,_=f.parents.length;_>h;h++)this._model.data[f.parents[h]].children_d=this._model.data[f.parents[h]].children_d.concat(l);for(l=[],h=0,_=f.children.length;_>h;h++)l[h>=a?h+1:h]=f.children[h];return l[a]=c.id,f.children=l,f.children_d.push(c.id),f.children_d=f.children_d.concat(c.children_d),this._node_changed(f.id),this.redraw("#"===f.id),i&&i.call(this,c,f,a),this.trigger("copy_node",{node:c,original:n,parent:f.id,position:a,old_parent:g,is_multi:m,old_instance:p,new_instance:this}),c.id},cut:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="move_node",this.trigger("cut",{node:n}),t):!1},copy:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="copy_node",this.trigger("copy",{node:n}),t):!1},get_buffer:function(){return{mode:i,node:a,inst:s}},can_paste:function(){return i!==!1&&a!==!1},paste:function(e){return e=this.get_node(e),e&&i&&i.match(/^(copy_node|move_node)$/)&&a?(this[i](a,e)&&this.trigger("paste",{parent:e.id,node:a,mode:i}),a=!1,i=!1,s=!1,t):!1},edit:function(n,r){if(n=this.get_node(n,!0),!n||!n.length)return!1;n.parentsUntil(".jstree",".jstree-closed").each(e.proxy(function(e,t){this.open_node(t,!1,0)},this));var a=this._data.core.rtl,i=this.element.width(),s=n.children(".jstree-anchor"),o="string"==typeof r?r:this.get_text(n),d=e("
",{css:{position:"absolute",top:"-200px",left:a?"0px":"-1000px",visibility:"hidden"}}).appendTo("body"),l=e("",{value:o,"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:e.proxy(function(){var e=s.children(".jstree-rename-input"),t=e.val();""===t&&(t=o),d.remove(),e.remove(),this.rename_node(n,t)===!1&&this.rename_node(n,o)},this),keydown:function(e){var t=e.which;27===t&&(this.value=o),(27===t||13===t||37===t||38===t||39===t||40===t)&&e.stopImmediatePropagation(),(27===t||13===t)&&(e.preventDefault(),this.blur())},keyup:function(e){l.width(Math.min(d.text("pW"+this.value).width(),i))},keypress:function(e){return 13===e.which?!1:t}}),c={fontFamily:s.css("fontFamily")||"",fontSize:s.css("fontSize")||"",fontWeight:s.css("fontWeight")||"",fontStyle:s.css("fontStyle")||"",fontStretch:s.css("fontStretch")||"",fontVariant:s.css("fontVariant")||"",letterSpacing:s.css("letterSpacing")||"",wordSpacing:s.css("wordSpacing")||""};this.set_text(n,""),s.append(l),d.css(c),l.css(c).width(Math.min(d.text("pW"+l[0].value).width(),i))[0].select()},set_theme:function(t,n){if(!t)return!1;if(n===!0){var r=this.settings.core.themes.dir;r||(r=e.jstree.path+"/themes"),n=r+"/"+t+"/style.css"}n&&-1===e.inArray(n,o)&&(e("head").append(''),o.push(n)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=t,this.element.addClass("jstree-"+t),this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(e){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=e,e&&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=!0,this.get_container_ul().addClass("jstree-striped")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped")},toggle_stripes:function(){this._data.core.themes.stripes?this.hide_stripes():this.show_stripes()},show_dots:function(){this._data.core.themes.dots=!0,this.get_container_ul().removeClass("jstree-no-dots")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-dots")},toggle_dots:function(){this._data.core.themes.dots?this.hide_dots():this.show_dots()},show_icons:function(){this._data.core.themes.icons=!0,this.get_container_ul().removeClass("jstree-no-icons")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},set_icon:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_icon(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.icon=n,i=this.get_node(t,!0).children("jstree-anchor").children(".jstree-themeicon"),n===!1?this.removeClass("jstree-themeicon-custom").hide_icon(t):-1===n.indexOf("/")?i.addClass(n+" jstree-themeicon-custom").attr("rel",n):i.removeClass("jstree-themeicon-custom").css("background","url('"+n+"') center center no-repeat").attr("rel",n),!0):!1},get_icon:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.icon:!1},hide_icon:function(t){var n,r;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.hide_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(t.icon=!1,this.get_node(t,!0).children("a").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(t){var n,r,a;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.show_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(a=this.get_node(t,!0),t.icon=a.length?a.children("a").children(".jstree-themeicon").attr("rel"):!0,t.icon||(t.icon=!0),a.children("a").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},e.vakata={},e.fn.vakata_reverse=[].reverse,e.vakata.attributes=function(t,n){t=e(t)[0];var r=n?{}:[];return e.each(t.attributes,function(t,a){-1===e.inArray(a.nodeName.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==a.nodeValue&&""!==e.trim(a.nodeValue)&&(n?r[a.nodeName]=a.nodeValue:r.push(a.nodeName))}),r},e.vakata.array_unique=function(e){var t=[],n,r,a;for(n=0,a=e.length;a>n;n++){for(r=0;n>=r;r++)if(e[n]===e[r])break;r===n&&t.push(e[n])}return t},e.vakata.array_remove=function(e,t,n){var r=e.slice((n||t)+1||e.length);return e.length=0>t?e.length+t:t,e.push.apply(e,r),e},function(){var t={},n=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},r=n(window.navigator.userAgent);r.browser&&(t[r.browser]=!0,t.version=r.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),e.vakata.browser=t}(),e.vakata.browser.msie&&8>e.vakata.browser.version&&(e.jstree.defaults.core.animation=0);var u=document.createElement("I");u.className="jstree-icon jstree-checkbox",e.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0},e.jstree.plugins.checkbox=function(t,n){this.bind=function(){n.bind.call(this),this._data.checkbox.uto=!1,this.element.on("init.jstree",e.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked")},this)).on("loading.jstree",e.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),this.settings.checkbox.three_state&&this.element.on("changed.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",e.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)},this)).on("model.jstree",e.proxy(function(t,n){var r=this._model.data,a=r[n.parent],i=n.nodes,s=[],o,d,l,c,h,_;if(a.state.selected){for(d=0,l=i.length;l>d;d++)r[i[d]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(i)}else for(d=0,l=i.length;l>d;d++)if(r[i[d]].state.selected){for(c=0,h=r[i[d]].children_d.length;h>c;c++)r[r[i[d]].children_d[c]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(r[i[d]].children_d)}for(d=0,l=a.children_d.length;l>d;d++)r[a.children_d[d]].children.length||s.push(r[a.children_d[d]].parent);for(s=e.vakata.array_unique(s),c=0,h=s.length;h>c;c++){a=r[s[c]];while(a&&"#"!==a.id){for(o=0,d=0,l=a.children.length;l>d;d++)o+=r[a.children[d]].state.selected;if(o!==l)break;a.state.selected=!0,this._data.core.selected.push(a.id),_=this.get_node(a,!0),_&&_.length&&_.children(".jstree-anchor").addClass("jstree-clicked"),a=this.get_node(a.parent)}}this._data.core.selected=e.vakata.array_unique(this._data.core.selected)},this)).on("select_node.jstree",e.proxy(function(t,n){var r=n.node,a=this._model.data,i=this.get_node(r.parent),s=this.get_node(r,!0),o,d,l,c;for(this._data.core.selected=e.vakata.array_unique(this._data.core.selected.concat(r.children_d)),o=0,d=r.children_d.length;d>o;o++)a[r.children_d[o]].state.selected=!0;while(i&&"#"!==i.id){for(l=0,o=0,d=i.children.length;d>o;o++)l+=a[i.children[o]].state.selected;if(l!==d)break;i.state.selected=!0,this._data.core.selected.push(i.id),c=this.get_node(i,!0),c&&c.length&&c.children(".jstree-anchor").addClass("jstree-clicked"),i=this.get_node(i.parent)}s.length&&s.find(".jstree-anchor").addClass("jstree-clicked")},this)).on("deselect_node.jstree",e.proxy(function(t,n){var r=n.node,a=this.get_node(r,!0),i,s,o;for(i=0,s=r.children_d.length;s>i;i++)this._model.data[r.children_d[i]].state.selected=!1;for(i=0,s=r.parents.length;s>i;i++)this._model.data[r.parents[i]].state.selected=!1,o=this.get_node(r.parents[i],!0),o&&o.length&&o.children(".jstree-anchor").removeClass("jstree-clicked");for(o=[],i=0,s=this._data.core.selected.length;s>i;i++)-1===e.inArray(this._data.core.selected[i],r.children_d)&&-1===e.inArray(this._data.core.selected[i],r.parents)&&o.push(this._data.core.selected[i]);this._data.core.selected=e.vakata.array_unique(o),a.length&&a.find(".jstree-anchor").removeClass("jstree-clicked")},this)).on("delete_node.jstree",e.proxy(function(e,t){var n=this.get_node(t.parent),r=this._model.data,a,i,s,o;while(n&&"#"!==n.id){for(s=0,a=0,i=n.children.length;i>a;a++)s+=r[n.children[a]].state.selected;if(s!==i)break;n.state.selected=!0,this._data.core.selected.push(n.id),o=this.get_node(n,!0),o&&o.length&&o.children(".jstree-anchor").addClass("jstree-clicked"),n=this.get_node(n.parent)}},this)).on("move_node.jstree",e.proxy(function(t,n){var r=n.is_multi,a=n.old_parent,i=this.get_node(n.parent),s=this._model.data,o,d,l,c,h;if(!r){o=this.get_node(a);while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d!==c)break;o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"),o=this.get_node(o.parent)}}o=i;while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d===c)o.state.selected||(o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"));else{if(!o.state.selected)break;o.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(o.id,this._data.core.selected)),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").removeClass("jstree-clicked")}o=this.get_node(o.parent)}},this))},this._undetermined=function(){var t,n,r=this._model.data,a=this._data.core.selected,i=[],s=this;for(t=0,n=a.length;n>t;t++)i=i.concat(r[a[t]].parents);for(this.element.find(".jstree-closed").not(":has(ul)").each(function(){var e=s.get_node(this);e.state.loaded||e.original.state.undetermined!==!0||(i.push(e.id),i=i.concat(e.parents))}),i=e.vakata.array_unique(i),t=e.inArray("#",i),-1!==t&&(i=e.vakata.array_remove(i,t)),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),t=0,n=i.length;n>t;t++)r[i[t]].state.selected||(a=this.get_node(i[t],!0),a&&a.length&&a.children("a").children(".jstree-checkbox").addClass("jstree-undetermined"))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=t.getElementsByTagName("A")[0];i.insertBefore(u.cloneNode(),i.childNodes[0])}return!a&&this.settings.checkbox.three_state&&(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)),t},this.activate_node=function(t,r){return(this.settings.checkbox.whole_node||e(r.target).hasClass("jstree-checkbox"))&&(r.ctrlKey=!0),n.activate_node.call(this,t,r)},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.element.children("ul").removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.element.children("ul").addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()}},e.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(t){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.create_node(r,{},"last",function(e){setTimeout(function(){n.edit(e)},0)})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.edit(r)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.delete_node(n.get_selected()):n.delete_node(r)}},ccp:{separator_before:!0,icon:!1,separator_after:!1,label:"Edit",action:!1,submenu:{cut:{separator_before:!1,separator_after:!1,label:"Cut",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.cut(n.get_selected()):n.cut(r)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.copy(n.get_selected()):n.copy(r)}},paste:{separator_before:!1,icon:!1,_disabled:!this.can_paste(),separator_after:!1,label:"Paste",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.paste(r)}}}}}}},e.jstree.plugins.contextmenu=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("contextmenu.jstree","a",e.proxy(function(e){e.preventDefault(),this.is_loading(e.currentTarget)||this.show_contextmenu(e.currentTarget,e.pageX,e.pageY)},this)).on("click.jstree","a",e.proxy(function(t){this._data.contextmenu.visible&&e.vakata.context.hide()},this)),e(document).on("context_hide.vakata",e.proxy(function(){this._data.contextmenu.visible=!1},this))},this.teardown=function(){this._data.contextmenu.visible&&e.vakata.context.hide(),r.teardown.call(this)},this.show_contextmenu=function(n,r,a){if(n=this.get_node(n),!n||"#"===n.id)return!1;var i=this.settings.contextmenu,s=this.get_node(n,!0),o=s.children(".jstree-anchor"),d=!1,l=!1;(i.show_at_node||r===t||a===t)&&(d=o.offset(),r=d.left,a=d.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(n)&&(this.deselect_all(),this.select_node(n)),l=i.items,e.isFunction(l)&&(l=l.call(this,n)),e(document).one("context_show.vakata",e.proxy(function(t,n){var r="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";e(n.element).addClass(r)},this)),this._data.contextmenu.visible=!0,e.vakata.context.show(o,{x:r,y:a},l),this.trigger("show_contextmenu",{node:n,x:r,y:a})}},function(e){var n=!1,r={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};e.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(t){e(document).triggerHandler("context_"+t+".vakata",{reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}})},_execute:function(e){return e=r.items[e],e&&!e._disabled&&e.action?e.action.call(null,{item:e,reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}}):!1},_parse:function(n,a){if(!n)return!1;a||(r.html="",r.items=[]);var i="",s=!1,o;return a&&(i+=""),a||(r.html=i,e.vakata.context._trigger("parse")),i.length>10?i:!1},_show_submenu:function(t){if(t=e(t),t.length&&t.children("ul").length){var r=t.children("ul"),a=t.offset().left+t.outerWidth(),i=t.offset().top,s=r.width(),o=r.height(),d=e(window).width()+e(window).scrollLeft(),l=e(window).height()+e(window).scrollTop();n?t[0>a-(s+10+t.outerWidth())?"addClass":"removeClass"]("vakata-context-left"):t[a+s+10>d?"addClass":"removeClass"]("vakata-context-right"),i+o+10>l&&r.css("bottom","-1px"),r.show()}},show:function(t,a,i){var s,o,d,l,c,h,_,u,g=!0;switch(r.element&&r.element.length&&r.element.width(""),g){case!a&&!t:return!1;case!!a&&!!t:r.reference=t,r.position_x=a.x,r.position_y=a.y;break;case!a&&!!t:r.reference=t,s=t.offset(),r.position_x=s.left+t.outerHeight(),r.position_y=s.top;break;case!!a&&!t:r.position_x=a.x,r.position_y=a.y}t&&!i&&e(t).data("vakata_contextmenu")&&(i=e(t).data("vakata_contextmenu")),e.vakata.context._parse(i)&&r.element.html(r.html),r.items.length&&(o=r.element,d=r.position_x,l=r.position_y,c=o.width(),h=o.height(),_=e(window).width()+e(window).scrollLeft(),u=e(window).height()+e(window).scrollTop(),n&&(d-=o.outerWidth(),e(window).scrollLeft()+20>d&&(d=e(window).scrollLeft()+20)),d+c+20>_&&(d=_-(c+20)),l+h+20>u&&(l=u-(h+20)),r.element.css({left:d,top:l}).show().find("a:eq(0)").focus().parent().addClass("vakata-context-hover"),r.is_visible=!0,e.vakata.context._trigger("show"))},hide:function(){r.is_visible&&(r.element.hide().find("ul").hide().end().find(":focus").blur(),r.is_visible=!1,e.vakata.context._trigger("hide"))}},e(function(){n="rtl"===e("body").css("direction");var t=!1,a='.vakata-context { display:none; _width:1px; } .vakata-context, .vakata-context ul { margin:0; padding:2px; position:absolute; background:#f5f5f5; border:1px solid #979797; -moz-box-shadow:5px 5px 4px -4px #666666; -webkit-box-shadow:2px 2px 2px #999999; box-shadow:2px 2px 2px #999999; }.vakata-context ul { list-style:none; left:100%; margin-top:-2.7em; margin-left:-4px; } .vakata-context li.vakata-context-right ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context li { list-style:none; display:inline; }.vakata-context li a { display:block; padding:0 2em 0 2em; text-decoration:none; width:auto; color:black; white-space:nowrap; line-height:2.4em; -moz-text-shadow:1px 1px 0px white; -webkit-text-shadow:1px 1px 0px white; text-shadow:1px 1px 0px white; -moz-border-radius:1px; -webkit-border-radius:1px; border-radius:1px; }.vakata-context li a:hover { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li.vakata-context-hover > a { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); background-position:right center; background-repeat:no-repeat; } .vakata-context li.vakata-context-separator a, .vakata-context li.vakata-context-separator a:hover { background:white; border:0; border-top:1px solid #e2e3e3; height:1px; min-height:1px; max-height:1px; padding:0; margin:0 0 0 2.4em; border-left:1px solid #e0e0e0; _overflow:hidden; -moz-text-shadow:0 0 0 transparent; -webkit-text-shadow:0 0 0 transparent; text-shadow:0 0 0 transparent; -moz-box-shadow:0 0 0 transparent; -webkit-box-shadow:0 0 0 transparent; box-shadow:0 0 0 transparent; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0; }.vakata-context li.vakata-contextmenu-disabled a, .vakata-context li.vakata-contextmenu-disabled a:hover { color:silver; background-color:transparent; border:0; box-shadow:0 0 0; }.vakata-context li a ins { text-decoration:none; display:inline-block; width:2.4em; height:2.4em; background:transparent; margin:0 0 0 -2em; } .vakata-context li a span { display:inline-block; width:1px; height:2.4em; background:white; margin:0 0.5em 0 0; border-left:1px solid #e2e3e3; _overflow:hidden; } .vakata-context-rtl ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context-rtl li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); background-position:left center; background-repeat:no-repeat; } .vakata-context-rtl li.vakata-context-separator a { margin:0 2.4em 0 0; border-left:0; border-right:1px solid #e2e3e3;} .vakata-context-rtl li.vakata-context-left ul { right:auto; left:100%; margin-left:-4px; margin-right:auto; } .vakata-context-rtl li a ins { margin:0 -2em 0 0; } .vakata-context-rtl li a span { margin:0 0 0 0.5em; border-left-color:white; background:#e2e3e3; } ';e.jstree.no_css||e("head").append('"),r.element=e("
    "),r.element.on("mouseenter","li",function(n){n.stopImmediatePropagation(),e.contains(this,n.relatedTarget)||(t&&clearTimeout(t),r.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),e(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),e.vakata.context._show_submenu(this))}).on("mouseleave","li",function(t){e.contains(this,t.relatedTarget)||e(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(n){e(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),e.vakata.context.settings.hide_onmouseleave&&(t=setTimeout(function(t){return function(){e.vakata.context.hide()}}(this),e.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(e){e.preventDefault()}).on("mouseup","a",function(t){e(this).blur().parent().hasClass("vakata-context-disabled")||e.vakata.context._execute(e(this).attr("rel"))===!1||e.vakata.context.hide()}).on("keydown","a",function(t){var n=null;switch(t.which){case 13:case 32:t.type="mouseup",t.preventDefault(),e(t.currentTarget).trigger(t);break;case 37:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 39:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 27:e.vakata.context.hide(),t.preventDefault();break;default:}}).appendTo("body"),e(document).on("mousedown",function(t){r.is_visible&&!e.contains(r.element[0],t.target)&&e.vakata.context.hide()}).on("context_show.vakata",function(e,t){r.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),n&&r.element.addClass("vakata-context-rtl").css("direction","rtl"),r.element.find("ul").hide().end()})})}(e),e.jstree.defaults.dnd={copy:!0,open_timeout:500},e.jstree.plugins.dnd=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("mousedown","a",e.proxy(function(n){var r=this.get_node(n.target),a=this.is_selected(r)?this.get_selected().length:1;return r&&r.id&&"#"!==r.id&&1===n.which?(this.element.trigger("mousedown.jstree"),e.vakata.dnd.start(n,{jstree:!0,origin:this,obj:this.get_node(r,!0),nodes:a>1?this.get_selected():[r.id]},'
    '+(a>1?a+" "+this.get_string("nodes"):this.get_text(n.currentTarget,!0))+'
    ')):t},this))}},e(function(){var n=!1,r=!1,a=e('
     
    ').hide().appendTo("body");e(document).bind("dnd_start.vakata",function(e,t){n=!1}).bind("dnd_move.vakata",function(i,s){if(r&&clearTimeout(r),s.data.jstree&&(!s.event.target.id||"jstree-marker"!==s.event.target.id)){var o=e.jstree.reference(s.event.target),d=!1,l=!1,c=!1,h,_,u,g,f,p,m,v,j,x,y,k;if(o&&o._data&&o._data.dnd)if(a.attr("class","jstree-"+o.get_theme()),s.helper.children().attr("class","jstree-"+o.get_theme()).find(".jstree-copy:eq(0)")[s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"show":"hide"](),s.event.target!==o.element[0]&&s.event.target!==o.get_container_ul()[0]||0!==o.get_container_ul().children().length){if(d=e(s.event.target).closest("a"),d&&d.length&&d.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(l=d.offset(),c=s.event.pageY-l.top,u=d.height(),p=u/3>c?["b","i","a"]:c>u-u/3?["a","i","b"]:c>u/2?["i","a","b"]:["i","b","a"],e.each(p,function(i,c){switch(c){case"b":h=l.left-6,_=l.top-5,g=o.get_parent(d),f=d.parent().index();break;case"i":h=l.left-2,_=l.top-5+u/2+1,g=d.parent(),f=0;break;case"a":h=l.left-6,_=l.top-5+u,g=o.get_parent(d),f=d.parent().index()+1}for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(x=s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",y=f,"move_node"===x&&"a"===c&&s.data.origin===o&&g===o.get_parent(s.data.nodes[v])&&(k=o.get_node(g),y>e.inArray(s.data.nodes[v],k.children)&&(y-=1)),m=m&&o.check(x,s.data.nodes[v],g,y),!m)break;return m?("i"===c&&d.parent().is(".jstree-closed")&&o.settings.dnd.open_timeout&&(r=setTimeout(function(e,t){return function(){e.open_node(t)}}(o,d),o.settings.dnd.open_timeout)),n={ins:o,par:g,pos:f},a.css({left:h+"px",top:_+"px"}).show(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),p=!0,!1):t}),p===!0))return}else{for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(m=m&&o.check(s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",s.data.nodes[v],"#","last"),!m)break;if(m)return n={ins:o,par:"#",pos:"last"},a.hide(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),t}n=!1,s.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),a.hide() -}}).bind("dnd_scroll.vakata",function(e,t){t.data.jstree&&(a.hide(),n=!1,t.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er"))}).bind("dnd_stop.vakata",function(e,t){r&&clearTimeout(r),t.data.jstree&&(a.hide(),n&&n.ins[t.data.origin.settings.dnd.copy&&(t.event.metaKey||t.event.ctrlKey)?"copy_node":"move_node"](t.data.nodes,n.par,n.pos))}).bind("keyup keydown",function(t,n){n=e.vakata.dnd._get(),n.data&&n.data.jstree&&n.helper.find(".jstree-copy:eq(0)")[n.data.origin.settings.dnd.copy&&(t.metaKey||t.ctrlKey)?"show":"hide"]()})}),function(e){e.fn.vakata_reverse=[].reverse;var n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1};e.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5},_trigger:function(t,n){var r=e.vakata.dnd._get();r.event=n,e(document).triggerHandler("dnd_"+t+".vakata",r)},_get:function(){return{data:n.data,element:n.element,helper:n.helper}},_clean:function(){n.helper&&n.helper.remove(),n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1},e(document).unbind("mousemove",e.vakata.dnd.drag),e(document).unbind("mouseup",e.vakata.dnd.stop)},_scroll:function(t){if(!n.scroll_e||!n.scroll_l&&!n.scroll_t)return n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),!1;if(!n.scroll_i)return n.scroll_i=setInterval(e.vakata.dnd._scroll,100),!1;if(t===!0)return!1;var r=n.scroll_e.scrollTop(),a=n.scroll_e.scrollLeft();n.scroll_e.scrollTop(r+n.scroll_t*e.vakata.dnd.settings.scroll_speed),n.scroll_e.scrollLeft(a+n.scroll_l*e.vakata.dnd.settings.scroll_speed),(r!==n.scroll_e.scrollTop()||a!==n.scroll_e.scrollLeft())&&e.vakata.dnd._trigger("scroll",n.scroll_e)},start:function(t,r,a){n.is_drag&&e.vakata.dnd.stop({});try{t.currentTarget.unselectable="on",t.currentTarget.onselectstart=function(){return!1},t.currentTarget.style&&(t.currentTarget.style.MozUserSelect="none")}catch(i){}return n.init_x=t.pageX,n.init_y=t.pageY,n.data=r,n.is_down=!0,n.element=t.currentTarget,a!==!1&&(n.helper=e("
    ").html(a).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),e(document).bind("mousemove",e.vakata.dnd.drag),e(document).bind("mouseup",e.vakata.dnd.stop),!1},drag:function(r){if(n.is_down){if(!n.is_drag){if(!(Math.abs(r.pageX-n.init_x)>e.vakata.dnd.settings.threshold||Math.abs(r.pageY-n.init_y)>e.vakata.dnd.settings.threshold))return;n.helper&&(n.helper.appendTo("body"),n.helper_w=n.helper.outerWidth()),n.is_drag=!0,e.vakata.dnd._trigger("start",r)}var a=!1,i=!1,s=!1,o=!1,d=!1,l=!1,c=!1,h=!1,_=!1,u=!1;n.scroll_t=0,n.scroll_l=0,n.scroll_e=!1,e(r.target).parentsUntil("body").addBack().vakata_reverse().filter(function(){return/^auto|scroll$/.test(e(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var a=e(this),i=a.offset();return this.scrollHeight>this.offsetHeight&&(i.top+a.height()-r.pageYthis.offsetWidth&&(i.left+a.width()-r.pageXo&&r.pageY-co&&o-(r.pageY-c)l&&r.pageX-hl&&l-(r.pageX-h)s&&(_=s-50),d&&u+n.helper_w>d&&(u=d-(n.helper_w+2)),n.helper.css({left:u+"px",top:_+"px"})),e.vakata.dnd._trigger("move",r)}},stop:function(t){n.is_drag&&e.vakata.dnd._trigger("stop",t),e.vakata.dnd._clean()}}}(jQuery),e.jstree.defaults.search={ajax:!1,fuzzy:!0,case_sensitive:!1,show_only_matches:!1},e.jstree.plugins.search=function(t,n){this.bind=function(){n.bind.call(this),this._data.search.str="",this._data.search.dom=e(),this._data.search.res=[],this.settings.search.show_only_matches&&this.element.on("search.jstree",function(t,n){n.nodes.length&&(e(this).find("li").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last"),n.nodes.parentsUntil(".jstree").addBack().show().filter("ul").each(function(){e(this).children("li:visible").eq(-1).addClass("jstree-last")}))}).on("clear_search.jstree",function(t,n){n.nodes.length&&e(this).find("li").css("display","").filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last")})},this.search=function(t,n){if(t===!1||""===e.trim(t))return this.clear_search();var r=this.settings.search,a=r.ajax?e.extend({},r.ajax):!1,i=null,s=[],o=[],d,l;if(this._data.search.res.length&&this.clear_search(),!n&&a!==!1)return a.data||(a.data={}),a.data.str=t,e.ajax(r.ajax).done(e.proxy(function(e){this._search_load(e,t)},this));if(this._data.search.str=t,this._data.search.dom=e(),this._data.search.res=[],i=new e.vakata.search(t,!0,{caseSensitive:r.case_sensitive,fuzzy:r.fuzzy}),e.each(this._model.data,function(e,t){t.text&&i.search(t.text).isMatch&&(s.push(e),o=o.concat(t.parents))}),s.length){for(o=e.vakata.array_unique(o),this._search_open(o),d=0,l=s.length;l>d;d++)i=this.get_node(s[d],!0),i&&(this._data.search.dom=this._data.search.dom.add(i));this._data.search.res=s,this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:t,res:this._data.search.res})},this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"),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.dom=e()},this._search_open=function(t){var n=this;e.each(t.concat([]),function(e,r){r=document.getElementById(r),r&&n.is_closed(r)&&n.open_node(r,function(){n._search_open(t)})})},this._search_load=function(t,n){var r=!0,a=this,i=a._model.data;e.each(t.concat([]),function(e,s){i[s]&&(i[s].state.loaded||(a.load_node(s,function(){a._search_load(t,n)}),r=!1))}),r&&this.search(n,!0)}},function(e){e.vakata.search=function(e,t,n){n=n||{},n.fuzzy!==!1&&(n.fuzzy=!0),e=n.caseSensitive?e:e.toLowerCase();var r=n.location||0,a=n.distance||100,i=n.threshold||.6,s=e.length,o,d,l,c;return s>32&&(n.fuzzy=!1),n.fuzzy&&(o=1<n;n++)t[e.charAt(n)]=0;for(n=0;s>n;n++)t[e.charAt(n)]|=1<a;a++){g=0,f=p;while(f>g)_>=l(a,r+f)?g=f:p=f,f=Math.floor((p-g)/2+g);for(p=f,v=Math.max(1,r-f+1),j=Math.min(r+f,h)+s,x=Array(j+2),x[j+1]=(1<=v;c--)if(y=d[t.charAt(c-1)],x[c]=0===a?(1|x[c+1]<<1)&y:(1|x[c+1]<<1)&y|(1|(m[c+1]|m[c])<<1)|m[c+1],x[c]&o&&(k=l(a,c-1),_>=k)){if(_=k,u=c-1,b.push(u),!(u>r))break;v=Math.max(1,2*r-u)}if(l(a+1,r)>_)break;m=x}return{isMatch:u>=0,score:k}},t===!0?{search:c}:c(t)}}(jQuery),e.jstree.defaults.sort=function(e,t){return this.get_text(e)>this.get_text(t)?1:-1},e.jstree.plugins.sort=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",e.proxy(function(e,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",e.proxy(function(e,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,n){var r,a;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(e.proxy(this.settings.sort,this)),n))for(r=0,a=t.children_d.length;a>r;r++)this.sort(t.children_d[r],!1)}};var g=!1;e.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:!1},e.jstree.plugins.state=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("ready.jstree",e.proxy(function(t,n){this.element.one("restore_state.jstree set_state.jstree",e.proxy(function(){this.element.on(this.settings.state.events,e.proxy(function(){g&&clearTimeout(g),g=setTimeout(e.proxy(function(){this.save_state()},this),100)},this))},this)),this.restore_state()},this))},this.save_state=function(){e.vakata.storage.set(this.settings.state.key,this.get_state(),this.settings.state.ttl)},this.restore_state=function(){var t=e.vakata.storage.get(this.settings.state.key);t&&this.set_state(t),this.trigger("restore_state",{state:t})},this.clear_state=function(){return e.vakata.storage.del(this.settings.state.key)}},function(e,t){var n=function(e){var t=/["\\\x00-\x1f\x7f-\x9f]/g,n={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return e.match(t)?'"'+e.replace(t,function(e){var t=n[e];return"string"==typeof t?t:(t=e.charCodeAt(),"\\u00"+Math.floor(t/16).toString(16)+(t%16).toString(16))})+'"':'"'+e+'"'};e.vakata.json={encode:JSON&&JSON.stringify?JSON.stringify:function(r){if(null===r)return"null";var a=[],i;switch(typeof r){case"undefined":return t;case"number":case"boolean":return""+r;case"string":return n(r);case"object":if(e.isFunction(r.toJSON))return e.vakata.json.encode(r.toJSON());if(r.constructor===Date)return'"'+r.getUTCFullYear()+"-"+("0"+(r.getUTCMonth()+1)+"").slice(-2)+"-"+("0"+r.getUTCDate()+"").slice(-2)+"T"+("0"+r.getUTCHours()+"").slice(-2)+":"+("0"+r.getUTCMinutes()+"").slice(-2)+":"+("0"+r.getUTCSeconds()+"").slice(-2)+"."+("00"+r.getUTCMilliseconds()+"").slice(-3)+'Z"';if(r.constructor===Array){for(i=0;r.length>i;i++)a.push(e.vakata.json.encode(r[i])||"null");return"["+a.join(",")+"]"}return e.each(r,function(r,i){return e.isFunction(i)?!0:(r="number"==typeof r?'"'+r+'"':n(r),i=e.vakata.json.encode(i),a.push(r+":"+i),t)}),"{"+a.join(", ")+"}"}},decode:JSON&&JSON.parse?JSON.parse:function(t){return e.parseJSON(t)}}}(jQuery),function(e,t,n){var r=function(e){return e},a=function(e){return decodeURIComponent(e.replace(/\+/g," "))},i=e.vakata.cookie=function(s,o,d){var l,c,h,_,u,g,f,p;if(o!==n)return d=e.extend({},i.defaults,d),null===o&&(d.expires=-1),"number"==typeof d.expires&&(l=d.expires,c=d.expires=new Date,c.setDate(c.getDate()+l)),o=i.json?e.vakata.json.encode(o):o+"",o=[encodeURIComponent(s),"=",i.raw?o:encodeURIComponent(o),d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join(""),t.cookie=o,o;for(h=i.raw?r:a,_=t.cookie.split("; "),u=0,g=_.length;g>u;u++)if(f=_[u].split("="),h(f.shift())===s)return p=h(f.join("=")),i.json?e.vakata.json.decode(p):p;return null};i.defaults={},e.vakata.removeCookie=function(t,n){return null!==e.vakata.cookie(t)?(e.vakata.cookie(t,null,n),!0):!1}}(jQuery,document),function(e,t){var n={},r={jStorage:"{}"},a=null,i=0,s=e.vakata.json.encode,o=e.vakata.json.decode,d=!1,l=!1;function c(){if(r.jStorage)try{n=o(r.jStorage+"")}catch(e){r.jStorage="{}"}else r.jStorage="{}";i=r.jStorage?(r.jStorage+"").length:0}function h(){try{r.jStorage=s(n),"userDataBehavior"===d&&(a.setAttribute("jStorage",r.jStorage),a.save("jStorage")),"cookie"===d&&e.vakata.cookie("__vjstorage",r.jStorage,{expires:365}),i=r.jStorage?(r.jStorage+"").length:0}catch(t){}}function _(e){if(!e||"string"!=typeof e&&"number"!=typeof e)throw new TypeError("Key name must be string or numeric");if("__jstorage_meta"===e)throw new TypeError("Reserved key name");return!0}function u(){var e=+new Date,t,r,a=1/0,i=!1;if(l!==!1&&clearTimeout(l),n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL){r=n.__jstorage_meta.TTL;for(t in r)r.hasOwnProperty(t)&&(e>=r[t]?(delete r[t],delete n[t],i=!0):a>r[t]&&(a=r[t]));1/0!==a&&(l=setTimeout(u,a-e)),i&&h()}}function g(){var n=!1,i;if(window.hasOwnProperty("localStorage"))try{window.localStorage.setItem("_tmptest","tmpval"),n=!0,window.localStorage.removeItem("_tmptest")}catch(s){}if(n)try{window.localStorage&&(r=window.localStorage,d="localStorage")}catch(s){}else if(window.hasOwnProperty("globalStorage"))try{window.globalStorage&&(r=window.globalStorage[window.location.hostname],d="globalStorage")}catch(s){}else{if(a=document.createElement("link"),a.addBehavior){a.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(a);try{a.load("jStorage"),i="{}",i=a.getAttribute("jStorage"),r.jStorage=i,d="userDataBehavior"}catch(s){}}if(!d&&(e.vakata.cookie("__vjstorage")||e.vakata.cookie("__vjstorage","{}",{expires:365})&&"{}"===e.vakata.cookie("__vjstorage"))&&(a=null,r.jStorage=e.vakata.cookie("__vjstorage"),d="cookie"),!d)return a=null,t}c(),u()}e.vakata.storage={version:"0.3.0",set:function(t,r,a){return _(t),"object"==typeof r&&(r=o(s(r))),n[t]=r,h(),a&&parseInt(a,10)&&e.vakata.storage.setTTL(t,parseInt(a,10)),r},get:function(e,r){return _(e),n.hasOwnProperty(e)?n[e]:r===t?null:r},del:function(e){return _(e),n.hasOwnProperty(e)?(delete n[e],n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL.hasOwnProperty(e)&&delete n.__jstorage_meta.TTL[e],h(),!0):!1},setTTL:function(e,t){var r=+new Date;return _(e),t=Number(t)||0,n.hasOwnProperty(e)?(n.__jstorage_meta||(n.__jstorage_meta={}),n.__jstorage_meta.TTL||(n.__jstorage_meta.TTL={}),t>0?n.__jstorage_meta.TTL[e]=r+t:delete n.__jstorage_meta.TTL[e],h(),u(),!0):!1},getTTL:function(e){var t=+new Date,r;return _(e),n.hasOwnProperty(e)&&n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL[e]?(r=n.__jstorage_meta.TTL[e]-t,r||0):0},flush:function(){return n={},h(),!0},storageObj:function(){return e.extend(!0,{},n)},index:function(){var t=[];return e.each(n,function(e,n){"__jstorage_meta"!==e&&t.push(e)}),t},storageSize:function(){return i},currentBackend:function(){return d},storageAvailable:function(){return!!d}},g()}(jQuery),e.jstree.defaults.types={"#":{},"default":{}},e.jstree.plugins.types=function(n,r){this.init=function(e,t){r.init.call(this,e,t),this._model.data["#"].type="#"},this.bind=function(){r.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){var n=this._model.data,r=t.nodes,a=this.settings.types,i,s,o="default";for(i=0,s=r.length;s>i;i++)o="default",n[r[i]].original&&n[r[i]].original.type&&a[n[r[i]].original.type]&&(o=n[r[i]].original.type),n[r[i]].data&&n[r[i]].data.jstree&&n[r[i]].data.jstree.type&&a[n[r[i]].data.jstree.type]&&(o=n[r[i]].data.jstree.type),n[r[i]].type=o,n[r[i]].icon===!0&&a[o].icon&&(n[r[i]].icon=a[o].icon)},this))},this.check=function(n,a,i,s){if(r.check.call(this,n,a,i,s)===!1)return!1;a=a&&a.id?a:this.get_node(a),i=i&&i.id?i:this.get_node(i);var o=this._model.data,d,l,c,h;switch(n){case"create_node":case"move_node":case"copy_node":if("move_node"!==n||-1===e.inArray(a.id,i.children)){if(d=this.get_rules(i),d.max_children!==t&&-1!==d.max_children&&d.max_children===i.children.length)return!1;if(d.valid_children!==t&&-1!==d.valid_children&&-1===e.inArray(a.type,d.valid_children))return!1;if(a.children_d&&a.parents){for(l=0,c=0,h=a.children_d.length;h>c;c++)l=Math.max(l,o[a.children_d[c]].parents.length);l=l-a.parents.length+1}0>=l&&(l=1);do{if(d.max_depth!==t&&-1!==d.max_depth&&l>d.max_depth)return!1;i=this.get_node(i.parent),d=this.get_rules(i),l++}while(i)}}return!0},this.get_rules=function(e){if(e=this.get_node(e),!e)return!1;var n=this.get_type(e,!0);return n.max_depth===t&&(n.max_depth=-1),n.max_children===t&&(n.max_children=-1),n.valid_children===t&&(n.valid_children=-1),n},this.get_type=function(t,n){return t=this.get_node(t),t?n?e.extend({type:t.type},this.settings.types[t.type]):t.type:!1},this.set_type=function(t,n){var r,a,i;if(e.isArray(t)){for(a=0,i=t.length;i>a;a++)this.set_type(t[a],n);return!0}return r=this.settings.types,t=this.get_node(t),r[n]&&t?(t.type=n,r[n].icon&&this.get_icon(t)===!0&&this.set_icon(t,r[n].icon),!0):!1}},e.jstree.plugins.unique=function(t,n){this.check=function(t,r,a,i){if(n.check.call(this,t,r,a,i)===!1)return!1;if(r=r&&r.id?r:this.get_node(r),a=a&&a.id?a:this.get_node(a),!a||!a.children)return!0;var s="rename_node"===t?i:r.text,o=[],d=this._model.data,l,c;for(l=0,c=a.children.length;c>l;l++)o.push(d[a.children[l]].text);switch(t){case"delete_node":return!0;case"rename_node":case"copy_node":return-1===e.inArray(s,o);case"move_node":return r.parent===a.id||-1===e.inArray(s,o)}return!0}};var f=document.createElement("DIV");f.setAttribute("unselectable","on"),f.className="jstree-wholerow",f.innerHTML=" ",e.jstree.plugins.wholerow=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("loading",e.proxy(function(){f.style.height=this._data.core.li_height+"px"},this)).on("ready.jstree set_state.jstree",e.proxy(function(){this.hide_dots()},this)).on("ready.jstree",e.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var n=!1,r,a;for(r=0,a=t.selected.length;a>r;r++)n=this.get_node(t.selected[r],!0),n&&n.length&&n.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",e.proxy(function(e,t){this.get_node(t.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",e.proxy(function(t,n){this.element.find(".jstree-wholerow-hovered").removeClass("jstree-wholerow-hovered"),"hover_node"===t.type&&this.get_node(n.node,!0).each(function(){e(this).children(".jstree-wholerow").addClass("jstree-wholerow-hovered")})},this)).on("contextmenu.jstree",".jstree-wholerow",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).closest("li").children("a:eq(0)").trigger("contextmenu",t)},this)).on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",e.proxy(function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",e.proxy(function(e){return e.stopImmediatePropagation(),this.hover_node(e.currentTarget),!1},this)).on("mouseleave.jstree","li",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&(this.element.find(".jstree-wholerow").remove(),n.teardown.call(this))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=f.cloneNode(!0);-1!==e.inArray(t.id,this._data.core.selected)&&(i.className+=" jstree-wholerow-clicked"),t.insertBefore(i,t.childNodes[0])}return t}}}}); \ No newline at end of file +/*! jsTree - v3.0.0-beta - 2013-12-31 - (MIT) */ +(function(e){"use strict";"function"==typeof define&&define.amd?define("jstree",["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e,t){"use strict";if(!e.jstree){var n=0,r=0,a=!1,i=!1,s=!1,o=[],d=e("script:last").attr("src"),l=document,c=l.createElement("LI"),h,_;c.setAttribute("role","treeitem"),h=l.createElement("I"),h.className="jstree-icon jstree-ocl",c.appendChild(h),h=l.createElement("A"),h.className="jstree-anchor",h.setAttribute("href","#"),_=l.createElement("I"),_.className="jstree-icon jstree-themeicon",h.appendChild(_),c.appendChild(h),h=_=null,e.jstree={version:"3.0.0-alpha",defaults:{plugins:[]},plugins:{},path:d&&-1!==d.indexOf("/")?d.replace(/\/[^\/]+$/,""):""},e.jstree.create=function(t,r){var a=new e.jstree.core(++n),i=r;return r=e.extend(!0,{},e.jstree.defaults,r),i&&i.plugins&&(r.plugins=i.plugins),e.each(r.plugins,function(e,t){"core"!==e&&(a=a.plugin(t,r[t]))}),a.init(t,r),a},e.jstree.core=function(e){this._id=e,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[]}}},e.jstree.reference=function(n){if(n&&!e(n).length){n.id&&(n=n.id);var r=null;return e(".jstree").each(function(){var a=e(this).data("jstree");return a&&a._model.data[n]?(r=a,!1):t}),r}return e(n).closest(".jstree").data("jstree")},e.fn.jstree=function(n){var r="string"==typeof n,a=Array.prototype.slice.call(arguments,1),i=null;return this.each(function(){var s=e.jstree.reference(this),o=r&&s?s[n]:null;return i=r&&o?o.apply(s,a):null,s||r||n!==t&&!e.isPlainObject(n)||e(this).data("jstree",new e.jstree.create(this,n)),s&&!r&&(i=s),null!==i&&i!==t?!1:t}),null!==i&&i!==t?i:this},e.expr[":"].jstree=e.expr.createPseudo(function(n){return function(n){return e(n).hasClass("jstree")&&e(n).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1},expand_selected_onload:!0},e.jstree.core.prototype={plugin:function(t,n){var r=e.jstree.plugins[t];return r?(this._data[t]={},r.prototype=this,new r(n,this)):this},init:function(t,n){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=n,this.element.bind("destroyed",e.proxy(this.teardown,this)),this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),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(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html("
    "),this._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||18,this.trigger("loading"),this.load_node("#")},destroy:function(){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[^ ]*|$/gi,"")}),this.element=null},bind:function(){e.support.touch&&this.element.addTouch(),this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var e=window.getSelection();try{e.removeAllRanges(),e.collapse()}catch(t){}}}).on("click.jstree",".jstree-ocl",e.proxy(function(e){this.toggle_node(e.target)},this)).on("click.jstree",".jstree-anchor",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).focus(),this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",e.proxy(function(t){var n=null;switch(t.which){case 13:case 32:t.type="click",e(t.currentTarget).trigger(t);break;case 37:t.preventDefault(),this.is_open(t.currentTarget)?this.close_node(t.currentTarget):(n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 38:t.preventDefault(),n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 39:t.preventDefault(),this.is_closed(t.currentTarget)?this.open_node(t.currentTarget,function(e){this.get_node(e,!0).children(".jstree-anchor").focus()}):(n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 40:t.preventDefault(),n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 46:t.preventDefault(),n=this.get_node(t.currentTarget),n&&n.id&&"#"!==n.id&&(n=this.is_selected(n)?this.get_selected():n);break;case 113:t.preventDefault(),n=this.get_node(t.currentTarget);break;default:}},this)).on("load_node.jstree",e.proxy(function(t,n){if(n.status&&("#"!==n.node.id||this._data.core.loaded||(this._data.core.loaded=!0,this.trigger("loaded")),!this._data.core.ready&&!this.get_container_ul().find(".jstree-loading:eq(0)").length)){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var r=[],a,i;for(a=0,i=this._data.core.selected.length;i>a;a++)r=r.concat(this._model.data[this._data.core.selected[a]].parents);for(r=e.vakata.array_unique(r),a=0,i=r.length;i>a;a++)this.open_node(r[a],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this)).on("init.jstree",e.proxy(function(){var e=this.settings.core.themes;this._data.core.themes.dots=e.dots,this._data.core.themes.stripes=e.stripes,this._data.core.themes.icons=e.icons,this.set_theme(e.name||"default",e.url),this.set_theme_variant(e.variant)},this)).on("loading.jstree",e.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("focus.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseenter()},this)).on("blur.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseleave()},this)).on("mouseenter.jstree",".jstree-anchor",e.proxy(function(e){var t=this.element.find(".jstree-anchor:focus").not(".jstree-clicked");t&&t.length&&t[0]!==e.currentTarget&&t.blur(),this.hover_node(e.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),e(document).off(".jstree-"+this._id)},trigger:function(e,t){t||(t={}),t.instance=this,this.element.triggerHandler(e.replace(".jstree","")+".jstree",t)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children("ul:eq(0)")},get_string:function(t){var n=this.settings.core.strings;return e.isFunction(n)?n.call(this,t):n&&n[t]?n[t]:t},_firstChild:function(e){e=e?e.firstChild:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_nextSibling:function(e){e=e?e.nextSibling:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_previousSibling:function(e){e=e?e.previousSibling:null;while(null!==e&&1!==e.nodeType)e=e.previousSibling;return e},get_node:function(t,n){t&&t.id&&(t=t.id);var r;if(this._model.data[t])t=this._model.data[t];else if(((r=e(t,this.element)).length||(r=e("#"+t,this.element)).length)&&this._model.data[r.closest("li").attr("id")])t=this._model.data[r.closest("li").attr("id")];else{if(!(r=e(t,this.element)).length||!r.hasClass("jstree"))return!1;t=this._model.data["#"]}return n&&(t="#"===t.id?this.element:e(document.getElementById(t.id))),t},get_next_dom:function(t,n){var r;return t=this.get_node(t,!0),t[0]===this.element[0]?(r=this._firstChild(this.get_container_ul()[0]),r?e(r):!1):t&&t.length?n?(r=this._nextSibling(t[0]),r?e(r):!1):t.hasClass("jstree-open")?(r=this._firstChild(t.children("ul")[0]),r?e(r):!1):null!==(r=this._nextSibling(t[0]))?e(r):t.parentsUntil(".jstree","li").next("li").eq(0):!1},get_prev_dom:function(t,n){var r;if(t=this.get_node(t,!0),t[0]===this.element[0])return r=this.get_container_ul()[0].lastChild,r?e(r):!1;if(!t||!t.length)return!1;if(n)return r=this._previousSibling(t[0]),r?e(r):!1;if(null!==(r=this._previousSibling(t[0]))){t=e(r);while(t.hasClass("jstree-open"))t=t.children("ul:eq(0)").children("li:last");return t}return r=t[0].parentNode.parentNode,r&&"LI"===r.tagName?e(r):!1},get_parent:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.parent:!1},get_children_dom:function(e){return e=this.get_node(e,!0),e[0]===this.element[0]?this.get_container_ul().children("li"):e&&e.length?e.children("ul").children("li"):!1},is_parent:function(e){return e=this.get_node(e),e&&(e.state.loaded===!1||e.children.length)},is_loaded:function(e){return e=this.get_node(e),e&&e.state.loaded},is_loading:function(e){return e=this.get_node(e,!0),e&&e.hasClass("jstree-loading")},is_open:function(e){return e=this.get_node(e),e&&e.state.opened},is_closed:function(e){return e=this.get_node(e),e&&this.is_parent(e)&&!e.state.opened},is_leaf:function(e){return!this.is_parent(e)},load_node:function(t,n){var r,a;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.load_node(t[r],n);return!0}return(t=this.get_node(t))?(this.get_node(t,!0).addClass("jstree-loading"),this._load_node(t,e.proxy(function(e){t.state.loaded=e,this.get_node(t,!0).removeClass("jstree-loading"),this.trigger("load_node",{node:t,status:e}),n&&n.call(this,t,e)},this)),!0):(n.call(this,t,!1),!1)},_load_node:function(n,r){var a=this.settings.core.data;return a?e.isFunction(a)?a.call(this,n,e.proxy(function(t){return r.call(this,this["string"==typeof t?"_append_html_data":"_append_json_data"](n,"string"==typeof t?e(t):t))},this)):"object"==typeof a?a.url?(a=e.extend(!0,{},a),e.isFunction(a.url)&&(a.url=a.url.call(this,n)),e.isFunction(a.data)&&(a.data=a.data.call(this,n)),e.ajax(a).done(e.proxy(function(a,i,s){var o=s.getResponseHeader("Content-Type");return-1!==o.indexOf("json")?r.call(this,this._append_json_data(n,a)):-1!==o.indexOf("html")?r.call(this,this._append_html_data(n,e(a))):t},this)).fail(e.proxy(function(){r.call(this,!1)},this))):r.call(this,this._append_json_data(n,a)):"string"==typeof a?r.call(this,this._append_html_data(n,a)):r.call(this,!1):r.call(this,"#"===n.id?this._append_html_data(n,this._data.core.original_container_html.clone(!0)):!1)},_node_changed:function(e){e=this.get_node(e),e&&this._model.changed.push(e.id)},_append_html_data:function(t,n){t=this.get_node(t);var r=n.is("ul")?n.children():n,a=t.id,i=[],s=[],o=this._model.data,d=o[a],l=this._data.core.selected.length,c,h,_;for(r.each(e.proxy(function(t,n){c=this._parse_model_from_html(e(n),a,d.parents.concat()),c&&(i.push(c),s.push(c),o[c].children_d.length&&(s=s.concat(o[c].children_d)))},this)),d.children=i,d.children_d=s,h=0,_=d.parents.length;_>h;h++)o[d.parents[h]].children_d=o[d.parents[h]].children_d.concat(s);return this.trigger("model",{nodes:s,parent:a}),"#"!==a?(this._node_changed(a),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==l&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_append_json_data:function(n,r){n=this.get_node(n);var a=r,i=n.id,s=[],o=[],d=this._model.data,l=d[i],c=this._data.core.selected.length,h,_,u;if(e.isArray(a)||(a=[a]),a.length&&a[0].id!==t&&a[0].parent!==t){for(_=0,u=a.length;u>_;_++)a[_].children||(a[_].children=[]),d[a[_].id]=a[_];for(_=0,u=a.length;u>_;_++)d[a[_].parent].children.push(a[_].id),l.children_d.push(a[_].id);for(_=0,u=l.children.length;u>_;_++)this._parse_model_from_flat_json(d[l.children[_]],i,l.parents.concat())}else{for(_=0,u=a.length;u>_;_++)h=this._parse_model_from_json(a[_],i,l.parents.concat()),h&&(s.push(h),o.push(h),d[h].children_d.length&&(o=o.concat(d[h].children_d)));for(l.children=s,l.children_d=o,_=0,u=l.parents.length;u>_;_++)d[l.parents[_]].children_d=d[l.parents[_]].children_d.concat(o)}return this.trigger("model",{nodes:o,parent:i}),"#"!==i?(this._node_changed(i),this.redraw()):this.redraw(!0),this._data.core.selected.length!==c&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_parse_model_from_html:function(n,a,i){i=i?[].concat(i):[],a&&i.unshift(a);var s,o,d=this._model.data,l={id:!1,text:!1,icon:!0,parent:a,parents:i,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},c,h,_;for(c in this._model.default_state)this._model.default_state.hasOwnProperty(c)&&(l.state[c]=this._model.default_state[c]);if(h=e.vakata.attributes(n,!0),e.each(h,function(n,r){return r=e.trim(r),r.length?(l.li_attr[n]=r,"id"===n&&(l.id=r),t):!0}),h=n.children("a").eq(0),h.length&&(h=e.vakata.attributes(h,!0),e.each(h,function(t,n){n=e.trim(n),n.length&&(l.a_attr[t]=n)})),h=n.children("a:eq(0)").length?n.children("a:eq(0)").clone():n.clone(),h.children("ins, i, ul").remove(),h=h.html(),h=e("
    ").html(h),l.text=h.html(),h=n.data(),l.data=h?e.extend(!0,{},h):null,l.state.opened=n.hasClass("jstree-open"),l.state.selected=n.children("a").hasClass("jstree-clicked"),l.state.disabled=n.children("a").hasClass("jstree-disabled"),l.data&&l.data.jstree)for(c in l.data.jstree)l.data.jstree.hasOwnProperty(c)&&(l.state[c]=l.data.jstree[c]);h=n.children("a").children(".jstree-themeicon"),h.length&&(l.icon=h.hasClass("jstree-themeicon-hidden")?!1:h.attr("rel")),l.state.icon&&(l.icon=l.state.icon),h=n.children("ul").children("li");do _="j"+this._id+"_"+ ++r;while(d[_]);return l.id=l.li_attr.id||_,h.length?(h.each(e.proxy(function(t,n){s=this._parse_model_from_html(e(n),l.id,i),o=this._model.data[s],l.children.push(s),o.children_d.length&&(l.children_d=l.children_d.concat(o.children_d))},this)),l.children_d=l.children_d.concat(l.children)):n.hasClass("jstree-closed")&&(l.state.loaded=!1),d[l.id]=l,l.state.selected&&this._data.core.selected.push(l.id),l.id},_parse_model_from_flat_json:function(e,n,r){r=r?r.concat():[],n&&r.unshift(n);var a=e.id,i=this._model.data,s=this._model.default_state,o,d,l,c,h={id:a,text:e.text||"",icon:e.icon!==t?e.icon:!0,parent:n,parents:r,children:e.children||[],children_d:e.children_d||[],data:e.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(o in s)s.hasOwnProperty(o)&&(h.state[o]=s[o]);if(e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(h.icon=e.data.jstree.icon),e&&e.data&&(h.data=e.data,e.data.jstree))for(o in e.data.jstree)e.data.jstree.hasOwnProperty(o)&&(h.state[o]=e.data.jstree[o]);if(e&&"object"==typeof e.state)for(o in e.state)e.state.hasOwnProperty(o)&&(h.state[o]=e.state[o]);if(e&&"object"==typeof e.li_attr)for(o in e.li_attr)e.li_attr.hasOwnProperty(o)&&(h.li_attr[o]=e.li_attr[o]);if(h.li_attr.id||(h.li_attr.id=a),e&&"object"==typeof e.a_attr)for(o in e.a_attr)e.a_attr.hasOwnProperty(o)&&(h.a_attr[o]=e.a_attr[o]);for(e&&e.children&&e.children===!0&&(h.state.loaded=!1,h.children=[],h.children_d=[]),i[h.id]=h,o=0,d=h.children.length;d>o;o++)l=this._parse_model_from_flat_json(i[h.children[o]],h.id,r),c=i[l],h.children_d.push(l),c.children_d.length&&(h.children_d=h.children_d.concat(c.children_d));return delete e.data,delete e.children,i[h.id].original=e,h.state.selected&&this._data.core.selected.push(h.id),h.id},_parse_model_from_json:function(e,n,a){a=a?a.concat():[],n&&a.unshift(n);var i=!1,s,o,d,l,c=this._model.data,h=this._model.default_state,_;do i="j"+this._id+"_"+ ++r;while(c[i]);_={id:!1,text:"string"==typeof e?e:"",icon:"object"==typeof e&&e.icon!==t?e.icon:!0,parent:n,parents:a,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(s in h)h.hasOwnProperty(s)&&(_.state[s]=h[s]);if(e&&e.id&&(_.id=e.id),e&&e.text&&(_.text=e.text),e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(_.icon=e.data.jstree.icon),e&&e.data&&(_.data=e.data,e.data.jstree))for(s in e.data.jstree)e.data.jstree.hasOwnProperty(s)&&(_.state[s]=e.data.jstree[s]);if(e&&"object"==typeof e.state)for(s in e.state)e.state.hasOwnProperty(s)&&(_.state[s]=e.state[s]);if(e&&"object"==typeof e.li_attr)for(s in e.li_attr)e.li_attr.hasOwnProperty(s)&&(_.li_attr[s]=e.li_attr[s]);if(_.li_attr.id&&!_.id&&(_.id=_.li_attr.id),_.id||(_.id=i),_.li_attr.id||(_.li_attr.id=_.id),e&&"object"==typeof e.a_attr)for(s in e.a_attr)e.a_attr.hasOwnProperty(s)&&(_.a_attr[s]=e.a_attr[s]);if(e&&e.children&&e.children.length){for(s=0,o=e.children.length;o>s;s++)d=this._parse_model_from_json(e.children[s],_.id,a),l=c[d],_.children.push(d),l.children_d.length&&(_.children_d=_.children_d.concat(l.children_d));_.children_d=_.children_d.concat(_.children)}return e&&e.children&&e.children===!0&&(_.state.loaded=!1,_.children=[],_.children_d=[]),delete e.data,delete e.children,_.original=e,c[_.id]=_,_.state.selected&&this._data.core.selected.push(_.id),_.id},_redraw:function(){var e=this._model.force_full_redraw?this._model.data["#"].children.concat([]):this._model.changed.concat([]),t=document.createElement("UL"),n,r,a;for(r=0,a=e.length;a>r;r++)n=this.redraw_node(e[r],!0,this._model.force_full_redraw),n&&this._model.force_full_redraw&&t.appendChild(n);this._model.force_full_redraw&&(t.className=this.get_container_ul()[0].className,this.element.empty().append(t)),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:e})},redraw:function(e){e&&(this._model.force_full_redraw=!0),this._redraw()},redraw_node:function(t,n,r){var a=this.get_node(t),i=!1,s=!1,o=!1,d=!1,l=!1,h=!1,_="",u=document,g=this._model.data;if(!a)return!1;if("#"===a.id)return this.redraw(!0);if(n=n||0===a.children.length,t=u.getElementById(a.id))t=e(t),r||(i=t.parent().parent()[0],i===this.element[0]&&(i=null),s=t.index()),g[a.id].data=t.data(),n||!a.children.length||t.children("ul").length||(n=!0),n||(o=t.children("UL")[0]),t.remove();else if(n=!0,!r){if(i="#"!==a.parent?e("#"+a.parent,this.element)[0]:null,!(null===i||i&&g[a.parent].state.opened))return!1;s=e.inArray(a.id,null===i?g["#"].children:g[a.parent].children)}t=c.cloneNode(!0),_="jstree-node ";for(d in a.li_attr)if(a.li_attr.hasOwnProperty(d)){if("id"===d)continue;"class"!==d?c.setAttribute(d,a.li_attr[d]):_+=a.li_attr[d]}_+=!a.children.length&&a.state.loaded?" jstree-leaf":a.state.opened?" jstree-open":" jstree-closed",null!==a.parent&&g[a.parent].children[g[a.parent].children.length-1]===a.id&&(_+=" jstree-last"),t.id=a.id,t.className=_,_=(a.state.selected?" jstree-clicked":"")+(a.state.disabled?" jstree-disabled":"");for(l in a.a_attr)if(a.a_attr.hasOwnProperty(l)){if("href"===l&&"#"===a.a_attr[l])continue;"class"!==l?t.childNodes[1].setAttribute(l,a.a_attr[l]):_+=" "+a.a_attr[l]}if(_.length&&(t.childNodes[1].className="jstree-anchor "+_),a.icon&&a.icon!==!0&&(a.icon===!1?t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===a.icon.indexOf("/")?t.childNodes[1].childNodes[0].className+=" "+a.icon+" jstree-themeicon-custom":(t.childNodes[1].childNodes[0].style.backgroundImage="url("+a.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")),t.childNodes[1].appendChild(u.createTextNode(a.text)),a.data&&e.data(t,a.data),n&&a.children.length&&a.state.opened){for(h=u.createElement("UL"),h.setAttribute("role","group"),h.className="jstree-children",d=0,l=a.children.length;l>d;d++)h.appendChild(this.redraw_node(a.children[d],n,!0));t.appendChild(h)}return o&&t.appendChild(o),r||(i||(i=this.element[0]),i.getElementsByTagName("UL").length?i=i.getElementsByTagName("UL")[0]:(d=u.createElement("UL"),d.setAttribute("role","group"),d.className="jstree-children",i.appendChild(d),i=d),i.childNodes.length>s?i.insertBefore(t,i.childNodes[s]):i.appendChild(t)),t},open_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(i=0,s=n.length;s>i;i++)this.open_node(n[i],r,a);return!0}if(n=this.get_node(n),!n||"#"===n.id)return!1;if(a=a===t?this.settings.core.animation:a,!this.is_closed(n))return r&&r.call(this,n,!1),!1;if(this.is_loaded(n))o=this.get_node(n,!0),d=this,o.length&&(n.children.length&&!this._firstChild(o.children("ul")[0])&&(n.state.opened=!0,this.redraw_node(n,!0),o=this.get_node(n,!0)),a?o.children("ul").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").children("ul").stop(!0,!0).slideDown(a,function(){this.style.display="",d.trigger("after_open",{node:n})}):o[0].className=o[0].className.replace("jstree-closed","jstree-open")),n.state.opened=!0,r&&r.call(this,n,!0),this.trigger("open_node",{node:n}),a&&o.length||this.trigger("after_open",{node:n});else{if(this.is_loading(n))return setTimeout(e.proxy(function(){this.open_node(n,r,a)},this),500);this.load_node(n,function(e,t){return t?this.open_node(e,r,a):r?r.call(this,e,!1):!1})}},close_node:function(n,r){var a,i,s,o;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.close_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(r=r===t?this.settings.core.animation:r,s=this,o=this.get_node(n,!0),o.length&&(r?o.children("ul").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").children("ul").stop(!0,!0).slideUp(r,function(){this.style.display="",o.children("ul").remove(),s.trigger("after_close",{node:n})}):o[0].className=o[0].className.replace("jstree-open","jstree-closed")),n.state.opened=!1,this.trigger("close_node",{node:n}),r&&o.length||this.trigger("after_close",{node:n}),t):!1},toggle_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.toggle_node(n[r]);return!0}return this.is_closed(n)?this.open_node(n):this.is_open(n)?this.close_node(n):t},open_all:function(e,t,n){if(e||(e="#"),e=this.get_node(e),!e)return!1;var r="#"===e.id?this.get_container_ul():this.get_node(e,!0),a,i,s;if(!r.length){for(a=0,i=e.children_d.length;i>a;a++)this.is_closed(this._mode.data[e.children_d[a]])&&(this._mode.data[e.children_d[a]].state.opened=!0);return this.trigger("open_all",{node:e})}n=n||r,s=this,r=this.is_closed(e)?r.find("li.jstree-closed").addBack():r.find("li.jstree-closed"),r.each(function(){s.open_node(this,s.is_loaded(this)?!1:function(e){this.open_all(e,t,n)},t||0)}),0===n.find("li.jstree-closed").length&&this.trigger("open_all",{node:this.get_node(n)})},close_all:function(e,t){if(e||(e="#"),e=this.get_node(e),!e)return!1;var n="#"===e.id?this.get_container_ul():this.get_node(e,!0),r=this,a,i;if(!n.length){for(a=0,i=e.children_d.length;i>a;a++)this._mode.data[e.children_d[a]].state.opened=!1;return this.trigger("close_all",{node:e})}n=this.is_open(e)?n.find("li.jstree-open").addBack():n.find("li.jstree-open"),n.vakata_reverse().each(function(){r.close_node(this,t||0)}),this.trigger("close_all",{node:e})},is_disabled:function(e){return e=this.get_node(e),e&&e.state&&e.state.disabled},enable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.enable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!1,this.get_node(n,!0).children(".jstree-anchor").removeClass("jstree-disabled"),this.trigger("enable_node",{node:n}),t):!1},disable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.disable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!0,this.get_node(n,!0).children(".jstree-anchor").addClass("jstree-disabled"),this.trigger("disable_node",{node:n}),t):!1},activate_node:function(e,t){if(this.is_disabled(e))return!1;if(this.settings.core.multiple&&(t.metaKey||t.ctrlKey||t.shiftKey)&&(!t.shiftKey||this._data.core.last_clicked&&this.get_parent(e)&&this.get_parent(e)===this._data.core.last_clicked.parent))if(t.shiftKey){var n=this.get_node(e).id,r=this._data.core.last_clicked.id,a=this.get_node(this._data.core.last_clicked.parent).children,i=!1,s,o;for(s=0,o=a.length;o>s;s+=1)a[s]===n&&(i=!i),a[s]===r&&(i=!i),i||a[s]===n||a[s]===r?this.select_node(a[s]):this.deselect_node(a[s])}else this.is_selected(e)?this.deselect_node(e):this.select_node(e);else this.deselect_all(!0),this.select_node(e),this._data.core.last_clicked=this.get_node(e);this.trigger("activate_node",{node:this.get_node(e)})},hover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(e)}),t):!1},dehover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").removeClass("jstree-hovered"),this.trigger("dehover_node",{node:this.get_node(e)}),t):!1},select_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(s=0,o=n.length;o>s;s++)this.select_node(n[s],r,a);return!0}return n=this.get_node(n),n&&"#"!==n.id?(i=this.get_node(n,!0),n.state.selected||(n.state.selected=!0,this._data.core.selected.push(n.id),i.length&&(i.children(".jstree-anchor").addClass("jstree-clicked"),a||(d=this,i.parents(".jstree-closed").each(function(){d.open_node(this,!1,0)}))),this.trigger("select_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"select_node",node:n,selected:this._data.core.selected})),t):!1},deselect_node:function(n,r){var a,i,s;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.deselect_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(s=this.get_node(n,!0),n.state.selected&&(n.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(n.id,this._data.core.selected)),s.length&&s.children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"deselect_node",node:n,selected:this._data.core.selected})),t):!1},select_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(this._data.core.selected=this._model.data["#"].children_d.concat(),n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),e||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:t})},deselect_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked"),this.trigger("deselect_all",{selected:this._data.core.selected,node:t}),e||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:t})},is_selected:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.state.selected:!1},get_selected:function(){return this._data.core.selected},get_state:function(){var e={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},t;for(t in this._model.data)this._model.data.hasOwnProperty(t)&&"#"!==t&&(this._model.data[t].state.opened&&e.core.open.push(t),this._model.data[t].state.selected&&e.core.selected.push(t));return e},set_state:function(n,r){if(n){if(n.core){var a,i,s,o;return e.isArray(n.core.open)?(a=!0,i=!1,s=this,e.each(n.core.open.concat([]),function(t,r){i=document.getElementById(r),i&&(s.is_loaded(r)?(s.is_closed(r)&&s.open_node(r,!1,0),e.vakata.array_remove(n.core.open,e.inArray(r,n.core.open))):(s.is_loading(r)||s.open_node(r,e.proxy(function(){this.set_state(n)},s),0),a=!1))}),a&&(delete n.core.open,this.set_state(n,r)),!1):n.core.scroll?(n.core.scroll&&n.core.scroll.left!==t&&this.element.scrollLeft(n.core.scroll.left),n.core.scroll&&n.core.scroll.top!==t&&this.element.scrollTop(n.core.scroll.top),delete n.core.scroll,delete n.core.open,this.set_state(n,r),!1):n.core.selected?(o=this,this.deselect_all(),e.each(n.core.selected,function(e,t){o.select_node(t)}),delete n.core.selected,this.set_state(n,r),!1):e.isEmptyObject(n)?(r&&r.call(this),this.trigger("set_state"),!1):!0}return!0}return!1},refresh:function(){this._data.core.state=this.get_state(),this.load_node("#",function(t,n){n&&this.set_state(e.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")}),this._data.core.state=null})},get_text:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.text:!1},set_text:function(t,n){var r,a,i,s;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_text(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.text=n,i=this.get_node(t,!0),i.length&&(i=i.children(".jstree-anchor:eq(0)"),s=i.children("I").clone(),i.html(n).prepend(s),this.trigger("set_text",{obj:t,text:n})),!0):!1},get_json:function(e,t){if(e=this.get_node(e||"#"),!e)return!1;var n={id:e.id,text:e.text,icon:this.get_icon(e),li_attr:e.li_attr,a_attr:e.a_attr,state:{},data:t&&t.no_data?!1:this.get_node(e,!0).length?this.get_node(e,!0).data():e.data,children:[]},r,a;if(!t||!t.no_state)for(r in e.state)e.state.hasOwnProperty(r)&&(n.state[r]=e.state[r]);if(t&&t.no_id&&n.li_attr&&n.li_attr.id&&(delete n.li_attr.id,delete n.id),!t||!t.no_children)for(r=0,a=e.children.length;a>r;r++)n.children.push(this.get_json(e.children[r],t));return"#"===e.id?n.children:n},create_node:function(n,r,a,i,s){if(n=this.get_node(n),!n)return!1;if(a=a===t?"last":a,!a.match(/^(before|after)$/)&&!s&&!this.is_loaded(n))return this.load_node(n,function(){this.create_node(n,r,a,i,!0)});r||(r={text:this.get_string("New node")}),r.text===t&&(r.text=this.get_string("New node"));var o,d,l,c;switch("#"===n.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"after":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"inside":case"first":a=0;break;case"last":a=n.children.length;break;default:a||(a=0)}if(a>n.children.length&&(a=n.children.length),r.id||(r.id=!0),!this.check("create_node",r,n,a))return!1;if(delete r.id,r=this._parse_model_from_json(r,n.id,n.parents.concat()),!r)return!1;for(o=this.get_node(r),d=[],d.push(r),d=d.concat(o.children_d),this.trigger("model",{nodes:d,parent:n.id}),n.children_d=n.children_d.concat(d),l=0,c=n.parents.length;c>l;l++)this._model.data[n.parents[l]].children_d=this._model.data[n.parents[l]].children_d.concat(d);for(r=o,o=[],l=0,c=n.children.length;c>l;l++)o[l>=a?l+1:l]=n.children[l];return o[a]=r.id,n.children=o,this.redraw_node(n,!0),i&&i.call(this,this.get_node(r)),this.trigger("create_node",{node:this.get_node(r),parent:n.id,position:a}),r.id},rename_node:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.rename_node(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(i=t.text,this.check("rename_node",t,this.get_parent(t),n)?(this.set_text(t,n),this.trigger("rename_node",{node:t,text:n,old:i}),!0):!1):!1},delete_node:function(t){var n,r,a,i,s,o,d,l,c,h;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.delete_node(t[n]);return!0}if(t=this.get_node(t),!t||"#"===t.id)return!1;if(a=this.get_node(t.parent),i=e.inArray(t.id,a.children),h=!1,!this.check("delete_node",t,a,i))return!1;for(a.children=e.vakata.array_remove(a.children,i),s=t.children_d.concat([]),s.push(t.id),l=0,c=s.length;c>l;l++){for(o=0,d=t.parents.length;d>o;o++)this._model.data[t.parents[o]].children_d=e.vakata.array_remove(this._model.data[t.parents[o]].children_d,e.inArray(s[l],this._model.data[t.parents[o]].children_d));this._model.data[s[l]].state.selected&&(h=!0,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(s[l],this._data.core.selected)))}return this.trigger("delete_node",{node:t,parent:a.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:a.id}),delete this._model.data[t.id],this.redraw_node(a,!0),!0 +},check:function(t,n,r,a){n=n&&n.id?n:this.get_node(n),r=r&&r.id?r:this.get_node(r);var i=t.match(/^move_node|copy_node|create_node$/i)?r:n,s=this.settings.core.check_callback;return"move_node"!==t||n.id!==r.id&&e.inArray(n.id,r.children)!==a&&-1===e.inArray(r.id,n.children_d)?(i=this.get_node(i,!0),i.length&&(i=i.data("jstree")),i&&i.functions&&(i.functions[t]===!1||i.functions[t]===!0)?i.functions[t]:s===!1||e.isFunction(s)&&s.call(this,t,n,r,a)===!1||s&&s[t]===!1?!1:!0):!1},move_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m,v,j;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.move_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.move_node(n,r,a,i,!0)});switch(l=""+n.parent,c=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,h=this._model.data[n.id]?this:e.jstree.reference(n.id),_=this._id!==h._id,"#"===c.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,c.children);break;case"after":a=e.inArray(r.id,c.children)+1;break;case"inside":case"first":a=0;break;case"last":a=c.children.length;break;default:a||(a=0)}if(a>c.children.length&&(a=c.children.length),!this.check("move_node",n,c,a))return!1;if(_||n.parent!==c.id){for(g=n.children_d.concat(),g.push(n.id),f=0,p=n.parents.length;p>f;f++){for(u=[],j=h._model.data[n.parents[f]].children_d,m=0,v=j.length;v>m;m++)-1===e.inArray(j[m],g)&&u.push(j[m]);h._model.data[n.parents[f]].children_d=u}for(h._model.data[l].children=e.vakata.array_remove(h._model.data[l].children,e.inArray(n.id,h._model.data[l].children)),f=0,p=c.parents.length;p>f;f++)this._model.data[c.parents[f]].children_d=this._model.data[c.parents[f]].children_d.concat(g);for(u=[],f=0,p=c.children.length;p>f;f++)u[f>=a?f+1:f]=c.children[f];u[a]=n.id,c.children=u,c.children_d.push(n.id),c.children_d=c.children_d.concat(n.children_d),n.parent=c.id,g=c.parents.concat(),g.push(c.id),n.parents=g,_?(h.delete_node(n.id),this._node_changed(c.id),this.redraw("#"===c.id)):(this._node_changed(l),this._node_changed(c.id),this.redraw("#"===l||"#"===c.id))}else{for(u=c.children.concat(),g=e.inArray(n.id,u),-1!==g&&(u=e.vakata.array_remove(u,g),a>g&&a--),g=[],f=0,p=u.length;p>f;f++)g[f>=a?f+1:f]=u[f];g[a]=n.id,c.children=g,this._node_changed(c.id),this.redraw("#"===c.id)}return i&&i.call(this,n,c,a),this.trigger("move_node",{node:n,parent:c.id,position:a,old_parent:l,is_multi:_,old_instance:h,new_instance:this}),!0},copy_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.copy_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.copy_node(n,r,a,i,!0)});switch(g=""+n.parent,f=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,p=this._model.data[n.id]?this:e.jstree.reference(n.id),m=this._id!==p._id,"#"===f.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,f.children);break;case"after":a=e.inArray(r.id,f.children)+1;break;case"inside":case"first":a=0;break;case"last":a=f.children.length;break;default:a||(a=0)}if(a>f.children.length&&(a=f.children.length),!this.check("copy_node",n,f,a))return!1;if(u=p.get_json(n,{no_id:!0,no_data:!0,no_state:!0}),!u)return!1;if(u=this._parse_model_from_json(u,f.id,f.parents.concat()),!u)return!1;for(c=this.get_node(u),l=[],l.push(u),l=l.concat(c.children_d),this.trigger("model",{nodes:l,parent:f.id}),h=0,_=f.parents.length;_>h;h++)this._model.data[f.parents[h]].children_d=this._model.data[f.parents[h]].children_d.concat(l);for(l=[],h=0,_=f.children.length;_>h;h++)l[h>=a?h+1:h]=f.children[h];return l[a]=c.id,f.children=l,f.children_d.push(c.id),f.children_d=f.children_d.concat(c.children_d),this._node_changed(f.id),this.redraw("#"===f.id),i&&i.call(this,c,f,a),this.trigger("copy_node",{node:c,original:n,parent:f.id,position:a,old_parent:g,is_multi:m,old_instance:p,new_instance:this}),c.id},cut:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="move_node",this.trigger("cut",{node:n}),t):!1},copy:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="copy_node",this.trigger("copy",{node:n}),t):!1},get_buffer:function(){return{mode:i,node:a,inst:s}},can_paste:function(){return i!==!1&&a!==!1},paste:function(e){return e=this.get_node(e),e&&i&&i.match(/^(copy_node|move_node)$/)&&a?(this[i](a,e)&&this.trigger("paste",{parent:e.id,node:a,mode:i}),a=!1,i=!1,s=!1,t):!1},edit:function(n,r){if(n=this.get_node(n,!0),!n||!n.length)return!1;n.parentsUntil(".jstree",".jstree-closed").each(e.proxy(function(e,t){this.open_node(t,!1,0)},this));var a=this._data.core.rtl,i=this.element.width(),s=n.children(".jstree-anchor"),o="string"==typeof r?r:this.get_text(n),d=e("
    ",{css:{position:"absolute",top:"-200px",left:a?"0px":"-1000px",visibility:"hidden"}}).appendTo("body"),l=e("",{value:o,"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:e.proxy(function(){var e=s.children(".jstree-rename-input"),t=e.val();""===t&&(t=o),d.remove(),e.remove(),this.rename_node(n,t)===!1&&this.rename_node(n,o)},this),keydown:function(e){var t=e.which;27===t&&(this.value=o),(27===t||13===t||37===t||38===t||39===t||40===t||32===t)&&e.stopImmediatePropagation(),(27===t||13===t)&&(e.preventDefault(),this.blur())},keyup:function(e){l.width(Math.min(d.text("pW"+this.value).width(),i))},keypress:function(e){return 13===e.which?!1:t}}),c={fontFamily:s.css("fontFamily")||"",fontSize:s.css("fontSize")||"",fontWeight:s.css("fontWeight")||"",fontStyle:s.css("fontStyle")||"",fontStretch:s.css("fontStretch")||"",fontVariant:s.css("fontVariant")||"",letterSpacing:s.css("letterSpacing")||"",wordSpacing:s.css("wordSpacing")||""};this.set_text(n,""),s.append(l),d.css(c),l.css(c).width(Math.min(d.text("pW"+l[0].value).width(),i))[0].select()},set_theme:function(t,n){if(!t)return!1;if(n===!0){var r=this.settings.core.themes.dir;r||(r=e.jstree.path+"/themes"),n=r+"/"+t+"/style.css"}n&&-1===e.inArray(n,o)&&(e("head").append(''),o.push(n)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=t,this.element.addClass("jstree-"+t),this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(e){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=e,e&&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=!0,this.get_container_ul().addClass("jstree-striped")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped")},toggle_stripes:function(){this._data.core.themes.stripes?this.hide_stripes():this.show_stripes()},show_dots:function(){this._data.core.themes.dots=!0,this.get_container_ul().removeClass("jstree-no-dots")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-dots")},toggle_dots:function(){this._data.core.themes.dots?this.hide_dots():this.show_dots()},show_icons:function(){this._data.core.themes.icons=!0,this.get_container_ul().removeClass("jstree-no-icons")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},set_icon:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_icon(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.icon=n,i=this.get_node(t,!0).children("jstree-anchor").children(".jstree-themeicon"),n===!1?this.removeClass("jstree-themeicon-custom").hide_icon(t):-1===n.indexOf("/")?i.addClass(n+" jstree-themeicon-custom").attr("rel",n):i.removeClass("jstree-themeicon-custom").css("background","url('"+n+"') center center no-repeat").attr("rel",n),!0):!1},get_icon:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.icon:!1},hide_icon:function(t){var n,r;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.hide_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(t.icon=!1,this.get_node(t,!0).children("a").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(t){var n,r,a;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.show_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(a=this.get_node(t,!0),t.icon=a.length?a.children("a").children(".jstree-themeicon").attr("rel"):!0,t.icon||(t.icon=!0),a.children("a").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},e.vakata={},e.fn.vakata_reverse=[].reverse,e.vakata.attributes=function(t,n){t=e(t)[0];var r=n?{}:[];return e.each(t.attributes,function(t,a){-1===e.inArray(a.nodeName.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==a.nodeValue&&""!==e.trim(a.nodeValue)&&(n?r[a.nodeName]=a.nodeValue:r.push(a.nodeName))}),r},e.vakata.array_unique=function(e){var t=[],n,r,a;for(n=0,a=e.length;a>n;n++){for(r=0;n>=r;r++)if(e[n]===e[r])break;r===n&&t.push(e[n])}return t},e.vakata.array_remove=function(e,t,n){var r=e.slice((n||t)+1||e.length);return e.length=0>t?e.length+t:t,e.push.apply(e,r),e},function(){var t={},n=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},r=n(window.navigator.userAgent);r.browser&&(t[r.browser]=!0,t.version=r.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),e.vakata.browser=t}(),e.vakata.browser.msie&&8>e.vakata.browser.version&&(e.jstree.defaults.core.animation=0);var u=document.createElement("I");u.className="jstree-icon jstree-checkbox",e.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0},e.jstree.plugins.checkbox=function(t,n){this.bind=function(){n.bind.call(this),this._data.checkbox.uto=!1,this.element.on("init.jstree",e.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked")},this)).on("loading.jstree",e.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),this.settings.checkbox.three_state&&this.element.on("changed.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",e.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)},this)).on("model.jstree",e.proxy(function(t,n){var r=this._model.data,a=r[n.parent],i=n.nodes,s=[],o,d,l,c,h,_;if(a.state.selected){for(d=0,l=i.length;l>d;d++)r[i[d]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(i)}else for(d=0,l=i.length;l>d;d++)if(r[i[d]].state.selected){for(c=0,h=r[i[d]].children_d.length;h>c;c++)r[r[i[d]].children_d[c]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(r[i[d]].children_d)}for(d=0,l=a.children_d.length;l>d;d++)r[a.children_d[d]].children.length||s.push(r[a.children_d[d]].parent);for(s=e.vakata.array_unique(s),c=0,h=s.length;h>c;c++){a=r[s[c]];while(a&&"#"!==a.id){for(o=0,d=0,l=a.children.length;l>d;d++)o+=r[a.children[d]].state.selected;if(o!==l)break;a.state.selected=!0,this._data.core.selected.push(a.id),_=this.get_node(a,!0),_&&_.length&&_.children(".jstree-anchor").addClass("jstree-clicked"),a=this.get_node(a.parent)}}this._data.core.selected=e.vakata.array_unique(this._data.core.selected)},this)).on("select_node.jstree",e.proxy(function(t,n){var r=n.node,a=this._model.data,i=this.get_node(r.parent),s=this.get_node(r,!0),o,d,l,c;for(this._data.core.selected=e.vakata.array_unique(this._data.core.selected.concat(r.children_d)),o=0,d=r.children_d.length;d>o;o++)a[r.children_d[o]].state.selected=!0;while(i&&"#"!==i.id){for(l=0,o=0,d=i.children.length;d>o;o++)l+=a[i.children[o]].state.selected;if(l!==d)break;i.state.selected=!0,this._data.core.selected.push(i.id),c=this.get_node(i,!0),c&&c.length&&c.children(".jstree-anchor").addClass("jstree-clicked"),i=this.get_node(i.parent)}s.length&&s.find(".jstree-anchor").addClass("jstree-clicked")},this)).on("deselect_node.jstree",e.proxy(function(t,n){var r=n.node,a=this.get_node(r,!0),i,s,o;for(i=0,s=r.children_d.length;s>i;i++)this._model.data[r.children_d[i]].state.selected=!1;for(i=0,s=r.parents.length;s>i;i++)this._model.data[r.parents[i]].state.selected=!1,o=this.get_node(r.parents[i],!0),o&&o.length&&o.children(".jstree-anchor").removeClass("jstree-clicked");for(o=[],i=0,s=this._data.core.selected.length;s>i;i++)-1===e.inArray(this._data.core.selected[i],r.children_d)&&-1===e.inArray(this._data.core.selected[i],r.parents)&&o.push(this._data.core.selected[i]);this._data.core.selected=e.vakata.array_unique(o),a.length&&a.find(".jstree-anchor").removeClass("jstree-clicked")},this)).on("delete_node.jstree",e.proxy(function(e,t){var n=this.get_node(t.parent),r=this._model.data,a,i,s,o;while(n&&"#"!==n.id){for(s=0,a=0,i=n.children.length;i>a;a++)s+=r[n.children[a]].state.selected;if(s!==i)break;n.state.selected=!0,this._data.core.selected.push(n.id),o=this.get_node(n,!0),o&&o.length&&o.children(".jstree-anchor").addClass("jstree-clicked"),n=this.get_node(n.parent)}},this)).on("move_node.jstree",e.proxy(function(t,n){var r=n.is_multi,a=n.old_parent,i=this.get_node(n.parent),s=this._model.data,o,d,l,c,h;if(!r){o=this.get_node(a);while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d!==c)break;o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"),o=this.get_node(o.parent)}}o=i;while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d===c)o.state.selected||(o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"));else{if(!o.state.selected)break;o.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(o.id,this._data.core.selected)),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").removeClass("jstree-clicked")}o=this.get_node(o.parent)}},this))},this._undetermined=function(){var t,n,r=this._model.data,a=this._data.core.selected,i=[],s=this;for(t=0,n=a.length;n>t;t++)r[a[t]]&&r[a[t]].parents&&(i=i.concat(r[a[t]].parents));for(this.element.find(".jstree-closed").not(":has(ul)").each(function(){var e=s.get_node(this);!e.state.loaded&&e.original&&e.original.state&&e.original.state.undetermined&&e.original.state.undetermined===!0&&(i.push(e.id),i=i.concat(e.parents))}),i=e.vakata.array_unique(i),t=e.inArray("#",i),-1!==t&&(i=e.vakata.array_remove(i,t)),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),t=0,n=i.length;n>t;t++)r[i[t]].state.selected||(a=this.get_node(i[t],!0),a&&a.length&&a.children("a").children(".jstree-checkbox").addClass("jstree-undetermined"))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=t.getElementsByTagName("A")[0];i.insertBefore(u.cloneNode(),i.childNodes[0])}return!a&&this.settings.checkbox.three_state&&(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)),t},this.activate_node=function(t,r){return(this.settings.checkbox.whole_node||e(r.target).hasClass("jstree-checkbox"))&&(r.ctrlKey=!0),n.activate_node.call(this,t,r)},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.element.children("ul").removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.element.children("ul").addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()}},e.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(t){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.create_node(r,{},"last",function(e){setTimeout(function(){n.edit(e)},0)})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.edit(r)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.delete_node(n.get_selected()):n.delete_node(r)}},ccp:{separator_before:!0,icon:!1,separator_after:!1,label:"Edit",action:!1,submenu:{cut:{separator_before:!1,separator_after:!1,label:"Cut",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.cut(n.get_selected()):n.cut(r)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.copy(n.get_selected()):n.copy(r)}},paste:{separator_before:!1,icon:!1,_disabled:!this.can_paste(),separator_after:!1,label:"Paste",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.paste(r)}}}}}}},e.jstree.plugins.contextmenu=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("contextmenu.jstree","a",e.proxy(function(e){e.preventDefault(),this.is_loading(e.currentTarget)||this.show_contextmenu(e.currentTarget,e.pageX,e.pageY)},this)).on("click.jstree","a",e.proxy(function(t){this._data.contextmenu.visible&&e.vakata.context.hide()},this)),e(document).on("context_hide.vakata",e.proxy(function(){this._data.contextmenu.visible=!1},this))},this.teardown=function(){this._data.contextmenu.visible&&e.vakata.context.hide(),r.teardown.call(this)},this.show_contextmenu=function(n,r,a){if(n=this.get_node(n),!n||"#"===n.id)return!1;var i=this.settings.contextmenu,s=this.get_node(n,!0),o=s.children(".jstree-anchor"),d=!1,l=!1;(i.show_at_node||r===t||a===t)&&(d=o.offset(),r=d.left,a=d.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(n)&&(this.deselect_all(),this.select_node(n)),l=i.items,e.isFunction(l)&&(l=l.call(this,n)),e(document).one("context_show.vakata",e.proxy(function(t,n){var r="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";e(n.element).addClass(r)},this)),this._data.contextmenu.visible=!0,e.vakata.context.show(o,{x:r,y:a},l),this.trigger("show_contextmenu",{node:n,x:r,y:a})}},function(e){var n=!1,r={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};e.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(t){e(document).triggerHandler("context_"+t+".vakata",{reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}})},_execute:function(e){return e=r.items[e],e&&!e._disabled&&e.action?e.action.call(null,{item:e,reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}}):!1},_parse:function(n,a){if(!n)return!1;a||(r.html="",r.items=[]);var i="",s=!1,o;return a&&(i+=""),a||(r.html=i,e.vakata.context._trigger("parse")),i.length>10?i:!1},_show_submenu:function(t){if(t=e(t),t.length&&t.children("ul").length){var r=t.children("ul"),a=t.offset().left+t.outerWidth(),i=t.offset().top,s=r.width(),o=r.height(),d=e(window).width()+e(window).scrollLeft(),l=e(window).height()+e(window).scrollTop();n?t[0>a-(s+10+t.outerWidth())?"addClass":"removeClass"]("vakata-context-left"):t[a+s+10>d?"addClass":"removeClass"]("vakata-context-right"),i+o+10>l&&r.css("bottom","-1px"),r.show()}},show:function(t,a,i){var s,o,d,l,c,h,_,u,g=!0;switch(r.element&&r.element.length&&r.element.width(""),g){case!a&&!t:return!1;case!!a&&!!t:r.reference=t,r.position_x=a.x,r.position_y=a.y;break;case!a&&!!t:r.reference=t,s=t.offset(),r.position_x=s.left+t.outerHeight(),r.position_y=s.top;break;case!!a&&!t:r.position_x=a.x,r.position_y=a.y}t&&!i&&e(t).data("vakata_contextmenu")&&(i=e(t).data("vakata_contextmenu")),e.vakata.context._parse(i)&&r.element.html(r.html),r.items.length&&(o=r.element,d=r.position_x,l=r.position_y,c=o.width(),h=o.height(),_=e(window).width()+e(window).scrollLeft(),u=e(window).height()+e(window).scrollTop(),n&&(d-=o.outerWidth(),e(window).scrollLeft()+20>d&&(d=e(window).scrollLeft()+20)),d+c+20>_&&(d=_-(c+20)),l+h+20>u&&(l=u-(h+20)),r.element.css({left:d,top:l}).show().find("a:eq(0)").focus().parent().addClass("vakata-context-hover"),r.is_visible=!0,e.vakata.context._trigger("show"))},hide:function(){r.is_visible&&(r.element.hide().find("ul").hide().end().find(":focus").blur(),r.is_visible=!1,e.vakata.context._trigger("hide"))}},e(function(){n="rtl"===e("body").css("direction");var t=!1,a='.vakata-context { display:none; _width:1px; } .vakata-context, .vakata-context ul { margin:0; padding:2px; position:absolute; background:#f5f5f5; border:1px solid #979797; -moz-box-shadow:5px 5px 4px -4px #666666; -webkit-box-shadow:2px 2px 2px #999999; box-shadow:2px 2px 2px #999999; }.vakata-context ul { list-style:none; left:100%; margin-top:-2.7em; margin-left:-4px; } .vakata-context li.vakata-context-right ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context li { list-style:none; display:inline; }.vakata-context li a { display:block; padding:0 2em 0 2em; text-decoration:none; width:auto; color:black; white-space:nowrap; line-height:2.4em; -moz-text-shadow:1px 1px 0px white; -webkit-text-shadow:1px 1px 0px white; text-shadow:1px 1px 0px white; -moz-border-radius:1px; -webkit-border-radius:1px; border-radius:1px; }.vakata-context li a:hover { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li.vakata-context-hover > a { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); background-position:right center; background-repeat:no-repeat; } .vakata-context li.vakata-context-separator a, .vakata-context li.vakata-context-separator a:hover { background:white; border:0; border-top:1px solid #e2e3e3; height:1px; min-height:1px; max-height:1px; padding:0; margin:0 0 0 2.4em; border-left:1px solid #e0e0e0; _overflow:hidden; -moz-text-shadow:0 0 0 transparent; -webkit-text-shadow:0 0 0 transparent; text-shadow:0 0 0 transparent; -moz-box-shadow:0 0 0 transparent; -webkit-box-shadow:0 0 0 transparent; box-shadow:0 0 0 transparent; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0; }.vakata-context li.vakata-contextmenu-disabled a, .vakata-context li.vakata-contextmenu-disabled a:hover { color:silver; background-color:transparent; border:0; box-shadow:0 0 0; }.vakata-context li a ins { text-decoration:none; display:inline-block; width:2.4em; height:2.4em; background:transparent; margin:0 0 0 -2em; } .vakata-context li a span { display:inline-block; width:1px; height:2.4em; background:white; margin:0 0.5em 0 0; border-left:1px solid #e2e3e3; _overflow:hidden; } .vakata-context-rtl ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context-rtl li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); background-position:left center; background-repeat:no-repeat; } .vakata-context-rtl li.vakata-context-separator a { margin:0 2.4em 0 0; border-left:0; border-right:1px solid #e2e3e3;} .vakata-context-rtl li.vakata-context-left ul { right:auto; left:100%; margin-left:-4px; margin-right:auto; } .vakata-context-rtl li a ins { margin:0 -2em 0 0; } .vakata-context-rtl li a span { margin:0 0 0 0.5em; border-left-color:white; background:#e2e3e3; } ';e.jstree.no_css||e("head").append('"),r.element=e("
      "),r.element.on("mouseenter","li",function(n){n.stopImmediatePropagation(),e.contains(this,n.relatedTarget)||(t&&clearTimeout(t),r.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),e(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),e.vakata.context._show_submenu(this))}).on("mouseleave","li",function(t){e.contains(this,t.relatedTarget)||e(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(n){e(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),e.vakata.context.settings.hide_onmouseleave&&(t=setTimeout(function(t){return function(){e.vakata.context.hide()}}(this),e.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(e){e.preventDefault()}).on("mouseup","a",function(t){e(this).blur().parent().hasClass("vakata-context-disabled")||e.vakata.context._execute(e(this).attr("rel"))===!1||e.vakata.context.hide()}).on("keydown","a",function(t){var n=null;switch(t.which){case 13:case 32:t.type="mouseup",t.preventDefault(),e(t.currentTarget).trigger(t);break;case 37:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 39:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 27:e.vakata.context.hide(),t.preventDefault();break;default:}}).appendTo("body"),e(document).on("mousedown",function(t){r.is_visible&&!e.contains(r.element[0],t.target)&&e.vakata.context.hide()}).on("context_show.vakata",function(e,t){r.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),n&&r.element.addClass("vakata-context-rtl").css("direction","rtl"),r.element.find("ul").hide().end()})})}(e),e.jstree.defaults.dnd={copy:!0,open_timeout:500},e.jstree.plugins.dnd=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("mousedown","a",e.proxy(function(n){var r=this.get_node(n.target),a=this.is_selected(r)?this.get_selected().length:1;return r&&r.id&&"#"!==r.id&&1===n.which?(this.element.trigger("mousedown.jstree"),e.vakata.dnd.start(n,{jstree:!0,origin:this,obj:this.get_node(r,!0),nodes:a>1?this.get_selected():[r.id]},'
      '+(a>1?a+" "+this.get_string("nodes"):this.get_text(n.currentTarget,!0))+'
      ')):t},this))}},e(function(){var n=!1,r=!1,a=e('
       
      ').hide().appendTo("body");e(document).bind("dnd_start.vakata",function(e,t){n=!1}).bind("dnd_move.vakata",function(i,s){if(r&&clearTimeout(r),s.data.jstree&&(!s.event.target.id||"jstree-marker"!==s.event.target.id)){var o=e.jstree.reference(s.event.target),d=!1,l=!1,c=!1,h,_,u,g,f,p,m,v,j,x,y,k;if(o&&o._data&&o._data.dnd)if(a.attr("class","jstree-"+o.get_theme()),s.helper.children().attr("class","jstree-"+o.get_theme()).find(".jstree-copy:eq(0)")[s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"show":"hide"](),s.event.target!==o.element[0]&&s.event.target!==o.get_container_ul()[0]||0!==o.get_container_ul().children().length){if(d=e(s.event.target).closest("a"),d&&d.length&&d.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(l=d.offset(),c=s.event.pageY-l.top,u=d.height(),p=u/3>c?["b","i","a"]:c>u-u/3?["a","i","b"]:c>u/2?["i","a","b"]:["i","b","a"],e.each(p,function(i,c){switch(c){case"b":h=l.left-6,_=l.top-5,g=o.get_parent(d),f=d.parent().index();break;case"i":h=l.left-2,_=l.top-5+u/2+1,g=d.parent(),f=0;break;case"a":h=l.left-6,_=l.top-5+u,g=o.get_parent(d),f=d.parent().index()+1}for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(x=s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",y=f,"move_node"===x&&"a"===c&&s.data.origin===o&&g===o.get_parent(s.data.nodes[v])&&(k=o.get_node(g),y>e.inArray(s.data.nodes[v],k.children)&&(y-=1)),m=m&&o.check(x,s.data.nodes[v],g,y),!m)break;return m?("i"===c&&d.parent().is(".jstree-closed")&&o.settings.dnd.open_timeout&&(r=setTimeout(function(e,t){return function(){e.open_node(t)}}(o,d),o.settings.dnd.open_timeout)),n={ins:o,par:g,pos:f},a.css({left:h+"px",top:_+"px"}).show(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),p=!0,!1):t}),p===!0))return}else{for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(m=m&&o.check(s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",s.data.nodes[v],"#","last"),!m)break;if(m)return n={ins:o,par:"#",pos:"last"},a.hide(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),t +}n=!1,s.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),a.hide()}}).bind("dnd_scroll.vakata",function(e,t){t.data.jstree&&(a.hide(),n=!1,t.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er"))}).bind("dnd_stop.vakata",function(e,t){r&&clearTimeout(r),t.data.jstree&&(a.hide(),n&&n.ins[t.data.origin.settings.dnd.copy&&(t.event.metaKey||t.event.ctrlKey)?"copy_node":"move_node"](t.data.nodes,n.par,n.pos))}).bind("keyup keydown",function(t,n){n=e.vakata.dnd._get(),n.data&&n.data.jstree&&n.helper.find(".jstree-copy:eq(0)")[n.data.origin.settings.dnd.copy&&(t.metaKey||t.ctrlKey)?"show":"hide"]()})}),function(e){e.fn.vakata_reverse=[].reverse;var n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1};e.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5},_trigger:function(t,n){var r=e.vakata.dnd._get();r.event=n,e(document).triggerHandler("dnd_"+t+".vakata",r)},_get:function(){return{data:n.data,element:n.element,helper:n.helper}},_clean:function(){n.helper&&n.helper.remove(),n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1},e(document).unbind("mousemove",e.vakata.dnd.drag),e(document).unbind("mouseup",e.vakata.dnd.stop)},_scroll:function(t){if(!n.scroll_e||!n.scroll_l&&!n.scroll_t)return n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),!1;if(!n.scroll_i)return n.scroll_i=setInterval(e.vakata.dnd._scroll,100),!1;if(t===!0)return!1;var r=n.scroll_e.scrollTop(),a=n.scroll_e.scrollLeft();n.scroll_e.scrollTop(r+n.scroll_t*e.vakata.dnd.settings.scroll_speed),n.scroll_e.scrollLeft(a+n.scroll_l*e.vakata.dnd.settings.scroll_speed),(r!==n.scroll_e.scrollTop()||a!==n.scroll_e.scrollLeft())&&e.vakata.dnd._trigger("scroll",n.scroll_e)},start:function(t,r,a){n.is_drag&&e.vakata.dnd.stop({});try{t.currentTarget.unselectable="on",t.currentTarget.onselectstart=function(){return!1},t.currentTarget.style&&(t.currentTarget.style.MozUserSelect="none")}catch(i){}return n.init_x=t.pageX,n.init_y=t.pageY,n.data=r,n.is_down=!0,n.element=t.currentTarget,a!==!1&&(n.helper=e("
      ").html(a).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),e(document).bind("mousemove",e.vakata.dnd.drag),e(document).bind("mouseup",e.vakata.dnd.stop),!1},drag:function(r){if(n.is_down){if(!n.is_drag){if(!(Math.abs(r.pageX-n.init_x)>e.vakata.dnd.settings.threshold||Math.abs(r.pageY-n.init_y)>e.vakata.dnd.settings.threshold))return;n.helper&&(n.helper.appendTo("body"),n.helper_w=n.helper.outerWidth()),n.is_drag=!0,e.vakata.dnd._trigger("start",r)}var a=!1,i=!1,s=!1,o=!1,d=!1,l=!1,c=!1,h=!1,_=!1,u=!1;n.scroll_t=0,n.scroll_l=0,n.scroll_e=!1,e(r.target).parentsUntil("body").addBack().vakata_reverse().filter(function(){return/^auto|scroll$/.test(e(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var a=e(this),i=a.offset();return this.scrollHeight>this.offsetHeight&&(i.top+a.height()-r.pageYthis.offsetWidth&&(i.left+a.width()-r.pageXo&&r.pageY-co&&o-(r.pageY-c)l&&r.pageX-hl&&l-(r.pageX-h)s&&(_=s-50),d&&u+n.helper_w>d&&(u=d-(n.helper_w+2)),n.helper.css({left:u+"px",top:_+"px"})),e.vakata.dnd._trigger("move",r)}},stop:function(t){n.is_drag&&e.vakata.dnd._trigger("stop",t),e.vakata.dnd._clean()}}}(jQuery),e.jstree.defaults.search={ajax:!1,fuzzy:!0,case_sensitive:!1,show_only_matches:!1},e.jstree.plugins.search=function(t,n){this.bind=function(){n.bind.call(this),this._data.search.str="",this._data.search.dom=e(),this._data.search.res=[],this.settings.search.show_only_matches&&this.element.on("search.jstree",function(t,n){n.nodes.length&&(e(this).find("li").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last"),n.nodes.parentsUntil(".jstree").addBack().show().filter("ul").each(function(){e(this).children("li:visible").eq(-1).addClass("jstree-last")}))}).on("clear_search.jstree",function(t,n){n.nodes.length&&e(this).find("li").css("display","").filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last")})},this.search=function(t,n){if(t===!1||""===e.trim(t))return this.clear_search();var r=this.settings.search,a=r.ajax?e.extend({},r.ajax):!1,i=null,s=[],o=[],d,l;if(this._data.search.res.length&&this.clear_search(),!n&&a!==!1)return a.data||(a.data={}),a.data.str=t,e.ajax(r.ajax).done(e.proxy(function(e){this._search_load(e,t)},this));if(this._data.search.str=t,this._data.search.dom=e(),this._data.search.res=[],i=new e.vakata.search(t,!0,{caseSensitive:r.case_sensitive,fuzzy:r.fuzzy}),e.each(this._model.data,function(e,t){t.text&&i.search(t.text).isMatch&&(s.push(e),o=o.concat(t.parents))}),s.length){for(o=e.vakata.array_unique(o),this._search_open(o),d=0,l=s.length;l>d;d++)i=this.get_node(s[d],!0),i&&(this._data.search.dom=this._data.search.dom.add(i));this._data.search.res=s,this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:t,res:this._data.search.res})},this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"),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.dom=e()},this._search_open=function(t){var n=this;e.each(t.concat([]),function(e,r){r=document.getElementById(r),r&&n.is_closed(r)&&n.open_node(r,function(){n._search_open(t)})})},this._search_load=function(t,n){var r=!0,a=this,i=a._model.data;e.each(t.concat([]),function(e,s){i[s]&&(i[s].state.loaded||(a.load_node(s,function(){a._search_load(t,n)}),r=!1))}),r&&this.search(n,!0)}},function(e){e.vakata.search=function(e,t,n){n=n||{},n.fuzzy!==!1&&(n.fuzzy=!0),e=n.caseSensitive?e:e.toLowerCase();var r=n.location||0,a=n.distance||100,i=n.threshold||.6,s=e.length,o,d,l,c;return s>32&&(n.fuzzy=!1),n.fuzzy&&(o=1<n;n++)t[e.charAt(n)]=0;for(n=0;s>n;n++)t[e.charAt(n)]|=1<a;a++){g=0,f=p;while(f>g)_>=l(a,r+f)?g=f:p=f,f=Math.floor((p-g)/2+g);for(p=f,v=Math.max(1,r-f+1),j=Math.min(r+f,h)+s,x=Array(j+2),x[j+1]=(1<=v;c--)if(y=d[t.charAt(c-1)],x[c]=0===a?(1|x[c+1]<<1)&y:(1|x[c+1]<<1)&y|(1|(m[c+1]|m[c])<<1)|m[c+1],x[c]&o&&(k=l(a,c-1),_>=k)){if(_=k,u=c-1,b.push(u),!(u>r))break;v=Math.max(1,2*r-u)}if(l(a+1,r)>_)break;m=x}return{isMatch:u>=0,score:k}},t===!0?{search:c}:c(t)}}(jQuery),e.jstree.defaults.sort=function(e,t){return this.get_text(e)>this.get_text(t)?1:-1},e.jstree.plugins.sort=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",e.proxy(function(e,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",e.proxy(function(e,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,n){var r,a;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(e.proxy(this.settings.sort,this)),n))for(r=0,a=t.children_d.length;a>r;r++)this.sort(t.children_d[r],!1)}};var g=!1;e.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:!1},e.jstree.plugins.state=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("ready.jstree",e.proxy(function(t,n){this.element.one("restore_state.jstree set_state.jstree",e.proxy(function(){this.element.on(this.settings.state.events,e.proxy(function(){g&&clearTimeout(g),g=setTimeout(e.proxy(function(){this.save_state()},this),100)},this))},this)),this.restore_state()},this))},this.save_state=function(){e.vakata.storage.set(this.settings.state.key,this.get_state(),this.settings.state.ttl)},this.restore_state=function(){var t=e.vakata.storage.get(this.settings.state.key);t&&this.set_state(t),this.trigger("restore_state",{state:t})},this.clear_state=function(){return e.vakata.storage.del(this.settings.state.key)}},function(e,t){var n=function(e){var t=/["\\\x00-\x1f\x7f-\x9f]/g,n={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return e.match(t)?'"'+e.replace(t,function(e){var t=n[e];return"string"==typeof t?t:(t=e.charCodeAt(),"\\u00"+Math.floor(t/16).toString(16)+(t%16).toString(16))})+'"':'"'+e+'"'};e.vakata.json={encode:JSON&&JSON.stringify?JSON.stringify:function(r){if(null===r)return"null";var a=[],i;switch(typeof r){case"undefined":return t;case"number":case"boolean":return""+r;case"string":return n(r);case"object":if(e.isFunction(r.toJSON))return e.vakata.json.encode(r.toJSON());if(r.constructor===Date)return'"'+r.getUTCFullYear()+"-"+("0"+(r.getUTCMonth()+1)+"").slice(-2)+"-"+("0"+r.getUTCDate()+"").slice(-2)+"T"+("0"+r.getUTCHours()+"").slice(-2)+":"+("0"+r.getUTCMinutes()+"").slice(-2)+":"+("0"+r.getUTCSeconds()+"").slice(-2)+"."+("00"+r.getUTCMilliseconds()+"").slice(-3)+'Z"';if(r.constructor===Array){for(i=0;r.length>i;i++)a.push(e.vakata.json.encode(r[i])||"null");return"["+a.join(",")+"]"}return e.each(r,function(r,i){return e.isFunction(i)?!0:(r="number"==typeof r?'"'+r+'"':n(r),i=e.vakata.json.encode(i),a.push(r+":"+i),t)}),"{"+a.join(", ")+"}"}},decode:JSON&&JSON.parse?JSON.parse:function(t){return e.parseJSON(t)}}}(jQuery),function(e,t,n){var r=function(e){return e},a=function(e){return decodeURIComponent(e.replace(/\+/g," "))},i=e.vakata.cookie=function(s,o,d){var l,c,h,_,u,g,f,p;if(o!==n)return d=e.extend({},i.defaults,d),null===o&&(d.expires=-1),"number"==typeof d.expires&&(l=d.expires,c=d.expires=new Date,c.setDate(c.getDate()+l)),o=i.json?e.vakata.json.encode(o):o+"",o=[encodeURIComponent(s),"=",i.raw?o:encodeURIComponent(o),d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join(""),t.cookie=o,o;for(h=i.raw?r:a,_=t.cookie.split("; "),u=0,g=_.length;g>u;u++)if(f=_[u].split("="),h(f.shift())===s)return p=h(f.join("=")),i.json?e.vakata.json.decode(p):p;return null};i.defaults={},e.vakata.removeCookie=function(t,n){return null!==e.vakata.cookie(t)?(e.vakata.cookie(t,null,n),!0):!1}}(jQuery,document),function(e,t){var n={},r={jStorage:"{}"},a=null,i=0,s=e.vakata.json.encode,o=e.vakata.json.decode,d=!1,l=!1;function c(){if(r.jStorage)try{n=o(r.jStorage+"")}catch(e){r.jStorage="{}"}else r.jStorage="{}";i=r.jStorage?(r.jStorage+"").length:0}function h(){try{r.jStorage=s(n),"userDataBehavior"===d&&(a.setAttribute("jStorage",r.jStorage),a.save("jStorage")),"cookie"===d&&e.vakata.cookie("__vjstorage",r.jStorage,{expires:365}),i=r.jStorage?(r.jStorage+"").length:0}catch(t){}}function _(e){if(!e||"string"!=typeof e&&"number"!=typeof e)throw new TypeError("Key name must be string or numeric");if("__jstorage_meta"===e)throw new TypeError("Reserved key name");return!0}function u(){var e=+new Date,t,r,a=1/0,i=!1;if(l!==!1&&clearTimeout(l),n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL){r=n.__jstorage_meta.TTL;for(t in r)r.hasOwnProperty(t)&&(e>=r[t]?(delete r[t],delete n[t],i=!0):a>r[t]&&(a=r[t]));1/0!==a&&(l=setTimeout(u,a-e)),i&&h()}}function g(){var n=!1,i;if(window.hasOwnProperty("localStorage"))try{window.localStorage.setItem("_tmptest","tmpval"),n=!0,window.localStorage.removeItem("_tmptest")}catch(s){}if(n)try{window.localStorage&&(r=window.localStorage,d="localStorage")}catch(s){}else if(window.hasOwnProperty("globalStorage"))try{window.globalStorage&&(r=window.globalStorage[window.location.hostname],d="globalStorage")}catch(s){}else{if(a=document.createElement("link"),a.addBehavior){a.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(a);try{a.load("jStorage"),i="{}",i=a.getAttribute("jStorage"),r.jStorage=i,d="userDataBehavior"}catch(s){}}if(!d&&(e.vakata.cookie("__vjstorage")||e.vakata.cookie("__vjstorage","{}",{expires:365})&&"{}"===e.vakata.cookie("__vjstorage"))&&(a=null,r.jStorage=e.vakata.cookie("__vjstorage"),d="cookie"),!d)return a=null,t}c(),u()}e.vakata.storage={version:"0.3.0",set:function(t,r,a){return _(t),"object"==typeof r&&(r=o(s(r))),n[t]=r,h(),a&&parseInt(a,10)&&e.vakata.storage.setTTL(t,parseInt(a,10)),r},get:function(e,r){return _(e),n.hasOwnProperty(e)?n[e]:r===t?null:r},del:function(e){return _(e),n.hasOwnProperty(e)?(delete n[e],n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL.hasOwnProperty(e)&&delete n.__jstorage_meta.TTL[e],h(),!0):!1},setTTL:function(e,t){var r=+new Date;return _(e),t=Number(t)||0,n.hasOwnProperty(e)?(n.__jstorage_meta||(n.__jstorage_meta={}),n.__jstorage_meta.TTL||(n.__jstorage_meta.TTL={}),t>0?n.__jstorage_meta.TTL[e]=r+t:delete n.__jstorage_meta.TTL[e],h(),u(),!0):!1},getTTL:function(e){var t=+new Date,r;return _(e),n.hasOwnProperty(e)&&n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL[e]?(r=n.__jstorage_meta.TTL[e]-t,r||0):0},flush:function(){return n={},h(),!0},storageObj:function(){return e.extend(!0,{},n)},index:function(){var t=[];return e.each(n,function(e,n){"__jstorage_meta"!==e&&t.push(e)}),t},storageSize:function(){return i},currentBackend:function(){return d},storageAvailable:function(){return!!d}},g()}(jQuery),e.jstree.defaults.types={"#":{},"default":{}},e.jstree.plugins.types=function(n,r){this.init=function(e,t){r.init.call(this,e,t),this._model.data["#"].type="#"},this.bind=function(){r.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){var n=this._model.data,r=t.nodes,a=this.settings.types,i,s,o="default";for(i=0,s=r.length;s>i;i++)o="default",n[r[i]].original&&n[r[i]].original.type&&a[n[r[i]].original.type]&&(o=n[r[i]].original.type),n[r[i]].data&&n[r[i]].data.jstree&&n[r[i]].data.jstree.type&&a[n[r[i]].data.jstree.type]&&(o=n[r[i]].data.jstree.type),n[r[i]].type=o,n[r[i]].icon===!0&&a[o].icon&&(n[r[i]].icon=a[o].icon)},this))},this.check=function(n,a,i,s){if(r.check.call(this,n,a,i,s)===!1)return!1;a=a&&a.id?a:this.get_node(a),i=i&&i.id?i:this.get_node(i);var o=this._model.data,d,l,c,h;switch(n){case"create_node":case"move_node":case"copy_node":if("move_node"!==n||-1===e.inArray(a.id,i.children)){if(d=this.get_rules(i),d.max_children!==t&&-1!==d.max_children&&d.max_children===i.children.length)return!1;if(d.valid_children!==t&&-1!==d.valid_children&&-1===e.inArray(a.type,d.valid_children))return!1;if(a.children_d&&a.parents){for(l=0,c=0,h=a.children_d.length;h>c;c++)l=Math.max(l,o[a.children_d[c]].parents.length);l=l-a.parents.length+1}0>=l&&(l=1);do{if(d.max_depth!==t&&-1!==d.max_depth&&l>d.max_depth)return!1;i=this.get_node(i.parent),d=this.get_rules(i),l++}while(i)}}return!0},this.get_rules=function(e){if(e=this.get_node(e),!e)return!1;var n=this.get_type(e,!0);return n.max_depth===t&&(n.max_depth=-1),n.max_children===t&&(n.max_children=-1),n.valid_children===t&&(n.valid_children=-1),n},this.get_type=function(t,n){return t=this.get_node(t),t?n?e.extend({type:t.type},this.settings.types[t.type]):t.type:!1},this.set_type=function(t,n){var r,a,i;if(e.isArray(t)){for(a=0,i=t.length;i>a;a++)this.set_type(t[a],n);return!0}return r=this.settings.types,t=this.get_node(t),r[n]&&t?(t.type=n,r[n].icon&&this.get_icon(t)===!0&&this.set_icon(t,r[n].icon),!0):!1}},e.jstree.plugins.unique=function(t,n){this.check=function(t,r,a,i){if(n.check.call(this,t,r,a,i)===!1)return!1;if(r=r&&r.id?r:this.get_node(r),a=a&&a.id?a:this.get_node(a),!a||!a.children)return!0;var s="rename_node"===t?i:r.text,o=[],d=this._model.data,l,c;for(l=0,c=a.children.length;c>l;l++)o.push(d[a.children[l]].text);switch(t){case"delete_node":return!0;case"rename_node":case"copy_node":return-1===e.inArray(s,o);case"move_node":return r.parent===a.id||-1===e.inArray(s,o)}return!0}};var f=document.createElement("DIV");f.setAttribute("unselectable","on"),f.className="jstree-wholerow",f.innerHTML=" ",e.jstree.plugins.wholerow=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("loading",e.proxy(function(){f.style.height=this._data.core.li_height+"px"},this)).on("ready.jstree set_state.jstree",e.proxy(function(){this.hide_dots()},this)).on("ready.jstree",e.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var n=!1,r,a;for(r=0,a=t.selected.length;a>r;r++)n=this.get_node(t.selected[r],!0),n&&n.length&&n.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",e.proxy(function(e,t){this.get_node(t.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",e.proxy(function(t,n){this.element.find(".jstree-wholerow-hovered").removeClass("jstree-wholerow-hovered"),"hover_node"===t.type&&this.get_node(n.node,!0).each(function(){e(this).children(".jstree-wholerow").addClass("jstree-wholerow-hovered")})},this)).on("contextmenu.jstree",".jstree-wholerow",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).closest("li").children("a:eq(0)").trigger("contextmenu",t)},this)).on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",e.proxy(function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",e.proxy(function(e){return e.stopImmediatePropagation(),this.hover_node(e.currentTarget),!1},this)).on("mouseleave.jstree","li",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&(this.element.find(".jstree-wholerow").remove(),n.teardown.call(this))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=f.cloneNode(!0);-1!==e.inArray(t.id,this._data.core.selected)&&(i.className+=" jstree-wholerow-clicked"),t.insertBefore(i,t.childNodes[0])}return t}}}}); \ No newline at end of file diff --git a/docs/ajax_children.json b/docs/ajax_children.json deleted file mode 100644 index cc6e12ea..00000000 --- a/docs/ajax_children.json +++ /dev/null @@ -1 +0,0 @@ -["Child 1","Child 2"] \ No newline at end of file diff --git a/docs/assets/ajax_children.json b/docs/assets/ajax_children.json new file mode 100644 index 00000000..555ab903 --- /dev/null +++ b/docs/assets/ajax_children.json @@ -0,0 +1 @@ +["Child 1", { "text" : "Child 2", "children" : ["One more"] }] \ No newline at end of file diff --git a/docs/assets/ajax_demo_children.json b/docs/assets/ajax_demo_children.json new file mode 100644 index 00000000..3239c8e0 --- /dev/null +++ b/docs/assets/ajax_demo_children.json @@ -0,0 +1 @@ +["Child 1", { "id" : "demo_child_1", "text" : "Child 2", "children" : [ { "id" : "demo_child_2", "text" : "One more", "type" : "file" }] }] \ No newline at end of file diff --git a/docs/assets/ajax_demo_roots.json b/docs/assets/ajax_demo_roots.json new file mode 100644 index 00000000..c58fd39c --- /dev/null +++ b/docs/assets/ajax_demo_roots.json @@ -0,0 +1,4 @@ +[ + { "id" : "demo_root_1", "text" : "Root 1", "children" : true, "type" : "root" }, + { "id" : "demo_root_2", "text" : "Root 2", "type" : "root" } +] \ No newline at end of file diff --git a/docs/ajax_nodes.html b/docs/assets/ajax_nodes.html similarity index 100% rename from docs/ajax_nodes.html rename to docs/assets/ajax_nodes.html diff --git a/docs/ajax_roots.json b/docs/assets/ajax_roots.json similarity index 100% rename from docs/ajax_roots.json rename to docs/assets/ajax_roots.json diff --git a/docs/assets/dist/jstree.js b/docs/assets/dist/jstree.js new file mode 100644 index 00000000..b542de08 --- /dev/null +++ b/docs/assets/dist/jstree.js @@ -0,0 +1,5731 @@ +/*globals jQuery, define, exports, require, window, document */ +(function (factory) { + "use strict"; + if (typeof define === 'function' && define.amd) { + define('jstree', ['jquery'], factory); + } + else if(typeof exports === 'object') { + factory(require('jquery')); + } + else { + factory(jQuery); + } +}(function ($, undefined) { + "use strict"; +/*! + * jsTree 3.0.0 + * http://jstree.com/ + * + * Copyright (c) 2013 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 + */ + + // prevent another load? maybe there is a better way? + if($.jstree) { + return; + } + + /** + * ### jsTree core functionality + */ + + // internal variables + var instance_counter = 0, + total_nodes = 0, + ccp_node = false, + ccp_mode = false, + ccp_inst = false, + themes_loaded = [], + src = $('script:last').attr('src'), + _d = document, _node = _d.createElement('LI'), _temp1, _temp2; + + _node.setAttribute('role', 'treeitem'); + _temp1 = _d.createElement('I'); + _temp1.className = 'jstree-icon jstree-ocl'; + _node.appendChild(_temp1); + _temp1 = _d.createElement('A'); + _temp1.className = 'jstree-anchor'; + _temp1.setAttribute('href','#'); + _temp2 = _d.createElement('I'); + _temp2.className = 'jstree-icon jstree-themeicon'; + _temp1.appendChild(_temp2); + _node.appendChild(_temp1); + _temp1 = _temp2 = null; + + + /** + * holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances. + * @name $.jstree + */ + $.jstree = { + /** + * specifies the jstree version in use + * @name $.jstree.version + */ + version : '3.0.0-alpha', + /** + * holds all the default options used when creating new instances + * @name $.jstree.defaults + */ + defaults : { + /** + * configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]` + * @name $.jstree.defaults.plugins + */ + plugins : [] + }, + /** + * stores all loaded jstree plugins (used internally) + * @name $.jstree.plugins + */ + plugins : {}, + path : src && src.indexOf('/') !== -1 ? src.replace(/\/[^\/]+$/,'') : '' + }; + /** + * creates a jstree instance + * @name $.jstree.create(el [, options]) + * @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector + * @param {Object} options options for this instance (extends `$.jstree.defaults`) + * @return {jsTree} the new instance + */ + $.jstree.create = function (el, options) { + var tmp = new $.jstree.core(++instance_counter), + opt = options; + options = $.extend(true, {}, $.jstree.defaults, options); + if(opt && opt.plugins) { + options.plugins = opt.plugins; + } + $.each(options.plugins, function (i, k) { + if(i !== 'core') { + tmp = tmp.plugin(k, options[k]); + } + }); + tmp.init(el, options); + return tmp; + }; + /** + * the jstree class constructor, used only internally + * @private + * @name $.jstree.core(id) + * @param {Number} id this instance's index + */ + $.jstree.core = function (id) { + this._id = id; + this._data = { + core : { + themes : { + name : false, + dots : false, + icons : false + }, + selected : [] + } + }; + }; + /** + * get a reference to an existing instance + * + * __Examples__ + * + * // provided a container with an ID of "tree", and a nested node with an ID of "branch" + * // all of there will return the same instance + * $.jstree.reference('tree'); + * $.jstree.reference('#tree'); + * $.jstree.reference($('#tree')); + * $.jstree.reference(document.getElementByID('tree')); + * $.jstree.reference('branch'); + * $.jstree.reference('#branch'); + * $.jstree.reference($('#branch')); + * $.jstree.reference(document.getElementByID('branch')); + * + * @name $.jstree.reference(needle) + * @param {DOMElement|jQuery|String} needle + * @return {jsTree|null} the instance or `null` if not found + */ + $.jstree.reference = function (needle) { + if(needle && !$(needle).length) { + if(needle.id) { + needle = needle.id; + } + var tmp = null; + $('.jstree').each(function () { + var inst = $(this).data('jstree'); + if(inst && inst._model.data[needle]) { + tmp = inst; + return false; + } + }); + return tmp; + } + return $(needle).closest('.jstree').data('jstree'); + }; + /** + * Create an instance, get an instance or invoke a command on a instance. + * + * If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken). + * + * If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function). + * + * If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`). + * + * In any other case - nothing is returned and chaining is not broken. + * + * __Examples__ + * + * $('#tree1').jstree(); // creates an instance + * $('#tree2').jstree({ plugins : [] }); // create an instance with some options + * $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments + * $('#tree2').jstree(); // get an existing instance (or create an instance) + * $('#tree2').jstree(true); // get an existing instance (will not create new instance) + * $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method) + * + * @name $().jstree([arg]) + * @param {String|Object} arg + * @return {Mixed} + */ + $.fn.jstree = function (arg) { + // check for string argument + var is_method = (typeof arg === 'string'), + args = Array.prototype.slice.call(arguments, 1), + result = null; + this.each(function () { + // get the instance (if there is one) and method (if it exists) + var instance = $.jstree.reference(this), + method = is_method && instance ? instance[arg] : null; + // if calling a method, and method is available - execute on the instance + result = is_method && method ? + method.apply(instance, args) : + null; + // if there is no instance and no method is being called - create one + if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) { + $(this).data('jstree', new $.jstree.create(this, arg)); + } + // if there is an instance and no method is called - return the instance + if(instance && !is_method) { + result = instance; + } + // if there was a method call which returned a result - break and return the value + if(result !== null && result !== undefined) { + return false; + } + }); + // if there was a method call with a valid return value - return that, otherwise continue the chain + return result !== null && result !== undefined ? + result : this; + }; + /** + * used to find elements containing an instance + * + * __Examples__ + * + * $('div:jstree').each(function () { + * $(this).jstree('destroy'); + * }); + * + * @name $(':jstree') + * @return {jQuery} + */ + $.expr[':'].jstree = $.expr.createPseudo(function(search) { + return function(a) { + return $(a).hasClass('jstree') && + $(a).data('jstree') !== undefined; + }; + }); + + /** + * stores all defaults for the core + * @name $.jstree.defaults.core + */ + $.jstree.defaults.core = { + /** + * data configuration + * + * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items). + * + * You can also pass in a HTML string or a JSON array here. + * + * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree. + * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used. + * + * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result. + * + * __Examples__ + * + * // AJAX + * $('#tree').jstree({ + * 'core' : { + * 'data' : { + * 'url' : '/get/children/', + * 'data' : function (node) { + * return { 'id' : node.id }; + * } + * } + * }); + * + * // direct data + * $('#tree').jstree({ + * 'core' : { + * 'data' : [ + * 'Simple root node', + * { + * 'id' : 'node_2', + * 'text' : 'Root node with options', + * 'state' : { 'opened' : true, 'selected' : true }, + * 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] + * } + * ] + * }); + * + * // function + * $('#tree').jstree({ + * 'core' : { + * 'data' : function (obj, callback) { + * callback.call(this, ['Root 1', 'Root 2']); + * } + * }); + * + * @name $.jstree.defaults.core.data + */ + data : false, + /** + * configure the various strings used throughout the tree + * + * You can use an object where the key is the string you need to replace and the value is your replacement. + * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement. + * If left as `false` no replacement is made. + * + * __Examples__ + * + * $('#tree').jstree({ + * 'core' : { + * 'strings' : { + * 'Loading...' : 'Please wait ...' + * } + * } + * }); + * + * @name $.jstree.defaults.core.strings + */ + strings : false, + /** + * determines what happens when a user tries to modify the structure of the tree + * If left as `false` all operations like create, rename, delete, move or copy are prevented. + * You can set this to `true` to allow all interactions or use a function to have better control. + * + * __Examples__ + * + * $('#tree').jstree({ + * 'core' : { + * 'check_callback' : function (operation, node, node_parent, node_position) { + * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' + * // in case of 'rename_node' node_position is filled with the new node name + * return operation === 'rename_node' ? true : false; + * } + * } + * }); + * + * @name $.jstree.defaults.core.check_callback + */ + check_callback : false, + /** + * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) + * @name $.jstree.defaults.core.animation + */ + animation : 200, + /** + * a boolean indicating if multiple nodes can be selected + * @name $.jstree.defaults.core.multiple + */ + multiple : true, + /** + * theme configuration object + * @name $.jstree.defaults.core.themes + */ + themes : { + /** + * the name of the theme to use (if left as `false` the default theme is used) + * @name $.jstree.defaults.core.themes.name + */ + name : false, + /** + * the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme. + * @name $.jstree.defaults.core.themes.url + */ + url : false, + /** + * the location of all jstree themes - only used if `url` is set to `true` + * @name $.jstree.defaults.core.themes.dir + */ + dir : false, + /** + * a boolean indicating if connecting dots are shown + * @name $.jstree.defaults.core.themes.dots + */ + dots : true, + /** + * a boolean indicating if node icons are shown + * @name $.jstree.defaults.core.themes.icons + */ + icons : true, + /** + * a boolean indicating if the tree background is striped + * @name $.jstree.defaults.core.themes.stripes + */ + stripes : false, + /** + * a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants) + * @name $.jstree.defaults.core.themes.variant + */ + variant : false + }, + /** + * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user) + * @name $.jstree.defaults.core.expand_selected_onload + */ + expand_selected_onload : true + }; + $.jstree.core.prototype = { + /** + * used to decorate an instance with a plugin. Used internally. + * @private + * @name plugin(deco [, opts]) + * @param {String} deco the plugin to decorate with + * @param {Object} opts options for the plugin + * @return {jsTree} + */ + plugin : function (deco, opts) { + var Child = $.jstree.plugins[deco]; + if(Child) { + this._data[deco] = {}; + Child.prototype = this; + return new Child(opts, this); + } + return this; + }, + /** + * used to decorate an instance with a plugin. Used internally. + * @private + * @name init(el, optons) + * @param {DOMElement|jQuery|String} el the element we are transforming + * @param {Object} options options for this instance + * @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree + */ + init : function (el, options) { + 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 = $(el).addClass('jstree jstree-' + this._id); + this.settings = options; + this.element.bind("destroyed", $.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(); + /** + * triggered after all events are bound + * @event + * @name init.jstree + */ + 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'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last'><"+"a class='jstree-anchor' href='#'>" + this.get_string("Loading ...") + "
      "); + this._data.core.li_height = this.get_container_ul().children("li:eq(0)").height() || 18; + /** + * triggered after the loading text is shown and before loading starts + * @event + * @name loading.jstree + */ + this.trigger("loading"); + this.load_node('#'); + }, + /** + * destroy an instance + * @name destroy() + */ + destroy : function () { + this.element.unbind("destroyed", this.teardown); + this.teardown(); + }, + /** + * part of the destroying of an instance. Used internally. + * @private + * @name 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 all events. Used internally. + * @private + * @name bind() + */ + bind : function () { + if($.support.touch) { + this.element.addTouch(); + } + this.element + .on("dblclick.jstree", function () { + if(document.selection && document.selection.empty) { + document.selection.empty(); + } + else { + if(window.getSelection) { + var sel = window.getSelection(); + try { + sel.removeAllRanges(); + sel.collapse(); + } catch (ignore) { } + } + } + }) + .on("click.jstree", ".jstree-ocl", $.proxy(function (e) { + this.toggle_node(e.target); + }, this)) + .on("click.jstree", ".jstree-anchor", $.proxy(function (e) { + e.preventDefault(); + $(e.currentTarget).focus(); + this.activate_node(e.currentTarget, e); + }, this)) + .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) { + var o = null; + switch(e.which) { + case 13: + case 32: + e.type = "click"; + $(e.currentTarget).trigger(e); + break; + case 37: + e.preventDefault(); + if(this.is_open(e.currentTarget)) { + this.close_node(e.currentTarget); + } + else { + o = this.get_prev_dom(e.currentTarget); + if(o && o.length) { o.children('.jstree-anchor').focus(); } + } + break; + case 38: + e.preventDefault(); + o = this.get_prev_dom(e.currentTarget); + if(o && o.length) { o.children('.jstree-anchor').focus(); } + break; + case 39: + e.preventDefault(); + if(this.is_closed(e.currentTarget)) { + this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); }); + } + else { + o = this.get_next_dom(e.currentTarget); + if(o && o.length) { o.children('.jstree-anchor').focus(); } + } + break; + case 40: + e.preventDefault(); + o = this.get_next_dom(e.currentTarget); + if(o && o.length) { o.children('.jstree-anchor').focus(); } + break; + // delete + case 46: + e.preventDefault(); + o = this.get_node(e.currentTarget); + if(o && o.id && o.id !== '#') { + o = this.is_selected(o) ? this.get_selected() : o; + // this.delete_node(o); + } + break; + // f2 + case 113: + e.preventDefault(); + o = this.get_node(e.currentTarget); + /*! + if(o && o.id && o.id !== '#') { + // this.edit(o); + } + */ + break; + default: + // console.log(e.which); + break; + } + }, this)) + .on("load_node.jstree", $.proxy(function (e, data) { + if(data.status) { + if(data.node.id === '#' && !this._data.core.loaded) { + this._data.core.loaded = true; + /** + * triggered after the root node is loaded for the first time + * @event + * @name loaded.jstree + */ + 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 tmp = [], i, j; + for(i = 0, j = this._data.core.selected.length; i < j; i++) { + tmp = tmp.concat(this._model.data[this._data.core.selected[i]].parents); + } + tmp = $.vakata.array_unique(tmp); + for(i = 0, j = tmp.length; i < j; i++) { + this.open_node(tmp[i], false, 0); + } + } + this.trigger('changed', { 'action' : 'ready', 'selected' : this._data.core.selected }); + } + /** + * triggered after all nodes are finished loading + * @event + * @name ready.jstree + */ + this.trigger("ready"); + } + } + }, this)) + // THEME RELATED + .on("init.jstree", $.proxy(function () { + var s = this.settings.core.themes; + this._data.core.themes.dots = s.dots; + this._data.core.themes.stripes = s.stripes; + this._data.core.themes.icons = s.icons; + this.set_theme(s.name || "default", s.url); + this.set_theme_variant(s.variant); + }, this)) + .on("loading.jstree", $.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('focus.jstree', '.jstree-anchor', $.proxy(function (e) { + $(e.currentTarget).mouseenter(); + }, this)) + .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) { + $(e.currentTarget).mouseleave(); + }, this)) + .on('mouseenter.jstree', '.jstree-anchor', $.proxy(function (e) { + var o = this.element.find('.jstree-anchor:focus').not('.jstree-clicked'); + if(o && o.length && o[0] !== e.currentTarget) { + o.blur(); + } + this.hover_node(e.currentTarget); + }, this)) + .on('mouseleave.jstree', '.jstree-anchor', $.proxy(function (e) { + this.dehover_node(e.currentTarget); + }, this)); + }, + /** + * part of the destroying of an instance. Used internally. + * @private + * @name unbind() + */ + unbind : function () { + this.element.off('.jstree'); + $(document).off('.jstree-' + this._id); + }, + /** + * trigger an event. Used internally. + * @private + * @name trigger(ev [, data]) + * @param {String} ev the name of the event to trigger + * @param {Object} data additional data to pass with the event + */ + trigger : function (ev, data) { + if(!data) { + data = {}; + } + data.instance = this; + this.element.triggerHandler(ev.replace('.jstree','') + '.jstree', data); + }, + /** + * returns the jQuery extended instance container + * @name get_container() + * @return {jQuery} + */ + get_container : function () { + return this.element; + }, + /** + * returns the jQuery extended main UL node inside the instance container. Used internally. + * @private + * @name get_container_ul() + * @return {jQuery} + */ + get_container_ul : function () { + return this.element.children("ul:eq(0)"); + }, + /** + * gets string replacements (localization). Used internally. + * @private + * @name get_string(key) + * @param {String} key + * @return {String} + */ + get_string : function (key) { + var a = this.settings.core.strings; + if($.isFunction(a)) { return a.call(this, key); } + if(a && a[key]) { return a[key]; } + return key; + }, + /** + * gets the first child of a DOM node. Used internally. + * @private + * @name _firstChild(dom) + * @param {DOMElement} dom + * @return {DOMElement} + */ + _firstChild : function (dom) { + dom = dom ? dom.firstChild : null; + while(dom !== null && dom.nodeType !== 1) { + dom = dom.nextSibling; + } + return dom; + }, + /** + * gets the next sibling of a DOM node. Used internally. + * @private + * @name _nextSibling(dom) + * @param {DOMElement} dom + * @return {DOMElement} + */ + _nextSibling : function (dom) { + dom = dom ? dom.nextSibling : null; + while(dom !== null && dom.nodeType !== 1) { + dom = dom.nextSibling; + } + return dom; + }, + /** + * gets the previous sibling of a DOM node. Used internally. + * @private + * @name _previousSibling(dom) + * @param {DOMElement} dom + * @return {DOMElement} + */ + _previousSibling : function (dom) { + dom = dom ? dom.previousSibling : null; + while(dom !== null && dom.nodeType !== 1) { + dom = dom.previousSibling; + } + return dom; + }, + /** + * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc) + * @name get_node(obj [, as_dom]) + * @param {mixed} obj + * @param {Boolean} as_dom + * @return {Object|jQuery} + */ + get_node : function (obj, as_dom) { + if(obj && obj.id) { + obj = obj.id; + } + var dom; + if(this._model.data[obj]) { + obj = this._model.data[obj]; + } + else if(((dom = $(obj, this.element)).length || (dom = $('#' + obj, this.element)).length) && this._model.data[dom.closest('li').attr('id')]) { + obj = this._model.data[dom.closest('li').attr('id')]; + } + else if((dom = $(obj, this.element)).length && dom.hasClass('jstree')) { + obj = this._model.data['#']; + } + else { + return false; + } + + if(as_dom) { + obj = obj.id === '#' ? this.element : $(document.getElementById(obj.id)); + } + return obj; + }, + /** + * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. + * @name get_next_dom(obj [, strict]) + * @param {mixed} obj + * @param {Boolean} strict + * @return {jQuery} + */ + get_next_dom : function (obj, strict) { + var tmp; + obj = this.get_node(obj, true); + if(obj[0] === this.element[0]) { + tmp = this._firstChild(this.get_container_ul()[0]); + return tmp ? $(tmp) : false; + } + if(!obj || !obj.length) { + return false; + } + if(strict) { + tmp = this._nextSibling(obj[0]); + return tmp ? $(tmp) : false; + } + if(obj.hasClass("jstree-open")) { + tmp = this._firstChild(obj.children('ul')[0]); + return tmp ? $(tmp) : false; + } + if((tmp = this._nextSibling(obj[0])) !== null) { + return $(tmp); + } + return obj.parentsUntil(".jstree","li").next("li").eq(0); + }, + /** + * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned. + * @name get_prev_dom(obj [, strict]) + * @param {mixed} obj + * @param {Boolean} strict + * @return {jQuery} + */ + get_prev_dom : function (obj, strict) { + var tmp; + obj = this.get_node(obj, true); + if(obj[0] === this.element[0]) { + tmp = this.get_container_ul()[0].lastChild; + return tmp ? $(tmp) : false; + } + if(!obj || !obj.length) { + return false; + } + if(strict) { + tmp = this._previousSibling(obj[0]); + return tmp ? $(tmp) : false; + } + if((tmp = this._previousSibling(obj[0])) !== null) { + obj = $(tmp); + while(obj.hasClass("jstree-open")) { + obj = obj.children("ul:eq(0)").children("li:last"); + } + return obj; + } + tmp = obj[0].parentNode.parentNode; + return tmp && tmp.tagName === 'LI' ? $(tmp) : false; + }, + /** + * get the parent ID of a node + * @name get_parent(obj) + * @param {mixed} obj + * @return {String} + */ + get_parent : function (obj) { + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + return obj.parent; + }, + /** + * get a jQuery collection of all the children of a node (node must be rendered) + * @name get_children_dom(obj) + * @param {mixed} obj + * @return {jQuery} + */ + get_children_dom : function (obj) { + obj = this.get_node(obj, true); + if(obj[0] === this.element[0]) { + return this.get_container_ul().children("li"); + } + if(!obj || !obj.length) { + return false; + } + return obj.children("ul").children("li"); + }, + /** + * checks if a node has children + * @name is_parent(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_parent : function (obj) { + obj = this.get_node(obj); + return obj && (obj.state.loaded === false || obj.children.length); + }, + /** + * checks if a node is loaded (its children are available) + * @name is_loaded(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_loaded : function (obj) { + obj = this.get_node(obj); + return obj && obj.state.loaded; + }, + /** + * check if a node is currently loading (fetching children) + * @name is_loading(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_loading : function (obj) { + obj = this.get_node(obj, true); + return obj && obj.hasClass("jstree-loading"); + }, + /** + * check if a node is opened + * @name is_open(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_open : function (obj) { + obj = this.get_node(obj); + return obj && obj.state.opened; + }, + /** + * check if a node is in a closed state + * @name is_closed(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_closed : function (obj) { + obj = this.get_node(obj); + return obj && this.is_parent(obj) && !obj.state.opened; + }, + /** + * check if a node has no children + * @name is_leaf(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_leaf : function (obj) { + return !this.is_parent(obj); + }, + /** + * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array. + * @name load_node(obj [, callback]) + * @param {mixed} obj + * @param {function} callback a function to be executed once loading is conplete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status + * @return {Boolean} + * @trigger load_node.jstree + */ + load_node : function (obj, callback) { + var t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.load_node(obj[t1], callback); + } + return true; + } + obj = this.get_node(obj); + if(!obj) { + callback.call(this, obj, false); + return false; + } + this.get_node(obj, true).addClass("jstree-loading"); + this._load_node(obj, $.proxy(function (status) { + obj.state.loaded = status; + this.get_node(obj, true).removeClass("jstree-loading"); + /** + * triggered after a node is loaded + * @event + * @name load_node.jstree + * @param {Object} node the node that was loading + * @param {Boolean} status was the node loaded successfully + */ + this.trigger('load_node', { "node" : obj, "status" : status }); + if(callback) { + callback.call(this, obj, status); + } + }, this)); + return true; + }, + /** + * handles the actual loading of a node. Used only internally. + * @private + * @name _load_node(obj [, callback]) + * @param {mixed} obj + * @param {function} callback a function to be executed once loading is conplete, the function is executed in the instance's scope and receives one argument - a boolean status + * @return {Boolean} + */ + _load_node : function (obj, callback) { + var s = this.settings.core.data; + // use original HTML + if(!s) { + return callback.call(this, obj.id === '#' ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false); + } + if($.isFunction(s)) { + return s.call(this, obj, $.proxy(function (d) { + return callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d)); + }, this)); + } + if(typeof s === 'object') { + if(s.url) { + s = $.extend(true, {}, s); + if($.isFunction(s.url)) { + s.url = s.url.call(this, obj); + } + if($.isFunction(s.data)) { + s.data = s.data.call(this, obj); + } + return $.ajax(s) + .done($.proxy(function (d,t,x) { + var type = x.getResponseHeader('Content-Type'); + if(type.indexOf('json') !== -1) { + return callback.call(this, this._append_json_data(obj, d)); + } + if(type.indexOf('html') !== -1) { + return callback.call(this, this._append_html_data(obj, $(d))); + } + }, this)) + .fail($.proxy(function () { + callback.call(this, false); + }, this)); + } + return callback.call(this, this._append_json_data(obj, s)); + } + if(typeof s === 'string') { + return callback.call(this, this._append_html_data(obj, s)); + } + return callback.call(this, false); + }, + /** + * adds a node to the list of nodes to redraw. Used only internally. + * @private + * @name _node_changed(obj [, callback]) + * @param {mixed} obj + */ + _node_changed : function (obj) { + obj = this.get_node(obj); + if(obj) { + this._model.changed.push(obj.id); + } + }, + /** + * appends HTML content to the tree. Used internally. + * @private + * @name _append_html_data(obj, data) + * @param {mixed} obj the node to append to + * @param {String} data the HTML string to parse and append + * @return {Boolean} + * @trigger model.jstree, changed.jstree + */ + _append_html_data : function (dom, data) { + dom = this.get_node(dom); + var dat = data.is('ul') ? data.children() : data, + par = dom.id, + chd = [], + dpc = [], + m = this._model.data, + p = m[par], + s = this._data.core.selected.length, + tmp, i, j; + dat.each($.proxy(function (i, v) { + tmp = this._parse_model_from_html($(v), par, p.parents.concat()); + if(tmp) { + chd.push(tmp); + dpc.push(tmp); + if(m[tmp].children_d.length) { + dpc = dpc.concat(m[tmp].children_d); + } + } + }, this)); + p.children = chd; + p.children_d = dpc; + for(i = 0, j = p.parents.length; i < j; i++) { + m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); + } + /** + * triggered when new data is inserted to the tree model + * @event + * @name model.jstree + * @param {Array} nodes an array of node IDs + * @param {String} parent the parent ID of the nodes + */ + this.trigger('model', { "nodes" : dpc, 'parent' : par }); + if(par !== '#') { + this._node_changed(par); + this.redraw(); + } + else { + this.get_container_ul().children('.jstree-initial-node').remove(); + this.redraw(true); + } + if(this._data.core.selected.length !== s) { + this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); + } + return true; + }, + /** + * appends JSON content to the tree. Used internally. + * @private + * @name _append_json_data(obj, data) + * @param {mixed} obj the node to append to + * @param {String} data the JSON object to parse and append + * @return {Boolean} + */ + _append_json_data : function (dom, data) { + dom = this.get_node(dom); + var dat = data, + par = dom.id, + chd = [], + dpc = [], + m = this._model.data, + p = m[par], + s = this._data.core.selected.length, + tmp, i, j; + if(!$.isArray(dat)) { dat = [dat]; } + if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) { + // Flat JSON support (for easy import from DB): + // 1) convert to object (foreach) + for(i = 0, j = dat.length; i < j; i++) { + if(!dat[i].children) { + dat[i].children = []; + } + m[dat[i].id] = dat[i]; + } + // 2) populate children (foreach) + for(i = 0, j = dat.length; i < j; i++) { + m[dat[i].parent].children.push(dat[i].id); + // populate parent.children_d + p.children_d.push(dat[i].id); + } + // 3) normalize && populate parents and children_d with recursion + for(i = 0, j = p.children.length; i < j; i++) { + this._parse_model_from_flat_json(m[p.children[i]], par, p.parents.concat()); + } + // ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true; + } + else { + for(i = 0, j = dat.length; i < j; i++) { + tmp = this._parse_model_from_json(dat[i], par, p.parents.concat()); + if(tmp) { + chd.push(tmp); + dpc.push(tmp); + if(m[tmp].children_d.length) { + dpc = dpc.concat(m[tmp].children_d); + } + } + } + p.children = chd; + p.children_d = dpc; + for(i = 0, j = p.parents.length; i < j; i++) { + m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); + } + } + this.trigger('model', { "nodes" : dpc, 'parent' : par }); + + if(par !== '#') { + this._node_changed(par); + this.redraw(); + } + else { + // this.get_container_ul().children('.jstree-initial-node').remove(); + this.redraw(true); + } + if(this._data.core.selected.length !== s) { + this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); + } + return true; + }, + /** + * parses a node from a jQuery object and appends them to the in memory tree model. Used internally. + * @private + * @name _parse_model_from_html(d [, p, ps]) + * @param {jQuery} d the jQuery object to parse + * @param {String} p the parent ID + * @param {Array} ps list of all parents + * @return {String} the ID of the object added to the model + */ + _parse_model_from_html : function (d, p, ps) { + if(!ps) { ps = []; } + else { ps = [].concat(ps); } + if(p) { ps.unshift(p); } + var c, e, m = this._model.data, + data = { + id : false, + text : false, + icon : true, + parent : p, + parents : ps, + children : [], + children_d : [], + data : null, + state : { }, + li_attr : { id : false }, + a_attr : { href : '#' }, + original : false + }, i, tmp, tid; + for(i in this._model.default_state) { + if(this._model.default_state.hasOwnProperty(i)) { + data.state[i] = this._model.default_state[i]; + } + } + tmp = $.vakata.attributes(d, true); + $.each(tmp, function (i, v) { + v = $.trim(v); + if(!v.length) { return true; } + data.li_attr[i] = v; + if(i === 'id') { + data.id = v; + } + }); + tmp = d.children('a').eq(0); + if(tmp.length) { + tmp = $.vakata.attributes(tmp, true); + $.each(tmp, function (i, v) { + v = $.trim(v); + if(v.length) { + data.a_attr[i] = v; + } + }); + } + tmp = d.children("a:eq(0)").length ? d.children("a:eq(0)").clone() : d.clone(); + tmp.children("ins, i, ul").remove(); + tmp = tmp.html(); + tmp = $('
      ').html(tmp); + data.text = tmp.html(); + tmp = d.data(); + data.data = tmp ? $.extend(true, {}, tmp) : null; + data.state.opened = d.hasClass('jstree-open'); + data.state.selected = d.children('a').hasClass('jstree-clicked'); + data.state.disabled = d.children('a').hasClass('jstree-disabled'); + if(data.data && data.data.jstree) { + for(i in data.data.jstree) { + if(data.data.jstree.hasOwnProperty(i)) { + data.state[i] = data.data.jstree[i]; + } + } + } + tmp = d.children("a").children(".jstree-themeicon"); + if(tmp.length) { + data.icon = tmp.hasClass('jstree-themeicon-hidden') ? false : tmp.attr('rel'); + } + if(data.state.icon) { + data.icon = data.state.icon; + } + tmp = d.children("ul").children("li"); + do { + tid = 'j' + this._id + '_' + (++total_nodes); + } while(m[tid]); + data.id = data.li_attr.id || tid; + if(tmp.length) { + tmp.each($.proxy(function (i, v) { + c = this._parse_model_from_html($(v), data.id, ps); + e = this._model.data[c]; + data.children.push(c); + if(e.children_d.length) { + data.children_d = data.children_d.concat(e.children_d); + } + }, this)); + data.children_d = data.children_d.concat(data.children); + } + else { + if(d.hasClass('jstree-closed')) { + data.state.loaded = false; + } + } + m[data.id] = data; + if(data.state.selected) { + this._data.core.selected.push(data.id); + } + return data.id; + }, + /** + * parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally. + * @private + * @name _parse_model_from_flat_json(d [, p, ps]) + * @param {Object} d the JSON object to parse + * @param {String} p the parent ID + * @param {Array} ps list of all parents + * @return {String} the ID of the object added to the model + */ + _parse_model_from_flat_json : function (d, p, ps) { + if(!ps) { ps = []; } + else { ps = ps.concat(); } + if(p) { ps.unshift(p); } + var tid = d.id, + m = this._model.data, + df = this._model.default_state, + i, j, c, e, + tmp = { + id : tid, + text : d.text || '', + icon : d.icon !== undefined ? d.icon : true, + parent : p, + parents : ps, + children : d.children || [], + children_d : d.children_d || [], + data : d.data, + state : { }, + li_attr : { id : false }, + a_attr : { href : '#' }, + original : false + }; + for(i in df) { + if(df.hasOwnProperty(i)) { + tmp.state[i] = df[i]; + } + } + if(d && d.data && d.data.jstree && d.data.jstree.icon) { + tmp.icon = d.data.jstree.icon; + } + if(d && d.data) { + tmp.data = d.data; + if(d.data.jstree) { + for(i in d.data.jstree) { + if(d.data.jstree.hasOwnProperty(i)) { + tmp.state[i] = d.data.jstree[i]; + } + } + } + } + if(d && typeof d.state === 'object') { + for (i in d.state) { + if(d.state.hasOwnProperty(i)) { + tmp.state[i] = d.state[i]; + } + } + } + if(d && typeof d.li_attr === 'object') { + for (i in d.li_attr) { + if(d.li_attr.hasOwnProperty(i)) { + tmp.li_attr[i] = d.li_attr[i]; + } + } + } + if(!tmp.li_attr.id) { + tmp.li_attr.id = tid; + } + if(d && typeof d.a_attr === 'object') { + for (i in d.a_attr) { + if(d.a_attr.hasOwnProperty(i)) { + tmp.a_attr[i] = d.a_attr[i]; + } + } + } + if(d && d.children && d.children === true) { + tmp.state.loaded = false; + tmp.children = []; + tmp.children_d = []; + } + m[tmp.id] = tmp; + for(i = 0, j = tmp.children.length; i < j; i++) { + c = this._parse_model_from_flat_json(m[tmp.children[i]], tmp.id, ps); + e = m[c]; + tmp.children_d.push(c); + if(e.children_d.length) { + tmp.children_d = tmp.children_d.concat(e.children_d); + } + } + delete d.data; + delete d.children; + m[tmp.id].original = d; + if(tmp.state.selected) { + this._data.core.selected.push(tmp.id); + } + return tmp.id; + }, + /** + * parses a node from a JSON object and appends it to the in memory tree model. Used internally. + * @private + * @name _parse_model_from_json(d [, p, ps]) + * @param {Object} d the JSON object to parse + * @param {String} p the parent ID + * @param {Array} ps list of all parents + * @return {String} the ID of the object added to the model + */ + _parse_model_from_json : function (d, p, ps) { + if(!ps) { ps = []; } + else { ps = ps.concat(); } + if(p) { ps.unshift(p); } + var tid = false, i, j, c, e, m = this._model.data, df = this._model.default_state, tmp; + do { + tid = 'j' + this._id + '_' + (++total_nodes); + } while(m[tid]); + + tmp = { + id : false, + text : typeof d === 'string' ? d : '', + icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true, + parent : p, + parents : ps, + children : [], + children_d : [], + data : null, + state : { }, + li_attr : { id : false }, + a_attr : { href : '#' }, + original : false + }; + for(i in df) { + if(df.hasOwnProperty(i)) { + tmp.state[i] = df[i]; + } + } + if(d && d.id) { tmp.id = d.id; } + if(d && d.text) { tmp.text = d.text; } + if(d && d.data && d.data.jstree && d.data.jstree.icon) { + tmp.icon = d.data.jstree.icon; + } + if(d && d.data) { + tmp.data = d.data; + if(d.data.jstree) { + for(i in d.data.jstree) { + if(d.data.jstree.hasOwnProperty(i)) { + tmp.state[i] = d.data.jstree[i]; + } + } + } + } + if(d && typeof d.state === 'object') { + for (i in d.state) { + if(d.state.hasOwnProperty(i)) { + tmp.state[i] = d.state[i]; + } + } + } + if(d && typeof d.li_attr === 'object') { + for (i in d.li_attr) { + if(d.li_attr.hasOwnProperty(i)) { + tmp.li_attr[i] = d.li_attr[i]; + } + } + } + if(tmp.li_attr.id && !tmp.id) { + tmp.id = tmp.li_attr.id; + } + if(!tmp.id) { + tmp.id = tid; + } + if(!tmp.li_attr.id) { + tmp.li_attr.id = tmp.id; + } + if(d && typeof d.a_attr === 'object') { + for (i in d.a_attr) { + if(d.a_attr.hasOwnProperty(i)) { + tmp.a_attr[i] = d.a_attr[i]; + } + } + } + if(d && d.children && d.children.length) { + for(i = 0, j = d.children.length; i < j; i++) { + c = this._parse_model_from_json(d.children[i], tmp.id, ps); + e = m[c]; + tmp.children.push(c); + if(e.children_d.length) { + tmp.children_d = tmp.children_d.concat(e.children_d); + } + } + tmp.children_d = tmp.children_d.concat(tmp.children); + } + if(d && d.children && d.children === true) { + tmp.state.loaded = false; + tmp.children = []; + tmp.children_d = []; + } + delete d.data; + delete d.children; + tmp.original = d; + m[tmp.id] = tmp; + if(tmp.state.selected) { + this._data.core.selected.push(tmp.id); + } + return tmp.id; + }, + /** + * redraws all nodes that need to be redrawn. Used internally. + * @private + * @name _redraw() + * @trigger redraw.jstree + */ + _redraw : function () { + var nodes = this._model.force_full_redraw ? this._model.data['#'].children.concat([]) : this._model.changed.concat([]), + f = document.createElement('UL'), tmp, i, j; + for(i = 0, j = nodes.length; i < j; i++) { + tmp = this.redraw_node(nodes[i], true, this._model.force_full_redraw); + if(tmp && this._model.force_full_redraw) { + f.appendChild(tmp); + } + } + if(this._model.force_full_redraw) { + f.className = this.get_container_ul()[0].className; + this.element.empty().append(f); + //this.get_container_ul()[0].appendChild(f); + } + this._model.force_full_redraw = false; + this._model.changed = []; + /** + * triggered after nodes are redrawn + * @event + * @name redraw.jstree + * @param {array} nodes the redrawn nodes + */ + this.trigger('redraw', { "nodes" : nodes }); + }, + /** + * redraws all nodes that need to be redrawn or optionally - the whole tree + * @name redraw([full]) + * @param {Boolean} full if set to `true` all nodes are redrawn. + */ + redraw : function (full) { + if(full) { + this._model.force_full_redraw = true; + } + //if(this._model.redraw_timeout) { + // clearTimeout(this._model.redraw_timeout); + //} + //this._model.redraw_timeout = setTimeout($.proxy(this._redraw, this),0); + this._redraw(); + }, + /** + * redraws a single node. Used internally. + * @private + * @name redraw_node(node, deep, is_callback) + * @param {mixed} node the node to redraw + * @param {Boolean} deep should child nodes be redrawn too + * @param {Boolean} is_callback is this a recursion call + */ + redraw_node : function (node, deep, is_callback) { + var obj = this.get_node(node), + par = false, + ind = false, + old = false, + i = false, + j = false, + k = false, + c = '', + d = document, + m = this._model.data; + if(!obj) { return false; } + if(obj.id === '#') { return this.redraw(true); } + deep = deep || obj.children.length === 0; + node = d.getElementById(obj.id); //, this.element); + if(!node) { + deep = true; + //node = d.createElement('LI'); + if(!is_callback) { + par = obj.parent !== '#' ? $('#' + obj.parent, this.element)[0] : null; + if(par !== null && (!par || !m[obj.parent].state.opened)) { + return false; + } + ind = $.inArray(obj.id, par === null ? m['#'].children : m[obj.parent].children); + } + } + else { + node = $(node); + if(!is_callback) { + par = node.parent().parent()[0]; + if(par === this.element[0]) { + par = null; + } + ind = node.index(); + } + m[obj.id].data = node.data(); + if(!deep && obj.children.length && !node.children('ul').length) { + deep = true; + } + if(!deep) { + old = node.children('UL')[0]; + } + node.remove(); + //node = d.createElement('LI'); + //node = node[0]; + } + node = _node.cloneNode(true); + // node is DOM, deep is boolean + + c = 'jstree-node '; + for(i in obj.li_attr) { + if(obj.li_attr.hasOwnProperty(i)) { + if(i === 'id') { continue; } + if(i !== 'class') { + _node.setAttribute(i, obj.li_attr[i]); + } + else { + c += obj.li_attr[i]; + } + } + } + if(!obj.children.length && obj.state.loaded) { + c += ' jstree-leaf'; + } + else { + c += obj.state.opened ? ' jstree-open' : ' jstree-closed'; + } + if(obj.parent !== null && m[obj.parent].children[m[obj.parent].children.length - 1] === obj.id) { + c += ' jstree-last'; + } + node.id = obj.id; + node.className = c; + c = ( obj.state.selected ? ' jstree-clicked' : '') + ( obj.state.disabled ? ' jstree-disabled' : ''); + for(j in obj.a_attr) { + if(obj.a_attr.hasOwnProperty(j)) { + if(j === 'href' && obj.a_attr[j] === '#') { continue; } + if(j !== 'class') { + node.childNodes[1].setAttribute(j, obj.a_attr[j]); + } + else { + c += ' ' + obj.a_attr[j]; + } + } + } + if(c.length) { + node.childNodes[1].className = 'jstree-anchor ' + c; + } + if(obj.icon && obj.icon !== true) { + if(obj.icon === false) { + node.childNodes[1].childNodes[0].className += ' jstree-themeicon-hidden'; + } + else if(obj.icon.indexOf('/') === -1) { + node.childNodes[1].childNodes[0].className += ' ' + obj.icon + ' jstree-themeicon-custom'; + } + else { + node.childNodes[1].childNodes[0].style.backgroundImage = 'url('+obj.icon+')'; + node.childNodes[1].childNodes[0].style.backgroundPosition = 'center center'; + node.childNodes[1].childNodes[0].style.backgroundSize = 'auto'; + node.childNodes[1].childNodes[0].className += ' jstree-themeicon-custom'; + } + } + node.childNodes[1].appendChild(d.createTextNode(obj.text)); + if(obj.data) { $.data(node, obj.data); } + + if(deep && obj.children.length && obj.state.opened) { + k = d.createElement('UL'); + k.setAttribute('role', 'group'); + k.className = 'jstree-children'; + for(i = 0, j = obj.children.length; i < j; i++) { + k.appendChild(this.redraw_node(obj.children[i], deep, true)); + } + node.appendChild(k); + } + if(old) { + node.appendChild(old); + } + if(!is_callback) { + // append back using par / ind + if(!par) { + par = this.element[0]; + } + if(!par.getElementsByTagName('UL').length) { + i = d.createElement('UL'); + i.setAttribute('role', 'group'); + i.className = 'jstree-children'; + par.appendChild(i); + par = i; + } + else { + par = par.getElementsByTagName('UL')[0]; + } + + if(ind < par.childNodes.length) { + par.insertBefore(node, par.childNodes[ind]); + } + else { + par.appendChild(node); + } + } + return node; + }, + /** + * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready. + * @name open_node(obj [, callback, animation]) + * @param {mixed} obj the node to open + * @param {Function} callback a function to execute once the node is opened + * @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation. + * @trigger open_node.jstree, after_open.jstree + */ + open_node : function (obj, callback, animation) { + var t1, t2, d, t; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.open_node(obj[t1], callback, animation); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + animation = animation === undefined ? this.settings.core.animation : animation; + if(!this.is_closed(obj)) { + if(callback) { + callback.call(this, obj, false); + } + return false; + } + if(!this.is_loaded(obj)) { + if(this.is_loading(obj)) { + return setTimeout($.proxy(function () { + this.open_node(obj, callback, animation); + }, this), 500); + } + this.load_node(obj, function (o, ok) { + return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false); + }); + } + else { + d = this.get_node(obj, true); + t = this; + if(d.length) { + if(obj.children.length && !this._firstChild(d.children('ul')[0])) { + obj.state.opened = true; + this.redraw_node(obj, true); + d = this.get_node(obj, true); + } + if(!animation) { + d[0].className = d[0].className.replace('jstree-closed', 'jstree-open'); + } + else { + d + .children("ul").css("display","none").end() + .removeClass("jstree-closed").addClass("jstree-open") + .children("ul").stop(true, true) + .slideDown(animation, function () { + this.style.display = ""; + t.trigger("after_open", { "node" : obj }); + }); + } + } + obj.state.opened = true; + if(callback) { + callback.call(this, obj, true); + } + /** + * triggered when a node is opened (if there is an animation it will not be completed yet) + * @event + * @name open_node.jstree + * @param {Object} node the opened node + */ + this.trigger('open_node', { "node" : obj }); + if(!animation || !d.length) { + /** + * triggered when a node is opened and the animation is complete + * @event + * @name after_open.jstree + * @param {Object} node the opened node + */ + this.trigger("after_open", { "node" : obj }); + } + } + }, + /** + * closes a node, hiding its children + * @name close_node(obj [, animation]) + * @param {mixed} obj the node to close + * @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation. + * @trigger close_node.jstree, after_close.jstree + */ + close_node : function (obj, animation) { + var t1, t2, t, d; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.close_node(obj[t1], animation); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + animation = animation === undefined ? this.settings.core.animation : animation; + t = this; + d = this.get_node(obj, true); + if(d.length) { + if(!animation) { + d[0].className = d[0].className.replace('jstree-open', 'jstree-closed'); + //d.children('ul').remove(); + } + else { + d + .children("ul").attr("style","display:block !important").end() + .removeClass("jstree-open").addClass("jstree-closed") + .children("ul").stop(true, true).slideUp(animation, function () { + this.style.display = ""; + d.children('ul').remove(); + t.trigger("after_close", { "node" : obj }); + }); + } + } + obj.state.opened = false; + /** + * triggered when a node is closed (if there is an animation it will not be complete yet) + * @event + * @name close_node.jstree + * @param {Object} node the closed node + */ + this.trigger('close_node',{ "node" : obj }); + if(!animation || !d.length) { + /** + * triggered when a node is closed and the animation is complete + * @event + * @name after_close.jstree + * @param {Object} node the closed node + */ + this.trigger("after_close", { "node" : obj }); + } + }, + /** + * toggles a node - closing it if it is open, opening it if it is closed + * @name toggle_node(obj) + * @param {mixed} obj the node to toggle + */ + toggle_node : function (obj) { + var t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.toggle_node(obj[t1]); + } + return true; + } + if(this.is_closed(obj)) { + return this.open_node(obj); + } + if(this.is_open(obj)) { + return this.close_node(obj); + } + }, + /** + * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready. + * @name open_all([obj, animation, original_obj]) + * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree + * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation + * @param {jQuery} reference to the node that started the process (internal use) + * @trigger open_all.jstree + */ + open_all : function (obj, animation, original_obj) { + if(!obj) { obj = '#'; } + obj = this.get_node(obj); + if(!obj) { return false; } + var dom = obj.id === '#' ? this.get_container_ul() : this.get_node(obj, true), i, j, _this; + if(!dom.length) { + for(i = 0, j = obj.children_d.length; i < j; i++) { + if(this.is_closed(this._mode.data[obj.children_d[i]])) { + this._mode.data[obj.children_d[i]].state.opened = true; + } + } + return this.trigger('open_all', { "node" : obj }); + } + original_obj = original_obj || dom; + _this = this; + dom = this.is_closed(obj) ? dom.find('li.jstree-closed').addBack() : dom.find('li.jstree-closed'); + dom.each(function () { + _this.open_node( + this, + _this.is_loaded(this) ? + false : + function(dom) { this.open_all(dom, animation, original_obj); }, + animation || 0 + ); + }); + if(original_obj.find('li.jstree-closed').length === 0) { + /** + * triggered when an `open_all` call completes + * @event + * @name open_all.jstree + * @param {Object} node the opened node + */ + this.trigger('open_all', { "node" : this.get_node(original_obj) }); + } + }, + /** + * closes all nodes within a node (or the tree), revaling their children + * @name open_all([obj, animation]) + * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree + * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation + * @trigger close_all.jstree + */ + close_all : function (obj, animation) { + if(!obj) { obj = '#'; } + obj = this.get_node(obj); + if(!obj) { return false; } + var dom = obj.id === '#' ? this.get_container_ul() : this.get_node(obj, true), + _this = this, i, j; + if(!dom.length) { + for(i = 0, j = obj.children_d.length; i < j; i++) { + this._mode.data[obj.children_d[i]].state.opened = false; + } + return this.trigger('close_all', { "node" : obj }); + } + dom = this.is_open(obj) ? dom.find('li.jstree-open').addBack() : dom.find('li.jstree-open'); + dom.vakata_reverse().each(function () { _this.close_node(this, animation || 0); }); + /** + * triggered when an `close_all` call completes + * @event + * @name close_all.jstree + * @param {Object} node the closed node + */ + this.trigger('close_all', { "node" : obj }); + }, + /** + * checks if a node is disabled (not selectable) + * @name is_disabled(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_disabled : function (obj) { + obj = this.get_node(obj); + return obj && obj.state && obj.state.disabled; + }, + /** + * enables a node - so that it can be selected + * @name enable_node(obj) + * @param {mixed} obj the node to enable + * @trigger enable_node.jstree + */ + enable_node : function (obj) { + var t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.enable_node(obj[t1]); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + obj.state.disabled = false; + this.get_node(obj,true).children('.jstree-anchor').removeClass('jstree-disabled'); + /** + * triggered when an node is enabled + * @event + * @name enable_node.jstree + * @param {Object} node the enabled node + */ + this.trigger('enable_node', { 'node' : obj }); + }, + /** + * disables a node - so that it can not be selected + * @name disable_node(obj) + * @param {mixed} obj the node to disable + * @trigger disable_node.jstree + */ + disable_node : function (obj) { + var t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.disable_node(obj[t1]); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + obj.state.disabled = true; + this.get_node(obj,true).children('.jstree-anchor').addClass('jstree-disabled'); + /** + * triggered when an node is disabled + * @event + * @name disable_node.jstree + * @param {Object} node the disabled node + */ + this.trigger('disable_node', { 'node' : obj }); + }, + /** + * called when a node is selected by the user. Used internally. + * @private + * @name activate_node(obj, e) + * @param {mixed} obj the node + * @param {Object} e the related event + * @trigger activate_node.jstree + */ + activate_node : function (obj, e) { + if(this.is_disabled(obj)) { + return false; + } + if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) { + this.deselect_all(true); + this.select_node(obj); + this._data.core.last_clicked = this.get_node(obj); + } + else { + if(e.shiftKey) { + var o = this.get_node(obj).id, + l = this._data.core.last_clicked.id, + p = this.get_node(this._data.core.last_clicked.parent).children, + c = false, + i, j; + for(i = 0, j = p.length; i < j; i += 1) { + // separate IFs work whem o and l are the same + if(p[i] === o) { + c = !c; + } + if(p[i] === l) { + c = !c; + } + if(c || p[i] === o || p[i] === l) { + this.select_node(p[i]); + } + else { + this.deselect_node(p[i]); + } + } + } + else { + if(!this.is_selected(obj)) { + this.select_node(obj); + } + else { + this.deselect_node(obj); + } + } + } + /** + * triggered when an node is clicked or intercated with by the user + * @event + * @name activate_node.jstree + * @param {Object} node + */ + this.trigger('activate_node', { 'node' : this.get_node(obj) }); + }, + /** + * applies the hover state on a node, called when a node is hovered by the user. Used internally. + * @private + * @name hover_node(obj) + * @param {mixed} obj + * @trigger hover_node.jstree + */ + hover_node : function (obj) { + obj = this.get_node(obj, true); + if(!obj || !obj.length) { + return false; + } + obj.children('.jstree-anchor').addClass('jstree-hovered'); + /** + * triggered when an node is hovered + * @event + * @name hover_node.jstree + * @param {Object} node + */ + this.trigger('hover_node', { 'node' : this.get_node(obj) }); + }, + /** + * removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally. + * @private + * @name dehover_node(obj) + * @param {mixed} obj + * @trigger dehover_node.jstree + */ + dehover_node : function (obj) { + obj = this.get_node(obj, true); + if(!obj || !obj.length) { + return false; + } + obj.children('.jstree-anchor').removeClass('jstree-hovered'); + /** + * triggered when an node is no longer hovered + * @event + * @name dehover_node.jstree + * @param {Object} node + */ + this.trigger('dehover_node', { 'node' : this.get_node(obj) }); + }, + /** + * select a node + * @name select_node(obj [, supress_event, prevent_open]) + * @param {mixed} obj an array can be used to select multiple nodes + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened + * @trigger select_node.jstree, changed.jstree + */ + select_node : function (obj, supress_event, prevent_open) { + var dom, t1, t2, th; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.select_node(obj[t1], supress_event, prevent_open); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + dom = this.get_node(obj, true); + if(!obj.state.selected) { + obj.state.selected = true; + this._data.core.selected.push(obj.id); + + if(dom.length) { + dom.children('.jstree-anchor').addClass('jstree-clicked'); + if(!prevent_open) { + th = this; + dom.parents(".jstree-closed").each(function () { th.open_node(this, false, 0); }); + } + } + /** + * triggered when an node is selected + * @event + * @name select_node.jstree + * @param {Object} node + * @param {Array} selected the current selection + */ + this.trigger('select_node', { 'node' : obj, 'selected' : this._data.core.selected }); + if(!supress_event) { + /** + * triggered when selection changes + * @event + * @name changed.jstree + * @param {Object} node + * @param {Object} action the action that caused the selection to change + * @param {Array} selected the current selection + */ + this.trigger('changed', { 'action' : 'select_node', 'node' : obj, 'selected' : this._data.core.selected }); + } + } + }, + /** + * deselect a node + * @name deselect_node(obj [, supress_event]) + * @param {mixed} obj an array can be used to deselect multiple nodes + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger deselect_node.jstree, changed.jstree + */ + deselect_node : function (obj, supress_event) { + var t1, t2, dom; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.deselect_node(obj[t1], supress_event); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + dom = this.get_node(obj, true); + if(obj.state.selected) { + obj.state.selected = false; + this._data.core.selected = $.vakata.array_remove(this._data.core.selected, $.inArray(obj.id, this._data.core.selected)); + if(dom.length) { + dom.children('.jstree-anchor').removeClass('jstree-clicked'); + } + /** + * triggered when an node is deselected + * @event + * @name deselect_node.jstree + * @param {Object} node + * @param {Array} selected the current selection + */ + this.trigger('deselect_node', { 'node' : obj, 'selected' : this._data.core.selected }); + if(!supress_event) { + this.trigger('changed', { 'action' : 'deselect_node', 'node' : obj, 'selected' : this._data.core.selected }); + } + } + }, + /** + * select all nodes in the tree + * @name select_all([supress_event]) + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger select_all.jstree, changed.jstree + */ + select_all : function (supress_event) { + var tmp = this._data.core.selected.concat([]), i, j; + this._data.core.selected = this._model.data['#'].children_d.concat(); + for(i = 0, j = this._data.core.selected.length; i < j; i++) { + if(this._model.data[this._data.core.selected[i]]) { + this._model.data[this._data.core.selected[i]].state.selected = true; + } + } + this.redraw(true); + /** + * triggered when all nodes are selected + * @event + * @name select_all.jstree + * @param {Array} selected the current selection + */ + this.trigger('select_all', { 'selected' : this._data.core.selected }); + if(!supress_event) { + this.trigger('changed', { 'action' : 'select_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); + } + }, + /** + * deselect all selected nodes + * @name deselect_all([supress_event]) + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger deselect_all.jstree, changed.jstree + */ + deselect_all : function (supress_event) { + var tmp = this._data.core.selected.concat([]), i, j; + for(i = 0, j = this._data.core.selected.length; i < j; i++) { + if(this._model.data[this._data.core.selected[i]]) { + this._model.data[this._data.core.selected[i]].state.selected = false; + } + } + this._data.core.selected = []; + this.element.find('.jstree-clicked').removeClass('jstree-clicked'); + /** + * triggered when all nodes are deselected + * @event + * @name deselect_all.jstree + * @param {Object} node the previous selection + * @param {Array} selected the current selection + */ + this.trigger('deselect_all', { 'selected' : this._data.core.selected, 'node' : tmp }); + if(!supress_event) { + this.trigger('changed', { 'action' : 'deselect_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); + } + }, + /** + * checks if a node is selected + * @name is_selected(obj) + * @param {mixed} obj + * @return {Boolean} + */ + is_selected : function (obj) { + obj = this.get_node(obj); + if(!obj || obj.id === '#') { + return false; + } + return obj.state.selected; + }, + /** + * get an array of all selected node IDs + * @name get_selected() + * @return {Array} + */ + get_selected : function () { + return this._data.core.selected; + }, + /** + * gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally. + * @name get_state() + * @private + * @return {Object} + */ + get_state : function () { + var state = { + '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' : [] + } + }, i; + for(i in this._model.data) { + if(this._model.data.hasOwnProperty(i)) { + if(i !== '#') { + if(this._model.data[i].state.opened) { + state.core.open.push(i); + } + if(this._model.data[i].state.selected) { + state.core.selected.push(i); + } + } + } + } + return state; + }, + /** + * sets the state of the tree. Used internally. + * @name set_state(state [, callback]) + * @private + * @param {Object} state the state to restore + * @param {Function} callback an optional function to execute once the state is restored. + * @trigger set_state.jstree + */ + set_state : function (state, callback) { + if(state) { + if(state.core) { + var res, n, t, _this; + if($.isArray(state.core.open)) { + res = true; + n = false; + t = this; + $.each(state.core.open.concat([]), function (i, v) { + n = document.getElementById(v); + if(n) { + if(t.is_loaded(v)) { + if(t.is_closed(v)) { + t.open_node(v, false, 0); + } + $.vakata.array_remove(state.core.open, $.inArray(v,state.core.open)); + } + else { + if(!t.is_loading(v)) { + t.open_node(v, $.proxy(function () { this.set_state(state); }, t), 0); + } + // there will be some async activity - so wait for it + res = false; + } + } + }); + if(res) { + delete state.core.open; + this.set_state(state, callback); + } + return false; + } + if(state.core.scroll) { + if(state.core.scroll && state.core.scroll.left !== undefined) { + this.element.scrollLeft(state.core.scroll.left); + } + if(state.core.scroll && state.core.scroll.top !== undefined) { + this.element.scrollTop(state.core.scroll.top); + } + delete state.core.scroll; + delete state.core.open; + this.set_state(state, callback); + 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(state.core.selected) { + _this = this; + this.deselect_all(); + $.each(state.core.selected, function (i, v) { + _this.select_node(v); + }); + delete state.core.selected; + this.set_state(state, callback); + return false; + } + if($.isEmptyObject(state)) { + if(callback) { callback.call(this); } + /** + * triggered when a `set_state` call completes + * @event + * @name set_state.jstree + */ + this.trigger('set_state'); + return false; + } + return true; + } + return true; + } + return false; + }, + /** + * refreshes the tree - all nodes are reloaded with calls to `load_node`. + * @name refresh() + * @trigger refresh.jstree + */ + refresh : function () { + this._data.core.state = this.get_state(); + this.load_node('#', function (o, s) { + if(s) { + this.set_state($.extend(true, {}, this._data.core.state), function () { + /** + * triggered when a `refresh` call completes + * @event + * @name refresh.jstree + */ + this.trigger('refresh'); + }); + } + this._data.core.state = null; + }); + }, + /** + * get the text value of a node + * @name get_text(obj) + * @param {mixed} obj the node + * @return {String} + */ + get_text : function (obj) { + obj = this.get_node(obj); + return (!obj || obj.id === '#') ? false : obj.text; + }, + /** + * set the text value of a node. Used internally, please use `rename_node(obj, val)`. + * @private + * @name set_text(obj, val) + * @param {mixed} obj the node, you can pass an array to set the text on multiple nodes + * @param {String} val the new text value + * @return {Boolean} + * @trigger set_text.jstree + */ + set_text : function (obj, val) { + var t1, t2, dom, tmp; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.set_text(obj[t1], val); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { return false; } + obj.text = val; + dom = this.get_node(obj, true); + if(dom.length) { + dom = dom.children(".jstree-anchor:eq(0)"); + tmp = dom.children("I").clone(); + dom.html(val).prepend(tmp); + /** + * triggered when a node text value is changed + * @event + * @name set_text.jstree + * @param {Object} obj + * @param {String} text the new value + */ + this.trigger('set_text',{ "obj" : obj, "text" : val }); + } + return true; + }, + /** + * gets a JSON representation of a node (or the whole tree) + * @name get_json([obj, options]) + * @param {mixed} obj + * @param {Object} options + * @param {Boolean} options.no_state do not return state information + * @param {Boolean} options.no_id do not return ID + * @param {Boolean} options.no_children do not include children + * @return {Object} + */ + get_json : function (obj, options) { + obj = this.get_node(obj || '#'); + if(!obj) { return false; } + var tmp = { + 'id' : obj.id, + 'text' : obj.text, + 'icon' : this.get_icon(obj), + 'li_attr' : obj.li_attr, + 'a_attr' : obj.a_attr, + 'state' : {}, + 'data' : options && options.no_data ? false : ( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ), + 'children' : [] + }, i, j; + if(!options || !options.no_state) { + for(i in obj.state) { + if(obj.state.hasOwnProperty(i)) { + tmp.state[i] = obj.state[i]; + } + } + } + if(options && options.no_id && tmp.li_attr && tmp.li_attr.id) { + delete tmp.li_attr.id; + delete tmp.id; + } + if(!options || !options.no_children) { + for(i = 0, j = obj.children.length; i < j; i++) { + tmp.children.push(this.get_json(obj.children[i], options)); + } + } + return obj.id === '#' ? tmp.children : tmp; + }, + /** + * create a new node (do not confuse with load_node) + * @name create_node([obj, node, pos, callback, is_loaded]) + * @param {mixed} par the parent node + * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name) + * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last" + * @param {Function} callback a function to be called once the node is created + * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded + * @return {String} the ID of the newly create node + * @trigger model.jstree, create_node.jstree + */ + create_node : function (par, node, pos, callback, is_loaded) { + par = this.get_node(par); + if(!par) { return false; } + pos = pos === undefined ? "last" : pos; + if(!pos.match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { + return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); }); + } + if(!node) { node = { "text" : this.get_string('New node') }; } + if(node.text === undefined) { node.text = this.get_string('New node'); } + var tmp, dpc, i, j; + + if(par.id === '#') { + if(pos === "before") { pos = "first"; } + if(pos === "after") { pos = "last"; } + } + switch(pos) { + case "before": + tmp = this.get_node(par.parent); + pos = $.inArray(par, tmp.children); + par = tmp; + break; + case "after" : + tmp = this.get_node(par.parent); + pos = $.inArray(par, tmp.children); + par = tmp; + break; + case "inside": + case "first": + pos = 0; + break; + case "last": + pos = par.children.length; + break; + default: + if(!pos) { pos = 0; } + break; + } + if(pos > par.children.length) { pos = par.children.length; } + if(!node.id) { node.id = true; } + if(!this.check("create_node", node, par, pos)) { return false; } + delete node.id; + node = this._parse_model_from_json(node, par.id, par.parents.concat()); + if(!node) { return false; } + tmp = this.get_node(node); + dpc = []; + dpc.push(node); + dpc = dpc.concat(tmp.children_d); + this.trigger('model', { "nodes" : dpc, "parent" : par.id }); + + par.children_d = par.children_d.concat(dpc); + for(i = 0, j = par.parents.length; i < j; i++) { + this._model.data[par.parents[i]].children_d = this._model.data[par.parents[i]].children_d.concat(dpc); + } + node = tmp; + tmp = []; + for(i = 0, j = par.children.length; i < j; i++) { + tmp[i >= pos ? i+1 : i] = par.children[i]; + } + tmp[pos] = node.id; + par.children = tmp; + + this.redraw_node(par, true); + if(callback) { callback.call(this, this.get_node(node)); } + /** + * triggered when a node is created + * @event + * @name create_node.jstree + * @param {Object} node + * @param {String} parent the parent's ID + * @param {Number} position the position of the new node among the parent's children + */ + this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos }); + return node.id; + }, + /** + * set the text value of a node + * @name rename_node(obj, val) + * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name + * @param {String} val the new text value + * @return {Boolean} + * @trigger rename_node.jstree + */ + rename_node : function (obj, val) { + var t1, t2, old; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.rename_node(obj[t1], val); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { return false; } + old = obj.text; + if(!this.check("rename_node", obj, this.get_parent(obj), val)) { return false; } + this.set_text(obj, val); // .apply(this, Array.prototype.slice.call(arguments)) + /** + * triggered when a node is renamed + * @event + * @name rename_node.jstree + * @param {Object} node + * @param {String} text the new value + * @param {String} old the old value + */ + this.trigger('rename_node', { "node" : obj, "text" : val, "old" : old }); + return true; + }, + /** + * remove a node + * @name delete_node(obj) + * @param {mixed} obj the node, you can pass an array to delete multiple nodes + * @return {Boolean} + * @trigger delete_node.jstree, changed.jstree + */ + delete_node : function (obj) { + var t1, t2, par, pos, tmp, i, j, k, l, c; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.delete_node(obj[t1]); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { return false; } + par = this.get_node(obj.parent); + pos = $.inArray(obj.id, par.children); + c = false; + if(!this.check("delete_node", obj, par, pos)) { return false; } + par.children = $.vakata.array_remove(par.children, pos); + tmp = obj.children_d.concat([]); + tmp.push(obj.id); + for(k = 0, l = tmp.length; k < l; k++) { + for(i = 0, j = obj.parents.length; i < j; i++) { + this._model.data[obj.parents[i]].children_d = $.vakata.array_remove(this._model.data[obj.parents[i]].children_d, $.inArray(tmp[k], this._model.data[obj.parents[i]].children_d)); + } + if(this._model.data[tmp[k]].state.selected) { + c = true; + this._data.core.selected = $.vakata.array_remove(this._data.core.selected, $.inArray(tmp[k], this._data.core.selected)); + } + } + /** + * triggered when a node is deleted + * @event + * @name delete_node.jstree + * @param {Object} node + * @param {String} parent the parent's ID + */ + this.trigger('delete_node', { "node" : obj, "parent" : par.id }); + if(c) { + this.trigger('changed', { 'action' : 'delete_node', 'node' : obj, 'selected' : this._data.core.selected, 'parent' : par.id }); + } + delete this._model.data[obj.id]; + this.redraw_node(par, true); + return true; + }, + /** + * check if an operation is premitted on the tree. Used internally. + * @private + * @name check(chk, obj, par, pos) + * @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node" + * @param {mixed} obj the node + * @param {mixed} par the parent + * @param {mixed} pos the position to insert at, or if "rename_node" - the new name + * @return {Boolean} + */ + check : function (chk, obj, par, pos) { + obj = obj && obj.id ? obj : this.get_node(obj); + par = par && par.id ? par : this.get_node(par); + var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj, + chc = this.settings.core.check_callback; + if(chk === "move_node") { + if(obj.id === par.id || $.inArray(obj.id, par.children) === pos || $.inArray(par.id, obj.children_d) !== -1) { + return false; + } + } + tmp = this.get_node(tmp, true); + if(tmp.length) { tmp = tmp.data('jstree'); } + if(tmp && tmp.functions && (tmp.functions[chk] === false || tmp.functions[chk] === true)) { + return tmp.functions[chk]; + } + if(chc === false || ($.isFunction(chc) && chc.call(this, chk, obj, par, pos) === false) || (chc && chc[chk] === false)) { + return false; + } + return true; + }, + /** + * move a node to a new parent + * @name move_node(obj, par [, pos, callback, is_loaded]) + * @param {mixed} obj the node to move, pass an array to move multiple nodes + * @param {mixed} par the new parent + * @param {mixed} pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` + * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param {Boolean} internal parameter indicating if the parent node has been loaded + * @trigger move_node.jstree + */ + move_node : function (obj, par, pos, callback, is_loaded) { + var t1, t2, old_par, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p; + if($.isArray(obj)) { + obj.reverse(); + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.move_node(obj[t1], par, pos, callback, is_loaded); + } + return true; + } + obj = obj && obj.id ? obj : this.get_node(obj); + par = this.get_node(par); + pos = pos === undefined ? 0 : pos; + + if(!par || !obj || obj.id === '#') { return false; } + if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { + return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true); }); + } + + old_par = obj.parent.toString(); + new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent); + old_ins = this._model.data[obj.id] ? this : $.jstree.reference(obj.id); + is_multi = (this._id !== old_ins._id); + //var m = this._model.data; + if(new_par.id === '#') { + if(pos === "before") { pos = "first"; } + if(pos === "after") { pos = "last"; } + } + switch(pos) { + case "before": + pos = $.inArray(par.id, new_par.children); + break; + case "after" : + pos = $.inArray(par.id, new_par.children) + 1; + break; + case "inside": + case "first": + pos = 0; + break; + case "last": + pos = new_par.children.length; + break; + default: + if(!pos) { pos = 0; } + break; + } + if(pos > new_par.children.length) { pos = new_par.children.length; } + if(!this.check("move_node", obj, new_par, pos)) { return false; } + if(!is_multi && obj.parent === new_par.id) { + dpc = new_par.children.concat(); + tmp = $.inArray(obj.id, dpc); + if(tmp !== -1) { + dpc = $.vakata.array_remove(dpc, tmp); + if(pos > tmp) { pos--; } + } + tmp = []; + for(i = 0, j = dpc.length; i < j; i++) { + tmp[i >= pos ? i+1 : i] = dpc[i]; + } + tmp[pos] = obj.id; + new_par.children = tmp; + this._node_changed(new_par.id); + this.redraw(new_par.id === '#'); + } + else { + // clean old parent and up + tmp = obj.children_d.concat(); + tmp.push(obj.id); + for(i = 0, j = obj.parents.length; i < j; i++) { + dpc = []; + p = old_ins._model.data[obj.parents[i]].children_d; + for(k = 0, l = p.length; k < l; k++) { + if($.inArray(p[k], tmp) === -1) { + dpc.push(p[k]); + } + } + old_ins._model.data[obj.parents[i]].children_d = dpc; + } + old_ins._model.data[old_par].children = $.vakata.array_remove(old_ins._model.data[old_par].children, $.inArray(obj.id, old_ins._model.data[old_par].children)); + + // insert into new parent and up + for(i = 0, j = new_par.parents.length; i < j; i++) { + this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(tmp); + } + dpc = []; + for(i = 0, j = new_par.children.length; i < j; i++) { + dpc[i >= pos ? i+1 : i] = new_par.children[i]; + } + dpc[pos] = obj.id; + new_par.children = dpc; + new_par.children_d.push(obj.id); + new_par.children_d = new_par.children_d.concat(obj.children_d); + + // update object + obj.parent = new_par.id; + tmp = new_par.parents.concat(); + tmp.push(new_par.id); + obj.parents = tmp; + + if(is_multi) { + old_ins.delete_node(obj.id); + this._node_changed(new_par.id); + this.redraw(new_par.id === '#'); + } + else { + this._node_changed(old_par); + this._node_changed(new_par.id); + this.redraw(old_par === '#' || new_par.id === '#'); + } + } + if(callback) { callback.call(this, obj, new_par, pos); } + /** + * triggered when a node is moved + * @event + * @name move_node.jstree + * @param {Object} node + * @param {String} parent the parent's ID + * @param {Number} position the position of the node among the parent's children + * @param {String} old_parent the old parent of the node + * @param {Boolean} is_multi do the node and new parent belong to different instances + * @param {jsTree} old_instance the instance the node came from + * @param {jsTree} new_instance the instance of the new parent + */ + this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "is_multi" : is_multi, 'old_instance' : old_ins, 'new_instance' : this }); + return true; + }, + /** + * copy a node to a new parent + * @name copy_node(obj, par [, pos, callback, is_loaded]) + * @param {mixed} obj the node to copy, pass an array to copy multiple nodes + * @param {mixed} par the new parent + * @param {mixed} pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` + * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param {Boolean} internal parameter indicating if the parent node has been loaded + * @trigger model.jstree copy_node.jstree + */ + copy_node : function (obj, par, pos, callback, is_loaded) { + var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi; + if($.isArray(obj)) { + obj.reverse(); + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.copy_node(obj[t1], par, pos, callback, is_loaded); + } + return true; + } + obj = obj && obj.id ? obj : this.get_node(obj); + par = this.get_node(par); + pos = pos === undefined ? 0 : pos; + + if(!par || !obj || obj.id === '#') { return false; } + if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { + return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true); }); + } + + old_par = obj.parent.toString(); + new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent); + old_ins = this._model.data[obj.id] ? this : $.jstree.reference(obj.id); + is_multi = (this._id !== old_ins._id); + if(new_par.id === '#') { + if(pos === "before") { pos = "first"; } + if(pos === "after") { pos = "last"; } + } + switch(pos) { + case "before": + pos = $.inArray(par.id, new_par.children); + break; + case "after" : + pos = $.inArray(par.id, new_par.children) + 1; + break; + case "inside": + case "first": + pos = 0; + break; + case "last": + pos = new_par.children.length; + break; + default: + if(!pos) { pos = 0; } + break; + } + if(pos > new_par.children.length) { pos = new_par.children.length; } + if(!this.check("copy_node", obj, new_par, pos)) { return false; } + + node = old_ins.get_json(obj, { no_id : true, no_data : true, no_state : true }); + if(!node) { return false; } + node = this._parse_model_from_json(node, new_par.id, new_par.parents.concat()); + if(!node) { return false; } + tmp = this.get_node(node); + dpc = []; + dpc.push(node); + dpc = dpc.concat(tmp.children_d); + this.trigger('model', { "nodes" : dpc, "parent" : new_par.id }); + + // insert into new parent and up + for(i = 0, j = new_par.parents.length; i < j; i++) { + this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(dpc); + } + dpc = []; + for(i = 0, j = new_par.children.length; i < j; i++) { + dpc[i >= pos ? i+1 : i] = new_par.children[i]; + } + dpc[pos] = tmp.id; + new_par.children = dpc; + new_par.children_d.push(tmp.id); + new_par.children_d = new_par.children_d.concat(tmp.children_d); + + this._node_changed(new_par.id); + this.redraw(new_par.id === '#'); + if(callback) { callback.call(this, tmp, new_par, pos); } + /** + * triggered when a node is copied + * @event + * @name copy_node.jstree + * @param {Object} node the copied node + * @param {Object} original the original node + * @param {String} parent the parent's ID + * @param {Number} position the position of the node among the parent's children + * @param {String} old_parent the old parent of the node + * @param {Boolean} is_multi do the node and new parent belong to different instances + * @param {jsTree} old_instance the instance the node came from + * @param {jsTree} new_instance the instance of the new parent + */ + this.trigger('copy_node', { "node" : tmp, "original" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "is_multi" : is_multi, 'old_instance' : old_ins, 'new_instance' : this }); + return tmp.id; + }, + /** + * cut a node (a later call to `paste(obj)` would move the node) + * @name cut(obj) + * @param {mixed} obj multiple objects can be passed using an array + * @trigger cut.jstree + */ + cut : function (obj) { + if(!obj) { obj = this._data.core.selected.concat(); } + if(!$.isArray(obj)) { obj = [obj]; } + if(!obj.length) { return false; } + var tmp = [], o, t1, t2; + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + o = this.get_node(obj[t1]); + if(o && o.id && o.id !== '#') { tmp.push(o); } + } + if(!tmp.length) { return false; } + ccp_node = tmp; + ccp_inst = this; + ccp_mode = 'move_node'; + /** + * triggered when nodes are added to the buffer for moving + * @event + * @name cut.jstree + * @param {Array} node + */ + this.trigger('cut', { "node" : obj }); + }, + /** + * copy a node (a later call to `paste(obj)` would copy the node) + * @name copy(obj) + * @param {mixed} obj multiple objects can be passed using an array + * @trigger copy.jstre + */ + copy : function (obj) { + if(!obj) { obj = this._data.core.selected.concat(); } + if(!$.isArray(obj)) { obj = [obj]; } + if(!obj.length) { return false; } + var tmp = [], o, t1, t2; + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + o = this.get_node(obj[t1]); + if(o && o.id && o.id !== '#') { tmp.push(o); } + } + if(!tmp.length) { return false; } + ccp_node = tmp; + ccp_inst = this; + ccp_mode = 'copy_node'; + /** + * triggered when nodes are added to the buffer for copying + * @event + * @name copy.jstree + * @param {Array} node + */ + this.trigger('copy', { "node" : obj }); + }, + /** + * get the current buffer (any nodes that are waiting for a paste operation) + * @name get_buffer() + * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance) + */ + get_buffer : function () { + return { 'mode' : ccp_mode, 'node' : ccp_node, 'inst' : ccp_inst }; + }, + /** + * check if there is something in the buffer to paste + * @name can_paste() + * @return {Boolean} + */ + can_paste : function () { + return ccp_mode !== false && ccp_node !== false; // && ccp_inst._model.data[ccp_node]; + }, + /** + * copy or move the previously cut or copied nodes to a new parent + * @name paste(obj) + * @param {mixed} obj the new parent + * @trigger paste.jstree + */ + paste : function (obj) { + obj = this.get_node(obj); + if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; } + if(this[ccp_mode](ccp_node, obj)) { + /** + * triggered when paste is invoked + * @event + * @name paste.jstree + * @param {String} parent the ID of the receiving node + * @param {Array} node the nodes in the buffer + * @param {String} mode the performed operation - "copy_node" or "move_node" + */ + this.trigger('paste', { "parent" : obj.id, "node" : ccp_node, "mode" : ccp_mode }); + } + ccp_node = false; + ccp_mode = false; + ccp_inst = false; + }, + /** + * put a node in edit mode (input field to rename the node) + * @name edit(obj [, default_text]) + * @param {mixed} obj + * @param {String} default_text the text to populate the input with (if omitted the node text value is used) + */ + edit : function (obj, default_text) { + obj = this.get_node(obj, true); + if(!obj || !obj.length) { return false; } + obj.parentsUntil(".jstree",".jstree-closed").each($.proxy(function (i, v) { + this.open_node(v, false, 0); + }, this)); + var rtl = this._data.core.rtl, + w = this.element.width(), + a = obj.children('.jstree-anchor'), + /*! + oi = obj.children("i:visible"), + ai = a.children("i:visible"), + w1 = oi.width() * oi.length, + w2 = ai.width() * ai.length, + */ + t = typeof default_text === 'string' ? default_text : this.get_text(obj), + h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"), + h2 = $("<"+"input />", { + "value" : t, + "class" : "jstree-rename-input", + // "size" : t.length, + "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" // will be set a bit further down + }, + "blur" : $.proxy(function () { + var i = a.children(".jstree-rename-input"), + v = i.val(); + if(v === "") { v = t; } + h1.remove(); + i.remove(); + if(this.rename_node(obj, v) === false) { + this.rename_node(obj, t); + } + }, this), + "keydown" : function (event) { + var key = event.which; + if(key === 27) { + this.value = t; + } + if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) { + event.stopImmediatePropagation(); + } + if(key === 27 || key === 13) { + event.preventDefault(); + this.blur(); + } + }, + "keyup" : function (event) { + h2.width(Math.min(h1.text("pW" + this.value).width(),w)); + }, + "keypress" : function(event) { + if(event.which === 13) { return false; } + } + }), + fn = { + fontFamily : a.css('fontFamily') || '', + fontSize : a.css('fontSize') || '', + fontWeight : a.css('fontWeight') || '', + fontStyle : a.css('fontStyle') || '', + fontStretch : a.css('fontStretch') || '', + fontVariant : a.css('fontVariant') || '', + letterSpacing : a.css('letterSpacing') || '', + wordSpacing : a.css('wordSpacing') || '' + }; + this.set_text(obj, ""); + a.append(h2); + h1.css(fn); + h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select(); + }, + + + /** + * changes the theme + * @name set_theme(theme_name [, theme_url]) + * @param {String} theme_name the name of the new theme to apply + * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory. + * @trigger set_theme.jstree + */ + set_theme : function (theme_name, theme_url) { + if(!theme_name) { return false; } + if(theme_url === true) { + var dir = this.settings.core.themes.dir; + if(!dir) { dir = $.jstree.path + '/themes'; } + theme_url = dir + '/' + theme_name + '/style.css'; + } + if(theme_url && $.inArray(theme_url, themes_loaded) === -1) { + $('head').append('<'+'link rel="stylesheet" href="' + theme_url + '" type="text/css" />'); + themes_loaded.push(theme_url); + } + if(this._data.core.themes.name) { + this.element.removeClass('jstree-' + this._data.core.themes.name); + } + this._data.core.themes.name = theme_name; + this.element.addClass('jstree-' + theme_name); + /** + * triggered when a theme is set + * @event + * @name set_theme.jstree + * @param {String} theme the new theme + */ + this.trigger('set_theme', { 'theme' : theme_name }); + }, + /** + * gets the name of the currently applied theme name + * @name get_theme() + * @return {String} + */ + get_theme : function () { return this._data.core.themes.name; }, + /** + * changes the theme variant (if the theme has variants) + * @name set_theme_variant(variant_name) + * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed) + */ + set_theme_variant : function (variant_name) { + 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 = variant_name; + if(variant_name) { + this.element.addClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant); + } + }, + /** + * gets the name of the currently applied theme variant + * @name get_theme() + * @return {String} + */ + get_theme_variant : function () { return this._data.core.themes.variant; }, + /** + * shows a striped background on the container (if the theme supports it) + * @name show_stripes() + */ + show_stripes : function () { this._data.core.themes.stripes = true; this.get_container_ul().addClass("jstree-striped"); }, + /** + * hides the striped background on the container + * @name hide_stripes() + */ + hide_stripes : function () { this._data.core.themes.stripes = false; this.get_container_ul().removeClass("jstree-striped"); }, + /** + * toggles the striped background on the container + * @name toggle_stripes() + */ + toggle_stripes : function () { if(this._data.core.themes.stripes) { this.hide_stripes(); } else { this.show_stripes(); } }, + /** + * shows the connecting dots (if the theme supports it) + * @name show_dots() + */ + show_dots : function () { this._data.core.themes.dots = true; this.get_container_ul().removeClass("jstree-no-dots"); }, + /** + * hides the connecting dots + * @name hide_dots() + */ + hide_dots : function () { this._data.core.themes.dots = false; this.get_container_ul().addClass("jstree-no-dots"); }, + /** + * toggles the connecting dots + * @name toggle_dots() + */ + toggle_dots : function () { if(this._data.core.themes.dots) { this.hide_dots(); } else { this.show_dots(); } }, + /** + * show the node icons + * @name show_icons() + */ + show_icons : function () { this._data.core.themes.icons = true; this.get_container_ul().removeClass("jstree-no-icons"); }, + /** + * hide the node icons + * @name hide_icons() + */ + hide_icons : function () { this._data.core.themes.icons = false; this.get_container_ul().addClass("jstree-no-icons"); }, + /** + * toggle the node icons + * @name toggle_icons() + */ + toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }, + /** + * set the node icon for a node + * @name set_icon(obj, icon) + * @param {mixed} obj + * @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class + */ + set_icon : function (obj, icon) { + var t1, t2, dom; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.set_icon(obj[t1], icon); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj.id === '#') { return false; } + obj.icon = icon; + dom = this.get_node(obj, true).children("jstree-anchor").children(".jstree-themeicon"); + if(icon === false) { + this.removeClass('jstree-themeicon-custom').hide_icon(obj); + } + else if(icon.indexOf("/") === -1) { + dom.addClass(icon + ' jstree-themeicon-custom').attr("rel",icon); + } + else { + dom.removeClass('jstree-themeicon-custom').css("background", "url('" + icon + "') center center no-repeat").attr("rel",icon); + } + return true; + }, + /** + * get the node icon for a node + * @name get_icon(obj) + * @param {mixed} obj + * @return {String} + */ + get_icon : function (obj) { + obj = this.get_node(obj); + return (!obj || obj.id === '#') ? false : obj.icon; + }, + /** + * hide the icon on an individual node + * @name hide_icon(obj) + * @param {mixed} obj + */ + hide_icon : function (obj) { + var t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.hide_icon(obj[t1]); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj === '#') { return false; } + obj.icon = false; + this.get_node(obj, true).children("a").children(".jstree-themeicon").addClass('jstree-themeicon-hidden'); + return true; + }, + /** + * show the icon on an individual node + * @name show_icon(obj) + * @param {mixed} obj + */ + show_icon : function (obj) { + var t1, t2, dom; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.show_icon(obj[t1]); + } + return true; + } + obj = this.get_node(obj); + if(!obj || obj === '#') { return false; } + dom = this.get_node(obj, true); + obj.icon = dom.length ? dom.children("a").children(".jstree-themeicon").attr('rel') : true; + if(!obj.icon) { obj.icon = true; } + dom.children("a").children(".jstree-themeicon").removeClass('jstree-themeicon-hidden'); + return true; + } + }; + + // helpers + $.vakata = {}; + // reverse + $.fn.vakata_reverse = [].reverse; + // collect attributes + $.vakata.attributes = function(node, with_values) { + node = $(node)[0]; + var attr = with_values ? {} : []; + $.each(node.attributes, function (i, v) { + if($.inArray(v.nodeName.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; } + if(v.nodeValue !== null && $.trim(v.nodeValue) !== '') { + if(with_values) { attr[v.nodeName] = v.nodeValue; } + else { attr.push(v.nodeName); } + } + }); + return attr; + }; + $.vakata.array_unique = function(array) { + var a = [], i, j, l; + for(i = 0, l = array.length; i < l; i++) { + for(j = 0; j <= i; j++) { + if(array[i] === array[j]) { + break; + } + } + if(j === i) { a.push(array[i]); } + } + return a; + }; + // remove item from array + $.vakata.array_remove = function(array, from, to) { + var rest = array.slice((to || from) + 1 || array.length); + array.length = from < 0 ? array.length + from : from; + array.push.apply(array, rest); + return array; + }; + // browser sniffing + (function () { + var browser = {}, + b_match = function(ua) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + (ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua )) || + []; + return { + browser: match[1] || "", + version: match[2] || "0" + }; + }, + matched = b_match(window.navigator.userAgent); + if(matched.browser) { + browser[ matched.browser ] = true; + browser.version = matched.version; + } + if(browser.chrome) { + browser.webkit = true; + } + else if(browser.webkit) { + browser.safari = true; + } + $.vakata.browser = browser; + }()); + if($.vakata.browser.msie && $.vakata.browser.version < 8) { + $.jstree.defaults.core.animation = 0; + } + +/** + * ### Checkbox plugin + * + * This plugin renders checkbox icons in front of each node, making multiple selection much easier. + * It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up. + */ + + var _i = document.createElement('I'); + _i.className = 'jstree-icon jstree-checkbox'; + /** + * stores all defaults for the checkbox plugin + * @name $.jstree.defaults.checkbox + * @plugin checkbox + */ + $.jstree.defaults.checkbox = { + /** + * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`. + * @name $.jstree.defaults.checkbox.visible + * @plugin checkbox + */ + visible : true, + /** + * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`. + * @name $.jstree.defaults.checkbox.three_state + * @plugin checkbox + */ + three_state : true, + /** + * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`. + * @name $.jstree.defaults.checkbox.whole_node + * @plugin checkbox + */ + whole_node : true, + /** + * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`. + * @name $.jstree.defaults.checkbox.keep_selected_style + * @plugin checkbox + */ + keep_selected_style : true + }; + $.jstree.plugins.checkbox = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + this._data.checkbox.uto = false; + this.element + .on("init.jstree", $.proxy(function () { + this._data.checkbox.visible = this.settings.checkbox.visible; + if(!this.settings.checkbox.keep_selected_style) { + this.element.addClass('jstree-checkbox-no-clicked'); + } + }, this)) + .on("loading.jstree", $.proxy(function () { + this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ](); + }, this)); + if(this.settings.checkbox.three_state) { + this.element + .on('changed.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree', $.proxy(function () { + if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } + this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); + }, this)) + .on('model.jstree', $.proxy(function (e, data) { + var m = this._model.data, + p = m[data.parent], + dpc = data.nodes, + chd = [], + c, i, j, k, l, tmp; + + // apply down + if(p.state.selected) { + for(i = 0, j = dpc.length; i < j; i++) { + m[dpc[i]].state.selected = true; + } + this._data.core.selected = this._data.core.selected.concat(dpc); + } + else { + for(i = 0, j = dpc.length; i < j; i++) { + if(m[dpc[i]].state.selected) { + for(k = 0, l = m[dpc[i]].children_d.length; k < l; k++) { + m[m[dpc[i]].children_d[k]].state.selected = true; + } + this._data.core.selected = this._data.core.selected.concat(m[dpc[i]].children_d); + } + } + } + + // apply up + for(i = 0, j = p.children_d.length; i < j; i++) { + if(!m[p.children_d[i]].children.length) { + chd.push(m[p.children_d[i]].parent); + } + } + chd = $.vakata.array_unique(chd); + for(k = 0, l = chd.length; k < l; k++) { + p = m[chd[k]]; + while(p && p.id !== '#') { + c = 0; + for(i = 0, j = p.children.length; i < j; i++) { + c += m[p.children[i]].state.selected; + } + if(c === j) { + p.state.selected = true; + this._data.core.selected.push(p.id); + tmp = this.get_node(p, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').addClass('jstree-clicked'); + } + } + else { + break; + } + p = this.get_node(p.parent); + } + } + this._data.core.selected = $.vakata.array_unique(this._data.core.selected); + }, this)) + .on('select_node.jstree', $.proxy(function (e, data) { + var obj = data.node, + m = this._model.data, + par = this.get_node(obj.parent), + dom = this.get_node(obj, true), + i, j, c, tmp; + this._data.core.selected = $.vakata.array_unique(this._data.core.selected.concat(obj.children_d)); + for(i = 0, j = obj.children_d.length; i < j; i++) { + m[obj.children_d[i]].state.selected = true; + } + while(par && par.id !== '#') { + c = 0; + for(i = 0, j = par.children.length; i < j; i++) { + c += m[par.children[i]].state.selected; + } + if(c === j) { + par.state.selected = true; + this._data.core.selected.push(par.id); + tmp = this.get_node(par, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').addClass('jstree-clicked'); + } + } + else { + break; + } + par = this.get_node(par.parent); + } + if(dom.length) { + dom.find('.jstree-anchor').addClass('jstree-clicked'); + } + }, this)) + .on('deselect_node.jstree', $.proxy(function (e, data) { + var obj = data.node, + dom = this.get_node(obj, true), + i, j, tmp; + for(i = 0, j = obj.children_d.length; i < j; i++) { + this._model.data[obj.children_d[i]].state.selected = false; + } + for(i = 0, j = obj.parents.length; i < j; i++) { + this._model.data[obj.parents[i]].state.selected = false; + tmp = this.get_node(obj.parents[i], true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').removeClass('jstree-clicked'); + } + } + tmp = []; + for(i = 0, j = this._data.core.selected.length; i < j; i++) { + if($.inArray(this._data.core.selected[i], obj.children_d) === -1 && $.inArray(this._data.core.selected[i], obj.parents) === -1) { + tmp.push(this._data.core.selected[i]); + } + } + this._data.core.selected = $.vakata.array_unique(tmp); + if(dom.length) { + dom.find('.jstree-anchor').removeClass('jstree-clicked'); + } + }, this)) + .on('delete_node.jstree', $.proxy(function (e, data) { + var p = this.get_node(data.parent), + m = this._model.data, + i, j, c, tmp; + while(p && p.id !== '#') { + c = 0; + for(i = 0, j = p.children.length; i < j; i++) { + c += m[p.children[i]].state.selected; + } + if(c === j) { + p.state.selected = true; + this._data.core.selected.push(p.id); + tmp = this.get_node(p, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').addClass('jstree-clicked'); + } + } + else { + break; + } + p = this.get_node(p.parent); + } + }, this)) + .on('move_node.jstree', $.proxy(function (e, data) { + var is_multi = data.is_multi, + old_par = data.old_parent, + new_par = this.get_node(data.parent), + m = this._model.data, + p, c, i, j, tmp; + if(!is_multi) { + p = this.get_node(old_par); + while(p && p.id !== '#') { + c = 0; + for(i = 0, j = p.children.length; i < j; i++) { + c += m[p.children[i]].state.selected; + } + if(c === j) { + p.state.selected = true; + this._data.core.selected.push(p.id); + tmp = this.get_node(p, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').addClass('jstree-clicked'); + } + } + else { + break; + } + p = this.get_node(p.parent); + } + } + p = new_par; + while(p && p.id !== '#') { + c = 0; + for(i = 0, j = p.children.length; i < j; i++) { + c += m[p.children[i]].state.selected; + } + if(c === j) { + if(!p.state.selected) { + p.state.selected = true; + this._data.core.selected.push(p.id); + tmp = this.get_node(p, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').addClass('jstree-clicked'); + } + } + } + else { + if(p.state.selected) { + p.state.selected = false; + this._data.core.selected = $.vakata.array_remove(this._data.core.selected, $.inArray(p.id, this._data.core.selected)); + tmp = this.get_node(p, true); + if(tmp && tmp.length) { + tmp.children('.jstree-anchor').removeClass('jstree-clicked'); + } + } + else { + break; + } + } + p = this.get_node(p.parent); + } + }, this)); + } + }; + /** + * set the undetermined state where and if necessary. Used internally. + * @private + * @name _undetermined() + * @plugin checkbox + */ + this._undetermined = function () { + var i, j, m = this._model.data, s = this._data.core.selected, p = [], t = this; + for(i = 0, j = s.length; i < j; i++) { + if(m[s[i]] && m[s[i]].parents) { + p = p.concat(m[s[i]].parents); + } + } + // attempt for server side undetermined state + this.element.find('.jstree-closed').not(':has(ul)') + .each(function () { + var tmp = t.get_node(this); + if(!tmp.state.loaded && tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) { + p.push(tmp.id); + p = p.concat(tmp.parents); + } + }); + p = $.vakata.array_unique(p); + i = $.inArray('#', p); + if(i !== -1) { + p = $.vakata.array_remove(p, i); + } + + this.element.find('.jstree-undetermined').removeClass('jstree-undetermined'); + for(i = 0, j = p.length; i < j; i++) { + if(!m[p[i]].state.selected) { + s = this.get_node(p[i], true); + if(s && s.length) { + s.children('a').children('.jstree-checkbox').addClass('jstree-undetermined'); + } + } + } + }; + this.redraw_node = function(obj, deep, is_callback) { + obj = parent.redraw_node.call(this, obj, deep, is_callback); + if(obj) { + var tmp = obj.getElementsByTagName('A')[0]; + tmp.insertBefore(_i.cloneNode(), tmp.childNodes[0]); + } + if(!is_callback && this.settings.checkbox.three_state) { + if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } + this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); + } + return obj; + }; + this.activate_node = function (obj, e) { + if(this.settings.checkbox.whole_node || $(e.target).hasClass('jstree-checkbox')) { + e.ctrlKey = true; + } + return parent.activate_node.call(this, obj, e); + }; + /** + * show the node checkbox icons + * @name show_checkboxes() + * @plugin checkbox + */ + this.show_checkboxes = function () { this._data.core.themes.checkboxes = true; this.element.children("ul").removeClass("jstree-no-checkboxes"); }; + /** + * hide the node checkbox icons + * @name hide_checkboxes() + * @plugin checkbox + */ + this.hide_checkboxes = function () { this._data.core.themes.checkboxes = false; this.element.children("ul").addClass("jstree-no-checkboxes"); }; + /** + * toggle the node icons + * @name toggle_checkboxes() + * @plugin checkbox + */ + this.toggle_checkboxes = function () { if(this._data.core.themes.checkboxes) { this.hide_checkboxes(); } else { this.show_checkboxes(); } }; + }; + + // include the checkbox plugin by default + // $.jstree.defaults.plugins.push("checkbox"); + +/** + * ### Contextmenu plugin + * + * Shows a context menu when a node is right-clicked. + */ +// TODO: move logic outside of function + check multiple move + + /** + * stores all defaults for the contextmenu plugin + * @name $.jstree.defaults.contextmenu + * @plugin contextmenu + */ + $.jstree.defaults.contextmenu = { + /** + * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`. + * @name $.jstree.defaults.contextmenu.select_node + * @plugin contextmenu + */ + select_node : true, + /** + * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used. + * @name $.jstree.defaults.contextmenu.show_at_node + * @plugin contextmenu + */ + show_at_node : true, + /** + * an object of actions, or a function that accepts a node and returns an object of actions available for that node. + * + * Each action consists of a key (a unique name) and a value which is an object with the following properties: + * + * * `separator_before` - a boolean indicating if there should be a separator before this item + * * `separator_after` - a boolean indicating if there should be a separator after this item + * * `_disabled` - a boolean indicating if this action should be disabled + * * `label` - a string - the name of the action + * * `action` - a function to be executed if this item is chosen + * + * @name $.jstree.defaults.contextmenu.items + * @plugin contextmenu + */ + items : function (o) { // Could be an object directly + return { + "create" : { + "separator_before" : false, + "separator_after" : true, + "_disabled" : false, //(this.check("create_node", data.reference, {}, "last")), + "label" : "Create", + "action" : function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + inst.create_node(obj, {}, "last", function (new_node) { + setTimeout(function () { inst.edit(new_node); },0); + }); + } + }, + "rename" : { + "separator_before" : false, + "separator_after" : false, + "_disabled" : false, //(this.check("rename_node", data.reference, this.get_parent(data.reference), "")), + "label" : "Rename", + "action" : function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + inst.edit(obj); + } + }, + "remove" : { + "separator_before" : false, + "icon" : false, + "separator_after" : false, + "_disabled" : false, //(this.check("delete_node", data.reference, this.get_parent(data.reference), "")), + "label" : "Delete", + "action" : function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + if(inst.is_selected(obj)) { + inst.delete_node(inst.get_selected()); + } + else { + inst.delete_node(obj); + } + } + }, + "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 (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + if(inst.is_selected(obj)) { + inst.cut(inst.get_selected()); + } + else { + inst.cut(obj); + } + } + }, + "copy" : { + "separator_before" : false, + "icon" : false, + "separator_after" : false, + "label" : "Copy", + "action" : function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + if(inst.is_selected(obj)) { + inst.copy(inst.get_selected()); + } + else { + inst.copy(obj); + } + } + }, + "paste" : { + "separator_before" : false, + "icon" : false, + "_disabled" : !(this.can_paste()), + "separator_after" : false, + "label" : "Paste", + "action" : function (data) { + var inst = $.jstree.reference(data.reference), + obj = inst.get_node(data.reference); + inst.paste(obj); + } + } + } + } + }; + } + }; + + $.jstree.plugins.contextmenu = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + + this.element + .on("contextmenu.jstree", "a", $.proxy(function (e) { + e.preventDefault(); + if(!this.is_loading(e.currentTarget)) { + this.show_contextmenu(e.currentTarget, e.pageX, e.pageY); + } + }, this)) + .on("click.jstree", "a", $.proxy(function (e) { + if(this._data.contextmenu.visible) { + $.vakata.context.hide(); + } + }, this)); + $(document).on("context_hide.vakata", $.proxy(function () { this._data.contextmenu.visible = false; }, this)); + }; + this.teardown = function () { + if(this._data.contextmenu.visible) { + $.vakata.context.hide(); + } + parent.teardown.call(this); + }; + + /** + * show the context menu for a node + * @name show_contextmenu(obj [, x, y]) + * @param {mixed} obj the node + * @param {Number} x the x-coordinate relative to the document to show the menu at + * @param {Number} y the y-coordinate relative to the document to show the menu at + * @plugin contextmenu + * @trigger show_contextmenu.jstree + */ + this.show_contextmenu = function (obj, x, y) { + obj = this.get_node(obj); + if(!obj || obj.id === '#') { return false; } + var s = this.settings.contextmenu, + d = this.get_node(obj, true), + a = d.children(".jstree-anchor"), + o = false, + i = false; + if(s.show_at_node || x === undefined || y === undefined) { + o = a.offset(); + x = o.left; + y = o.top + this._data.core.li_height; + } + if(this.settings.contextmenu.select_node && !this.is_selected(obj)) { + this.deselect_all(); + this.select_node(obj); + } + + i = s.items; + if($.isFunction(i)) { i = i.call(this, obj); } + + $(document).one("context_show.vakata", $.proxy(function (e, data) { + var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu'; + $(data.element).addClass(cls); + }, this)); + this._data.contextmenu.visible = true; + $.vakata.context.show(a, { 'x' : x, 'y' : y }, i); + /** + * triggered when the contextmenu is shown for a node + * @event + * @name show_contextmenu.jstree + * @param {Object} node the node + * @param {Number} x the x-coordinate of the menu relative to the document + * @param {Number} y the y-coordinate of the menu relative to the document + * @plugin contextmenu + */ + this.trigger('show_contextmenu', { "node" : obj, "x" : x, "y" : y }); + }; + }; + + // contextmenu helper + (function ($) { + var right_to_left = false, + vakata_context = { + element : false, + reference : false, + position_x : 0, + position_y : 0, + items : [], + html : "", + is_visible : false + }; + + $.vakata.context = { + settings : { + hide_onmouseleave : 0, + icons : true + }, + _trigger : function (event_name) { + $(document).triggerHandler("context_" + event_name + ".vakata", { + "reference" : vakata_context.reference, + "element" : vakata_context.element, + "position" : { + "x" : vakata_context.position_x, + "y" : vakata_context.position_y + } + }); + }, + _execute : function (i) { + i = vakata_context.items[i]; + return i && !i._disabled && i.action ? i.action.call(null, { + "item" : i, + "reference" : vakata_context.reference, + "element" : vakata_context.element, + "position" : { + "x" : vakata_context.position_x, + "y" : vakata_context.position_y + } + }) : false; + }, + _parse : function (o, is_callback) { + if(!o) { return false; } + if(!is_callback) { + vakata_context.html = ""; + vakata_context.items = []; + } + var str = "", + sep = false, + tmp; + + if(is_callback) { str += "<"+"ul>"; } + $.each(o, function (i, val) { + if(!val) { return true; } + vakata_context.items.push(val); + if(!sep && val.separator_before) { + str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; + } + sep = false; + str += "<"+"li class='" + (val._class || "") + (val._disabled ? " vakata-contextmenu-disabled " : "") + "'>"; + str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "'>"; + if($.vakata.context.settings.icons) { + str += "<"+"ins "; + if(val.icon) { + if(val.icon.indexOf("/") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; } + else { str += " class='" + val.icon + "' "; } + } + str += "> <"+"/ins><"+"span> <"+"/span>"; + } + str += val.label + "<"+"/a>"; + if(val.submenu) { + tmp = $.vakata.context._parse(val.submenu, true); + if(tmp) { str += tmp; } + } + str += "<"+"/li>"; + if(val.separator_after) { + str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; + sep = true; + } + }); + str = str.replace(/
    • <\/li\>$/,""); + if(is_callback) { str += ""; } + if(!is_callback) { vakata_context.html = str; $.vakata.context._trigger("parse"); } + return str.length > 10 ? str : false; + }, + _show_submenu : function (o) { + o = $(o); + if(!o.length || !o.children("ul").length) { return; } + var e = o.children("ul"), + x = o.offset().left + o.outerWidth(), + y = o.offset().top, + w = e.width(), + h = e.height(), + dw = $(window).width() + $(window).scrollLeft(), + dh = $(window).height() + $(window).scrollTop(); + // може да се спести е една проверка - дали няма някой от класовете вече нагоре + if(right_to_left) { + o[x - (w + 10 + o.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left"); + } + else { + o[x + w + 10 > dw ? "addClass" : "removeClass"]("vakata-context-right"); + } + if(y + h + 10 > dh) { + e.css("bottom","-1px"); + } + e.show(); + }, + show : function (reference, position, data) { + var o, e, x, y, w, h, dw, dh, cond = true; + if(vakata_context.element && vakata_context.element.length) { + vakata_context.element.width(''); + } + switch(cond) { + case (!position && !reference): + return false; + case (!!position && !!reference): + vakata_context.reference = reference; + vakata_context.position_x = position.x; + vakata_context.position_y = position.y; + break; + case (!position && !!reference): + vakata_context.reference = reference; + o = reference.offset(); + vakata_context.position_x = o.left + reference.outerHeight(); + vakata_context.position_y = o.top; + break; + case (!!position && !reference): + vakata_context.position_x = position.x; + vakata_context.position_y = position.y; + break; + } + if(!!reference && !data && $(reference).data('vakata_contextmenu')) { + data = $(reference).data('vakata_contextmenu'); + } + if($.vakata.context._parse(data)) { + vakata_context.element.html(vakata_context.html); + } + if(vakata_context.items.length) { + e = vakata_context.element; + x = vakata_context.position_x; + y = vakata_context.position_y; + w = e.width(); + h = e.height(); + dw = $(window).width() + $(window).scrollLeft(); + dh = $(window).height() + $(window).scrollTop(); + if(right_to_left) { + x -= e.outerWidth(); + if(x < $(window).scrollLeft() + 20) { + x = $(window).scrollLeft() + 20; + } + } + if(x + w + 20 > dw) { + x = dw - (w + 20); + } + if(y + h + 20 > dh) { + y = dh - (h + 20); + } + + vakata_context.element + .css({ "left" : x, "top" : y }) + .show() + .find('a:eq(0)').focus().parent().addClass("vakata-context-hover"); + vakata_context.is_visible = true; + $.vakata.context._trigger("show"); + } + }, + hide : function () { + if(vakata_context.is_visible) { + vakata_context.element.hide().find("ul").hide().end().find(':focus').blur(); + vakata_context.is_visible = false; + $.vakata.context._trigger("hide"); + } + } + }; + $(function () { + right_to_left = $("body").css("direction") === "rtl"; + var to = false, + css_string = '.vakata-context { display:none; _width:1px; } ' + + '.vakata-context, ' + + '.vakata-context ul { margin:0; padding:2px; position:absolute; background:#f5f5f5; border:1px solid #979797; ' + + ' -moz-box-shadow:5px 5px 4px -4px #666666; -webkit-box-shadow:2px 2px 2px #999999; box-shadow:2px 2px 2px #999999; }' + + '.vakata-context ul { list-style:none; left:100%; margin-top:-2.7em; margin-left:-4px; } ' + + '.vakata-context li.vakata-context-right ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } ' + + '.vakata-context li { list-style:none; display:inline; }' + + '.vakata-context li a { display:block; padding:0 2em 0 2em; text-decoration:none; width:auto; color:black; white-space:nowrap; line-height:2.4em; ' + + ' -moz-text-shadow:1px 1px 0px white; -webkit-text-shadow:1px 1px 0px white; text-shadow:1px 1px 0px white; ' + + ' -moz-border-radius:1px; -webkit-border-radius:1px; border-radius:1px; }' + + '.vakata-context li a:hover { position:relative; background-color:#e8eff7; ' + + ' -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }' + + '.vakata-context li.vakata-context-hover > a { position:relative; background-color:#e8eff7; ' + + ' -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }' + + '.vakata-context li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); background-position:right center; background-repeat:no-repeat; } ' + + '.vakata-context li.vakata-context-separator a, ' + + '.vakata-context li.vakata-context-separator a:hover { background:white; border:0; border-top:1px solid #e2e3e3; height:1px; min-height:1px; max-height:1px; padding:0; margin:0 0 0 2.4em; border-left:1px solid #e0e0e0; _overflow:hidden; ' + + ' -moz-text-shadow:0 0 0 transparent; -webkit-text-shadow:0 0 0 transparent; text-shadow:0 0 0 transparent; ' + + ' -moz-box-shadow:0 0 0 transparent; -webkit-box-shadow:0 0 0 transparent; box-shadow:0 0 0 transparent; ' + + ' -moz-border-radius:0; -webkit-border-radius:0; border-radius:0; }' + + '.vakata-context li.vakata-contextmenu-disabled a, .vakata-context li.vakata-contextmenu-disabled a:hover { color:silver; background-color:transparent; border:0; box-shadow:0 0 0; }' + + '.vakata-context li a ins { text-decoration:none; display:inline-block; width:2.4em; height:2.4em; background:transparent; margin:0 0 0 -2em; } ' + + '.vakata-context li a span { display:inline-block; width:1px; height:2.4em; background:white; margin:0 0.5em 0 0; border-left:1px solid #e2e3e3; _overflow:hidden; } ' + + '.vakata-context-rtl ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } ' + + '.vakata-context-rtl li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); background-position:left center; background-repeat:no-repeat; } ' + + '.vakata-context-rtl li.vakata-context-separator a { margin:0 2.4em 0 0; border-left:0; border-right:1px solid #e2e3e3;} ' + + '.vakata-context-rtl li.vakata-context-left ul { right:auto; left:100%; margin-left:-4px; margin-right:auto; } ' + + '.vakata-context-rtl li a ins { margin:0 -2em 0 0; } ' + + '.vakata-context-rtl li a span { margin:0 0 0 0.5em; border-left-color:white; background:#e2e3e3; } '; + if(!$.jstree.no_css) { + $('head').append(''); + } + + vakata_context.element = $("
        "); + vakata_context.element + .on("mouseenter", "li", function (e) { + e.stopImmediatePropagation(); + + if($.contains(this, e.relatedTarget)) { + // премахнато заради delegate mouseleave по-долу + // $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); + return; + } + + if(to) { clearTimeout(to); } + vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(); + + $(this) + .siblings().find("ul").hide().end().end() + .parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover"); + $.vakata.context._show_submenu(this); + }) + // тестово - дали не натоварва? + .on("mouseleave", "li", function (e) { + if($.contains(this, e.relatedTarget)) { return; } + $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover"); + }) + .on("mouseleave", function (e) { + $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); + if($.vakata.context.settings.hide_onmouseleave) { + to = setTimeout( + (function (t) { + return function () { $.vakata.context.hide(); }; + }(this)), $.vakata.context.settings.hide_onmouseleave); + } + }) + .on("click", "a", function (e) { + e.preventDefault(); + }) + .on("mouseup", "a", function (e) { + if(!$(this).blur().parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) { + $.vakata.context.hide(); + } + }) + .on('keydown', 'a', function (e) { + var o = null; + switch(e.which) { + case 13: + case 32: + e.type = "mouseup"; + e.preventDefault(); + $(e.currentTarget).trigger(e); + break; + case 37: + if(vakata_context.is_visible) { + vakata_context.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(); + e.stopImmediatePropagation(); + e.preventDefault(); + } + break; + case 38: + if(vakata_context.is_visible) { + o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(); + if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); } + o.addClass("vakata-context-hover").children('a').focus(); + e.stopImmediatePropagation(); + e.preventDefault(); + } + break; + case 39: + if(vakata_context.is_visible) { + vakata_context.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(); + e.stopImmediatePropagation(); + e.preventDefault(); + } + break; + case 40: + if(vakata_context.is_visible) { + o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(); + if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); } + o.addClass("vakata-context-hover").children('a').focus(); + e.stopImmediatePropagation(); + e.preventDefault(); + } + break; + case 27: + $.vakata.context.hide(); + e.preventDefault(); + break; + default: + //console.log(e.which); + break; + } + }) + .appendTo("body"); + + $(document) + .on("mousedown", function (e) { + if(vakata_context.is_visible && !$.contains(vakata_context.element[0], e.target)) { $.vakata.context.hide(); } + }) + .on("context_show.vakata", function (e, data) { + vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"); + if(right_to_left) { + vakata_context.element.addClass("vakata-context-rtl").css("direction", "rtl"); + } + // also apply a RTL class? + vakata_context.element.find("ul").hide().end(); + }); + }); + }($)); + // $.jstree.defaults.plugins.push("contextmenu"); + +/** + * ### Drag'n'drop plugin + * + * Enables dragging and dropping of nodes in the tree, resulting in a move or copy operations. + */ + + /** + * stores all defaults for the drag'n'drop plugin + * @name $.jstree.defaults.dnd + * @plugin dnd + */ + $.jstree.defaults.dnd = { + /** + * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`. + * @name $.jstree.defaults.dnd.copy + * @plugin dnd + */ + copy : true, + /** + * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`. + * @name $.jstree.defaults.dnd.open_timeout + * @plugin dnd + */ + open_timeout : 500 + }; + // TODO: now check works by checking for each node individually, how about max_children, unique, etc? + // TODO: drop somewhere else - maybe demo only? + $.jstree.plugins.dnd = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + + this.element + .on('mousedown', 'a', $.proxy(function (e) { + var obj = this.get_node(e.target), + mlt = this.is_selected(obj) ? this.get_selected().length : 1; + if(obj && obj.id && obj.id !== "#" && e.which === 1) { + this.element.trigger('mousedown.jstree'); + return $.vakata.dnd.start(e, { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_selected() : [obj.id] }, '
        ' + (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget, true)) + '
        '); + } + }, this)); + }; + }; + + $(function() { + // bind only once for all instances + var lastmv = false, + opento = false, + marker = $('
         
        ').hide().appendTo('body'); + + $(document) + .bind('dnd_start.vakata', function (e, data) { + lastmv = false; + }) + .bind('dnd_move.vakata', function (e, data) { + if(opento) { clearTimeout(opento); } + if(!data.data.jstree) { return; } + + // if we are hovering the marker image do nothing (can happen on "inside" drags) + if(data.event.target.id && data.event.target.id === 'jstree-marker') { + return; + } + + var ins = $.jstree.reference(data.event.target), + ref = false, + off = false, + rel = false, + l, t, h, p, i, o, ok, t1, t2, op, ps, pr; + // if we are over an instance + if(ins && ins._data && ins._data.dnd) { + marker.attr('class', 'jstree-' + ins.get_theme()); + data.helper + .children().attr('class', 'jstree-' + ins.get_theme()) + .find('.jstree-copy:eq(0)')[ data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey) ? 'show' : 'hide' ](); + + + // if are hovering the container itself add a new root node + if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) { + ok = true; + for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { + ok = ok && ins.check( (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey) ? "copy_node" : "move_node"), data.data.nodes[t1], '#', 'last'); + if(!ok) { break; } + } + if(ok) { + lastmv = { 'ins' : ins, 'par' : '#', 'pos' : 'last' }; + marker.hide(); + data.helper.find('.jstree-icon:eq(0)').removeClass('jstree-er').addClass('jstree-ok'); + return; + } + } + else { + // if we are hovering a tree node + ref = $(data.event.target).closest('a'); + if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) { + off = ref.offset(); + rel = data.event.pageY - off.top; + h = ref.height(); + if(rel < h / 3) { + o = ['b', 'i', 'a']; + } + else if(rel > h - h / 3) { + o = ['a', 'i', 'b']; + } + else { + o = rel > h / 2 ? ['i', 'a', 'b'] : ['i', 'b', 'a']; + } + $.each(o, function (j, v) { + switch(v) { + case 'b': + l = off.left - 6; + t = off.top - 5; + p = ins.get_parent(ref); + i = ref.parent().index(); + break; + case 'i': + l = off.left - 2; + t = off.top - 5 + h / 2 + 1; + p = ref.parent(); + i = 0; + break; + case 'a': + l = off.left - 6; + t = off.top - 5 + h; + p = ins.get_parent(ref); + i = ref.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)) { } + */ + ok = true; + for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { + op = data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey) ? "copy_node" : "move_node"; + ps = i; + if(op === "move_node" && v === 'a' && data.data.origin === ins && p === ins.get_parent(data.data.nodes[t1])) { + pr = ins.get_node(p); + if(ps > $.inArray(data.data.nodes[t1], pr.children)) { + ps -= 1; + } + } + ok = ok && ins.check(op, data.data.nodes[t1], p, ps); + if(!ok) { break; } + } + if(ok) { + if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) { + opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout); + } + lastmv = { 'ins' : ins, 'par' : p, 'pos' : i }; + marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show(); + data.helper.find('.jstree-icon:eq(0)').removeClass('jstree-er').addClass('jstree-ok'); + o = true; + return false; + } + }); + if(o === true) { return; } + } + } + } + lastmv = false; + data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er'); + marker.hide(); + }) + .bind('dnd_scroll.vakata', function (e, data) { + if(!data.data.jstree) { return; } + marker.hide(); + lastmv = false; + data.helper.find('.jstree-icon:eq(0)').removeClass('jstree-ok').addClass('jstree-er'); + }) + .bind('dnd_stop.vakata', function (e, data) { + if(opento) { clearTimeout(opento); } + if(!data.data.jstree) { return; } + marker.hide(); + if(lastmv) { + lastmv.ins[ data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey) ? 'copy_node' : 'move_node' ](data.data.nodes, lastmv.par, lastmv.pos); + } + }) + .bind('keyup keydown', function (e, data) { + data = $.vakata.dnd._get(); + if(data.data && data.data.jstree) { + data.helper.find('.jstree-copy:eq(0)')[ data.data.origin.settings.dnd.copy && (e.metaKey || e.ctrlKey) ? 'show' : 'hide' ](); + } + }); + }); + + // helpers + (function ($) { + $.fn.vakata_reverse = [].reverse; + // private variable + var vakata_dnd = { + element : 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 + }; + $.vakata.dnd = { + settings : { + scroll_speed : 10, + scroll_proximity : 20, + helper_left : 5, + helper_top : 10, + threshold : 5 + }, + _trigger : function (event_name, e) { + var data = $.vakata.dnd._get(); + data.event = e; + $(document).triggerHandler("dnd_" + event_name + ".vakata", data); + }, + _get : function () { + return { + "data" : vakata_dnd.data, + "element" : vakata_dnd.element, + "helper" : vakata_dnd.helper + }; + }, + _clean : function () { + if(vakata_dnd.helper) { vakata_dnd.helper.remove(); } + if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } + vakata_dnd = { + element : 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 + }; + $(document).unbind("mousemove", $.vakata.dnd.drag); + $(document).unbind("mouseup", $.vakata.dnd.stop); + }, + _scroll : function (init_only) { + if(!vakata_dnd.scroll_e || (!vakata_dnd.scroll_l && !vakata_dnd.scroll_t)) { + if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } + return false; + } + if(!vakata_dnd.scroll_i) { + vakata_dnd.scroll_i = setInterval($.vakata.dnd._scroll, 100); + return false; + } + if(init_only === true) { return false; } + + var i = vakata_dnd.scroll_e.scrollTop(), + j = vakata_dnd.scroll_e.scrollLeft(); + vakata_dnd.scroll_e.scrollTop(i + vakata_dnd.scroll_t * $.vakata.dnd.settings.scroll_speed); + vakata_dnd.scroll_e.scrollLeft(j + vakata_dnd.scroll_l * $.vakata.dnd.settings.scroll_speed); + if(i !== vakata_dnd.scroll_e.scrollTop() || j !== vakata_dnd.scroll_e.scrollLeft()) { + $.vakata.dnd._trigger("scroll", vakata_dnd.scroll_e); + } + }, + start : function (e, data, html) { + if(vakata_dnd.is_drag) { $.vakata.dnd.stop({}); } + try { + e.currentTarget.unselectable = "on"; + e.currentTarget.onselectstart = function() { return false; }; + if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; } + } catch(ignore) { } + vakata_dnd.init_x = e.pageX; + vakata_dnd.init_y = e.pageY; + vakata_dnd.data = data; + vakata_dnd.is_down = true; + vakata_dnd.element = e.currentTarget; + if(html !== false) { + vakata_dnd.helper = $("
        ").html(html).css({ + "display" : "block", + "margin" : "0", + "padding" : "0", + "position" : "absolute", + "top" : "-2000px", + "lineHeight" : "16px", + "zIndex" : "10000" + }); + } + $(document).bind("mousemove", $.vakata.dnd.drag); + $(document).bind("mouseup", $.vakata.dnd.stop); + return false; + }, + drag : function (e) { + if(!vakata_dnd.is_down) { return; } + if(!vakata_dnd.is_drag) { + if( + Math.abs(e.pageX - vakata_dnd.init_x) > $.vakata.dnd.settings.threshold || + Math.abs(e.pageY - vakata_dnd.init_y) > $.vakata.dnd.settings.threshold + ) { + if(vakata_dnd.helper) { + vakata_dnd.helper.appendTo("body"); + vakata_dnd.helper_w = vakata_dnd.helper.outerWidth(); + } + vakata_dnd.is_drag = true; + $.vakata.dnd._trigger("start", e); + } + else { return; } + } + + var d = false, w = false, + dh = false, wh = false, + dw = false, ww = false, + dt = false, dl = false, + ht = false, hl = false; + + vakata_dnd.scroll_t = 0; + vakata_dnd.scroll_l = 0; + vakata_dnd.scroll_e = false; + $(e.target) + .parentsUntil("body").addBack().vakata_reverse() + .filter(function () { + return (/^auto|scroll$/).test($(this).css("overflow")) && + (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth); + }) + .each(function () { + var t = $(this), o = t.offset(); + if(this.scrollHeight > this.offsetHeight) { + if(o.top + t.height() - e.pageY < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } + if(e.pageY - o.top < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } + } + if(this.scrollWidth > this.offsetWidth) { + if(o.left + t.width() - e.pageX < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } + if(e.pageX - o.left < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } + } + if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { + vakata_dnd.scroll_e = $(this); + return false; + } + }); + + if(!vakata_dnd.scroll_e) { + d = $(document); w = $(window); + dh = d.height(); wh = w.height(); + dw = d.width(); ww = w.width(); + dt = d.scrollTop(); dl = d.scrollLeft(); + if(dh > wh && e.pageY - dt < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } + if(dh > wh && wh - (e.pageY - dt) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } + if(dw > ww && e.pageX - dl < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } + if(dw > ww && ww - (e.pageX - dl) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } + if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { + vakata_dnd.scroll_e = d; + } + } + if(vakata_dnd.scroll_e) { $.vakata.dnd._scroll(true); } + + if(vakata_dnd.helper) { + ht = parseInt(e.pageY + $.vakata.dnd.settings.helper_top, 10); + hl = parseInt(e.pageX + $.vakata.dnd.settings.helper_left, 10); + if(dh && ht + 25 > dh) { ht = dh - 50; } + if(dw && hl + vakata_dnd.helper_w > dw) { hl = dw - (vakata_dnd.helper_w + 2); } + vakata_dnd.helper.css({ + left : hl + "px", + top : ht + "px" + }); + } + $.vakata.dnd._trigger("move", e); + }, + stop : function (e) { + if(vakata_dnd.is_drag) { + $.vakata.dnd._trigger("stop", e); + } + $.vakata.dnd._clean(); + } + }; + }(jQuery)); + + // include the dnd plugin by default + // $.jstree.defaults.plugins.push("dnd"); + + +/** + * ### Search plugin + * + * Adds search functionality to jsTree. + */ + + /** + * stores all defaults for the search plugin + * @name $.jstree.defaults.search + * @plugin search + */ + $.jstree.defaults.search = { + /** + * a jQuery-like AJAX config, which jstree uses if a server should be queried for results. + * + * A `str` (which is the search string) parameter will be added with the request. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed. + * Leave this setting as `false` to not query the server. + * @name $.jstree.defaults.search.ajax + * @plugin search + */ + ajax : false, + /** + * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `true`. + * @name $.jstree.defaults.search.fuzzy + * @plugin search + */ + fuzzy : true, + /** + * Indicates if the search should be case sensitive. Default is `false`. + * @name $.jstree.defaults.search.case_sensitive + * @plugin search + */ + case_sensitive : false, + /** + * Indicates if the tree should be filtered to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers). Default is `false`. + * @name $.jstree.defaults.search.show_only_matches + * @plugin search + */ + show_only_matches : false + }; + + $.jstree.plugins.search = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + + this._data.search.str = ""; + this._data.search.dom = $(); + this._data.search.res = []; + + if(this.settings.search.show_only_matches) { + this.element + .on("search.jstree", function (e, data) { + if(data.nodes.length) { + $(this).find("li").hide().filter('.jstree-last').filter(function() { return this.nextSibling; }).removeClass('jstree-last'); + data.nodes.parentsUntil(".jstree").addBack().show() + .filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); }); + } + }) + .on("clear_search.jstree", function (e, data) { + if(data.nodes.length) { + $(this).find("li").css("display","").filter('.jstree-last').filter(function() { return this.nextSibling; }).removeClass('jstree-last'); + } + }); + } + }; + /** + * used to search the tree nodes for a given string + * @name search(str [, skip_async]) + * @param {String} str the search string + * @param {Boolean} skip_async if set to true server will not be queried even if configured + * @plugin search + * @trigger search.jstree + */ + this.search = function (str, skip_async) { + if(str === false || $.trim(str) === "") { + return this.clear_search(); + } + var s = this.settings.search, + a = s.ajax ? $.extend({}, s.ajax) : false, + f = null, + r = [], + p = [], i, j; + if(this._data.search.res.length) { + this.clear_search(); + } + if(!skip_async && a !== false) { + if(!a.data) { a.data = {}; } + a.data.str = str; + return $.ajax(s.ajax).done($.proxy(function (d) { + this._search_load(d, str); + }, this)); + } + this._data.search.str = str; + this._data.search.dom = $(); + this._data.search.res = []; + + f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy }); + + $.each(this._model.data, function (i, v) { + if(v.text && f.search(v.text).isMatch) { + r.push(i); + p = p.concat(v.parents); + } + }); + if(r.length) { + p = $.vakata.array_unique(p); + this._search_open(p); + for(i = 0, j = r.length; i < j; i++) { + f = this.get_node(r[i], true); + if(f) { + this._data.search.dom = this._data.search.dom.add(f); + } + } + this._data.search.res = r; + this._data.search.dom.children(".jstree-anchor").addClass('jstree-search'); + } + /** + * triggered after search is complete + * @event + * @name search.jstree + * @param {jQuery} nodes a jQuery collection of matching nodes + * @param {String} str the search string + * @param {Array} res a collection of objects represeing the matching nodes + * @plugin search + */ + this.trigger('search', { nodes : this._data.search.dom, str : str, res : this._data.search.res }); + }; + /** + * used to clear the last search (removes classes and shows all nodes if filtering is on) + * @name clear_search() + * @plugin search + * @trigger clear_search.jstree + */ + this.clear_search = function () { + this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"); + /** + * triggered after search is complete + * @event + * @name clear_search.jstree + * @param {jQuery} nodes a jQuery collection of matching nodes (the result from the last search) + * @param {String} str the search string (the last search string) + * @param {Array} res a collection of objects represeing the matching nodes (the result from the last search) + * @plugin search + */ + 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.dom = $(); + }; + /** + * opens nodes that need to be opened to reveal the search results. Used only internally. + * @private + * @name _search_open(d) + * @param {Array} d an array of node IDs + * @plugin search + */ + this._search_open = function (d) { + var t = this; + $.each(d.concat([]), function (i, v) { + v = document.getElementById(v); + if(v) { + if(t.is_closed(v)) { + t.open_node(v, function () { t._search_open(d); }); + } + } + }); + }; + /** + * loads nodes that need to be opened to reveal the search results. Used only internally. + * @private + * @name _search_load(d, str) + * @param {Array} d an array of node IDs + * @param {String} str the search string + * @plugin search + */ + this._search_load = function (d, str) { + var res = true, + t = this, + m = t._model.data; + $.each(d.concat([]), function (i, v) { + if(m[v]) { + if(!m[v].state.loaded) { + t.load_node(v, function () { t._search_load(d, str); }); + res = false; + } + } + }); + if(res) { + this.search(str, true); + } + }; + }; + + // helpers + (function ($) { + // from http://kiro.me/projects/fuse.html + $.vakata.search = function(pattern, txt, options) { + options = options || {}; + if(options.fuzzy !== false) { + options.fuzzy = true; + } + pattern = options.caseSensitive ? pattern : pattern.toLowerCase(); + var MATCH_LOCATION = options.location || 0, + MATCH_DISTANCE = options.distance || 100, + MATCH_THRESHOLD = options.threshold || 0.6, + patternLen = pattern.length, + matchmask, pattern_alphabet, match_bitapScore, search; + if(patternLen > 32) { + options.fuzzy = false; + } + if(options.fuzzy) { + matchmask = 1 << (patternLen - 1); + pattern_alphabet = (function () { + var mask = {}, + i = 0; + for (i = 0; i < patternLen; i++) { + mask[pattern.charAt(i)] = 0; + } + for (i = 0; i < patternLen; i++) { + mask[pattern.charAt(i)] |= 1 << (patternLen - i - 1); + } + return mask; + }()); + match_bitapScore = function (e, x) { + var accuracy = e / patternLen, + proximity = Math.abs(MATCH_LOCATION - x); + if(!MATCH_DISTANCE) { + return proximity ? 1.0 : accuracy; + } + return accuracy + (proximity / MATCH_DISTANCE); + }; + } + search = function (text) { + text = options.caseSensitive ? text : text.toLowerCase(); + if(pattern === text || text.indexOf(pattern) !== -1) { + return { + isMatch: true, + score: 0 + }; + } + if(!options.fuzzy) { + return { + isMatch: false, + score: 1 + }; + } + var i, j, + textLen = text.length, + scoreThreshold = MATCH_THRESHOLD, + bestLoc = text.indexOf(pattern, MATCH_LOCATION), + binMin, binMid, + binMax = patternLen + textLen, + lastRd, start, finish, rd, charMatch, + score = 1, + locations = []; + if (bestLoc !== -1) { + scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); + bestLoc = text.lastIndexOf(pattern, MATCH_LOCATION + patternLen); + if (bestLoc !== -1) { + scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); + } + } + bestLoc = -1; + for (i = 0; i < patternLen; i++) { + binMin = 0; + binMid = binMax; + while (binMin < binMid) { + if (match_bitapScore(i, MATCH_LOCATION + binMid) <= scoreThreshold) { + binMin = binMid; + } else { + binMax = binMid; + } + binMid = Math.floor((binMax - binMin) / 2 + binMin); + } + binMax = binMid; + start = Math.max(1, MATCH_LOCATION - binMid + 1); + finish = Math.min(MATCH_LOCATION + binMid, textLen) + patternLen; + rd = new Array(finish + 2); + rd[finish + 1] = (1 << i) - 1; + for (j = finish; j >= start; j--) { + charMatch = pattern_alphabet[text.charAt(j - 1)]; + if (i === 0) { + rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; + } else { + rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1]; + } + if (rd[j] & matchmask) { + score = match_bitapScore(i, j - 1); + if (score <= scoreThreshold) { + scoreThreshold = score; + bestLoc = j - 1; + locations.push(bestLoc); + if (bestLoc > MATCH_LOCATION) { + start = Math.max(1, 2 * MATCH_LOCATION - bestLoc); + } else { + break; + } + } + } + } + if (match_bitapScore(i + 1, MATCH_LOCATION) > scoreThreshold) { + break; + } + lastRd = rd; + } + return { + isMatch: bestLoc >= 0, + score: score + }; + }; + return txt === true ? { 'search' : search } : search(txt); + }; + }(jQuery)); + + // include the search plugin by default + // $.jstree.defaults.plugins.push("search"); + +/** + * ### Sort plugin + * + * Autmatically sorts all siblings in the tree according to a sorting function. + */ + + /** + * the settings function used to sort the nodes. + * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`. + * @name $.jstree.defaults.sort + * @plugin sort + */ + $.jstree.defaults.sort = function (a, b) { + //return this.get_type(a) === this.get_type(b) ? (this.get_text(a) > this.get_text(b) ? 1 : -1) : this.get_type(a) >= this.get_type(b); + return this.get_text(a) > this.get_text(b) ? 1 : -1; + }; + $.jstree.plugins.sort = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + this.element + .on("model.jstree", $.proxy(function (e, data) { + this.sort(data.parent, true); + }, this)) + .on("rename_node.jstree create_node.jstree", $.proxy(function (e, data) { + this.sort(data.parent || data.node.parent, false); + this.redraw_node(data.parent || data.node.parent, true); + }, this)) + .on("move_node.jstree copy_node.jstree", $.proxy(function (e, data) { + this.sort(data.parent, false); + this.redraw_node(data.parent, true); + }, this)); + }; + /** + * used to sort a node's children + * @private + * @name sort(obj [, deep]) + * @param {mixed} obj the node + * @param {Boolean} deep if set to `true` nodes are sorted recursively. + * @plugin sort + * @trigger search.jstree + */ + this.sort = function (obj, deep) { + var i, j; + obj = this.get_node(obj); + if(obj && obj.children && obj.children.length) { + obj.children.sort($.proxy(this.settings.sort, this)); + if(deep) { + for(i = 0, j = obj.children_d.length; i < j; i++) { + this.sort(obj.children_d[i], false); + } + } + } + }; + }; + + // include the sort plugin by default + // $.jstree.defaults.plugins.push("sort"); + +/** + * ### State plugin + * + * Saves the state of the tree (selected nodes, opened nodes) on the user's computer using available options (localStorage, cookies, etc) + */ + + var to = false; + /** + * stores all defaults for the state plugin + * @name $.jstree.defaults.state + * @plugin state + */ + $.jstree.defaults.state = { + /** + * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`. + * @name $.jstree.defaults.state.key + * @plugin state + */ + key : 'jstree', + /** + * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`. + * @name $.jstree.defaults.state.events + * @plugin state + */ + events : 'changed.jstree open_node.jstree close_node.jstree', + ttl : false + }; + $.jstree.plugins.state = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + + this.element + .on("ready.jstree", $.proxy(function (e, data) { + this.element.one("restore_state.jstree set_state.jstree", $.proxy(function () { + this.element.on(this.settings.state.events, $.proxy(function () { + if(to) { clearTimeout(to); } + to = setTimeout($.proxy(function () { this.save_state(); }, this), 100); + }, this)); + }, this)); + this.restore_state(); + }, this)); + }; + /** + * save the state + * @name save_state() + * @plugin state + */ + this.save_state = function () { + $.vakata.storage.set(this.settings.state.key, this.get_state(), this.settings.state.ttl); + }; + /** + * restore the state from the user's computer + * @name restore_state() + * @plugin state + */ + this.restore_state = function () { + var k = $.vakata.storage.get(this.settings.state.key); + + if(!!k) { this.set_state(k); } + this.trigger('restore_state', { 'state' : k }); + }; + /** + * clear the state on the user's computer + * @name clear_state() + * @plugin state + */ + this.clear_state = function () { + return $.vakata.storage.del(this.settings.state.key); + }; + }; + + // helpers + (function ($, undefined) { + // private function for json quoting strings + var _quote = function (str) { + var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g, + meta = { '\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"' :'\\"','\\':'\\\\' }; + if(str.match(escapeable)) { + return '"' + str.replace(escapeable, function (a) { + var c = meta[a]; + if(typeof c === 'string') { return c; } + c = a.charCodeAt(); + return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); + }) + '"'; + } + return '"' + str + '"'; + }; + $.vakata.json = { + encode : (JSON && JSON.stringify ? JSON.stringify : function (o) { + if (o === null) { return "null"; } + + var tmp = [], i; + switch(typeof o) { + case "undefined": + return undefined; + case "number": + case "boolean": + return o.toString(); + case "string": + return _quote(o); + case "object": + if($.isFunction(o.toJSON)) { + return $.vakata.json.encode(o.toJSON()); + } + if(o.constructor === Date) { + return '"' + + o.getUTCFullYear() + '-' + + String("0" + (o.getUTCMonth() + 1)).slice(-2) + '-' + + String("0" + o.getUTCDate()).slice(-2) + 'T' + + String("0" + o.getUTCHours()).slice(-2) + ':' + + String("0" + o.getUTCMinutes()).slice(-2) + ':' + + String("0" + o.getUTCSeconds()).slice(-2) + '.' + + String("00" + o.getUTCMilliseconds()).slice(-3) + 'Z"'; + } + if(o.constructor === Array) { + for(i = 0; i < o.length; i++) { + tmp.push( $.vakata.json.encode(o[i]) || "null" ); + } + return "[" + tmp.join(",") + "]"; + } + + $.each(o, function (i, v) { + if($.isFunction(v)) { return true; } + i = typeof i === "number" ? '"' + i + '"' : _quote(i); + v = $.vakata.json.encode(v); + tmp.push(i + ":" + v); + }); + return "{" + tmp.join(", ") + "}"; + } + }), + decode : (JSON && JSON.parse ? JSON.parse : function (json) { + return $.parseJSON(json); + }) + }; + }(jQuery)); + + (function ($, document, undefined) { + var raw = function (s) { return s; }, + decoded = function (s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }, + config = $.vakata.cookie = function (key, value, options) { + var days, t, decode, cookies, i, l, parts, cookie; + // write + if (value !== undefined) { + options = $.extend({}, config.defaults, options); + + if (value === null) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + days = options.expires; + t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = config.json ? $.vakata.json.encode(value) : String(value); + value = [ + encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join(''); + document.cookie = value; + return value; + } + // read + decode = config.raw ? raw : decoded; + cookies = document.cookie.split('; '); + for (i = 0, l = cookies.length; i < l; i++) { + parts = cookies[i].split('='); + if (decode(parts.shift()) === key) { + cookie = decode(parts.join('=')); + return config.json ? $.vakata.json.decode(cookie) : cookie; + } + } + return null; + }; + config.defaults = {}; + $.vakata.removeCookie = function (key, options) { + if ($.vakata.cookie(key) !== null) { + $.vakata.cookie(key, null, options); + return true; + } + return false; + }; + }(jQuery, document)); + + (function ($, undefined) { + var _storage = {}, + _storage_service = {jStorage:"{}"}, + _storage_elm = null, + _storage_size = 0, + json_encode = $.vakata.json.encode, + json_decode = $.vakata.json.decode, + _backend = false, + _ttl_timeout = false; + + function _load_storage() { + if(_storage_service.jStorage) { + try { + _storage = json_decode(String(_storage_service.jStorage)); + } catch(ex) { _storage_service.jStorage = "{}"; } + } else { + _storage_service.jStorage = "{}"; + } + _storage_size = _storage_service.jStorage ? String(_storage_service.jStorage).length : 0; + } + + function _save() { + try { + _storage_service.jStorage = json_encode(_storage); + if(_backend === 'userDataBehavior') { + _storage_elm.setAttribute("jStorage", _storage_service.jStorage); + _storage_elm.save("jStorage"); + } + if(_backend === 'cookie') { + $.vakata.cookie('__vjstorage', _storage_service.jStorage, { 'expires' : 365 }); + } + _storage_size = _storage_service.jStorage?String(_storage_service.jStorage).length:0; + } catch(ignore) { /*! probably cache is full, nothing is saved this way*/ } + } + + function _checkKey(key) { + if(!key || (typeof key !== "string" && typeof key !== "number")){ + throw new TypeError('Key name must be string or numeric'); + } + if(key === "__jstorage_meta") { + throw new TypeError('Reserved key name'); + } + return true; + } + + function _handleTTL() { + var curtime = +new Date(), + i, + TTL, + nextExpire = Infinity, + changed = false; + + if(_ttl_timeout !== false) { + clearTimeout(_ttl_timeout); + } + if(!_storage.__jstorage_meta || typeof _storage.__jstorage_meta.TTL !== "object"){ + return; + } + TTL = _storage.__jstorage_meta.TTL; + for(i in TTL) { + if(TTL.hasOwnProperty(i)) { + if(TTL[i] <= curtime) { + delete TTL[i]; + delete _storage[i]; + changed = true; + } + else if(TTL[i] < nextExpire) { + nextExpire = TTL[i]; + } + } + } + + // set next check + if(nextExpire !== Infinity) { + _ttl_timeout = setTimeout(_handleTTL, nextExpire - curtime); + } + // save changes + if(changed) { + _save(); + } + } + + function _init() { + var localStorageReallyWorks = false, data; + if(window.hasOwnProperty("localStorage")){ + try { + window.localStorage.setItem('_tmptest', 'tmpval'); + localStorageReallyWorks = true; + window.localStorage.removeItem('_tmptest'); + } catch(ignore) { + // Thanks be to iOS5 Private Browsing mode which throws + // QUOTA_EXCEEDED_ERRROR DOM Exception 22. + } + } + + if(localStorageReallyWorks){ + try { + if(window.localStorage) { + _storage_service = window.localStorage; + _backend = "localStorage"; + } + } catch(ignore) {/*! Firefox fails when touching localStorage and cookies are disabled */} + } + else if(window.hasOwnProperty("globalStorage")) { + try { + if(window.globalStorage) { + _storage_service = window.globalStorage[window.location.hostname]; + _backend = "globalStorage"; + } + } catch(ignore) {/*! Firefox fails when touching localStorage and cookies are disabled */} + } + else { + _storage_elm = document.createElement('link'); + if(_storage_elm.addBehavior) { + _storage_elm.style.behavior = 'url(#default#userData)'; + document.getElementsByTagName('head')[0].appendChild(_storage_elm); + try { + _storage_elm.load("jStorage"); + data = "{}"; + data = _storage_elm.getAttribute("jStorage"); + _storage_service.jStorage = data; + _backend = "userDataBehavior"; + } catch(ignore) {} + } + if( + !_backend && ( + !!$.vakata.cookie('__vjstorage') || + ($.vakata.cookie('__vjstorage', '{}', { 'expires' : 365 }) && $.vakata.cookie('__vjstorage') === '{}') + ) + ) { + _storage_elm = null; + _storage_service.jStorage = $.vakata.cookie('__vjstorage'); + _backend = "cookie"; + } + + if(!_backend) { + _storage_elm = null; + return; + } + } + _load_storage(); + _handleTTL(); + } + + /*! + Variable: $.vakata.storage + *object* holds all storage related functions and properties. + */ + $.vakata.storage = { + /*! + Variable: $.vakata.storage.version + *string* the version of jstorage used HEAVILY MODIFIED + */ + version: "0.3.0", + /*! + Function: $.vakata.storage.set + Set a key to a value + + Parameters: + key - the key + value - the value + + Returns: + _value_ + */ + set : function (key, value, ttl) { + _checkKey(key); + if(typeof value === "object") { + value = json_decode(json_encode(value)); + } + _storage[key] = value; + _save(); + if(ttl && parseInt(ttl, 10)) { + $.vakata.storage.setTTL(key, parseInt(ttl, 10)); + } + return value; + }, + /*! + Function: $.vakata.storage.get + Get a value by key. + + Parameters: + key - the key + def - the value to return if _key_ is not found + + Returns: + The found value, _def_ if key not found or _null_ if _def_ is not supplied. + */ + get : function (key, def) { + _checkKey(key); + if(_storage.hasOwnProperty(key)){ + return _storage[key]; + } + return def === undefined ? null : def; + }, + /*! + Function: $.vakata.storage.del + Remove a key. + + Parameters: + key - the key + + Returns: + *boolean* + */ + del : function (key) { + _checkKey(key); + if(_storage.hasOwnProperty(key)) { + delete _storage[key]; + + if(_storage.__jstorage_meta && typeof _storage.__jstorage_meta.TTL === "object" && _storage.__jstorage_meta.TTL.hasOwnProperty(key)) { + delete _storage.__jstorage_meta.TTL[key]; + } + _save(); + return true; + } + return false; + }, + + setTTL: function(key, ttl){ + var curtime = +new Date(); + + _checkKey(key); + ttl = Number(ttl) || 0; + if(_storage.hasOwnProperty(key)){ + if(!_storage.__jstorage_meta){ + _storage.__jstorage_meta = {}; + } + if(!_storage.__jstorage_meta.TTL) { + _storage.__jstorage_meta.TTL = {}; + } + if(ttl > 0) { + _storage.__jstorage_meta.TTL[key] = curtime + ttl; + } + else { + delete _storage.__jstorage_meta.TTL[key]; + } + _save(); + _handleTTL(); + return true; + } + return false; + }, + getTTL: function(key){ + var curtime = +new Date(), ttl; + _checkKey(key); + if(_storage.hasOwnProperty(key) && _storage.__jstorage_meta.TTL && _storage.__jstorage_meta.TTL[key]) { + ttl = _storage.__jstorage_meta.TTL[key] - curtime; + return ttl || 0; + } + return 0; + }, + + /*! + Function: $.vakata.storage.flush + Empty the storage. + + Returns: + _true_ + */ + flush : function(){ + _storage = {}; + _save(); + // try{ window.localStorage.clear(); } catch(E8) { } + return true; + }, + /*! + Function: $.vakata.storage.storageObj + Get a read only copy of the whole storage. + + Returns: + *object* + */ + storageObj : function(){ + return $.extend(true, {}, _storage); + }, + /*! + Function: $.vakata.storage.index + Get an array of all the set keys in the storage. + + Returns: + *array* + */ + index : function(){ + var index = []; + $.each(_storage, function (i, v) { if(i !== "__jstorage_meta") { index.push(i); } }); + return index; + }, + /*! + Function: $.vakata.storage.storageSize + Get the size of all items in the storage in bytes. + + Returns: + *number* + */ + storageSize : function(){ + return _storage_size; + }, + /*! + Function: $.vakata.storage.currentBackend + Get the current backend used. + + Returns: + *string* + */ + currentBackend : function(){ + return _backend; + }, + /*! + Function: $.vakata.storage.storageAvailable + See if storage functionality is available. + + Returns: + *boolean* + */ + storageAvailable : function(){ + return !!_backend; + } + }; + _init(); + }(jQuery)); + + // include the state plugin by default + // $.jstree.defaults.plugins.push("state"); + +/** + * ### Types plugin + * + * Makes it possible to add predefined types for groups of nodes, which make it possible to easily control nesting rules and icon for each group. + */ + + /** + * An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional). + * + * * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited. + * * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited. + * * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits. + * * `icon` a string - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class. Omit to use the default icon from your theme. + * + * There are two predefined types: + * + * * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes. + * * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified. + * + * @name $.jstree.defaults.types + * @plugin types + */ + $.jstree.defaults.types = { + '#' : {}, + 'default' : {} + }; + + $.jstree.plugins.types = function (options, parent) { + this.init = function (el, options) { + parent.init.call(this, el, options); + this._model.data['#'].type = '#'; + }; + this.bind = function () { + parent.bind.call(this); + this.element + .on('model.jstree', $.proxy(function (e, data) { + var m = this._model.data, + dpc = data.nodes, + t = this.settings.types, + i, j, c = 'default'; + for(i = 0, j = dpc.length; i < j; i++) { + c = 'default'; + if(m[dpc[i]].original && m[dpc[i]].original.type && t[m[dpc[i]].original.type]) { + c = m[dpc[i]].original.type; + } + if(m[dpc[i]].data && m[dpc[i]].data.jstree && m[dpc[i]].data.jstree.type && t[m[dpc[i]].data.jstree.type]) { + c = m[dpc[i]].data.jstree.type; + } + m[dpc[i]].type = c; + if(m[dpc[i]].icon === true && t[c].icon) { + m[dpc[i]].icon = t[c].icon; + } + } + }, this)); + }; + this.check = function (chk, obj, par, pos) { + if(parent.check.call(this, chk, obj, par, pos) === false) { return false; } + obj = obj && obj.id ? obj : this.get_node(obj); + par = par && par.id ? par : this.get_node(par); + var m = this._model.data, tmp, d, i, j; + switch(chk) { + case "create_node": + case "move_node": + case "copy_node": + if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) { + tmp = this.get_rules(par); + if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) { + return false; + } + if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray(obj.type, tmp.valid_children) === -1) { + return false; + } + if(obj.children_d && obj.parents) { + d = 0; + for(i = 0, j = obj.children_d.length; i < j; i++) { + d = Math.max(d, m[obj.children_d[i]].parents.length); + } + d = d - obj.parents.length + 1; + } + if(d <= 0) { d = 1; } + do { + if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) { + return false; + } + par = this.get_node(par.parent); + tmp = this.get_rules(par); + d++; + } while(par); + } + break; + } + return true; + }; + /** + * used to retrieve the type settings object for a node + * @name get_rules(obj) + * @param {mixed} obj the node to find the rules for + * @return {Object} + * @plugin types + */ + this.get_rules = function (obj) { + obj = this.get_node(obj); + if(!obj) { return false; } + var tmp = this.get_type(obj, true); + if(tmp.max_depth === undefined) { tmp.max_depth = -1; } + if(tmp.max_children === undefined) { tmp.max_children = -1; } + if(tmp.valid_children === undefined) { tmp.valid_children = -1; } + return tmp; + }; + /** + * used to retrieve the type string or settings object for a node + * @name get_type(obj [, rules]) + * @param {mixed} obj the node to find the rules for + * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned + * @return {String|Object} + * @plugin types + */ + this.get_type = function (obj, rules) { + obj = this.get_node(obj); + return (!obj) ? false : ( rules ? $.extend({ 'type' : obj.type }, this.settings.types[obj.type]) : obj.type); + }; + /** + * used to change a node's type + * @name set_type(obj, type) + * @param {mixed} obj the node to change + * @param {String} type the new type + * @plugin types + */ + this.set_type = function (obj, type) { + var t, t1, t2; + if($.isArray(obj)) { + for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { + this.set_type(obj[t1], type); + } + return true; + } + t = this.settings.types; + obj = this.get_node(obj); + if(!t[type] || !obj) { return false; } + obj.type = type; + if(t[type].icon && this.get_icon(obj) === true) { + this.set_icon(obj, t[type].icon); + } + return true; + }; + }; + // include the types plugin by default + // $.jstree.defaults.plugins.push("types"); + +/** + * ### Unique plugin + * + * Enforces that no nodes with the same name can coexist as siblings. + */ + + $.jstree.plugins.unique = function (options, parent) { + this.check = function (chk, obj, par, pos) { + if(parent.check.call(this, chk, obj, par, pos) === false) { return false; } + obj = obj && obj.id ? obj : this.get_node(obj); + par = par && par.id ? par : this.get_node(par); + if(!par || !par.children) { return true; } + var n = chk === "rename_node" ? pos : obj.text, + c = [], + m = this._model.data, i, j; + for(i = 0, j = par.children.length; i < j; i++) { + c.push(m[par.children[i]].text); + } + switch(chk) { + case "delete_node": + return true; + case "rename_node": + case "copy_node": + return ($.inArray(n, c) === -1); + case "move_node": + return (obj.parent === par.id || $.inArray(n, c) === -1); + } + return true; + }; + }; + + // include the unique plugin by default + // $.jstree.defaults.plugins.push("unique"); + + +/** + * ### Wholerow plugin + * + * Makes each node appear block level. Making selection easier. May cause slow down for large trees in old browsers. + */ + + var div = document.createElement('DIV'); + div.setAttribute('unselectable','on'); + div.className = 'jstree-wholerow'; + div.innerHTML = ' '; + $.jstree.plugins.wholerow = function (options, parent) { + this.bind = function () { + parent.bind.call(this); + + this.element + .on('loading', $.proxy(function () { + div.style.height = this._data.core.li_height + 'px'; + }, this)) + .on('ready.jstree set_state.jstree', $.proxy(function () { + this.hide_dots(); + }, this)) + .on("ready.jstree", $.proxy(function () { + this.get_container_ul().addClass('jstree-wholerow-ul'); + }, this)) + .on("deselect_all.jstree", $.proxy(function (e, data) { + this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); + }, this)) + .on("changed.jstree", $.proxy(function (e, data) { + this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); + var tmp = false, i, j; + for(i = 0, j = data.selected.length; i < j; i++) { + tmp = this.get_node(data.selected[i], true); + if(tmp && tmp.length) { + tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); + } + } + }, this)) + .on("open_node.jstree", $.proxy(function (e, data) { + this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); + }, this)) + .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) { + this.element.find('.jstree-wholerow-hovered').removeClass('jstree-wholerow-hovered'); + if(e.type === "hover_node") { + this.get_node(data.node, true).each(function () { + $(this).children('.jstree-wholerow').addClass('jstree-wholerow-hovered'); + }); + } + }, this)) + .on("contextmenu.jstree", ".jstree-wholerow", $.proxy(function (e) { + //if(typeof this._data.contextmenu !== 'undefined') { + e.preventDefault(); + $(e.currentTarget).closest("li").children("a:eq(0)").trigger('contextmenu',e); + //} + }, this)) + .on("click.jstree", ".jstree-wholerow", function (e) { + e.stopImmediatePropagation(); + var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); + $(e.currentTarget).closest("li").children("a:eq(0)").trigger(tmp).focus(); + }) + .on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) { + e.stopImmediatePropagation(); + var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); + $(e.currentTarget).closest("li").children("a:eq(0)").trigger(tmp).focus(); + }, this)) + .on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", $.proxy(function (e) { + e.stopImmediatePropagation(); + //if($(e.currentTarget).closest('li').children(".jstree-clicked").length) { + // return false; + //} + this.hover_node(e.currentTarget); + return false; + }, this)) + .on("mouseleave.jstree", "li", $.proxy(function (e) { + this.dehover_node(e.currentTarget); + }, this)); + }; + this.teardown = function () { + if(this.settings.wholerow) { + this.element.find(".jstree-wholerow").remove(); + parent.teardown.call(this); + } + }; + this.redraw_node = function(obj, deep, callback) { + obj = parent.redraw_node.call(this, obj, deep, callback); + if(obj) { + var tmp = div.cloneNode(true); + //tmp.style.height = this._data.core.li_height + 'px'; + if($.inArray(obj.id, this._data.core.selected) !== -1) { tmp.className += ' jstree-wholerow-clicked'; } + obj.insertBefore(tmp, obj.childNodes[0]); + } + return obj; + }; + }; + // include the wholerow plugin by default + // $.jstree.defaults.plugins.push("wholerow"); + +})); \ No newline at end of file diff --git a/docs/assets/dist/jstree.min.js b/docs/assets/dist/jstree.min.js new file mode 100644 index 00000000..abd08cd4 --- /dev/null +++ b/docs/assets/dist/jstree.min.js @@ -0,0 +1,4 @@ +/*! jsTree - v3.0.0-beta - 2013-12-31 - (MIT) */ +(function(e){"use strict";"function"==typeof define&&define.amd?define("jstree",["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e,t){"use strict";if(!e.jstree){var n=0,r=0,a=!1,i=!1,s=!1,o=[],d=e("script:last").attr("src"),l=document,c=l.createElement("LI"),h,_;c.setAttribute("role","treeitem"),h=l.createElement("I"),h.className="jstree-icon jstree-ocl",c.appendChild(h),h=l.createElement("A"),h.className="jstree-anchor",h.setAttribute("href","#"),_=l.createElement("I"),_.className="jstree-icon jstree-themeicon",h.appendChild(_),c.appendChild(h),h=_=null,e.jstree={version:"3.0.0-alpha",defaults:{plugins:[]},plugins:{},path:d&&-1!==d.indexOf("/")?d.replace(/\/[^\/]+$/,""):""},e.jstree.create=function(t,r){var a=new e.jstree.core(++n),i=r;return r=e.extend(!0,{},e.jstree.defaults,r),i&&i.plugins&&(r.plugins=i.plugins),e.each(r.plugins,function(e,t){"core"!==e&&(a=a.plugin(t,r[t]))}),a.init(t,r),a},e.jstree.core=function(e){this._id=e,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[]}}},e.jstree.reference=function(n){if(n&&!e(n).length){n.id&&(n=n.id);var r=null;return e(".jstree").each(function(){var a=e(this).data("jstree");return a&&a._model.data[n]?(r=a,!1):t}),r}return e(n).closest(".jstree").data("jstree")},e.fn.jstree=function(n){var r="string"==typeof n,a=Array.prototype.slice.call(arguments,1),i=null;return this.each(function(){var s=e.jstree.reference(this),o=r&&s?s[n]:null;return i=r&&o?o.apply(s,a):null,s||r||n!==t&&!e.isPlainObject(n)||e(this).data("jstree",new e.jstree.create(this,n)),s&&!r&&(i=s),null!==i&&i!==t?!1:t}),null!==i&&i!==t?i:this},e.expr[":"].jstree=e.expr.createPseudo(function(n){return function(n){return e(n).hasClass("jstree")&&e(n).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1},expand_selected_onload:!0},e.jstree.core.prototype={plugin:function(t,n){var r=e.jstree.plugins[t];return r?(this._data[t]={},r.prototype=this,new r(n,this)):this},init:function(t,n){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=n,this.element.bind("destroyed",e.proxy(this.teardown,this)),this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),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(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html(""),this._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||18,this.trigger("loading"),this.load_node("#")},destroy:function(){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[^ ]*|$/gi,"")}),this.element=null},bind:function(){e.support.touch&&this.element.addTouch(),this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var e=window.getSelection();try{e.removeAllRanges(),e.collapse()}catch(t){}}}).on("click.jstree",".jstree-ocl",e.proxy(function(e){this.toggle_node(e.target)},this)).on("click.jstree",".jstree-anchor",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).focus(),this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",e.proxy(function(t){var n=null;switch(t.which){case 13:case 32:t.type="click",e(t.currentTarget).trigger(t);break;case 37:t.preventDefault(),this.is_open(t.currentTarget)?this.close_node(t.currentTarget):(n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 38:t.preventDefault(),n=this.get_prev_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 39:t.preventDefault(),this.is_closed(t.currentTarget)?this.open_node(t.currentTarget,function(e){this.get_node(e,!0).children(".jstree-anchor").focus()}):(n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus());break;case 40:t.preventDefault(),n=this.get_next_dom(t.currentTarget),n&&n.length&&n.children(".jstree-anchor").focus();break;case 46:t.preventDefault(),n=this.get_node(t.currentTarget),n&&n.id&&"#"!==n.id&&(n=this.is_selected(n)?this.get_selected():n);break;case 113:t.preventDefault(),n=this.get_node(t.currentTarget);break;default:}},this)).on("load_node.jstree",e.proxy(function(t,n){if(n.status&&("#"!==n.node.id||this._data.core.loaded||(this._data.core.loaded=!0,this.trigger("loaded")),!this._data.core.ready&&!this.get_container_ul().find(".jstree-loading:eq(0)").length)){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var r=[],a,i;for(a=0,i=this._data.core.selected.length;i>a;a++)r=r.concat(this._model.data[this._data.core.selected[a]].parents);for(r=e.vakata.array_unique(r),a=0,i=r.length;i>a;a++)this.open_node(r[a],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this)).on("init.jstree",e.proxy(function(){var e=this.settings.core.themes;this._data.core.themes.dots=e.dots,this._data.core.themes.stripes=e.stripes,this._data.core.themes.icons=e.icons,this.set_theme(e.name||"default",e.url),this.set_theme_variant(e.variant)},this)).on("loading.jstree",e.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("focus.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseenter()},this)).on("blur.jstree",".jstree-anchor",e.proxy(function(t){e(t.currentTarget).mouseleave()},this)).on("mouseenter.jstree",".jstree-anchor",e.proxy(function(e){var t=this.element.find(".jstree-anchor:focus").not(".jstree-clicked");t&&t.length&&t[0]!==e.currentTarget&&t.blur(),this.hover_node(e.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),e(document).off(".jstree-"+this._id)},trigger:function(e,t){t||(t={}),t.instance=this,this.element.triggerHandler(e.replace(".jstree","")+".jstree",t)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children("ul:eq(0)")},get_string:function(t){var n=this.settings.core.strings;return e.isFunction(n)?n.call(this,t):n&&n[t]?n[t]:t},_firstChild:function(e){e=e?e.firstChild:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_nextSibling:function(e){e=e?e.nextSibling:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_previousSibling:function(e){e=e?e.previousSibling:null;while(null!==e&&1!==e.nodeType)e=e.previousSibling;return e},get_node:function(t,n){t&&t.id&&(t=t.id);var r;if(this._model.data[t])t=this._model.data[t];else if(((r=e(t,this.element)).length||(r=e("#"+t,this.element)).length)&&this._model.data[r.closest("li").attr("id")])t=this._model.data[r.closest("li").attr("id")];else{if(!(r=e(t,this.element)).length||!r.hasClass("jstree"))return!1;t=this._model.data["#"]}return n&&(t="#"===t.id?this.element:e(document.getElementById(t.id))),t},get_next_dom:function(t,n){var r;return t=this.get_node(t,!0),t[0]===this.element[0]?(r=this._firstChild(this.get_container_ul()[0]),r?e(r):!1):t&&t.length?n?(r=this._nextSibling(t[0]),r?e(r):!1):t.hasClass("jstree-open")?(r=this._firstChild(t.children("ul")[0]),r?e(r):!1):null!==(r=this._nextSibling(t[0]))?e(r):t.parentsUntil(".jstree","li").next("li").eq(0):!1},get_prev_dom:function(t,n){var r;if(t=this.get_node(t,!0),t[0]===this.element[0])return r=this.get_container_ul()[0].lastChild,r?e(r):!1;if(!t||!t.length)return!1;if(n)return r=this._previousSibling(t[0]),r?e(r):!1;if(null!==(r=this._previousSibling(t[0]))){t=e(r);while(t.hasClass("jstree-open"))t=t.children("ul:eq(0)").children("li:last");return t}return r=t[0].parentNode.parentNode,r&&"LI"===r.tagName?e(r):!1},get_parent:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.parent:!1},get_children_dom:function(e){return e=this.get_node(e,!0),e[0]===this.element[0]?this.get_container_ul().children("li"):e&&e.length?e.children("ul").children("li"):!1},is_parent:function(e){return e=this.get_node(e),e&&(e.state.loaded===!1||e.children.length)},is_loaded:function(e){return e=this.get_node(e),e&&e.state.loaded},is_loading:function(e){return e=this.get_node(e,!0),e&&e.hasClass("jstree-loading")},is_open:function(e){return e=this.get_node(e),e&&e.state.opened},is_closed:function(e){return e=this.get_node(e),e&&this.is_parent(e)&&!e.state.opened},is_leaf:function(e){return!this.is_parent(e)},load_node:function(t,n){var r,a;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.load_node(t[r],n);return!0}return(t=this.get_node(t))?(this.get_node(t,!0).addClass("jstree-loading"),this._load_node(t,e.proxy(function(e){t.state.loaded=e,this.get_node(t,!0).removeClass("jstree-loading"),this.trigger("load_node",{node:t,status:e}),n&&n.call(this,t,e)},this)),!0):(n.call(this,t,!1),!1)},_load_node:function(n,r){var a=this.settings.core.data;return a?e.isFunction(a)?a.call(this,n,e.proxy(function(t){return r.call(this,this["string"==typeof t?"_append_html_data":"_append_json_data"](n,"string"==typeof t?e(t):t))},this)):"object"==typeof a?a.url?(a=e.extend(!0,{},a),e.isFunction(a.url)&&(a.url=a.url.call(this,n)),e.isFunction(a.data)&&(a.data=a.data.call(this,n)),e.ajax(a).done(e.proxy(function(a,i,s){var o=s.getResponseHeader("Content-Type");return-1!==o.indexOf("json")?r.call(this,this._append_json_data(n,a)):-1!==o.indexOf("html")?r.call(this,this._append_html_data(n,e(a))):t},this)).fail(e.proxy(function(){r.call(this,!1)},this))):r.call(this,this._append_json_data(n,a)):"string"==typeof a?r.call(this,this._append_html_data(n,a)):r.call(this,!1):r.call(this,"#"===n.id?this._append_html_data(n,this._data.core.original_container_html.clone(!0)):!1)},_node_changed:function(e){e=this.get_node(e),e&&this._model.changed.push(e.id)},_append_html_data:function(t,n){t=this.get_node(t);var r=n.is("ul")?n.children():n,a=t.id,i=[],s=[],o=this._model.data,d=o[a],l=this._data.core.selected.length,c,h,_;for(r.each(e.proxy(function(t,n){c=this._parse_model_from_html(e(n),a,d.parents.concat()),c&&(i.push(c),s.push(c),o[c].children_d.length&&(s=s.concat(o[c].children_d)))},this)),d.children=i,d.children_d=s,h=0,_=d.parents.length;_>h;h++)o[d.parents[h]].children_d=o[d.parents[h]].children_d.concat(s);return this.trigger("model",{nodes:s,parent:a}),"#"!==a?(this._node_changed(a),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==l&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_append_json_data:function(n,r){n=this.get_node(n);var a=r,i=n.id,s=[],o=[],d=this._model.data,l=d[i],c=this._data.core.selected.length,h,_,u;if(e.isArray(a)||(a=[a]),a.length&&a[0].id!==t&&a[0].parent!==t){for(_=0,u=a.length;u>_;_++)a[_].children||(a[_].children=[]),d[a[_].id]=a[_];for(_=0,u=a.length;u>_;_++)d[a[_].parent].children.push(a[_].id),l.children_d.push(a[_].id);for(_=0,u=l.children.length;u>_;_++)this._parse_model_from_flat_json(d[l.children[_]],i,l.parents.concat())}else{for(_=0,u=a.length;u>_;_++)h=this._parse_model_from_json(a[_],i,l.parents.concat()),h&&(s.push(h),o.push(h),d[h].children_d.length&&(o=o.concat(d[h].children_d)));for(l.children=s,l.children_d=o,_=0,u=l.parents.length;u>_;_++)d[l.parents[_]].children_d=d[l.parents[_]].children_d.concat(o)}return this.trigger("model",{nodes:o,parent:i}),"#"!==i?(this._node_changed(i),this.redraw()):this.redraw(!0),this._data.core.selected.length!==c&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_parse_model_from_html:function(n,a,i){i=i?[].concat(i):[],a&&i.unshift(a);var s,o,d=this._model.data,l={id:!1,text:!1,icon:!0,parent:a,parents:i,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},c,h,_;for(c in this._model.default_state)this._model.default_state.hasOwnProperty(c)&&(l.state[c]=this._model.default_state[c]);if(h=e.vakata.attributes(n,!0),e.each(h,function(n,r){return r=e.trim(r),r.length?(l.li_attr[n]=r,"id"===n&&(l.id=r),t):!0}),h=n.children("a").eq(0),h.length&&(h=e.vakata.attributes(h,!0),e.each(h,function(t,n){n=e.trim(n),n.length&&(l.a_attr[t]=n)})),h=n.children("a:eq(0)").length?n.children("a:eq(0)").clone():n.clone(),h.children("ins, i, ul").remove(),h=h.html(),h=e("
        ").html(h),l.text=h.html(),h=n.data(),l.data=h?e.extend(!0,{},h):null,l.state.opened=n.hasClass("jstree-open"),l.state.selected=n.children("a").hasClass("jstree-clicked"),l.state.disabled=n.children("a").hasClass("jstree-disabled"),l.data&&l.data.jstree)for(c in l.data.jstree)l.data.jstree.hasOwnProperty(c)&&(l.state[c]=l.data.jstree[c]);h=n.children("a").children(".jstree-themeicon"),h.length&&(l.icon=h.hasClass("jstree-themeicon-hidden")?!1:h.attr("rel")),l.state.icon&&(l.icon=l.state.icon),h=n.children("ul").children("li");do _="j"+this._id+"_"+ ++r;while(d[_]);return l.id=l.li_attr.id||_,h.length?(h.each(e.proxy(function(t,n){s=this._parse_model_from_html(e(n),l.id,i),o=this._model.data[s],l.children.push(s),o.children_d.length&&(l.children_d=l.children_d.concat(o.children_d))},this)),l.children_d=l.children_d.concat(l.children)):n.hasClass("jstree-closed")&&(l.state.loaded=!1),d[l.id]=l,l.state.selected&&this._data.core.selected.push(l.id),l.id},_parse_model_from_flat_json:function(e,n,r){r=r?r.concat():[],n&&r.unshift(n);var a=e.id,i=this._model.data,s=this._model.default_state,o,d,l,c,h={id:a,text:e.text||"",icon:e.icon!==t?e.icon:!0,parent:n,parents:r,children:e.children||[],children_d:e.children_d||[],data:e.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(o in s)s.hasOwnProperty(o)&&(h.state[o]=s[o]);if(e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(h.icon=e.data.jstree.icon),e&&e.data&&(h.data=e.data,e.data.jstree))for(o in e.data.jstree)e.data.jstree.hasOwnProperty(o)&&(h.state[o]=e.data.jstree[o]);if(e&&"object"==typeof e.state)for(o in e.state)e.state.hasOwnProperty(o)&&(h.state[o]=e.state[o]);if(e&&"object"==typeof e.li_attr)for(o in e.li_attr)e.li_attr.hasOwnProperty(o)&&(h.li_attr[o]=e.li_attr[o]);if(h.li_attr.id||(h.li_attr.id=a),e&&"object"==typeof e.a_attr)for(o in e.a_attr)e.a_attr.hasOwnProperty(o)&&(h.a_attr[o]=e.a_attr[o]);for(e&&e.children&&e.children===!0&&(h.state.loaded=!1,h.children=[],h.children_d=[]),i[h.id]=h,o=0,d=h.children.length;d>o;o++)l=this._parse_model_from_flat_json(i[h.children[o]],h.id,r),c=i[l],h.children_d.push(l),c.children_d.length&&(h.children_d=h.children_d.concat(c.children_d));return delete e.data,delete e.children,i[h.id].original=e,h.state.selected&&this._data.core.selected.push(h.id),h.id},_parse_model_from_json:function(e,n,a){a=a?a.concat():[],n&&a.unshift(n);var i=!1,s,o,d,l,c=this._model.data,h=this._model.default_state,_;do i="j"+this._id+"_"+ ++r;while(c[i]);_={id:!1,text:"string"==typeof e?e:"",icon:"object"==typeof e&&e.icon!==t?e.icon:!0,parent:n,parents:a,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(s in h)h.hasOwnProperty(s)&&(_.state[s]=h[s]);if(e&&e.id&&(_.id=e.id),e&&e.text&&(_.text=e.text),e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(_.icon=e.data.jstree.icon),e&&e.data&&(_.data=e.data,e.data.jstree))for(s in e.data.jstree)e.data.jstree.hasOwnProperty(s)&&(_.state[s]=e.data.jstree[s]);if(e&&"object"==typeof e.state)for(s in e.state)e.state.hasOwnProperty(s)&&(_.state[s]=e.state[s]);if(e&&"object"==typeof e.li_attr)for(s in e.li_attr)e.li_attr.hasOwnProperty(s)&&(_.li_attr[s]=e.li_attr[s]);if(_.li_attr.id&&!_.id&&(_.id=_.li_attr.id),_.id||(_.id=i),_.li_attr.id||(_.li_attr.id=_.id),e&&"object"==typeof e.a_attr)for(s in e.a_attr)e.a_attr.hasOwnProperty(s)&&(_.a_attr[s]=e.a_attr[s]);if(e&&e.children&&e.children.length){for(s=0,o=e.children.length;o>s;s++)d=this._parse_model_from_json(e.children[s],_.id,a),l=c[d],_.children.push(d),l.children_d.length&&(_.children_d=_.children_d.concat(l.children_d));_.children_d=_.children_d.concat(_.children)}return e&&e.children&&e.children===!0&&(_.state.loaded=!1,_.children=[],_.children_d=[]),delete e.data,delete e.children,_.original=e,c[_.id]=_,_.state.selected&&this._data.core.selected.push(_.id),_.id},_redraw:function(){var e=this._model.force_full_redraw?this._model.data["#"].children.concat([]):this._model.changed.concat([]),t=document.createElement("UL"),n,r,a;for(r=0,a=e.length;a>r;r++)n=this.redraw_node(e[r],!0,this._model.force_full_redraw),n&&this._model.force_full_redraw&&t.appendChild(n);this._model.force_full_redraw&&(t.className=this.get_container_ul()[0].className,this.element.empty().append(t)),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:e})},redraw:function(e){e&&(this._model.force_full_redraw=!0),this._redraw()},redraw_node:function(t,n,r){var a=this.get_node(t),i=!1,s=!1,o=!1,d=!1,l=!1,h=!1,_="",u=document,g=this._model.data;if(!a)return!1;if("#"===a.id)return this.redraw(!0);if(n=n||0===a.children.length,t=u.getElementById(a.id))t=e(t),r||(i=t.parent().parent()[0],i===this.element[0]&&(i=null),s=t.index()),g[a.id].data=t.data(),n||!a.children.length||t.children("ul").length||(n=!0),n||(o=t.children("UL")[0]),t.remove();else if(n=!0,!r){if(i="#"!==a.parent?e("#"+a.parent,this.element)[0]:null,!(null===i||i&&g[a.parent].state.opened))return!1;s=e.inArray(a.id,null===i?g["#"].children:g[a.parent].children)}t=c.cloneNode(!0),_="jstree-node ";for(d in a.li_attr)if(a.li_attr.hasOwnProperty(d)){if("id"===d)continue;"class"!==d?c.setAttribute(d,a.li_attr[d]):_+=a.li_attr[d]}_+=!a.children.length&&a.state.loaded?" jstree-leaf":a.state.opened?" jstree-open":" jstree-closed",null!==a.parent&&g[a.parent].children[g[a.parent].children.length-1]===a.id&&(_+=" jstree-last"),t.id=a.id,t.className=_,_=(a.state.selected?" jstree-clicked":"")+(a.state.disabled?" jstree-disabled":"");for(l in a.a_attr)if(a.a_attr.hasOwnProperty(l)){if("href"===l&&"#"===a.a_attr[l])continue;"class"!==l?t.childNodes[1].setAttribute(l,a.a_attr[l]):_+=" "+a.a_attr[l]}if(_.length&&(t.childNodes[1].className="jstree-anchor "+_),a.icon&&a.icon!==!0&&(a.icon===!1?t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===a.icon.indexOf("/")?t.childNodes[1].childNodes[0].className+=" "+a.icon+" jstree-themeicon-custom":(t.childNodes[1].childNodes[0].style.backgroundImage="url("+a.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")),t.childNodes[1].appendChild(u.createTextNode(a.text)),a.data&&e.data(t,a.data),n&&a.children.length&&a.state.opened){for(h=u.createElement("UL"),h.setAttribute("role","group"),h.className="jstree-children",d=0,l=a.children.length;l>d;d++)h.appendChild(this.redraw_node(a.children[d],n,!0));t.appendChild(h)}return o&&t.appendChild(o),r||(i||(i=this.element[0]),i.getElementsByTagName("UL").length?i=i.getElementsByTagName("UL")[0]:(d=u.createElement("UL"),d.setAttribute("role","group"),d.className="jstree-children",i.appendChild(d),i=d),i.childNodes.length>s?i.insertBefore(t,i.childNodes[s]):i.appendChild(t)),t},open_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(i=0,s=n.length;s>i;i++)this.open_node(n[i],r,a);return!0}if(n=this.get_node(n),!n||"#"===n.id)return!1;if(a=a===t?this.settings.core.animation:a,!this.is_closed(n))return r&&r.call(this,n,!1),!1;if(this.is_loaded(n))o=this.get_node(n,!0),d=this,o.length&&(n.children.length&&!this._firstChild(o.children("ul")[0])&&(n.state.opened=!0,this.redraw_node(n,!0),o=this.get_node(n,!0)),a?o.children("ul").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").children("ul").stop(!0,!0).slideDown(a,function(){this.style.display="",d.trigger("after_open",{node:n})}):o[0].className=o[0].className.replace("jstree-closed","jstree-open")),n.state.opened=!0,r&&r.call(this,n,!0),this.trigger("open_node",{node:n}),a&&o.length||this.trigger("after_open",{node:n});else{if(this.is_loading(n))return setTimeout(e.proxy(function(){this.open_node(n,r,a)},this),500);this.load_node(n,function(e,t){return t?this.open_node(e,r,a):r?r.call(this,e,!1):!1})}},close_node:function(n,r){var a,i,s,o;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.close_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(r=r===t?this.settings.core.animation:r,s=this,o=this.get_node(n,!0),o.length&&(r?o.children("ul").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").children("ul").stop(!0,!0).slideUp(r,function(){this.style.display="",o.children("ul").remove(),s.trigger("after_close",{node:n})}):o[0].className=o[0].className.replace("jstree-open","jstree-closed")),n.state.opened=!1,this.trigger("close_node",{node:n}),r&&o.length||this.trigger("after_close",{node:n}),t):!1},toggle_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.toggle_node(n[r]);return!0}return this.is_closed(n)?this.open_node(n):this.is_open(n)?this.close_node(n):t},open_all:function(e,t,n){if(e||(e="#"),e=this.get_node(e),!e)return!1;var r="#"===e.id?this.get_container_ul():this.get_node(e,!0),a,i,s;if(!r.length){for(a=0,i=e.children_d.length;i>a;a++)this.is_closed(this._mode.data[e.children_d[a]])&&(this._mode.data[e.children_d[a]].state.opened=!0);return this.trigger("open_all",{node:e})}n=n||r,s=this,r=this.is_closed(e)?r.find("li.jstree-closed").addBack():r.find("li.jstree-closed"),r.each(function(){s.open_node(this,s.is_loaded(this)?!1:function(e){this.open_all(e,t,n)},t||0)}),0===n.find("li.jstree-closed").length&&this.trigger("open_all",{node:this.get_node(n)})},close_all:function(e,t){if(e||(e="#"),e=this.get_node(e),!e)return!1;var n="#"===e.id?this.get_container_ul():this.get_node(e,!0),r=this,a,i;if(!n.length){for(a=0,i=e.children_d.length;i>a;a++)this._mode.data[e.children_d[a]].state.opened=!1;return this.trigger("close_all",{node:e})}n=this.is_open(e)?n.find("li.jstree-open").addBack():n.find("li.jstree-open"),n.vakata_reverse().each(function(){r.close_node(this,t||0)}),this.trigger("close_all",{node:e})},is_disabled:function(e){return e=this.get_node(e),e&&e.state&&e.state.disabled},enable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.enable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!1,this.get_node(n,!0).children(".jstree-anchor").removeClass("jstree-disabled"),this.trigger("enable_node",{node:n}),t):!1},disable_node:function(n){var r,a;if(e.isArray(n)){for(r=0,a=n.length;a>r;r++)this.disable_node(n[r]);return!0}return n=this.get_node(n),n&&"#"!==n.id?(n.state.disabled=!0,this.get_node(n,!0).children(".jstree-anchor").addClass("jstree-disabled"),this.trigger("disable_node",{node:n}),t):!1},activate_node:function(e,t){if(this.is_disabled(e))return!1;if(this.settings.core.multiple&&(t.metaKey||t.ctrlKey||t.shiftKey)&&(!t.shiftKey||this._data.core.last_clicked&&this.get_parent(e)&&this.get_parent(e)===this._data.core.last_clicked.parent))if(t.shiftKey){var n=this.get_node(e).id,r=this._data.core.last_clicked.id,a=this.get_node(this._data.core.last_clicked.parent).children,i=!1,s,o;for(s=0,o=a.length;o>s;s+=1)a[s]===n&&(i=!i),a[s]===r&&(i=!i),i||a[s]===n||a[s]===r?this.select_node(a[s]):this.deselect_node(a[s])}else this.is_selected(e)?this.deselect_node(e):this.select_node(e);else this.deselect_all(!0),this.select_node(e),this._data.core.last_clicked=this.get_node(e);this.trigger("activate_node",{node:this.get_node(e)})},hover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(e)}),t):!1},dehover_node:function(e){return e=this.get_node(e,!0),e&&e.length?(e.children(".jstree-anchor").removeClass("jstree-hovered"),this.trigger("dehover_node",{node:this.get_node(e)}),t):!1},select_node:function(n,r,a){var i,s,o,d;if(e.isArray(n)){for(s=0,o=n.length;o>s;s++)this.select_node(n[s],r,a);return!0}return n=this.get_node(n),n&&"#"!==n.id?(i=this.get_node(n,!0),n.state.selected||(n.state.selected=!0,this._data.core.selected.push(n.id),i.length&&(i.children(".jstree-anchor").addClass("jstree-clicked"),a||(d=this,i.parents(".jstree-closed").each(function(){d.open_node(this,!1,0)}))),this.trigger("select_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"select_node",node:n,selected:this._data.core.selected})),t):!1},deselect_node:function(n,r){var a,i,s;if(e.isArray(n)){for(a=0,i=n.length;i>a;a++)this.deselect_node(n[a],r);return!0}return n=this.get_node(n),n&&"#"!==n.id?(s=this.get_node(n,!0),n.state.selected&&(n.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(n.id,this._data.core.selected)),s.length&&s.children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:n,selected:this._data.core.selected}),r||this.trigger("changed",{action:"deselect_node",node:n,selected:this._data.core.selected})),t):!1},select_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(this._data.core.selected=this._model.data["#"].children_d.concat(),n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),e||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:t})},deselect_all:function(e){var t=this._data.core.selected.concat([]),n,r;for(n=0,r=this._data.core.selected.length;r>n;n++)this._model.data[this._data.core.selected[n]]&&(this._model.data[this._data.core.selected[n]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked"),this.trigger("deselect_all",{selected:this._data.core.selected,node:t}),e||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:t})},is_selected:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.state.selected:!1},get_selected:function(){return this._data.core.selected},get_state:function(){var e={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},t;for(t in this._model.data)this._model.data.hasOwnProperty(t)&&"#"!==t&&(this._model.data[t].state.opened&&e.core.open.push(t),this._model.data[t].state.selected&&e.core.selected.push(t));return e},set_state:function(n,r){if(n){if(n.core){var a,i,s,o;return e.isArray(n.core.open)?(a=!0,i=!1,s=this,e.each(n.core.open.concat([]),function(t,r){i=document.getElementById(r),i&&(s.is_loaded(r)?(s.is_closed(r)&&s.open_node(r,!1,0),e.vakata.array_remove(n.core.open,e.inArray(r,n.core.open))):(s.is_loading(r)||s.open_node(r,e.proxy(function(){this.set_state(n)},s),0),a=!1))}),a&&(delete n.core.open,this.set_state(n,r)),!1):n.core.scroll?(n.core.scroll&&n.core.scroll.left!==t&&this.element.scrollLeft(n.core.scroll.left),n.core.scroll&&n.core.scroll.top!==t&&this.element.scrollTop(n.core.scroll.top),delete n.core.scroll,delete n.core.open,this.set_state(n,r),!1):n.core.selected?(o=this,this.deselect_all(),e.each(n.core.selected,function(e,t){o.select_node(t)}),delete n.core.selected,this.set_state(n,r),!1):e.isEmptyObject(n)?(r&&r.call(this),this.trigger("set_state"),!1):!0}return!0}return!1},refresh:function(){this._data.core.state=this.get_state(),this.load_node("#",function(t,n){n&&this.set_state(e.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")}),this._data.core.state=null})},get_text:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.text:!1},set_text:function(t,n){var r,a,i,s;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_text(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.text=n,i=this.get_node(t,!0),i.length&&(i=i.children(".jstree-anchor:eq(0)"),s=i.children("I").clone(),i.html(n).prepend(s),this.trigger("set_text",{obj:t,text:n})),!0):!1},get_json:function(e,t){if(e=this.get_node(e||"#"),!e)return!1;var n={id:e.id,text:e.text,icon:this.get_icon(e),li_attr:e.li_attr,a_attr:e.a_attr,state:{},data:t&&t.no_data?!1:this.get_node(e,!0).length?this.get_node(e,!0).data():e.data,children:[]},r,a;if(!t||!t.no_state)for(r in e.state)e.state.hasOwnProperty(r)&&(n.state[r]=e.state[r]);if(t&&t.no_id&&n.li_attr&&n.li_attr.id&&(delete n.li_attr.id,delete n.id),!t||!t.no_children)for(r=0,a=e.children.length;a>r;r++)n.children.push(this.get_json(e.children[r],t));return"#"===e.id?n.children:n},create_node:function(n,r,a,i,s){if(n=this.get_node(n),!n)return!1;if(a=a===t?"last":a,!a.match(/^(before|after)$/)&&!s&&!this.is_loaded(n))return this.load_node(n,function(){this.create_node(n,r,a,i,!0)});r||(r={text:this.get_string("New node")}),r.text===t&&(r.text=this.get_string("New node"));var o,d,l,c;switch("#"===n.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"after":o=this.get_node(n.parent),a=e.inArray(n,o.children),n=o;break;case"inside":case"first":a=0;break;case"last":a=n.children.length;break;default:a||(a=0)}if(a>n.children.length&&(a=n.children.length),r.id||(r.id=!0),!this.check("create_node",r,n,a))return!1;if(delete r.id,r=this._parse_model_from_json(r,n.id,n.parents.concat()),!r)return!1;for(o=this.get_node(r),d=[],d.push(r),d=d.concat(o.children_d),this.trigger("model",{nodes:d,parent:n.id}),n.children_d=n.children_d.concat(d),l=0,c=n.parents.length;c>l;l++)this._model.data[n.parents[l]].children_d=this._model.data[n.parents[l]].children_d.concat(d);for(r=o,o=[],l=0,c=n.children.length;c>l;l++)o[l>=a?l+1:l]=n.children[l];return o[a]=r.id,n.children=o,this.redraw_node(n,!0),i&&i.call(this,this.get_node(r)),this.trigger("create_node",{node:this.get_node(r),parent:n.id,position:a}),r.id},rename_node:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.rename_node(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(i=t.text,this.check("rename_node",t,this.get_parent(t),n)?(this.set_text(t,n),this.trigger("rename_node",{node:t,text:n,old:i}),!0):!1):!1},delete_node:function(t){var n,r,a,i,s,o,d,l,c,h;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.delete_node(t[n]);return!0}if(t=this.get_node(t),!t||"#"===t.id)return!1;if(a=this.get_node(t.parent),i=e.inArray(t.id,a.children),h=!1,!this.check("delete_node",t,a,i))return!1;for(a.children=e.vakata.array_remove(a.children,i),s=t.children_d.concat([]),s.push(t.id),l=0,c=s.length;c>l;l++){for(o=0,d=t.parents.length;d>o;o++)this._model.data[t.parents[o]].children_d=e.vakata.array_remove(this._model.data[t.parents[o]].children_d,e.inArray(s[l],this._model.data[t.parents[o]].children_d));this._model.data[s[l]].state.selected&&(h=!0,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(s[l],this._data.core.selected)))}return this.trigger("delete_node",{node:t,parent:a.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:a.id}),delete this._model.data[t.id],this.redraw_node(a,!0),!0 +},check:function(t,n,r,a){n=n&&n.id?n:this.get_node(n),r=r&&r.id?r:this.get_node(r);var i=t.match(/^move_node|copy_node|create_node$/i)?r:n,s=this.settings.core.check_callback;return"move_node"!==t||n.id!==r.id&&e.inArray(n.id,r.children)!==a&&-1===e.inArray(r.id,n.children_d)?(i=this.get_node(i,!0),i.length&&(i=i.data("jstree")),i&&i.functions&&(i.functions[t]===!1||i.functions[t]===!0)?i.functions[t]:s===!1||e.isFunction(s)&&s.call(this,t,n,r,a)===!1||s&&s[t]===!1?!1:!0):!1},move_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m,v,j;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.move_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.move_node(n,r,a,i,!0)});switch(l=""+n.parent,c=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,h=this._model.data[n.id]?this:e.jstree.reference(n.id),_=this._id!==h._id,"#"===c.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,c.children);break;case"after":a=e.inArray(r.id,c.children)+1;break;case"inside":case"first":a=0;break;case"last":a=c.children.length;break;default:a||(a=0)}if(a>c.children.length&&(a=c.children.length),!this.check("move_node",n,c,a))return!1;if(_||n.parent!==c.id){for(g=n.children_d.concat(),g.push(n.id),f=0,p=n.parents.length;p>f;f++){for(u=[],j=h._model.data[n.parents[f]].children_d,m=0,v=j.length;v>m;m++)-1===e.inArray(j[m],g)&&u.push(j[m]);h._model.data[n.parents[f]].children_d=u}for(h._model.data[l].children=e.vakata.array_remove(h._model.data[l].children,e.inArray(n.id,h._model.data[l].children)),f=0,p=c.parents.length;p>f;f++)this._model.data[c.parents[f]].children_d=this._model.data[c.parents[f]].children_d.concat(g);for(u=[],f=0,p=c.children.length;p>f;f++)u[f>=a?f+1:f]=c.children[f];u[a]=n.id,c.children=u,c.children_d.push(n.id),c.children_d=c.children_d.concat(n.children_d),n.parent=c.id,g=c.parents.concat(),g.push(c.id),n.parents=g,_?(h.delete_node(n.id),this._node_changed(c.id),this.redraw("#"===c.id)):(this._node_changed(l),this._node_changed(c.id),this.redraw("#"===l||"#"===c.id))}else{for(u=c.children.concat(),g=e.inArray(n.id,u),-1!==g&&(u=e.vakata.array_remove(u,g),a>g&&a--),g=[],f=0,p=u.length;p>f;f++)g[f>=a?f+1:f]=u[f];g[a]=n.id,c.children=g,this._node_changed(c.id),this.redraw("#"===c.id)}return i&&i.call(this,n,c,a),this.trigger("move_node",{node:n,parent:c.id,position:a,old_parent:l,is_multi:_,old_instance:h,new_instance:this}),!0},copy_node:function(n,r,a,i,s){var o,d,l,c,h,_,u,g,f,p,m;if(e.isArray(n)){for(n.reverse(),o=0,d=n.length;d>o;o++)this.copy_node(n[o],r,a,i,s);return!0}if(n=n&&n.id?n:this.get_node(n),r=this.get_node(r),a=a===t?0:a,!r||!n||"#"===n.id)return!1;if(!(""+a).match(/^(before|after)$/)&&!s&&!this.is_loaded(r))return this.load_node(r,function(){this.copy_node(n,r,a,i,!0)});switch(g=""+n.parent,f=(""+a).match(/^(before|after)$/)&&"#"!==r.id?this.get_node(r.parent):r,p=this._model.data[n.id]?this:e.jstree.reference(n.id),m=this._id!==p._id,"#"===f.id&&("before"===a&&(a="first"),"after"===a&&(a="last")),a){case"before":a=e.inArray(r.id,f.children);break;case"after":a=e.inArray(r.id,f.children)+1;break;case"inside":case"first":a=0;break;case"last":a=f.children.length;break;default:a||(a=0)}if(a>f.children.length&&(a=f.children.length),!this.check("copy_node",n,f,a))return!1;if(u=p.get_json(n,{no_id:!0,no_data:!0,no_state:!0}),!u)return!1;if(u=this._parse_model_from_json(u,f.id,f.parents.concat()),!u)return!1;for(c=this.get_node(u),l=[],l.push(u),l=l.concat(c.children_d),this.trigger("model",{nodes:l,parent:f.id}),h=0,_=f.parents.length;_>h;h++)this._model.data[f.parents[h]].children_d=this._model.data[f.parents[h]].children_d.concat(l);for(l=[],h=0,_=f.children.length;_>h;h++)l[h>=a?h+1:h]=f.children[h];return l[a]=c.id,f.children=l,f.children_d.push(c.id),f.children_d=f.children_d.concat(c.children_d),this._node_changed(f.id),this.redraw("#"===f.id),i&&i.call(this,c,f,a),this.trigger("copy_node",{node:c,original:n,parent:f.id,position:a,old_parent:g,is_multi:m,old_instance:p,new_instance:this}),c.id},cut:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="move_node",this.trigger("cut",{node:n}),t):!1},copy:function(n){if(n||(n=this._data.core.selected.concat()),e.isArray(n)||(n=[n]),!n.length)return!1;var r=[],o,d,l;for(d=0,l=n.length;l>d;d++)o=this.get_node(n[d]),o&&o.id&&"#"!==o.id&&r.push(o);return r.length?(a=r,s=this,i="copy_node",this.trigger("copy",{node:n}),t):!1},get_buffer:function(){return{mode:i,node:a,inst:s}},can_paste:function(){return i!==!1&&a!==!1},paste:function(e){return e=this.get_node(e),e&&i&&i.match(/^(copy_node|move_node)$/)&&a?(this[i](a,e)&&this.trigger("paste",{parent:e.id,node:a,mode:i}),a=!1,i=!1,s=!1,t):!1},edit:function(n,r){if(n=this.get_node(n,!0),!n||!n.length)return!1;n.parentsUntil(".jstree",".jstree-closed").each(e.proxy(function(e,t){this.open_node(t,!1,0)},this));var a=this._data.core.rtl,i=this.element.width(),s=n.children(".jstree-anchor"),o="string"==typeof r?r:this.get_text(n),d=e("
        ",{css:{position:"absolute",top:"-200px",left:a?"0px":"-1000px",visibility:"hidden"}}).appendTo("body"),l=e("",{value:o,"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:e.proxy(function(){var e=s.children(".jstree-rename-input"),t=e.val();""===t&&(t=o),d.remove(),e.remove(),this.rename_node(n,t)===!1&&this.rename_node(n,o)},this),keydown:function(e){var t=e.which;27===t&&(this.value=o),(27===t||13===t||37===t||38===t||39===t||40===t||32===t)&&e.stopImmediatePropagation(),(27===t||13===t)&&(e.preventDefault(),this.blur())},keyup:function(e){l.width(Math.min(d.text("pW"+this.value).width(),i))},keypress:function(e){return 13===e.which?!1:t}}),c={fontFamily:s.css("fontFamily")||"",fontSize:s.css("fontSize")||"",fontWeight:s.css("fontWeight")||"",fontStyle:s.css("fontStyle")||"",fontStretch:s.css("fontStretch")||"",fontVariant:s.css("fontVariant")||"",letterSpacing:s.css("letterSpacing")||"",wordSpacing:s.css("wordSpacing")||""};this.set_text(n,""),s.append(l),d.css(c),l.css(c).width(Math.min(d.text("pW"+l[0].value).width(),i))[0].select()},set_theme:function(t,n){if(!t)return!1;if(n===!0){var r=this.settings.core.themes.dir;r||(r=e.jstree.path+"/themes"),n=r+"/"+t+"/style.css"}n&&-1===e.inArray(n,o)&&(e("head").append(''),o.push(n)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=t,this.element.addClass("jstree-"+t),this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(e){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=e,e&&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=!0,this.get_container_ul().addClass("jstree-striped")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped")},toggle_stripes:function(){this._data.core.themes.stripes?this.hide_stripes():this.show_stripes()},show_dots:function(){this._data.core.themes.dots=!0,this.get_container_ul().removeClass("jstree-no-dots")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-dots")},toggle_dots:function(){this._data.core.themes.dots?this.hide_dots():this.show_dots()},show_icons:function(){this._data.core.themes.icons=!0,this.get_container_ul().removeClass("jstree-no-icons")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},set_icon:function(t,n){var r,a,i;if(e.isArray(t)){for(r=0,a=t.length;a>r;r++)this.set_icon(t[r],n);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.icon=n,i=this.get_node(t,!0).children("jstree-anchor").children(".jstree-themeicon"),n===!1?this.removeClass("jstree-themeicon-custom").hide_icon(t):-1===n.indexOf("/")?i.addClass(n+" jstree-themeicon-custom").attr("rel",n):i.removeClass("jstree-themeicon-custom").css("background","url('"+n+"') center center no-repeat").attr("rel",n),!0):!1},get_icon:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.icon:!1},hide_icon:function(t){var n,r;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.hide_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(t.icon=!1,this.get_node(t,!0).children("a").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(t){var n,r,a;if(e.isArray(t)){for(n=0,r=t.length;r>n;n++)this.show_icon(t[n]);return!0}return t=this.get_node(t),t&&"#"!==t?(a=this.get_node(t,!0),t.icon=a.length?a.children("a").children(".jstree-themeicon").attr("rel"):!0,t.icon||(t.icon=!0),a.children("a").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},e.vakata={},e.fn.vakata_reverse=[].reverse,e.vakata.attributes=function(t,n){t=e(t)[0];var r=n?{}:[];return e.each(t.attributes,function(t,a){-1===e.inArray(a.nodeName.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==a.nodeValue&&""!==e.trim(a.nodeValue)&&(n?r[a.nodeName]=a.nodeValue:r.push(a.nodeName))}),r},e.vakata.array_unique=function(e){var t=[],n,r,a;for(n=0,a=e.length;a>n;n++){for(r=0;n>=r;r++)if(e[n]===e[r])break;r===n&&t.push(e[n])}return t},e.vakata.array_remove=function(e,t,n){var r=e.slice((n||t)+1||e.length);return e.length=0>t?e.length+t:t,e.push.apply(e,r),e},function(){var t={},n=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},r=n(window.navigator.userAgent);r.browser&&(t[r.browser]=!0,t.version=r.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),e.vakata.browser=t}(),e.vakata.browser.msie&&8>e.vakata.browser.version&&(e.jstree.defaults.core.animation=0);var u=document.createElement("I");u.className="jstree-icon jstree-checkbox",e.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0},e.jstree.plugins.checkbox=function(t,n){this.bind=function(){n.bind.call(this),this._data.checkbox.uto=!1,this.element.on("init.jstree",e.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked")},this)).on("loading.jstree",e.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),this.settings.checkbox.three_state&&this.element.on("changed.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",e.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)},this)).on("model.jstree",e.proxy(function(t,n){var r=this._model.data,a=r[n.parent],i=n.nodes,s=[],o,d,l,c,h,_;if(a.state.selected){for(d=0,l=i.length;l>d;d++)r[i[d]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(i)}else for(d=0,l=i.length;l>d;d++)if(r[i[d]].state.selected){for(c=0,h=r[i[d]].children_d.length;h>c;c++)r[r[i[d]].children_d[c]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(r[i[d]].children_d)}for(d=0,l=a.children_d.length;l>d;d++)r[a.children_d[d]].children.length||s.push(r[a.children_d[d]].parent);for(s=e.vakata.array_unique(s),c=0,h=s.length;h>c;c++){a=r[s[c]];while(a&&"#"!==a.id){for(o=0,d=0,l=a.children.length;l>d;d++)o+=r[a.children[d]].state.selected;if(o!==l)break;a.state.selected=!0,this._data.core.selected.push(a.id),_=this.get_node(a,!0),_&&_.length&&_.children(".jstree-anchor").addClass("jstree-clicked"),a=this.get_node(a.parent)}}this._data.core.selected=e.vakata.array_unique(this._data.core.selected)},this)).on("select_node.jstree",e.proxy(function(t,n){var r=n.node,a=this._model.data,i=this.get_node(r.parent),s=this.get_node(r,!0),o,d,l,c;for(this._data.core.selected=e.vakata.array_unique(this._data.core.selected.concat(r.children_d)),o=0,d=r.children_d.length;d>o;o++)a[r.children_d[o]].state.selected=!0;while(i&&"#"!==i.id){for(l=0,o=0,d=i.children.length;d>o;o++)l+=a[i.children[o]].state.selected;if(l!==d)break;i.state.selected=!0,this._data.core.selected.push(i.id),c=this.get_node(i,!0),c&&c.length&&c.children(".jstree-anchor").addClass("jstree-clicked"),i=this.get_node(i.parent)}s.length&&s.find(".jstree-anchor").addClass("jstree-clicked")},this)).on("deselect_node.jstree",e.proxy(function(t,n){var r=n.node,a=this.get_node(r,!0),i,s,o;for(i=0,s=r.children_d.length;s>i;i++)this._model.data[r.children_d[i]].state.selected=!1;for(i=0,s=r.parents.length;s>i;i++)this._model.data[r.parents[i]].state.selected=!1,o=this.get_node(r.parents[i],!0),o&&o.length&&o.children(".jstree-anchor").removeClass("jstree-clicked");for(o=[],i=0,s=this._data.core.selected.length;s>i;i++)-1===e.inArray(this._data.core.selected[i],r.children_d)&&-1===e.inArray(this._data.core.selected[i],r.parents)&&o.push(this._data.core.selected[i]);this._data.core.selected=e.vakata.array_unique(o),a.length&&a.find(".jstree-anchor").removeClass("jstree-clicked")},this)).on("delete_node.jstree",e.proxy(function(e,t){var n=this.get_node(t.parent),r=this._model.data,a,i,s,o;while(n&&"#"!==n.id){for(s=0,a=0,i=n.children.length;i>a;a++)s+=r[n.children[a]].state.selected;if(s!==i)break;n.state.selected=!0,this._data.core.selected.push(n.id),o=this.get_node(n,!0),o&&o.length&&o.children(".jstree-anchor").addClass("jstree-clicked"),n=this.get_node(n.parent)}},this)).on("move_node.jstree",e.proxy(function(t,n){var r=n.is_multi,a=n.old_parent,i=this.get_node(n.parent),s=this._model.data,o,d,l,c,h;if(!r){o=this.get_node(a);while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d!==c)break;o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"),o=this.get_node(o.parent)}}o=i;while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=s[o.children[l]].state.selected;if(d===c)o.state.selected||(o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"));else{if(!o.state.selected)break;o.state.selected=!1,this._data.core.selected=e.vakata.array_remove(this._data.core.selected,e.inArray(o.id,this._data.core.selected)),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").removeClass("jstree-clicked")}o=this.get_node(o.parent)}},this))},this._undetermined=function(){var t,n,r=this._model.data,a=this._data.core.selected,i=[],s=this;for(t=0,n=a.length;n>t;t++)r[a[t]]&&r[a[t]].parents&&(i=i.concat(r[a[t]].parents));for(this.element.find(".jstree-closed").not(":has(ul)").each(function(){var e=s.get_node(this);!e.state.loaded&&e.original&&e.original.state&&e.original.state.undetermined&&e.original.state.undetermined===!0&&(i.push(e.id),i=i.concat(e.parents))}),i=e.vakata.array_unique(i),t=e.inArray("#",i),-1!==t&&(i=e.vakata.array_remove(i,t)),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),t=0,n=i.length;n>t;t++)r[i[t]].state.selected||(a=this.get_node(i[t],!0),a&&a.length&&a.children("a").children(".jstree-checkbox").addClass("jstree-undetermined"))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=t.getElementsByTagName("A")[0];i.insertBefore(u.cloneNode(),i.childNodes[0])}return!a&&this.settings.checkbox.three_state&&(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)),t},this.activate_node=function(t,r){return(this.settings.checkbox.whole_node||e(r.target).hasClass("jstree-checkbox"))&&(r.ctrlKey=!0),n.activate_node.call(this,t,r)},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.element.children("ul").removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.element.children("ul").addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()}},e.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(t){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.create_node(r,{},"last",function(e){setTimeout(function(){n.edit(e)},0)})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.edit(r)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.delete_node(n.get_selected()):n.delete_node(r)}},ccp:{separator_before:!0,icon:!1,separator_after:!1,label:"Edit",action:!1,submenu:{cut:{separator_before:!1,separator_after:!1,label:"Cut",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.cut(n.get_selected()):n.cut(r)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.is_selected(r)?n.copy(n.get_selected()):n.copy(r)}},paste:{separator_before:!1,icon:!1,_disabled:!this.can_paste(),separator_after:!1,label:"Paste",action:function(t){var n=e.jstree.reference(t.reference),r=n.get_node(t.reference);n.paste(r)}}}}}}},e.jstree.plugins.contextmenu=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("contextmenu.jstree","a",e.proxy(function(e){e.preventDefault(),this.is_loading(e.currentTarget)||this.show_contextmenu(e.currentTarget,e.pageX,e.pageY)},this)).on("click.jstree","a",e.proxy(function(t){this._data.contextmenu.visible&&e.vakata.context.hide()},this)),e(document).on("context_hide.vakata",e.proxy(function(){this._data.contextmenu.visible=!1},this))},this.teardown=function(){this._data.contextmenu.visible&&e.vakata.context.hide(),r.teardown.call(this)},this.show_contextmenu=function(n,r,a){if(n=this.get_node(n),!n||"#"===n.id)return!1;var i=this.settings.contextmenu,s=this.get_node(n,!0),o=s.children(".jstree-anchor"),d=!1,l=!1;(i.show_at_node||r===t||a===t)&&(d=o.offset(),r=d.left,a=d.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(n)&&(this.deselect_all(),this.select_node(n)),l=i.items,e.isFunction(l)&&(l=l.call(this,n)),e(document).one("context_show.vakata",e.proxy(function(t,n){var r="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";e(n.element).addClass(r)},this)),this._data.contextmenu.visible=!0,e.vakata.context.show(o,{x:r,y:a},l),this.trigger("show_contextmenu",{node:n,x:r,y:a})}},function(e){var n=!1,r={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};e.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(t){e(document).triggerHandler("context_"+t+".vakata",{reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}})},_execute:function(e){return e=r.items[e],e&&!e._disabled&&e.action?e.action.call(null,{item:e,reference:r.reference,element:r.element,position:{x:r.position_x,y:r.position_y}}):!1},_parse:function(n,a){if(!n)return!1;a||(r.html="",r.items=[]);var i="",s=!1,o;return a&&(i+=""),a||(r.html=i,e.vakata.context._trigger("parse")),i.length>10?i:!1},_show_submenu:function(t){if(t=e(t),t.length&&t.children("ul").length){var r=t.children("ul"),a=t.offset().left+t.outerWidth(),i=t.offset().top,s=r.width(),o=r.height(),d=e(window).width()+e(window).scrollLeft(),l=e(window).height()+e(window).scrollTop();n?t[0>a-(s+10+t.outerWidth())?"addClass":"removeClass"]("vakata-context-left"):t[a+s+10>d?"addClass":"removeClass"]("vakata-context-right"),i+o+10>l&&r.css("bottom","-1px"),r.show()}},show:function(t,a,i){var s,o,d,l,c,h,_,u,g=!0;switch(r.element&&r.element.length&&r.element.width(""),g){case!a&&!t:return!1;case!!a&&!!t:r.reference=t,r.position_x=a.x,r.position_y=a.y;break;case!a&&!!t:r.reference=t,s=t.offset(),r.position_x=s.left+t.outerHeight(),r.position_y=s.top;break;case!!a&&!t:r.position_x=a.x,r.position_y=a.y}t&&!i&&e(t).data("vakata_contextmenu")&&(i=e(t).data("vakata_contextmenu")),e.vakata.context._parse(i)&&r.element.html(r.html),r.items.length&&(o=r.element,d=r.position_x,l=r.position_y,c=o.width(),h=o.height(),_=e(window).width()+e(window).scrollLeft(),u=e(window).height()+e(window).scrollTop(),n&&(d-=o.outerWidth(),e(window).scrollLeft()+20>d&&(d=e(window).scrollLeft()+20)),d+c+20>_&&(d=_-(c+20)),l+h+20>u&&(l=u-(h+20)),r.element.css({left:d,top:l}).show().find("a:eq(0)").focus().parent().addClass("vakata-context-hover"),r.is_visible=!0,e.vakata.context._trigger("show"))},hide:function(){r.is_visible&&(r.element.hide().find("ul").hide().end().find(":focus").blur(),r.is_visible=!1,e.vakata.context._trigger("hide"))}},e(function(){n="rtl"===e("body").css("direction");var t=!1,a='.vakata-context { display:none; _width:1px; } .vakata-context, .vakata-context ul { margin:0; padding:2px; position:absolute; background:#f5f5f5; border:1px solid #979797; -moz-box-shadow:5px 5px 4px -4px #666666; -webkit-box-shadow:2px 2px 2px #999999; box-shadow:2px 2px 2px #999999; }.vakata-context ul { list-style:none; left:100%; margin-top:-2.7em; margin-left:-4px; } .vakata-context li.vakata-context-right ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context li { list-style:none; display:inline; }.vakata-context li a { display:block; padding:0 2em 0 2em; text-decoration:none; width:auto; color:black; white-space:nowrap; line-height:2.4em; -moz-text-shadow:1px 1px 0px white; -webkit-text-shadow:1px 1px 0px white; text-shadow:1px 1px 0px white; -moz-border-radius:1px; -webkit-border-radius:1px; border-radius:1px; }.vakata-context li a:hover { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li.vakata-context-hover > a { position:relative; background-color:#e8eff7; -moz-box-shadow:0px 0px 2px #0a6aa1; -webkit-box-shadow:0px 0px 2px #0a6aa1; box-shadow:0px 0px 2px #0a6aa1; }.vakata-context li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); background-position:right center; background-repeat:no-repeat; } .vakata-context li.vakata-context-separator a, .vakata-context li.vakata-context-separator a:hover { background:white; border:0; border-top:1px solid #e2e3e3; height:1px; min-height:1px; max-height:1px; padding:0; margin:0 0 0 2.4em; border-left:1px solid #e0e0e0; _overflow:hidden; -moz-text-shadow:0 0 0 transparent; -webkit-text-shadow:0 0 0 transparent; text-shadow:0 0 0 transparent; -moz-box-shadow:0 0 0 transparent; -webkit-box-shadow:0 0 0 transparent; box-shadow:0 0 0 transparent; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0; }.vakata-context li.vakata-contextmenu-disabled a, .vakata-context li.vakata-contextmenu-disabled a:hover { color:silver; background-color:transparent; border:0; box-shadow:0 0 0; }.vakata-context li a ins { text-decoration:none; display:inline-block; width:2.4em; height:2.4em; background:transparent; margin:0 0 0 -2em; } .vakata-context li a span { display:inline-block; width:1px; height:2.4em; background:white; margin:0 0.5em 0 0; border-left:1px solid #e2e3e3; _overflow:hidden; } .vakata-context-rtl ul { left:auto; right:100%; margin-left:auto; margin-right:-4px; } .vakata-context-rtl li a.vakata-context-parent { background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); background-position:left center; background-repeat:no-repeat; } .vakata-context-rtl li.vakata-context-separator a { margin:0 2.4em 0 0; border-left:0; border-right:1px solid #e2e3e3;} .vakata-context-rtl li.vakata-context-left ul { right:auto; left:100%; margin-left:-4px; margin-right:auto; } .vakata-context-rtl li a ins { margin:0 -2em 0 0; } .vakata-context-rtl li a span { margin:0 0 0 0.5em; border-left-color:white; background:#e2e3e3; } ';e.jstree.no_css||e("head").append('"),r.element=e("
          "),r.element.on("mouseenter","li",function(n){n.stopImmediatePropagation(),e.contains(this,n.relatedTarget)||(t&&clearTimeout(t),r.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),e(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),e.vakata.context._show_submenu(this))}).on("mouseleave","li",function(t){e.contains(this,t.relatedTarget)||e(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(n){e(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),e.vakata.context.settings.hide_onmouseleave&&(t=setTimeout(function(t){return function(){e.vakata.context.hide()}}(this),e.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(e){e.preventDefault()}).on("mouseup","a",function(t){e(this).blur().parent().hasClass("vakata-context-disabled")||e.vakata.context._execute(e(this).attr("rel"))===!1||e.vakata.context.hide()}).on("keydown","a",function(t){var n=null;switch(t.which){case 13:case 32:t.type="mouseup",t.preventDefault(),e(t.currentTarget).trigger(t);break;case 37:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 39:r.is_visible&&(r.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:r.is_visible&&(n=r.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),n.length||(n=r.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),n.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 27:e.vakata.context.hide(),t.preventDefault();break;default:}}).appendTo("body"),e(document).on("mousedown",function(t){r.is_visible&&!e.contains(r.element[0],t.target)&&e.vakata.context.hide()}).on("context_show.vakata",function(e,t){r.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),n&&r.element.addClass("vakata-context-rtl").css("direction","rtl"),r.element.find("ul").hide().end()})})}(e),e.jstree.defaults.dnd={copy:!0,open_timeout:500},e.jstree.plugins.dnd=function(n,r){this.bind=function(){r.bind.call(this),this.element.on("mousedown","a",e.proxy(function(n){var r=this.get_node(n.target),a=this.is_selected(r)?this.get_selected().length:1;return r&&r.id&&"#"!==r.id&&1===n.which?(this.element.trigger("mousedown.jstree"),e.vakata.dnd.start(n,{jstree:!0,origin:this,obj:this.get_node(r,!0),nodes:a>1?this.get_selected():[r.id]},'
          '+(a>1?a+" "+this.get_string("nodes"):this.get_text(n.currentTarget,!0))+'
          ')):t},this))}},e(function(){var n=!1,r=!1,a=e('
           
          ').hide().appendTo("body");e(document).bind("dnd_start.vakata",function(e,t){n=!1}).bind("dnd_move.vakata",function(i,s){if(r&&clearTimeout(r),s.data.jstree&&(!s.event.target.id||"jstree-marker"!==s.event.target.id)){var o=e.jstree.reference(s.event.target),d=!1,l=!1,c=!1,h,_,u,g,f,p,m,v,j,x,y,k;if(o&&o._data&&o._data.dnd)if(a.attr("class","jstree-"+o.get_theme()),s.helper.children().attr("class","jstree-"+o.get_theme()).find(".jstree-copy:eq(0)")[s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"show":"hide"](),s.event.target!==o.element[0]&&s.event.target!==o.get_container_ul()[0]||0!==o.get_container_ul().children().length){if(d=e(s.event.target).closest("a"),d&&d.length&&d.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(l=d.offset(),c=s.event.pageY-l.top,u=d.height(),p=u/3>c?["b","i","a"]:c>u-u/3?["a","i","b"]:c>u/2?["i","a","b"]:["i","b","a"],e.each(p,function(i,c){switch(c){case"b":h=l.left-6,_=l.top-5,g=o.get_parent(d),f=d.parent().index();break;case"i":h=l.left-2,_=l.top-5+u/2+1,g=d.parent(),f=0;break;case"a":h=l.left-6,_=l.top-5+u,g=o.get_parent(d),f=d.parent().index()+1}for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(x=s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",y=f,"move_node"===x&&"a"===c&&s.data.origin===o&&g===o.get_parent(s.data.nodes[v])&&(k=o.get_node(g),y>e.inArray(s.data.nodes[v],k.children)&&(y-=1)),m=m&&o.check(x,s.data.nodes[v],g,y),!m)break;return m?("i"===c&&d.parent().is(".jstree-closed")&&o.settings.dnd.open_timeout&&(r=setTimeout(function(e,t){return function(){e.open_node(t)}}(o,d),o.settings.dnd.open_timeout)),n={ins:o,par:g,pos:f},a.css({left:h+"px",top:_+"px"}).show(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),p=!0,!1):t}),p===!0))return}else{for(m=!0,v=0,j=s.data.nodes.length;j>v;v++)if(m=m&&o.check(s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)?"copy_node":"move_node",s.data.nodes[v],"#","last"),!m)break;if(m)return n={ins:o,par:"#",pos:"last"},a.hide(),s.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),t +}n=!1,s.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),a.hide()}}).bind("dnd_scroll.vakata",function(e,t){t.data.jstree&&(a.hide(),n=!1,t.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er"))}).bind("dnd_stop.vakata",function(e,t){r&&clearTimeout(r),t.data.jstree&&(a.hide(),n&&n.ins[t.data.origin.settings.dnd.copy&&(t.event.metaKey||t.event.ctrlKey)?"copy_node":"move_node"](t.data.nodes,n.par,n.pos))}).bind("keyup keydown",function(t,n){n=e.vakata.dnd._get(),n.data&&n.data.jstree&&n.helper.find(".jstree-copy:eq(0)")[n.data.origin.settings.dnd.copy&&(t.metaKey||t.ctrlKey)?"show":"hide"]()})}),function(e){e.fn.vakata_reverse=[].reverse;var n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1};e.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5},_trigger:function(t,n){var r=e.vakata.dnd._get();r.event=n,e(document).triggerHandler("dnd_"+t+".vakata",r)},_get:function(){return{data:n.data,element:n.element,helper:n.helper}},_clean:function(){n.helper&&n.helper.remove(),n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),n={element:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1},e(document).unbind("mousemove",e.vakata.dnd.drag),e(document).unbind("mouseup",e.vakata.dnd.stop)},_scroll:function(t){if(!n.scroll_e||!n.scroll_l&&!n.scroll_t)return n.scroll_i&&(clearInterval(n.scroll_i),n.scroll_i=!1),!1;if(!n.scroll_i)return n.scroll_i=setInterval(e.vakata.dnd._scroll,100),!1;if(t===!0)return!1;var r=n.scroll_e.scrollTop(),a=n.scroll_e.scrollLeft();n.scroll_e.scrollTop(r+n.scroll_t*e.vakata.dnd.settings.scroll_speed),n.scroll_e.scrollLeft(a+n.scroll_l*e.vakata.dnd.settings.scroll_speed),(r!==n.scroll_e.scrollTop()||a!==n.scroll_e.scrollLeft())&&e.vakata.dnd._trigger("scroll",n.scroll_e)},start:function(t,r,a){n.is_drag&&e.vakata.dnd.stop({});try{t.currentTarget.unselectable="on",t.currentTarget.onselectstart=function(){return!1},t.currentTarget.style&&(t.currentTarget.style.MozUserSelect="none")}catch(i){}return n.init_x=t.pageX,n.init_y=t.pageY,n.data=r,n.is_down=!0,n.element=t.currentTarget,a!==!1&&(n.helper=e("
          ").html(a).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),e(document).bind("mousemove",e.vakata.dnd.drag),e(document).bind("mouseup",e.vakata.dnd.stop),!1},drag:function(r){if(n.is_down){if(!n.is_drag){if(!(Math.abs(r.pageX-n.init_x)>e.vakata.dnd.settings.threshold||Math.abs(r.pageY-n.init_y)>e.vakata.dnd.settings.threshold))return;n.helper&&(n.helper.appendTo("body"),n.helper_w=n.helper.outerWidth()),n.is_drag=!0,e.vakata.dnd._trigger("start",r)}var a=!1,i=!1,s=!1,o=!1,d=!1,l=!1,c=!1,h=!1,_=!1,u=!1;n.scroll_t=0,n.scroll_l=0,n.scroll_e=!1,e(r.target).parentsUntil("body").addBack().vakata_reverse().filter(function(){return/^auto|scroll$/.test(e(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var a=e(this),i=a.offset();return this.scrollHeight>this.offsetHeight&&(i.top+a.height()-r.pageYthis.offsetWidth&&(i.left+a.width()-r.pageXo&&r.pageY-co&&o-(r.pageY-c)l&&r.pageX-hl&&l-(r.pageX-h)s&&(_=s-50),d&&u+n.helper_w>d&&(u=d-(n.helper_w+2)),n.helper.css({left:u+"px",top:_+"px"})),e.vakata.dnd._trigger("move",r)}},stop:function(t){n.is_drag&&e.vakata.dnd._trigger("stop",t),e.vakata.dnd._clean()}}}(jQuery),e.jstree.defaults.search={ajax:!1,fuzzy:!0,case_sensitive:!1,show_only_matches:!1},e.jstree.plugins.search=function(t,n){this.bind=function(){n.bind.call(this),this._data.search.str="",this._data.search.dom=e(),this._data.search.res=[],this.settings.search.show_only_matches&&this.element.on("search.jstree",function(t,n){n.nodes.length&&(e(this).find("li").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last"),n.nodes.parentsUntil(".jstree").addBack().show().filter("ul").each(function(){e(this).children("li:visible").eq(-1).addClass("jstree-last")}))}).on("clear_search.jstree",function(t,n){n.nodes.length&&e(this).find("li").css("display","").filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last")})},this.search=function(t,n){if(t===!1||""===e.trim(t))return this.clear_search();var r=this.settings.search,a=r.ajax?e.extend({},r.ajax):!1,i=null,s=[],o=[],d,l;if(this._data.search.res.length&&this.clear_search(),!n&&a!==!1)return a.data||(a.data={}),a.data.str=t,e.ajax(r.ajax).done(e.proxy(function(e){this._search_load(e,t)},this));if(this._data.search.str=t,this._data.search.dom=e(),this._data.search.res=[],i=new e.vakata.search(t,!0,{caseSensitive:r.case_sensitive,fuzzy:r.fuzzy}),e.each(this._model.data,function(e,t){t.text&&i.search(t.text).isMatch&&(s.push(e),o=o.concat(t.parents))}),s.length){for(o=e.vakata.array_unique(o),this._search_open(o),d=0,l=s.length;l>d;d++)i=this.get_node(s[d],!0),i&&(this._data.search.dom=this._data.search.dom.add(i));this._data.search.res=s,this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:t,res:this._data.search.res})},this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"),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.dom=e()},this._search_open=function(t){var n=this;e.each(t.concat([]),function(e,r){r=document.getElementById(r),r&&n.is_closed(r)&&n.open_node(r,function(){n._search_open(t)})})},this._search_load=function(t,n){var r=!0,a=this,i=a._model.data;e.each(t.concat([]),function(e,s){i[s]&&(i[s].state.loaded||(a.load_node(s,function(){a._search_load(t,n)}),r=!1))}),r&&this.search(n,!0)}},function(e){e.vakata.search=function(e,t,n){n=n||{},n.fuzzy!==!1&&(n.fuzzy=!0),e=n.caseSensitive?e:e.toLowerCase();var r=n.location||0,a=n.distance||100,i=n.threshold||.6,s=e.length,o,d,l,c;return s>32&&(n.fuzzy=!1),n.fuzzy&&(o=1<n;n++)t[e.charAt(n)]=0;for(n=0;s>n;n++)t[e.charAt(n)]|=1<a;a++){g=0,f=p;while(f>g)_>=l(a,r+f)?g=f:p=f,f=Math.floor((p-g)/2+g);for(p=f,v=Math.max(1,r-f+1),j=Math.min(r+f,h)+s,x=Array(j+2),x[j+1]=(1<=v;c--)if(y=d[t.charAt(c-1)],x[c]=0===a?(1|x[c+1]<<1)&y:(1|x[c+1]<<1)&y|(1|(m[c+1]|m[c])<<1)|m[c+1],x[c]&o&&(k=l(a,c-1),_>=k)){if(_=k,u=c-1,b.push(u),!(u>r))break;v=Math.max(1,2*r-u)}if(l(a+1,r)>_)break;m=x}return{isMatch:u>=0,score:k}},t===!0?{search:c}:c(t)}}(jQuery),e.jstree.defaults.sort=function(e,t){return this.get_text(e)>this.get_text(t)?1:-1},e.jstree.plugins.sort=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",e.proxy(function(e,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",e.proxy(function(e,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,n){var r,a;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(e.proxy(this.settings.sort,this)),n))for(r=0,a=t.children_d.length;a>r;r++)this.sort(t.children_d[r],!1)}};var g=!1;e.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:!1},e.jstree.plugins.state=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("ready.jstree",e.proxy(function(t,n){this.element.one("restore_state.jstree set_state.jstree",e.proxy(function(){this.element.on(this.settings.state.events,e.proxy(function(){g&&clearTimeout(g),g=setTimeout(e.proxy(function(){this.save_state()},this),100)},this))},this)),this.restore_state()},this))},this.save_state=function(){e.vakata.storage.set(this.settings.state.key,this.get_state(),this.settings.state.ttl)},this.restore_state=function(){var t=e.vakata.storage.get(this.settings.state.key);t&&this.set_state(t),this.trigger("restore_state",{state:t})},this.clear_state=function(){return e.vakata.storage.del(this.settings.state.key)}},function(e,t){var n=function(e){var t=/["\\\x00-\x1f\x7f-\x9f]/g,n={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return e.match(t)?'"'+e.replace(t,function(e){var t=n[e];return"string"==typeof t?t:(t=e.charCodeAt(),"\\u00"+Math.floor(t/16).toString(16)+(t%16).toString(16))})+'"':'"'+e+'"'};e.vakata.json={encode:JSON&&JSON.stringify?JSON.stringify:function(r){if(null===r)return"null";var a=[],i;switch(typeof r){case"undefined":return t;case"number":case"boolean":return""+r;case"string":return n(r);case"object":if(e.isFunction(r.toJSON))return e.vakata.json.encode(r.toJSON());if(r.constructor===Date)return'"'+r.getUTCFullYear()+"-"+("0"+(r.getUTCMonth()+1)+"").slice(-2)+"-"+("0"+r.getUTCDate()+"").slice(-2)+"T"+("0"+r.getUTCHours()+"").slice(-2)+":"+("0"+r.getUTCMinutes()+"").slice(-2)+":"+("0"+r.getUTCSeconds()+"").slice(-2)+"."+("00"+r.getUTCMilliseconds()+"").slice(-3)+'Z"';if(r.constructor===Array){for(i=0;r.length>i;i++)a.push(e.vakata.json.encode(r[i])||"null");return"["+a.join(",")+"]"}return e.each(r,function(r,i){return e.isFunction(i)?!0:(r="number"==typeof r?'"'+r+'"':n(r),i=e.vakata.json.encode(i),a.push(r+":"+i),t)}),"{"+a.join(", ")+"}"}},decode:JSON&&JSON.parse?JSON.parse:function(t){return e.parseJSON(t)}}}(jQuery),function(e,t,n){var r=function(e){return e},a=function(e){return decodeURIComponent(e.replace(/\+/g," "))},i=e.vakata.cookie=function(s,o,d){var l,c,h,_,u,g,f,p;if(o!==n)return d=e.extend({},i.defaults,d),null===o&&(d.expires=-1),"number"==typeof d.expires&&(l=d.expires,c=d.expires=new Date,c.setDate(c.getDate()+l)),o=i.json?e.vakata.json.encode(o):o+"",o=[encodeURIComponent(s),"=",i.raw?o:encodeURIComponent(o),d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join(""),t.cookie=o,o;for(h=i.raw?r:a,_=t.cookie.split("; "),u=0,g=_.length;g>u;u++)if(f=_[u].split("="),h(f.shift())===s)return p=h(f.join("=")),i.json?e.vakata.json.decode(p):p;return null};i.defaults={},e.vakata.removeCookie=function(t,n){return null!==e.vakata.cookie(t)?(e.vakata.cookie(t,null,n),!0):!1}}(jQuery,document),function(e,t){var n={},r={jStorage:"{}"},a=null,i=0,s=e.vakata.json.encode,o=e.vakata.json.decode,d=!1,l=!1;function c(){if(r.jStorage)try{n=o(r.jStorage+"")}catch(e){r.jStorage="{}"}else r.jStorage="{}";i=r.jStorage?(r.jStorage+"").length:0}function h(){try{r.jStorage=s(n),"userDataBehavior"===d&&(a.setAttribute("jStorage",r.jStorage),a.save("jStorage")),"cookie"===d&&e.vakata.cookie("__vjstorage",r.jStorage,{expires:365}),i=r.jStorage?(r.jStorage+"").length:0}catch(t){}}function _(e){if(!e||"string"!=typeof e&&"number"!=typeof e)throw new TypeError("Key name must be string or numeric");if("__jstorage_meta"===e)throw new TypeError("Reserved key name");return!0}function u(){var e=+new Date,t,r,a=1/0,i=!1;if(l!==!1&&clearTimeout(l),n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL){r=n.__jstorage_meta.TTL;for(t in r)r.hasOwnProperty(t)&&(e>=r[t]?(delete r[t],delete n[t],i=!0):a>r[t]&&(a=r[t]));1/0!==a&&(l=setTimeout(u,a-e)),i&&h()}}function g(){var n=!1,i;if(window.hasOwnProperty("localStorage"))try{window.localStorage.setItem("_tmptest","tmpval"),n=!0,window.localStorage.removeItem("_tmptest")}catch(s){}if(n)try{window.localStorage&&(r=window.localStorage,d="localStorage")}catch(s){}else if(window.hasOwnProperty("globalStorage"))try{window.globalStorage&&(r=window.globalStorage[window.location.hostname],d="globalStorage")}catch(s){}else{if(a=document.createElement("link"),a.addBehavior){a.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(a);try{a.load("jStorage"),i="{}",i=a.getAttribute("jStorage"),r.jStorage=i,d="userDataBehavior"}catch(s){}}if(!d&&(e.vakata.cookie("__vjstorage")||e.vakata.cookie("__vjstorage","{}",{expires:365})&&"{}"===e.vakata.cookie("__vjstorage"))&&(a=null,r.jStorage=e.vakata.cookie("__vjstorage"),d="cookie"),!d)return a=null,t}c(),u()}e.vakata.storage={version:"0.3.0",set:function(t,r,a){return _(t),"object"==typeof r&&(r=o(s(r))),n[t]=r,h(),a&&parseInt(a,10)&&e.vakata.storage.setTTL(t,parseInt(a,10)),r},get:function(e,r){return _(e),n.hasOwnProperty(e)?n[e]:r===t?null:r},del:function(e){return _(e),n.hasOwnProperty(e)?(delete n[e],n.__jstorage_meta&&"object"==typeof n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL.hasOwnProperty(e)&&delete n.__jstorage_meta.TTL[e],h(),!0):!1},setTTL:function(e,t){var r=+new Date;return _(e),t=Number(t)||0,n.hasOwnProperty(e)?(n.__jstorage_meta||(n.__jstorage_meta={}),n.__jstorage_meta.TTL||(n.__jstorage_meta.TTL={}),t>0?n.__jstorage_meta.TTL[e]=r+t:delete n.__jstorage_meta.TTL[e],h(),u(),!0):!1},getTTL:function(e){var t=+new Date,r;return _(e),n.hasOwnProperty(e)&&n.__jstorage_meta.TTL&&n.__jstorage_meta.TTL[e]?(r=n.__jstorage_meta.TTL[e]-t,r||0):0},flush:function(){return n={},h(),!0},storageObj:function(){return e.extend(!0,{},n)},index:function(){var t=[];return e.each(n,function(e,n){"__jstorage_meta"!==e&&t.push(e)}),t},storageSize:function(){return i},currentBackend:function(){return d},storageAvailable:function(){return!!d}},g()}(jQuery),e.jstree.defaults.types={"#":{},"default":{}},e.jstree.plugins.types=function(n,r){this.init=function(e,t){r.init.call(this,e,t),this._model.data["#"].type="#"},this.bind=function(){r.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){var n=this._model.data,r=t.nodes,a=this.settings.types,i,s,o="default";for(i=0,s=r.length;s>i;i++)o="default",n[r[i]].original&&n[r[i]].original.type&&a[n[r[i]].original.type]&&(o=n[r[i]].original.type),n[r[i]].data&&n[r[i]].data.jstree&&n[r[i]].data.jstree.type&&a[n[r[i]].data.jstree.type]&&(o=n[r[i]].data.jstree.type),n[r[i]].type=o,n[r[i]].icon===!0&&a[o].icon&&(n[r[i]].icon=a[o].icon)},this))},this.check=function(n,a,i,s){if(r.check.call(this,n,a,i,s)===!1)return!1;a=a&&a.id?a:this.get_node(a),i=i&&i.id?i:this.get_node(i);var o=this._model.data,d,l,c,h;switch(n){case"create_node":case"move_node":case"copy_node":if("move_node"!==n||-1===e.inArray(a.id,i.children)){if(d=this.get_rules(i),d.max_children!==t&&-1!==d.max_children&&d.max_children===i.children.length)return!1;if(d.valid_children!==t&&-1!==d.valid_children&&-1===e.inArray(a.type,d.valid_children))return!1;if(a.children_d&&a.parents){for(l=0,c=0,h=a.children_d.length;h>c;c++)l=Math.max(l,o[a.children_d[c]].parents.length);l=l-a.parents.length+1}0>=l&&(l=1);do{if(d.max_depth!==t&&-1!==d.max_depth&&l>d.max_depth)return!1;i=this.get_node(i.parent),d=this.get_rules(i),l++}while(i)}}return!0},this.get_rules=function(e){if(e=this.get_node(e),!e)return!1;var n=this.get_type(e,!0);return n.max_depth===t&&(n.max_depth=-1),n.max_children===t&&(n.max_children=-1),n.valid_children===t&&(n.valid_children=-1),n},this.get_type=function(t,n){return t=this.get_node(t),t?n?e.extend({type:t.type},this.settings.types[t.type]):t.type:!1},this.set_type=function(t,n){var r,a,i;if(e.isArray(t)){for(a=0,i=t.length;i>a;a++)this.set_type(t[a],n);return!0}return r=this.settings.types,t=this.get_node(t),r[n]&&t?(t.type=n,r[n].icon&&this.get_icon(t)===!0&&this.set_icon(t,r[n].icon),!0):!1}},e.jstree.plugins.unique=function(t,n){this.check=function(t,r,a,i){if(n.check.call(this,t,r,a,i)===!1)return!1;if(r=r&&r.id?r:this.get_node(r),a=a&&a.id?a:this.get_node(a),!a||!a.children)return!0;var s="rename_node"===t?i:r.text,o=[],d=this._model.data,l,c;for(l=0,c=a.children.length;c>l;l++)o.push(d[a.children[l]].text);switch(t){case"delete_node":return!0;case"rename_node":case"copy_node":return-1===e.inArray(s,o);case"move_node":return r.parent===a.id||-1===e.inArray(s,o)}return!0}};var f=document.createElement("DIV");f.setAttribute("unselectable","on"),f.className="jstree-wholerow",f.innerHTML=" ",e.jstree.plugins.wholerow=function(t,n){this.bind=function(){n.bind.call(this),this.element.on("loading",e.proxy(function(){f.style.height=this._data.core.li_height+"px"},this)).on("ready.jstree set_state.jstree",e.proxy(function(){this.hide_dots()},this)).on("ready.jstree",e.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var n=!1,r,a;for(r=0,a=t.selected.length;a>r;r++)n=this.get_node(t.selected[r],!0),n&&n.length&&n.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",e.proxy(function(e,t){this.get_node(t.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",e.proxy(function(t,n){this.element.find(".jstree-wholerow-hovered").removeClass("jstree-wholerow-hovered"),"hover_node"===t.type&&this.get_node(n.node,!0).each(function(){e(this).children(".jstree-wholerow").addClass("jstree-wholerow-hovered")})},this)).on("contextmenu.jstree",".jstree-wholerow",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).closest("li").children("a:eq(0)").trigger("contextmenu",t)},this)).on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",e.proxy(function(t){t.stopImmediatePropagation();var n=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(n).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",e.proxy(function(e){return e.stopImmediatePropagation(),this.hover_node(e.currentTarget),!1},this)).on("mouseleave.jstree","li",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&(this.element.find(".jstree-wholerow").remove(),n.teardown.call(this))},this.redraw_node=function(t,r,a){if(t=n.redraw_node.call(this,t,r,a)){var i=f.cloneNode(!0);-1!==e.inArray(t.id,this._data.core.selected)&&(i.className+=" jstree-wholerow-clicked"),t.insertBefore(i,t.childNodes[0])}return t}}}}); \ No newline at end of file diff --git a/docs/assets/dist/libs/jquery.js b/docs/assets/dist/libs/jquery.js new file mode 100644 index 00000000..8569bc49 --- /dev/null +++ b/docs/assets/dist/libs/jquery.js @@ -0,0 +1,4 @@ +/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license*/ +(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="
          ",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="
          ","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
          a",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="
          t
          ",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
          ",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t +}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
          ","
          "],area:[1,"",""],param:[1,"",""],thead:[1,"","
          "],tr:[2,"","
          "],col:[2,"","
          "],td:[3,"","
          "],_default:x.support.htmlSerialize?[0,"",""]:[1,"X
          ","
          "]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle); +u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("