home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / vlc-2-0-5-win32.exe / lua / http / js / jquery.jstree.js < prev    next >
Text File  |  2012-12-12  |  180KB  |  4,544 lines

  1. /*
  2.  * jsTree 1.0-rc3
  3.  * http://jstree.com/
  4.  *
  5.  * Copyright (c) 2010 Ivan Bozhanov (vakata.com)
  6.  *
  7.  * Licensed same as jquery - under the terms of either the MIT License or the GPL Version 2 License
  8.  *   http://www.opensource.org/licenses/mit-license.php
  9.  *   http://www.gnu.org/licenses/gpl.html
  10.  *
  11.  * $Date: 2011-02-09 01:17:14 +0200 (╤ü╤Ç, 09 ╤ä╨╡╨▓╤Ç 2011) $
  12.  * $Revision: 236 $
  13.  */
  14.  
  15. /*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */
  16. /*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
  17.  
  18. "use strict";
  19.  
  20. // top wrapper to prevent multiple inclusion (is this OK?)
  21. (function () { if(jQuery && jQuery.jstree) { return; }
  22.     var is_ie6 = false, is_ie7 = false, is_ff2 = false;
  23.  
  24. /* 
  25.  * jsTree core
  26.  */
  27. (function ($) {
  28.     // Common functions not related to jsTree 
  29.     // decided to move them to a `vakata` "namespace"
  30.     $.vakata = {};
  31.     // CSS related functions
  32.     $.vakata.css = {
  33.         get_css : function(rule_name, delete_flag, sheet) {
  34.             rule_name = rule_name.toLowerCase();
  35.             var css_rules = sheet.cssRules || sheet.rules,
  36.                 j = 0;
  37.             do {
  38.                 if(css_rules.length && j > css_rules.length + 5) { return false; }
  39.                 if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) {
  40.                     if(delete_flag === true) {
  41.                         if(sheet.removeRule) { sheet.removeRule(j); }
  42.                         if(sheet.deleteRule) { sheet.deleteRule(j); }
  43.                         return true;
  44.                     }
  45.                     else { return css_rules[j]; }
  46.                 }
  47.             }
  48.             while (css_rules[++j]);
  49.             return false;
  50.         },
  51.         add_css : function(rule_name, sheet) {
  52.             if($.jstree.css.get_css(rule_name, false, sheet)) { return false; }
  53.             if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
  54.             return $.vakata.css.get_css(rule_name);
  55.         },
  56.         remove_css : function(rule_name, sheet) { 
  57.             return $.vakata.css.get_css(rule_name, true, sheet); 
  58.         },
  59.         add_sheet : function(opts) {
  60.             var tmp = false, is_new = true;
  61.             if(opts.str) {
  62.                 if(opts.title) { tmp = $("style[id='" + opts.title + "-stylesheet']")[0]; }
  63.                 if(tmp) { is_new = false; }
  64.                 else {
  65.                     tmp = document.createElement("style");
  66.                     tmp.setAttribute('type',"text/css");
  67.                     if(opts.title) { tmp.setAttribute("id", opts.title + "-stylesheet"); }
  68.                 }
  69.                 if(tmp.styleSheet) {
  70.                     if(is_new) { 
  71.                         document.getElementsByTagName("head")[0].appendChild(tmp); 
  72.                         tmp.styleSheet.cssText = opts.str; 
  73.                     }
  74.                     else {
  75.                         tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str; 
  76.                     }
  77.                 }
  78.                 else {
  79.                     tmp.appendChild(document.createTextNode(opts.str));
  80.                     document.getElementsByTagName("head")[0].appendChild(tmp);
  81.                 }
  82.                 return tmp.sheet || tmp.styleSheet;
  83.             }
  84.             if(opts.url) {
  85.                 if(document.createStyleSheet) {
  86.                     try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
  87.                 }
  88.                 else {
  89.                     tmp            = document.createElement('link');
  90.                     tmp.rel        = 'stylesheet';
  91.                     tmp.type    = 'text/css';
  92.                     tmp.media    = "all";
  93.                     tmp.href    = opts.url;
  94.                     document.getElementsByTagName("head")[0].appendChild(tmp);
  95.                     return tmp.styleSheet;
  96.                 }
  97.             }
  98.         }
  99.     };
  100.  
  101.     // private variables 
  102.     var instances = [],            // instance array (used by $.jstree.reference/create/focused)
  103.         focused_instance = -1,    // the index in the instance array of the currently focused instance
  104.         plugins = {},            // list of included plugins
  105.         prepared_move = {};        // for the move_node function
  106.  
  107.     // jQuery plugin wrapper (thanks to jquery UI widget function)
  108.     $.fn.jstree = function (settings) {
  109.         var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
  110.             args = Array.prototype.slice.call(arguments, 1), 
  111.             returnValue = this;
  112.  
  113.         // if a method call execute the method on all selected instances
  114.         if(isMethodCall) {
  115.             if(settings.substring(0, 1) == '_') { return returnValue; }
  116.             this.each(function() {
  117.                 var instance = instances[$.data(this, "jstree-instance-id")],
  118.                     methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance;
  119.                     if(typeof methodValue !== "undefined" && (settings.indexOf("is_") === 0 || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; }
  120.             });
  121.         }
  122.         else {
  123.             this.each(function() {
  124.                 // extend settings and allow for multiple hashes and $.data
  125.                 var instance_id = $.data(this, "jstree-instance-id"),
  126.                     a = [],
  127.                     b = settings ? $.extend({}, true, settings) : {},
  128.                     c = $(this), 
  129.                     s = false, 
  130.                     t = [];
  131.                 a = a.concat(args);
  132.                 if(c.data("jstree")) { a.push(c.data("jstree")); }
  133.                 b = a.length ? $.extend.apply(null, [true, b].concat(a)) : b;
  134.  
  135.                 // if an instance already exists, destroy it first
  136.                 if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); }
  137.                 // push a new empty object to the instances array
  138.                 instance_id = parseInt(instances.push({}),10) - 1;
  139.                 // store the jstree instance id to the container element
  140.                 $.data(this, "jstree-instance-id", instance_id);
  141.                 // clean up all plugins
  142.                 b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice();
  143.                 b.plugins.unshift("core");
  144.                 // only unique plugins
  145.                 b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
  146.  
  147.                 // extend defaults with passed data
  148.                 s = $.extend(true, {}, $.jstree.defaults, b);
  149.                 s.plugins = b.plugins;
  150.                 $.each(plugins, function (i, val) { 
  151.                     if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; } 
  152.                     else { t.push(i); }
  153.                 });
  154.                 s.plugins = t;
  155.  
  156.                 // push the new object to the instances array (at the same time set the default classes to the container) and init
  157.                 instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s); 
  158.                 // init all activated plugins for this instance
  159.                 $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
  160.                 $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
  161.                 // initialize the instance
  162.                 setTimeout(function() { instances[instance_id].init(); }, 0);
  163.             });
  164.         }
  165.         // return the jquery selection (or if it was a method call that returned a value - the returned value)
  166.         return returnValue;
  167.     };
  168.     // object to store exposed functions and objects
  169.     $.jstree = {
  170.         defaults : {
  171.             plugins : []
  172.         },
  173.         _focused : function () { return instances[focused_instance] || null; },
  174.         _reference : function (needle) { 
  175.             // get by instance id
  176.             if(instances[needle]) { return instances[needle]; }
  177.             // get by DOM (if still no luck - return null
  178.             var o = $(needle); 
  179.             if(!o.length && typeof needle === "string") { o = $("#" + needle); }
  180.             if(!o.length) { return null; }
  181.             return instances[o.closest(".jstree").data("jstree-instance-id")] || null; 
  182.         },
  183.         _instance : function (index, container, settings) { 
  184.             // for plugins to store data in
  185.             this.data = { core : {} };
  186.             this.get_settings    = function () { return $.extend(true, {}, settings); };
  187.             this._get_settings    = function () { return settings; };
  188.             this.get_index        = function () { return index; };
  189.             this.get_container    = function () { return container; };
  190.             this.get_container_ul = function () { return container.children("ul:eq(0)"); };
  191.             this._set_settings    = function (s) { 
  192.                 settings = $.extend(true, {}, settings, s);
  193.             };
  194.         },
  195.         _fn : { },
  196.         plugin : function (pname, pdata) {
  197.             pdata = $.extend({}, {
  198.                 __init        : $.noop, 
  199.                 __destroy    : $.noop,
  200.                 _fn            : {},
  201.                 defaults    : false
  202.             }, pdata);
  203.             plugins[pname] = pdata;
  204.  
  205.             $.jstree.defaults[pname] = pdata.defaults;
  206.             $.each(pdata._fn, function (i, val) {
  207.                 val.plugin        = pname;
  208.                 val.old            = $.jstree._fn[i];
  209.                 $.jstree._fn[i] = function () {
  210.                     var rslt,
  211.                         func = val,
  212.                         args = Array.prototype.slice.call(arguments),
  213.                         evnt = new $.Event("before.jstree"),
  214.                         rlbk = false;
  215.  
  216.                     if(this.data.core.locked === true && i !== "unlock" && i !== "is_locked") { return; }
  217.  
  218.                     // Check if function belongs to the included plugins of this instance
  219.                     do {
  220.                         if(func && func.plugin && $.inArray(func.plugin, this._get_settings().plugins) !== -1) { break; }
  221.                         func = func.old;
  222.                     } while(func);
  223.                     if(!func) { return; }
  224.  
  225.                     // context and function to trigger events, then finally call the function
  226.                     if(i.indexOf("_") === 0) {
  227.                         rslt = func.apply(this, args);
  228.                     }
  229.                     else {
  230.                         rslt = this.get_container().triggerHandler(evnt, { "func" : i, "inst" : this, "args" : args, "plugin" : func.plugin });
  231.                         if(rslt === false) { return; }
  232.                         if(typeof rslt !== "undefined") { args = rslt; }
  233.  
  234.                         rslt = func.apply(
  235.                             $.extend({}, this, { 
  236.                                 __callback : function (data) { 
  237.                                     this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
  238.                                 },
  239.                                 __rollback : function () { 
  240.                                     rlbk = this.get_rollback();
  241.                                     return rlbk;
  242.                                 },
  243.                                 __call_old : function (replace_arguments) {
  244.                                     return func.old.apply(this, (replace_arguments ? Array.prototype.slice.call(arguments, 1) : args ) );
  245.                                 }
  246.                             }), args);
  247.                     }
  248.  
  249.                     // return the result
  250.                     return rslt;
  251.                 };
  252.                 $.jstree._fn[i].old = val.old;
  253.                 $.jstree._fn[i].plugin = pname;
  254.             });
  255.         },
  256.         rollback : function (rb) {
  257.             if(rb) {
  258.                 if(!$.isArray(rb)) { rb = [ rb ]; }
  259.                 $.each(rb, function (i, val) {
  260.                     instances[val.i].set_rollback(val.h, val.d);
  261.                 });
  262.             }
  263.         }
  264.     };
  265.     // set the prototype for all instances
  266.     $.jstree._fn = $.jstree._instance.prototype = {};
  267.  
  268.     // load the css when DOM is ready
  269.     $(function() {
  270.         // code is copied from jQuery ($.browser is deprecated + there is a bug in IE)
  271.         var u = navigator.userAgent.toLowerCase(),
  272.             v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
  273.             css_string = '' + 
  274.                 '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' + 
  275.                 '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } ' + 
  276.                 '.jstree-rtl li { margin-left:0; margin-right:18px; } ' + 
  277.                 '.jstree > ul > li { margin-left:0px; } ' + 
  278.                 '.jstree-rtl > ul > li { margin-right:0px; } ' + 
  279.                 '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' + 
  280.                 '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' + 
  281.                 '.jstree a:focus { outline: none; } ' + 
  282.                 '.jstree a > ins { height:16px; width:16px; } ' + 
  283.                 '.jstree a > .jstree-icon { margin-right:3px; } ' + 
  284.                 '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' + 
  285.                 'li.jstree-open > ul { display:block; } ' + 
  286.                 'li.jstree-closed > ul { display:none; } ';
  287.         // Correct IE 6 (does not support the > CSS selector)
  288.         if(/msie/.test(u) && parseInt(v, 10) == 6) { 
  289.             is_ie6 = true;
  290.  
  291.             // fix image flicker and lack of caching
  292.             try {
  293.                 document.execCommand("BackgroundImageCache", false, true);
  294.             } catch (err) { }
  295.  
  296.             css_string += '' + 
  297.                 '.jstree li { height:18px; margin-left:0; margin-right:0; } ' + 
  298.                 '.jstree li li { margin-left:18px; } ' + 
  299.                 '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' + 
  300.                 'li.jstree-open ul { display:block; } ' + 
  301.                 'li.jstree-closed ul { display:none !important; } ' + 
  302.                 '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' + 
  303.                 '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' + 
  304.                 '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
  305.         }
  306.         // Correct IE 7 (shifts anchor nodes onhover)
  307.         if(/msie/.test(u) && parseInt(v, 10) == 7) { 
  308.             is_ie7 = true;
  309.             css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
  310.         }
  311.         // correct ff2 lack of display:inline-block
  312.         if(!/compatible/.test(u) && /mozilla/.test(u) && parseFloat(v, 10) < 1.9) {
  313.             is_ff2 = true;
  314.             css_string += '' + 
  315.                 '.jstree ins { display:-moz-inline-box; } ' + 
  316.                 '.jstree li { line-height:12px; } ' + // WHY??
  317.                 '.jstree a { display:-moz-inline-box; } ' + 
  318.                 '.jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } ';
  319.                 /* this shouldn't be here as it is theme specific */
  320.         }
  321.         // the default stylesheet
  322.         $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
  323.     });
  324.  
  325.     // core functions (open, close, create, update, delete)
  326.     $.jstree.plugin("core", {
  327.         __init : function () {
  328.             this.data.core.locked = false;
  329.             this.data.core.to_open = this.get_settings().core.initially_open;
  330.             this.data.core.to_load = this.get_settings().core.initially_load;
  331.         },
  332.         defaults : { 
  333.             html_titles    : false,
  334.             animation    : 500,
  335.             initially_open : [],
  336.             initially_load : [],
  337.             open_parents : true,
  338.             notify_plugins : true,
  339.             rtl            : false,
  340.             load_open    : false,
  341.             strings        : {
  342.                 loading        : "Loading ...",
  343.                 new_node    : "New node",
  344.                 multiple_selection : "Multiple selection"
  345.             }
  346.         },
  347.         _fn : { 
  348.             init    : function () { 
  349.                 this.set_focus(); 
  350.                 if(this._get_settings().core.rtl) {
  351.                     this.get_container().addClass("jstree-rtl").css("direction", "rtl");
  352.                 }
  353.                 this.get_container().html("<ul><li class='jstree-last jstree-leaf'><ins> </ins><a class='jstree-loading' href='#'><ins class='jstree-icon'> </ins>" + this._get_string("loading") + "</a></li></ul>");
  354.                 this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;
  355.  
  356.                 this.get_container()
  357.                     .delegate("li > ins", "click.jstree", $.proxy(function (event) {
  358.                             var trgt = $(event.target);
  359.                             if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
  360.                         }, this))
  361.                     .bind("mousedown.jstree", $.proxy(function () { 
  362.                             this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
  363.                         }, this))
  364.                     .bind("dblclick.jstree", function (event) { 
  365.                         var sel;
  366.                         if(document.selection && document.selection.empty) { document.selection.empty(); }
  367.                         else {
  368.                             if(window.getSelection) {
  369.                                 sel = window.getSelection();
  370.                                 try { 
  371.                                     sel.removeAllRanges();
  372.                                     sel.collapse();
  373.                                 } catch (err) { }
  374.                             }
  375.                         }
  376.                     });
  377.                 if(this._get_settings().core.notify_plugins) {
  378.                     this.get_container()
  379.                         .bind("load_node.jstree", $.proxy(function (e, data) { 
  380.                                 var o = this._get_node(data.rslt.obj),
  381.                                     t = this;
  382.                                 if(o === -1) { o = this.get_container_ul(); }
  383.                                 if(!o.length) { return; }
  384.                                 o.find("li").each(function () {
  385.                                     var th = $(this);
  386.                                     if(th.data("jstree")) {
  387.                                         $.each(th.data("jstree"), function (plugin, values) {
  388.                                             if(t.data[plugin] && $.isFunction(t["_" + plugin + "_notify"])) {
  389.                                                 t["_" + plugin + "_notify"].call(t, th, values);
  390.                                             }
  391.                                         });
  392.                                     }
  393.                                 });
  394.                             }, this));
  395.                 }
  396.                 if(this._get_settings().core.load_open) {
  397.                     this.get_container()
  398.                         .bind("load_node.jstree", $.proxy(function (e, data) { 
  399.                                 var o = this._get_node(data.rslt.obj),
  400.                                     t = this;
  401.                                 if(o === -1) { o = this.get_container_ul(); }
  402.                                 if(!o.length) { return; }
  403.                                 o.find("li.jstree-open:not(:has(ul))").each(function () {
  404.                                     t.load_node(this, $.noop, $.noop);
  405.                                 });
  406.                             }, this));
  407.                 }
  408.                 this.__callback();
  409.                 this.load_node(-1, function () { this.loaded(); this.reload_nodes(); });
  410.             },
  411.             destroy    : function () { 
  412.                 var i,
  413.                     n = this.get_index(),
  414.                     s = this._get_settings(),
  415.                     _this = this;
  416.  
  417.                 $.each(s.plugins, function (i, val) {
  418.                     try { plugins[val].__destroy.apply(_this); } catch(err) { }
  419.                 });
  420.                 this.__callback();
  421.                 // set focus to another instance if this one is focused
  422.                 if(this.is_focused()) { 
  423.                     for(i in instances) { 
  424.                         if(instances.hasOwnProperty(i) && i != n) { 
  425.                             instances[i].set_focus(); 
  426.                             break; 
  427.                         } 
  428.                     }
  429.                 }
  430.                 // if no other instance found
  431.                 if(n === focused_instance) { focused_instance = -1; }
  432.                 // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
  433.                 this.get_container()
  434.                     .unbind(".jstree")
  435.                     .undelegate(".jstree")
  436.                     .removeData("jstree-instance-id")
  437.                     .find("[class^='jstree']")
  438.                         .andSelf()
  439.                         .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
  440.                 $(document)
  441.                     .unbind(".jstree-" + n)
  442.                     .undelegate(".jstree-" + n);
  443.                 // remove the actual data
  444.                 instances[n] = null;
  445.                 delete instances[n];
  446.             },
  447.  
  448.             _core_notify : function (n, data) {
  449.                 if(data.opened) {
  450.                     this.open_node(n, false, true);
  451.                 }
  452.             },
  453.  
  454.             lock : function () {
  455.                 this.data.core.locked = true;
  456.                 this.get_container().children("ul").addClass("jstree-locked").css("opacity","0.7");
  457.                 this.__callback({});
  458.             },
  459.             unlock : function () {
  460.                 this.data.core.locked = false;
  461.                 this.get_container().children("ul").removeClass("jstree-locked").css("opacity","1");
  462.                 this.__callback({});
  463.             },
  464.             is_locked : function () { return this.data.core.locked; },
  465.             save_opened : function () {
  466.                 var _this = this;
  467.                 this.data.core.to_open = [];
  468.                 this.get_container_ul().find("li.jstree-open").each(function () { 
  469.                     if(this.id) { _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")); }
  470.                 });
  471.                 this.__callback(_this.data.core.to_open);
  472.             },
  473.             save_loaded : function () { },
  474.             reload_nodes : function (is_callback) {
  475.                 var _this = this,
  476.                     done = true,
  477.                     current = [],
  478.                     remaining = [];
  479.                 if(!is_callback) { 
  480.                     this.data.core.reopen = false; 
  481.                     this.data.core.refreshing = true; 
  482.                     this.data.core.to_open = $.map($.makeArray(this.data.core.to_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
  483.                     this.data.core.to_load = $.map($.makeArray(this.data.core.to_load), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
  484.                     if(this.data.core.to_open.length) {
  485.                         this.data.core.to_load = this.data.core.to_load.concat(this.data.core.to_open);
  486.                     }
  487.                 }
  488.                 if(this.data.core.to_load.length) {
  489.                     $.each(this.data.core.to_load, function (i, val) {
  490.                         if(val == "#") { return true; }
  491.                         if($(val).length) { current.push(val); }
  492.                         else { remaining.push(val); }
  493.                     });
  494.                     if(current.length) {
  495.                         this.data.core.to_load = remaining;
  496.                         $.each(current, function (i, val) { 
  497.                             if(!_this._is_loaded(val)) {
  498.                                 _this.load_node(val, function () { _this.reload_nodes(true); }, function () { _this.reload_nodes(true); });
  499.                                 done = false;
  500.                             }
  501.                         });
  502.                     }
  503.                 }
  504.                 if(this.data.core.to_open.length) {
  505.                     $.each(this.data.core.to_open, function (i, val) {
  506.                         _this.open_node(val, false, true); 
  507.                     });
  508.                 }
  509.                 if(done) { 
  510.                     // TODO: find a more elegant approach to syncronizing returning requests
  511.                     if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
  512.                     this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
  513.                     this.data.core.refreshing = false;
  514.                     this.reopen();
  515.                 }
  516.             },
  517.             reopen : function () {
  518.                 var _this = this;
  519.                 if(this.data.core.to_open.length) {
  520.                     $.each(this.data.core.to_open, function (i, val) {
  521.                         _this.open_node(val, false, true); 
  522.                     });
  523.                 }
  524.                 this.__callback({});
  525.             },
  526.             refresh : function (obj) {
  527.                 var _this = this;
  528.                 this.save_opened();
  529.                 if(!obj) { obj = -1; }
  530.                 obj = this._get_node(obj);
  531.                 if(!obj) { obj = -1; }
  532.                 if(obj !== -1) { obj.children("UL").remove(); }
  533.                 else { this.get_container_ul().empty(); }
  534.                 this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reload_nodes(); });
  535.             },
  536.             // Dummy function to fire after the first load (so that there is a jstree.loaded event)
  537.             loaded    : function () { 
  538.                 this.__callback(); 
  539.             },
  540.             // deal with focus
  541.             set_focus    : function () { 
  542.                 if(this.is_focused()) { return; }
  543.                 var f = $.jstree._focused();
  544.                 if(f) { f.unset_focus(); }
  545.  
  546.                 this.get_container().addClass("jstree-focused"); 
  547.                 focused_instance = this.get_index(); 
  548.                 this.__callback();
  549.             },
  550.             is_focused    : function () { 
  551.                 return focused_instance == this.get_index(); 
  552.             },
  553.             unset_focus    : function () {
  554.                 if(this.is_focused()) {
  555.                     this.get_container().removeClass("jstree-focused"); 
  556.                     focused_instance = -1; 
  557.                 }
  558.                 this.__callback();
  559.             },
  560.  
  561.             // traverse
  562.             _get_node        : function (obj) { 
  563.                 var $obj = $(obj, this.get_container()); 
  564.                 if($obj.is(".jstree") || obj == -1) { return -1; } 
  565.                 $obj = $obj.closest("li", this.get_container()); 
  566.                 return $obj.length ? $obj : false; 
  567.             },
  568.             _get_next        : function (obj, strict) {
  569.                 obj = this._get_node(obj);
  570.                 if(obj === -1) { return this.get_container().find("> ul > li:first-child"); }
  571.                 if(!obj.length) { return false; }
  572.                 if(strict) { return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; }
  573.  
  574.                 if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); }
  575.                 else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); }
  576.                 else { return obj.parentsUntil(".jstree","li").next("li").eq(0); }
  577.             },
  578.             _get_prev        : function (obj, strict) {
  579.                 obj = this._get_node(obj);
  580.                 if(obj === -1) { return this.get_container().find("> ul > li:last-child"); }
  581.                 if(!obj.length) { return false; }
  582.                 if(strict) { return (obj.prevAll("li").length > 0) ? obj.prevAll("li:eq(0)") : false; }
  583.  
  584.                 if(obj.prev("li").length) {
  585.                     obj = obj.prev("li").eq(0);
  586.                     while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); }
  587.                     return obj;
  588.                 }
  589.                 else { var o = obj.parentsUntil(".jstree","li:eq(0)"); return o.length ? o : false; }
  590.             },
  591.             _get_parent        : function (obj) {
  592.                 obj = this._get_node(obj);
  593.                 if(obj == -1 || !obj.length) { return false; }
  594.                 var o = obj.parentsUntil(".jstree", "li:eq(0)");
  595.                 return o.length ? o : -1;
  596.             },
  597.             _get_children    : function (obj) {
  598.                 obj = this._get_node(obj);
  599.                 if(obj === -1) { return this.get_container().children("ul:eq(0)").children("li"); }
  600.                 if(!obj.length) { return false; }
  601.                 return obj.children("ul:eq(0)").children("li");
  602.             },
  603.             get_path        : function (obj, id_mode) {
  604.                 var p = [],
  605.                     _this = this;
  606.                 obj = this._get_node(obj);
  607.                 if(obj === -1 || !obj || !obj.length) { return false; }
  608.                 obj.parentsUntil(".jstree", "li").each(function () {
  609.                     p.push( id_mode ? this.id : _this.get_text(this) );
  610.                 });
  611.                 p.reverse();
  612.                 p.push( id_mode ? obj.attr("id") : this.get_text(obj) );
  613.                 return p;
  614.             },
  615.  
  616.             // string functions
  617.             _get_string : function (key) {
  618.                 return this._get_settings().core.strings[key] || key;
  619.             },
  620.  
  621.             is_open        : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-open"); },
  622.             is_closed    : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-closed"); },
  623.             is_leaf        : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-leaf"); },
  624.             correct_state    : function (obj) {
  625.                 obj = this._get_node(obj);
  626.                 if(!obj || obj === -1) { return false; }
  627.                 obj.removeClass("jstree-closed jstree-open").addClass("jstree-leaf").children("ul").remove();
  628.                 this.__callback({ "obj" : obj });
  629.             },
  630.             // open/close
  631.             open_node    : function (obj, callback, skip_animation) {
  632.                 obj = this._get_node(obj);
  633.                 if(!obj.length) { return false; }
  634.                 if(!obj.hasClass("jstree-closed")) { if(callback) { callback.call(); } return false; }
  635.                 var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
  636.                     t = this;
  637.                 if(!this._is_loaded(obj)) {
  638.                     obj.children("a").addClass("jstree-loading");
  639.                     this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
  640.                 }
  641.                 else {
  642.                     if(this._get_settings().core.open_parents) {
  643.                         obj.parentsUntil(".jstree",".jstree-closed").each(function () {
  644.                             t.open_node(this, false, true);
  645.                         });
  646.                     }
  647.                     if(s) { obj.children("ul").css("display","none"); }
  648.                     obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");
  649.                     if(s) { obj.children("ul").stop(true, true).slideDown(s, function () { this.style.display = ""; t.after_open(obj); }); }
  650.                     else { t.after_open(obj); }
  651.                     this.__callback({ "obj" : obj });
  652.                     if(callback) { callback.call(); }
  653.                 }
  654.             },
  655.             after_open    : function (obj) { this.__callback({ "obj" : obj }); },
  656.             close_node    : function (obj, skip_animation) {
  657.                 obj = this._get_node(obj);
  658.                 var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
  659.                     t = this;
  660.                 if(!obj.length || !obj.hasClass("jstree-open")) { return false; }
  661.                 if(s) { obj.children("ul").attr("style","display:block !important"); }
  662.                 obj.removeClass("jstree-open").addClass("jstree-closed");
  663.                 if(s) { obj.children("ul").stop(true, true).slideUp(s, function () { this.style.display = ""; t.after_close(obj); }); }
  664.                 else { t.after_close(obj); }
  665.                 this.__callback({ "obj" : obj });
  666.             },
  667.             after_close    : function (obj) { this.__callback({ "obj" : obj }); },
  668.             toggle_node    : function (obj) {
  669.                 obj = this._get_node(obj);
  670.                 if(obj.hasClass("jstree-closed")) { return this.open_node(obj); }
  671.                 if(obj.hasClass("jstree-open")) { return this.close_node(obj); }
  672.             },
  673.             open_all    : function (obj, do_animation, original_obj) {
  674.                 obj = obj ? this._get_node(obj) : -1;
  675.                 if(!obj || obj === -1) { obj = this.get_container_ul(); }
  676.                 if(original_obj) { 
  677.                     obj = obj.find("li.jstree-closed");
  678.                 }
  679.                 else {
  680.                     original_obj = obj;
  681.                     if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
  682.                     else { obj = obj.find("li.jstree-closed"); }
  683.                 }
  684.                 var _this = this;
  685.                 obj.each(function () { 
  686.                     var __this = this; 
  687.                     if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, do_animation, original_obj); }, !do_animation); }
  688.                     else { _this.open_node(this, false, !do_animation); }
  689.                 });
  690.                 // so that callback is fired AFTER all nodes are open
  691.                 if(original_obj.find('li.jstree-closed').length === 0) { this.__callback({ "obj" : original_obj }); }
  692.             },
  693.             close_all    : function (obj, do_animation) {
  694.                 var _this = this;
  695.                 obj = obj ? this._get_node(obj) : this.get_container();
  696.                 if(!obj || obj === -1) { obj = this.get_container_ul(); }
  697.                 obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this, !do_animation); });
  698.                 this.__callback({ "obj" : obj });
  699.             },
  700.             clean_node    : function (obj) {
  701.                 obj = obj && obj != -1 ? $(obj) : this.get_container_ul();
  702.                 obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
  703.                 obj.removeClass("jstree-last")
  704.                     .filter("li:last-child").addClass("jstree-last").end()
  705.                     .filter(":has(li)")
  706.                         .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
  707.                 obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();
  708.                 this.__callback({ "obj" : obj });
  709.             },
  710.             // rollback
  711.             get_rollback : function () { 
  712.                 this.__callback();
  713.                 return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data }; 
  714.             },
  715.             set_rollback : function (html, data) {
  716.                 this.get_container().empty().append(html);
  717.                 this.data = data;
  718.                 this.__callback();
  719.             },
  720.             // Dummy functions to be overwritten by any datastore plugin included
  721.             load_node    : function (obj, s_call, e_call) { this.__callback({ "obj" : obj }); },
  722.             _is_loaded    : function (obj) { return true; },
  723.  
  724.             // Basic operations: create
  725.             create_node    : function (obj, position, js, callback, is_loaded) {
  726.                 obj = this._get_node(obj);
  727.                 position = typeof position === "undefined" ? "last" : position;
  728.                 var d = $("<li />"),
  729.                     s = this._get_settings().core,
  730.                     tmp;
  731.  
  732.                 if(obj !== -1 && !obj.length) { return false; }
  733.                 if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
  734.  
  735.                 this.__rollback();
  736.  
  737.                 if(typeof js === "string") { js = { "data" : js }; }
  738.                 if(!js) { js = {}; }
  739.                 if(js.attr) { d.attr(js.attr); }
  740.                 if(js.metadata) { d.data(js.metadata); }
  741.                 if(js.state) { d.addClass("jstree-" + js.state); }
  742.                 if(!js.data) { js.data = this._get_string("new_node"); }
  743.                 if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
  744.                 $.each(js.data, function (i, m) {
  745.                     tmp = $("<a />");
  746.                     if($.isFunction(m)) { m = m.call(this, js); }
  747.                     if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
  748.                     else {
  749.                         if(!m.attr) { m.attr = {}; }
  750.                         if(!m.attr.href) { m.attr.href = '#'; }
  751.                         tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
  752.                         if(m.language) { tmp.addClass(m.language); }
  753.                     }
  754.                     tmp.prepend("<ins class='jstree-icon'> </ins>");
  755.                     if(m.icon) { 
  756.                         if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
  757.                         else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
  758.                     }
  759.                     d.append(tmp);
  760.                 });
  761.                 d.prepend("<ins class='jstree-icon'> </ins>");
  762.                 if(obj === -1) {
  763.                     obj = this.get_container();
  764.                     if(position === "before") { position = "first"; }
  765.                     if(position === "after") { position = "last"; }
  766.                 }
  767.                 switch(position) {
  768.                     case "before": obj.before(d); tmp = this._get_parent(obj); break;
  769.                     case "after" : obj.after(d);  tmp = this._get_parent(obj); break;
  770.                     case "inside":
  771.                     case "first" :
  772.                         if(!obj.children("ul").length) { obj.append("<ul />"); }
  773.                         obj.children("ul").prepend(d);
  774.                         tmp = obj;
  775.                         break;
  776.                     case "last":
  777.                         if(!obj.children("ul").length) { obj.append("<ul />"); }
  778.                         obj.children("ul").append(d);
  779.                         tmp = obj;
  780.                         break;
  781.                     default:
  782.                         if(!obj.children("ul").length) { obj.append("<ul />"); }
  783.                         if(!position) { position = 0; }
  784.                         tmp = obj.children("ul").children("li").eq(position);
  785.                         if(tmp.length) { tmp.before(d); }
  786.                         else { obj.children("ul").append(d); }
  787.                         tmp = obj;
  788.                         break;
  789.                 }
  790.                 if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
  791.                 this.clean_node(tmp);
  792.                 this.__callback({ "obj" : d, "parent" : tmp });
  793.                 if(callback) { callback.call(this, d); }
  794.                 return d;
  795.             },
  796.             // Basic operations: rename (deal with text)
  797.             get_text    : function (obj) {
  798.                 obj = this._get_node(obj);
  799.                 if(!obj.length) { return false; }
  800.                 var s = this._get_settings().core.html_titles;
  801.                 obj = obj.children("a:eq(0)");
  802.                 if(s) {
  803.                     obj = obj.clone();
  804.                     obj.children("INS").remove();
  805.                     return obj.html();
  806.                 }
  807.                 else {
  808.                     obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
  809.                     return obj.nodeValue;
  810.                 }
  811.             },
  812.             set_text    : function (obj, val) {
  813.                 obj = this._get_node(obj);
  814.                 if(!obj.length) { return false; }
  815.                 obj = obj.children("a:eq(0)");
  816.                 if(this._get_settings().core.html_titles) {
  817.                     var tmp = obj.children("INS").clone();
  818.                     obj.html(val).prepend(tmp);
  819.                     this.__callback({ "obj" : obj, "name" : val });
  820.                     return true;
  821.                 }
  822.                 else {
  823.                     obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
  824.                     this.__callback({ "obj" : obj, "name" : val });
  825.                     return (obj.nodeValue = val);
  826.                 }
  827.             },
  828.             rename_node : function (obj, val) {
  829.                 obj = this._get_node(obj);
  830.                 this.__rollback();
  831.                 if(obj && obj.length && this.set_text.apply(this, Array.prototype.slice.call(arguments))) { this.__callback({ "obj" : obj, "name" : val }); }
  832.             },
  833.             // Basic operations: deleting nodes
  834.             delete_node : function (obj) {
  835.                 obj = this._get_node(obj);
  836.                 if(!obj.length) { return false; }
  837.                 this.__rollback();
  838.                 var p = this._get_parent(obj), prev = $([]), t = this;
  839.                 obj.each(function () {
  840.                     prev = prev.add(t._get_prev(this));
  841.                 });
  842.                 obj = obj.detach();
  843.                 if(p !== -1 && p.find("> ul > li").length === 0) {
  844.                     p.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
  845.                 }
  846.                 this.clean_node(p);
  847.                 this.__callback({ "obj" : obj, "prev" : prev, "parent" : p });
  848.                 return obj;
  849.             },
  850.             prepare_move : function (o, r, pos, cb, is_cb) {
  851.                 var p = {};
  852.  
  853.                 p.ot = $.jstree._reference(o) || this;
  854.                 p.o = p.ot._get_node(o);
  855.                 p.r = r === - 1 ? -1 : this._get_node(r);
  856.                 p.p = (typeof pos === "undefined" || pos === false) ? "last" : pos; // TODO: move to a setting
  857.                 if(!is_cb && prepared_move.o && prepared_move.o[0] === p.o[0] && prepared_move.r[0] === p.r[0] && prepared_move.p === p.p) {
  858.                     this.__callback(prepared_move);
  859.                     if(cb) { cb.call(this, prepared_move); }
  860.                     return;
  861.                 }
  862.                 p.ot = $.jstree._reference(p.o) || this;
  863.                 p.rt = $.jstree._reference(p.r) || this; // r === -1 ? p.ot : $.jstree._reference(p.r) || this
  864.                 if(p.r === -1 || !p.r) {
  865.                     p.cr = -1;
  866.                     switch(p.p) {
  867.                         case "first":
  868.                         case "before":
  869.                         case "inside":
  870.                             p.cp = 0; 
  871.                             break;
  872.                         case "after":
  873.                         case "last":
  874.                             p.cp = p.rt.get_container().find(" > ul > li").length; 
  875.                             break;
  876.                         default:
  877.                             p.cp = p.p;
  878.                             break;
  879.                     }
  880.                 }
  881.                 else {
  882.                     if(!/^(before|after)$/.test(p.p) && !this._is_loaded(p.r)) {
  883.                         return this.load_node(p.r, function () { this.prepare_move(o, r, pos, cb, true); });
  884.                     }
  885.                     switch(p.p) {
  886.                         case "before":
  887.                             p.cp = p.r.index();
  888.                             p.cr = p.rt._get_parent(p.r);
  889.                             break;
  890.                         case "after":
  891.                             p.cp = p.r.index() + 1;
  892.                             p.cr = p.rt._get_parent(p.r);
  893.                             break;
  894.                         case "inside":
  895.                         case "first":
  896.                             p.cp = 0;
  897.                             p.cr = p.r;
  898.                             break;
  899.                         case "last":
  900.                             p.cp = p.r.find(" > ul > li").length; 
  901.                             p.cr = p.r;
  902.                             break;
  903.                         default: 
  904.                             p.cp = p.p;
  905.                             p.cr = p.r;
  906.                             break;
  907.                     }
  908.                 }
  909.                 p.np = p.cr == -1 ? p.rt.get_container() : p.cr;
  910.                 p.op = p.ot._get_parent(p.o);
  911.                 p.cop = p.o.index();
  912.                 if(p.op === -1) { p.op = p.ot ? p.ot.get_container() : this.get_container(); }
  913.                 if(!/^(before|after)$/.test(p.p) && p.op && p.np && p.op[0] === p.np[0] && p.o.index() < p.cp) { p.cp++; }
  914.                 //if(p.p === "before" && p.op && p.np && p.op[0] === p.np[0] && p.o.index() < p.cp) { p.cp--; }
  915.                 p.or = p.np.find(" > ul > li:nth-child(" + (p.cp + 1) + ")");
  916.                 prepared_move = p;
  917.                 this.__callback(prepared_move);
  918.                 if(cb) { cb.call(this, prepared_move); }
  919.             },
  920.             check_move : function () {
  921.                 var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r;
  922.                 if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; }
  923.                 if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
  924.                 obj.o.each(function () { 
  925.                     if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
  926.                 });
  927.                 return ret;
  928.             },
  929.             move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
  930.                 if(!is_prepared) { 
  931.                     return this.prepare_move(obj, ref, position, function (p) {
  932.                         this.move_node(p, false, false, is_copy, true, skip_check);
  933.                     });
  934.                 }
  935.                 if(is_copy) { 
  936.                     prepared_move.cy = true;
  937.                 }
  938.                 if(!skip_check && !this.check_move()) { return false; }
  939.  
  940.                 this.__rollback();
  941.                 var o = false;
  942.                 if(is_copy) {
  943.                     o = obj.o.clone(true);
  944.                     o.find("*[id]").andSelf().each(function () {
  945.                         if(this.id) { this.id = "copy_" + this.id; }
  946.                     });
  947.                 }
  948.                 else { o = obj.o; }
  949.  
  950.                 if(obj.or.length) { obj.or.before(o); }
  951.                 else { 
  952.                     if(!obj.np.children("ul").length) { $("<ul />").appendTo(obj.np); }
  953.                     obj.np.children("ul:eq(0)").append(o); 
  954.                 }
  955.  
  956.                 try { 
  957.                     obj.ot.clean_node(obj.op);
  958.                     obj.rt.clean_node(obj.np);
  959.                     if(!obj.op.find("> ul > li").length) {
  960.                         obj.op.removeClass("jstree-open jstree-closed").addClass("jstree-leaf").children("ul").remove();
  961.                     }
  962.                 } catch (e) { }
  963.  
  964.                 if(is_copy) { 
  965.                     prepared_move.cy = true;
  966.                     prepared_move.oc = o; 
  967.                 }
  968.                 this.__callback(prepared_move);
  969.                 return prepared_move;
  970.             },
  971.             _get_move : function () { return prepared_move; }
  972.         }
  973.     });
  974. })(jQuery);
  975. //*/
  976.  
  977. /* 
  978.  * jsTree ui plugin
  979.  * This plugins handles selecting/deselecting/hovering/dehovering nodes
  980.  */
  981. (function ($) {
  982.     var scrollbar_width, e1, e2;
  983.     $(function() {
  984.         if (/msie/.test(navigator.userAgent.toLowerCase())) {
  985.             e1 = $('<textarea cols="10" rows="2"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
  986.             e2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
  987.             scrollbar_width = e1.width() - e2.width();
  988.             e1.add(e2).remove();
  989.         } 
  990.         else {
  991.             e1 = $('<div />').css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: 0 })
  992.                     .prependTo('body').append('<div />').find('div').css({ width: '100%', height: 200 });
  993.             scrollbar_width = 100 - e1.width();
  994.             e1.parent().remove();
  995.         }
  996.     });
  997.     $.jstree.plugin("ui", {
  998.         __init : function () { 
  999.             this.data.ui.selected = $(); 
  1000.             this.data.ui.last_selected = false; 
  1001.             this.data.ui.hovered = null;
  1002.             this.data.ui.to_select = this.get_settings().ui.initially_select;
  1003.  
  1004.             this.get_container()
  1005.                 .delegate("a", "click.jstree", $.proxy(function (event) {
  1006.                         event.preventDefault();
  1007.                         event.currentTarget.blur();
  1008.                         if(!$(event.currentTarget).hasClass("jstree-loading")) {
  1009.                             this.select_node(event.currentTarget, true, event);
  1010.                         }
  1011.                     }, this))
  1012.                 .delegate("a", "mouseenter.jstree", $.proxy(function (event) {
  1013.                         if(!$(event.currentTarget).hasClass("jstree-loading")) {
  1014.                             this.hover_node(event.target);
  1015.                         }
  1016.                     }, this))
  1017.                 .delegate("a", "mouseleave.jstree", $.proxy(function (event) {
  1018.                         if(!$(event.currentTarget).hasClass("jstree-loading")) {
  1019.                             this.dehover_node(event.target);
  1020.                         }
  1021.                     }, this))
  1022.                 .bind("reopen.jstree", $.proxy(function () { 
  1023.                         this.reselect();
  1024.                     }, this))
  1025.                 .bind("get_rollback.jstree", $.proxy(function () { 
  1026.                         this.dehover_node();
  1027.                         this.save_selected();
  1028.                     }, this))
  1029.                 .bind("set_rollback.jstree", $.proxy(function () { 
  1030.                         this.reselect();
  1031.                     }, this))
  1032.                 .bind("close_node.jstree", $.proxy(function (event, data) { 
  1033.                         var s = this._get_settings().ui,
  1034.                             obj = this._get_node(data.rslt.obj),
  1035.                             clk = (obj && obj.length) ? obj.children("ul").find("a.jstree-clicked") : $(),
  1036.                             _this = this;
  1037.                         if(s.selected_parent_close === false || !clk.length) { return; }
  1038.                         clk.each(function () { 
  1039.                             _this.deselect_node(this);
  1040.                             if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
  1041.                         });
  1042.                     }, this))
  1043.                 .bind("delete_node.jstree", $.proxy(function (event, data) { 
  1044.                         var s = this._get_settings().ui.select_prev_on_delete,
  1045.                             obj = this._get_node(data.rslt.obj),
  1046.                             clk = (obj && obj.length) ? obj.find("a.jstree-clicked") : [],
  1047.                             _this = this;
  1048.                         clk.each(function () { _this.deselect_node(this); });
  1049.                         if(s && clk.length) { 
  1050.                             data.rslt.prev.each(function () { 
  1051.                                 if(this.parentNode) { _this.select_node(this); return false; /* if return false is removed all prev nodes will be selected */}
  1052.                             });
  1053.                         }
  1054.                     }, this))
  1055.                 .bind("move_node.jstree", $.proxy(function (event, data) { 
  1056.                         if(data.rslt.cy) { 
  1057.                             data.rslt.oc.find("a.jstree-clicked").removeClass("jstree-clicked");
  1058.                         }
  1059.                     }, this));
  1060.         },
  1061.         defaults : {
  1062.             select_limit : -1, // 0, 1, 2 ... or -1 for unlimited
  1063.             select_multiple_modifier : "ctrl", // on, or ctrl, shift, alt
  1064.             select_range_modifier : "shift",
  1065.             selected_parent_close : "select_parent", // false, "deselect", "select_parent"
  1066.             selected_parent_open : true,
  1067.             select_prev_on_delete : true,
  1068.             disable_selecting_children : false,
  1069.             initially_select : []
  1070.         },
  1071.         _fn : { 
  1072.             _get_node : function (obj, allow_multiple) {
  1073.                 if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
  1074.                 var $obj = $(obj, this.get_container()); 
  1075.                 if($obj.is(".jstree") || obj == -1) { return -1; } 
  1076.                 $obj = $obj.closest("li", this.get_container()); 
  1077.                 return $obj.length ? $obj : false; 
  1078.             },
  1079.             _ui_notify : function (n, data) {
  1080.                 if(data.selected) {
  1081.                     this.select_node(n, false);
  1082.                 }
  1083.             },
  1084.             save_selected : function () {
  1085.                 var _this = this;
  1086.                 this.data.ui.to_select = [];
  1087.                 this.data.ui.selected.each(function () { if(this.id) { _this.data.ui.to_select.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")); } });
  1088.                 this.__callback(this.data.ui.to_select);
  1089.             },
  1090.             reselect : function () {
  1091.                 var _this = this,
  1092.                     s = this.data.ui.to_select;
  1093.                 s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
  1094.                 // this.deselect_all(); WHY deselect, breaks plugin state notifier?
  1095.                 $.each(s, function (i, val) { if(val && val !== "#") { _this.select_node(val); } });
  1096.                 this.data.ui.selected = this.data.ui.selected.filter(function () { return this.parentNode; });
  1097.                 this.__callback();
  1098.             },
  1099.             refresh : function (obj) {
  1100.                 this.save_selected();
  1101.                 return this.__call_old();
  1102.             },
  1103.             hover_node : function (obj) {
  1104.                 obj = this._get_node(obj);
  1105.                 if(!obj.length) { return false; }
  1106.                 //if(this.data.ui.hovered && obj.get(0) === this.data.ui.hovered.get(0)) { return; }
  1107.                 if(!obj.hasClass("jstree-hovered")) { this.dehover_node(); }
  1108.                 this.data.ui.hovered = obj.children("a").addClass("jstree-hovered").parent();
  1109.                 this._fix_scroll(obj);
  1110.                 this.__callback({ "obj" : obj });
  1111.             },
  1112.             dehover_node : function () {
  1113.                 var obj = this.data.ui.hovered, p;
  1114.                 if(!obj || !obj.length) { return false; }
  1115.                 p = obj.children("a").removeClass("jstree-hovered").parent();
  1116.                 if(this.data.ui.hovered[0] === p[0]) { this.data.ui.hovered = null; }
  1117.                 this.__callback({ "obj" : obj });
  1118.             },
  1119.             select_node : function (obj, check, e) {
  1120.                 obj = this._get_node(obj);
  1121.                 if(obj == -1 || !obj || !obj.length) { return false; }
  1122.                 var s = this._get_settings().ui,
  1123.                     is_multiple = (s.select_multiple_modifier == "on" || (s.select_multiple_modifier !== false && e && e[s.select_multiple_modifier + "Key"])),
  1124.                     is_range = (s.select_range_modifier !== false && e && e[s.select_range_modifier + "Key"] && this.data.ui.last_selected && this.data.ui.last_selected[0] !== obj[0] && this.data.ui.last_selected.parent()[0] === obj.parent()[0]),
  1125.                     is_selected = this.is_selected(obj),
  1126.                     proceed = true,
  1127.                     t = this;
  1128.                 if(check) {
  1129.                     if(s.disable_selecting_children && is_multiple && 
  1130.                         (
  1131.                             (obj.parentsUntil(".jstree","li").children("a.jstree-clicked").length) ||
  1132.                             (obj.children("ul").find("a.jstree-clicked:eq(0)").length)
  1133.                         )
  1134.                     ) {
  1135.                         return false;
  1136.                     }
  1137.                     proceed = false;
  1138.                     switch(!0) {
  1139.                         case (is_range):
  1140.                             this.data.ui.last_selected.addClass("jstree-last-selected");
  1141.                             obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").andSelf();
  1142.                             if(s.select_limit == -1 || obj.length < s.select_limit) {
  1143.                                 this.data.ui.last_selected.removeClass("jstree-last-selected");
  1144.                                 this.data.ui.selected.each(function () {
  1145.                                     if(this !== t.data.ui.last_selected[0]) { t.deselect_node(this); }
  1146.                                 });
  1147.                                 is_selected = false;
  1148.                                 proceed = true;
  1149.                             }
  1150.                             else {
  1151.                                 proceed = false;
  1152.                             }
  1153.                             break;
  1154.                         case (is_selected && !is_multiple): 
  1155.                             this.deselect_all();
  1156.                             is_selected = false;
  1157.                             proceed = true;
  1158.                             break;
  1159.                         case (!is_selected && !is_multiple): 
  1160.                             if(s.select_limit == -1 || s.select_limit > 0) {
  1161.                                 this.deselect_all();
  1162.                                 proceed = true;
  1163.                             }
  1164.                             break;
  1165.                         case (is_selected && is_multiple): 
  1166.                             this.deselect_node(obj);
  1167.                             break;
  1168.                         case (!is_selected && is_multiple): 
  1169.                             if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) { 
  1170.                                 proceed = true;
  1171.                             }
  1172.                             break;
  1173.                     }
  1174.                 }
  1175.                 if(proceed && !is_selected) {
  1176.                     if(!is_range) { this.data.ui.last_selected = obj; }
  1177.                     obj.children("a").addClass("jstree-clicked");
  1178.                     if(s.selected_parent_open) {
  1179.                         obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
  1180.                     }
  1181.                     this.data.ui.selected = this.data.ui.selected.add(obj);
  1182.                     this._fix_scroll(obj.eq(0));
  1183.                     this.__callback({ "obj" : obj, "e" : e });
  1184.                 }
  1185.             },
  1186.             _fix_scroll : function (obj) {
  1187.                 var c = this.get_container()[0], t;
  1188.                 if(c.scrollHeight > c.offsetHeight) {
  1189.                     obj = this._get_node(obj);
  1190.                     if(!obj || obj === -1 || !obj.length || !obj.is(":visible")) { return; }
  1191.                     t = obj.offset().top - this.get_container().offset().top;
  1192.                     if(t < 0) { 
  1193.                         c.scrollTop = c.scrollTop + t - 1; 
  1194.                     }
  1195.                     if(t + this.data.core.li_height + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0) > c.offsetHeight) { 
  1196.                         c.scrollTop = c.scrollTop + (t - c.offsetHeight + this.data.core.li_height + 1 + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0)); 
  1197.                     }
  1198.                 }
  1199.             },
  1200.             deselect_node : function (obj) {
  1201.                 obj = this._get_node(obj);
  1202.                 if(!obj.length) { return false; }
  1203.                 if(this.is_selected(obj)) {
  1204.                     obj.children("a").removeClass("jstree-clicked");
  1205.                     this.data.ui.selected = this.data.ui.selected.not(obj);
  1206.                     if(this.data.ui.last_selected.get(0) === obj.get(0)) { this.data.ui.last_selected = this.data.ui.selected.eq(0); }
  1207.                     this.__callback({ "obj" : obj });
  1208.                 }
  1209.             },
  1210.             toggle_select : function (obj) {
  1211.                 obj = this._get_node(obj);
  1212.                 if(!obj.length) { return false; }
  1213.                 if(this.is_selected(obj)) { this.deselect_node(obj); }
  1214.                 else { this.select_node(obj); }
  1215.             },
  1216.             is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
  1217.             get_selected : function (context) { 
  1218.                 return context ? $(context).find("a.jstree-clicked").parent() : this.data.ui.selected; 
  1219.             },
  1220.             deselect_all : function (context) {
  1221.                 var ret = context ? $(context).find("a.jstree-clicked").parent() : this.get_container().find("a.jstree-clicked").parent();
  1222.                 ret.children("a.jstree-clicked").removeClass("jstree-clicked");
  1223.                 this.data.ui.selected = $([]);
  1224.                 this.data.ui.last_selected = false;
  1225.                 this.__callback({ "obj" : ret });
  1226.             }
  1227.         }
  1228.     });
  1229.     // include the selection plugin by default
  1230.     $.jstree.defaults.plugins.push("ui");
  1231. })(jQuery);
  1232. //*/
  1233.  
  1234. /* 
  1235.  * jsTree CRRM plugin
  1236.  * Handles creating/renaming/removing/moving nodes by user interaction.
  1237.  */
  1238. (function ($) {
  1239.     $.jstree.plugin("crrm", { 
  1240.         __init : function () {
  1241.             this.get_container()
  1242.                 .bind("move_node.jstree", $.proxy(function (e, data) {
  1243.                     if(this._get_settings().crrm.move.open_onmove) {
  1244.                         var t = this;
  1245.                         data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
  1246.                             t.open_node(this, false, true);
  1247.                         });
  1248.                     }
  1249.                 }, this));
  1250.         },
  1251.         defaults : {
  1252.             input_width_limit : 200,
  1253.             move : {
  1254.                 always_copy            : false, // false, true or "multitree"
  1255.                 open_onmove            : true,
  1256.                 default_position    : "last",
  1257.                 check_move            : function (m) { return true; }
  1258.             }
  1259.         },
  1260.         _fn : {
  1261.             _show_input : function (obj, callback) {
  1262.                 obj = this._get_node(obj);
  1263.                 var rtl = this._get_settings().core.rtl,
  1264.                     w = this._get_settings().crrm.input_width_limit,
  1265.                     w1 = obj.children("ins").width(),
  1266.                     w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
  1267.                     t = this.get_text(obj),
  1268.                     h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
  1269.                     h2 = obj.css("position","relative").append(
  1270.                     $("<input />", { 
  1271.                         "value" : t,
  1272.                         "class" : "jstree-rename-input",
  1273.                         // "size" : t.length,
  1274.                         "css" : {
  1275.                             "padding" : "0",
  1276.                             "border" : "1px solid silver",
  1277.                             "position" : "absolute",
  1278.                             "left"  : (rtl ? "auto" : (w1 + w2 + 4) + "px"),
  1279.                             "right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"),
  1280.                             "top" : "0px",
  1281.                             "height" : (this.data.core.li_height - 2) + "px",
  1282.                             "lineHeight" : (this.data.core.li_height - 2) + "px",
  1283.                             "width" : "150px" // will be set a bit further down
  1284.                         },
  1285.                         "blur" : $.proxy(function () {
  1286.                             var i = obj.children(".jstree-rename-input"),
  1287.                                 v = i.val();
  1288.                             if(v === "") { v = t; }
  1289.                             h1.remove();
  1290.                             i.remove(); // rollback purposes
  1291.                             this.set_text(obj,t); // rollback purposes
  1292.                             this.rename_node(obj, v);
  1293.                             callback.call(this, obj, v, t);
  1294.                             obj.css("position","");
  1295.                         }, this),
  1296.                         "keyup" : function (event) {
  1297.                             var key = event.keyCode || event.which;
  1298.                             if(key == 27) { this.value = t; this.blur(); return; }
  1299.                             else if(key == 13) { this.blur(); return; }
  1300.                             else {
  1301.                                 h2.width(Math.min(h1.text("pW" + this.value).width(),w));
  1302.                             }
  1303.                         },
  1304.                         "keypress" : function(event) {
  1305.                             var key = event.keyCode || event.which;
  1306.                             if(key == 13) { return false; }
  1307.                         }
  1308.                     })
  1309.                 ).children(".jstree-rename-input"); 
  1310.                 this.set_text(obj, "");
  1311.                 h1.css({
  1312.                         fontFamily        : h2.css('fontFamily')        || '',
  1313.                         fontSize        : h2.css('fontSize')        || '',
  1314.                         fontWeight        : h2.css('fontWeight')        || '',
  1315.                         fontStyle        : h2.css('fontStyle')        || '',
  1316.                         fontStretch        : h2.css('fontStretch')        || '',
  1317.                         fontVariant        : h2.css('fontVariant')        || '',
  1318.                         letterSpacing    : h2.css('letterSpacing')    || '',
  1319.                         wordSpacing        : h2.css('wordSpacing')        || ''
  1320.                 });
  1321.                 h2.width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
  1322.             },
  1323.             rename : function (obj) {
  1324.                 obj = this._get_node(obj);
  1325.                 this.__rollback();
  1326.                 var f = this.__callback;
  1327.                 this._show_input(obj, function (obj, new_name, old_name) { 
  1328.                     f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
  1329.                 });
  1330.             },
  1331.             create : function (obj, position, js, callback, skip_rename) {
  1332.                 var t, _this = this;
  1333.                 obj = this._get_node(obj);
  1334.                 if(!obj) { obj = -1; }
  1335.                 this.__rollback();
  1336.                 t = this.create_node(obj, position, js, function (t) {
  1337.                     var p = this._get_parent(t),
  1338.                         pos = $(t).index();
  1339.                     if(callback) { callback.call(this, t); }
  1340.                     if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
  1341.                     if(!skip_rename) { 
  1342.                         this._show_input(t, function (obj, new_name, old_name) { 
  1343.                             _this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
  1344.                         });
  1345.                     }
  1346.                     else { _this.__callback({ "obj" : t, "name" : this.get_text(t), "parent" : p, "position" : pos }); }
  1347.                 });
  1348.                 return t;
  1349.             },
  1350.             remove : function (obj) {
  1351.                 obj = this._get_node(obj, true);
  1352.                 var p = this._get_parent(obj), prev = this._get_prev(obj);
  1353.                 this.__rollback();
  1354.                 obj = this.delete_node(obj);
  1355.                 if(obj !== false) { this.__callback({ "obj" : obj, "prev" : prev, "parent" : p }); }
  1356.             },
  1357.             check_move : function () {
  1358.                 if(!this.__call_old()) { return false; }
  1359.                 var s = this._get_settings().crrm.move;
  1360.                 if(!s.check_move.call(this, this._get_move())) { return false; }
  1361.                 return true;
  1362.             },
  1363.             move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
  1364.                 var s = this._get_settings().crrm.move;
  1365.                 if(!is_prepared) { 
  1366.                     if(typeof position === "undefined") { position = s.default_position; }
  1367.                     if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
  1368.                     return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
  1369.                 }
  1370.                 // if the move is already prepared
  1371.                 if(s.always_copy === true || (s.always_copy === "multitree" && obj.rt.get_index() !== obj.ot.get_index() )) {
  1372.                     is_copy = true;
  1373.                 }
  1374.                 this.__call_old(true, obj, ref, position, is_copy, true, skip_check);
  1375.             },
  1376.  
  1377.             cut : function (obj) {
  1378.                 obj = this._get_node(obj, true);
  1379.                 if(!obj || !obj.length) { return false; }
  1380.                 this.data.crrm.cp_nodes = false;
  1381.                 this.data.crrm.ct_nodes = obj;
  1382.                 this.__callback({ "obj" : obj });
  1383.             },
  1384.             copy : function (obj) {
  1385.                 obj = this._get_node(obj, true);
  1386.                 if(!obj || !obj.length) { return false; }
  1387.                 this.data.crrm.ct_nodes = false;
  1388.                 this.data.crrm.cp_nodes = obj;
  1389.                 this.__callback({ "obj" : obj });
  1390.             },
  1391.             paste : function (obj) { 
  1392.                 obj = this._get_node(obj);
  1393.                 if(!obj || !obj.length) { return false; }
  1394.                 var nodes = this.data.crrm.ct_nodes ? this.data.crrm.ct_nodes : this.data.crrm.cp_nodes;
  1395.                 if(!this.data.crrm.ct_nodes && !this.data.crrm.cp_nodes) { return false; }
  1396.                 if(this.data.crrm.ct_nodes) { this.move_node(this.data.crrm.ct_nodes, obj); this.data.crrm.ct_nodes = false; }
  1397.                 if(this.data.crrm.cp_nodes) { this.move_node(this.data.crrm.cp_nodes, obj, false, true); }
  1398.                 this.__callback({ "obj" : obj, "nodes" : nodes });
  1399.             }
  1400.         }
  1401.     });
  1402.     // include the crr plugin by default
  1403.     // $.jstree.defaults.plugins.push("crrm");
  1404. })(jQuery);
  1405. //*/
  1406.  
  1407. /* 
  1408.  * jsTree themes plugin
  1409.  * Handles loading and setting themes, as well as detecting path to themes, etc.
  1410.  */
  1411. (function ($) {
  1412.     var themes_loaded = [];
  1413.     // this variable stores the path to the themes folder - if left as false - it will be autodetected
  1414.     $.jstree._themes = false;
  1415.     $.jstree.plugin("themes", {
  1416.         __init : function () { 
  1417.             this.get_container()
  1418.                 .bind("init.jstree", $.proxy(function () {
  1419.                         var s = this._get_settings().themes;
  1420.                         this.data.themes.dots = s.dots; 
  1421.                         this.data.themes.icons = s.icons; 
  1422.                         this.set_theme(s.theme, s.url);
  1423.                     }, this))
  1424.                 .bind("loaded.jstree", $.proxy(function () {
  1425.                         // bound here too, as simple HTML tree's won't honor dots & icons otherwise
  1426.                         if(!this.data.themes.dots) { this.hide_dots(); }
  1427.                         else { this.show_dots(); }
  1428.                         if(!this.data.themes.icons) { this.hide_icons(); }
  1429.                         else { this.show_icons(); }
  1430.                     }, this));
  1431.         },
  1432.         defaults : { 
  1433.             theme : "default", 
  1434.             url : false,
  1435.             dots : true,
  1436.             icons : true
  1437.         },
  1438.         _fn : {
  1439.             set_theme : function (theme_name, theme_url) {
  1440.                 if(!theme_name) { return false; }
  1441.                 if(!theme_url) { theme_url = $.jstree._themes + theme_name + '/style.css'; }
  1442.                 if($.inArray(theme_url, themes_loaded) == -1) {
  1443.                     $.vakata.css.add_sheet({ "url" : theme_url });
  1444.                     themes_loaded.push(theme_url);
  1445.                 }
  1446.                 if(this.data.themes.theme != theme_name) {
  1447.                     this.get_container().removeClass('jstree-' + this.data.themes.theme);
  1448.                     this.data.themes.theme = theme_name;
  1449.                 }
  1450.                 this.get_container().addClass('jstree-' + theme_name);
  1451.                 if(!this.data.themes.dots) { this.hide_dots(); }
  1452.                 else { this.show_dots(); }
  1453.                 if(!this.data.themes.icons) { this.hide_icons(); }
  1454.                 else { this.show_icons(); }
  1455.                 this.__callback();
  1456.             },
  1457.             get_theme    : function () { return this.data.themes.theme; },
  1458.  
  1459.             show_dots    : function () { this.data.themes.dots = true; this.get_container().children("ul").removeClass("jstree-no-dots"); },
  1460.             hide_dots    : function () { this.data.themes.dots = false; this.get_container().children("ul").addClass("jstree-no-dots"); },
  1461.             toggle_dots    : function () { if(this.data.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
  1462.  
  1463.             show_icons    : function () { this.data.themes.icons = true; this.get_container().children("ul").removeClass("jstree-no-icons"); },
  1464.             hide_icons    : function () { this.data.themes.icons = false; this.get_container().children("ul").addClass("jstree-no-icons"); },
  1465.             toggle_icons: function () { if(this.data.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }
  1466.         }
  1467.     });
  1468.     // autodetect themes path
  1469.     $(function () {
  1470.         if($.jstree._themes === false) {
  1471.             $("script").each(function () { 
  1472.                 if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) { 
  1473.                     $.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/'; 
  1474.                     return false; 
  1475.                 }
  1476.             });
  1477.         }
  1478.         if($.jstree._themes === false) { $.jstree._themes = "themes/"; }
  1479.     });
  1480.     // include the themes plugin by default
  1481.     $.jstree.defaults.plugins.push("themes");
  1482. })(jQuery);
  1483. //*/
  1484.  
  1485. /*
  1486.  * jsTree hotkeys plugin
  1487.  * Enables keyboard navigation for all tree instances
  1488.  * Depends on the jstree ui & jquery hotkeys plugins
  1489.  */
  1490. (function ($) {
  1491.     var bound = [];
  1492.     function exec(i, event) {
  1493.         var f = $.jstree._focused(), tmp;
  1494.         if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) { 
  1495.             tmp = f._get_settings().hotkeys[i];
  1496.             if(tmp) { return tmp.call(f, event); }
  1497.         }
  1498.     }
  1499.     $.jstree.plugin("hotkeys", {
  1500.         __init : function () {
  1501.             if(typeof $.hotkeys === "undefined") { throw "jsTree hotkeys: jQuery hotkeys plugin not included."; }
  1502.             if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
  1503.             $.each(this._get_settings().hotkeys, function (i, v) {
  1504.                 if(v !== false && $.inArray(i, bound) == -1) {
  1505.                     $(document).bind("keydown", i, function (event) { return exec(i, event); });
  1506.                     bound.push(i);
  1507.                 }
  1508.             });
  1509.             this.get_container()
  1510.                 .bind("lock.jstree", $.proxy(function () {
  1511.                         if(this.data.hotkeys.enabled) { this.data.hotkeys.enabled = false; this.data.hotkeys.revert = true; }
  1512.                     }, this))
  1513.                 .bind("unlock.jstree", $.proxy(function () {
  1514.                         if(this.data.hotkeys.revert) { this.data.hotkeys.enabled = true; }
  1515.                     }, this));
  1516.             this.enable_hotkeys();
  1517.         },
  1518.         defaults : {
  1519.             "up" : function () { 
  1520.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1521.                 this.hover_node(this._get_prev(o));
  1522.                 return false; 
  1523.             },
  1524.             "ctrl+up" : function () { 
  1525.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1526.                 this.hover_node(this._get_prev(o));
  1527.                 return false; 
  1528.             },
  1529.             "shift+up" : function () { 
  1530.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1531.                 this.hover_node(this._get_prev(o));
  1532.                 return false; 
  1533.             },
  1534.             "down" : function () { 
  1535.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1536.                 this.hover_node(this._get_next(o));
  1537.                 return false;
  1538.             },
  1539.             "ctrl+down" : function () { 
  1540.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1541.                 this.hover_node(this._get_next(o));
  1542.                 return false;
  1543.             },
  1544.             "shift+down" : function () { 
  1545.                 var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
  1546.                 this.hover_node(this._get_next(o));
  1547.                 return false;
  1548.             },
  1549.             "left" : function () { 
  1550.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1551.                 if(o) {
  1552.                     if(o.hasClass("jstree-open")) { this.close_node(o); }
  1553.                     else { this.hover_node(this._get_prev(o)); }
  1554.                 }
  1555.                 return false;
  1556.             },
  1557.             "ctrl+left" : function () { 
  1558.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1559.                 if(o) {
  1560.                     if(o.hasClass("jstree-open")) { this.close_node(o); }
  1561.                     else { this.hover_node(this._get_prev(o)); }
  1562.                 }
  1563.                 return false;
  1564.             },
  1565.             "shift+left" : function () { 
  1566.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1567.                 if(o) {
  1568.                     if(o.hasClass("jstree-open")) { this.close_node(o); }
  1569.                     else { this.hover_node(this._get_prev(o)); }
  1570.                 }
  1571.                 return false;
  1572.             },
  1573.             "right" : function () { 
  1574.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1575.                 if(o && o.length) {
  1576.                     if(o.hasClass("jstree-closed")) { this.open_node(o); }
  1577.                     else { this.hover_node(this._get_next(o)); }
  1578.                 }
  1579.                 return false;
  1580.             },
  1581.             "ctrl+right" : function () { 
  1582.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1583.                 if(o && o.length) {
  1584.                     if(o.hasClass("jstree-closed")) { this.open_node(o); }
  1585.                     else { this.hover_node(this._get_next(o)); }
  1586.                 }
  1587.                 return false;
  1588.             },
  1589.             "shift+right" : function () { 
  1590.                 var o = this.data.ui.hovered || this.data.ui.last_selected;
  1591.                 if(o && o.length) {
  1592.                     if(o.hasClass("jstree-closed")) { this.open_node(o); }
  1593.                     else { this.hover_node(this._get_next(o)); }
  1594.                 }
  1595.                 return false;
  1596.             },
  1597.             "space" : function () { 
  1598.                 if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); } 
  1599.                 return false; 
  1600.             },
  1601.             "ctrl+space" : function (event) { 
  1602.                 event.type = "click";
  1603.                 if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); } 
  1604.                 return false; 
  1605.             },
  1606.             "shift+space" : function (event) { 
  1607.                 event.type = "click";
  1608.                 if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); } 
  1609.                 return false; 
  1610.             },
  1611.             "f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
  1612.             "del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
  1613.         },
  1614.         _fn : {
  1615.             enable_hotkeys : function () {
  1616.                 this.data.hotkeys.enabled = true;
  1617.             },
  1618.             disable_hotkeys : function () {
  1619.                 this.data.hotkeys.enabled = false;
  1620.             }
  1621.         }
  1622.     });
  1623. })(jQuery);
  1624. //*/
  1625.  
  1626. /* 
  1627.  * jsTree JSON plugin
  1628.  * The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
  1629.  */
  1630. (function ($) {
  1631.     $.jstree.plugin("json_data", {
  1632.         __init : function() {
  1633.             var s = this._get_settings().json_data;
  1634.             if(s.progressive_unload) {
  1635.                 this.get_container().bind("after_close.jstree", function (e, data) {
  1636.                     data.rslt.obj.children("ul").remove();
  1637.                 });
  1638.             }
  1639.         },
  1640.         defaults : { 
  1641.             // `data` can be a function:
  1642.             //  * accepts two arguments - node being loaded and a callback to pass the result to
  1643.             //  * will be executed in the current tree's scope & ajax won't be supported
  1644.             data : false, 
  1645.             ajax : false,
  1646.             correct_state : true,
  1647.             progressive_render : false,
  1648.             progressive_unload : false
  1649.         },
  1650.         _fn : {
  1651.             load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
  1652.             _is_loaded : function (obj) { 
  1653.                 var s = this._get_settings().json_data;
  1654.                 obj = this._get_node(obj); 
  1655.                 return obj == -1 || !obj || (!s.ajax && !s.progressive_render && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").length > 0;
  1656.             },
  1657.             refresh : function (obj) {
  1658.                 obj = this._get_node(obj);
  1659.                 var s = this._get_settings().json_data;
  1660.                 if(obj && obj !== -1 && s.progressive_unload && ($.isFunction(s.data) || !!s.ajax)) {
  1661.                     obj.removeData("jstree-children");
  1662.                 }
  1663.                 return this.__call_old();
  1664.             },
  1665.             load_node_json : function (obj, s_call, e_call) {
  1666.                 var s = this.get_settings().json_data, d,
  1667.                     error_func = function () {},
  1668.                     success_func = function () {};
  1669.                 obj = this._get_node(obj);
  1670.  
  1671.                 if(obj && obj !== -1 && (s.progressive_render || s.progressive_unload) && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree-children")) {
  1672.                     d = this._parse_json(obj.data("jstree-children"), obj);
  1673.                     if(d) {
  1674.                         obj.append(d);
  1675.                         if(!s.progressive_unload) { obj.removeData("jstree-children"); }
  1676.                     }
  1677.                     this.clean_node(obj);
  1678.                     if(s_call) { s_call.call(this); }
  1679.                     return;
  1680.                 }
  1681.  
  1682.                 if(obj && obj !== -1) {
  1683.                     if(obj.data("jstree-is-loading")) { return; }
  1684.                     else { obj.data("jstree-is-loading",true); }
  1685.                 }
  1686.                 switch(!0) {
  1687.                     case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
  1688.                     // function option added here for easier model integration (also supporting async - see callback)
  1689.                     case ($.isFunction(s.data)):
  1690.                         s.data.call(this, obj, $.proxy(function (d) {
  1691.                             d = this._parse_json(d, obj);
  1692.                             if(!d) { 
  1693.                                 if(obj === -1 || !obj) {
  1694.                                     if(s.correct_state) { this.get_container().children("ul").empty(); }
  1695.                                 }
  1696.                                 else {
  1697.                                     obj.children("a.jstree-loading").removeClass("jstree-loading");
  1698.                                     obj.removeData("jstree-is-loading");
  1699.                                     if(s.correct_state) { this.correct_state(obj); }
  1700.                                 }
  1701.                                 if(e_call) { e_call.call(this); }
  1702.                             }
  1703.                             else {
  1704.                                 if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
  1705.                                 else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
  1706.                                 this.clean_node(obj);
  1707.                                 if(s_call) { s_call.call(this); }
  1708.                             }
  1709.                         }, this));
  1710.                         break;
  1711.                     case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
  1712.                         if(!obj || obj == -1) {
  1713.                             d = this._parse_json(s.data, obj);
  1714.                             if(d) {
  1715.                                 this.get_container().children("ul").empty().append(d.children());
  1716.                                 this.clean_node();
  1717.                             }
  1718.                             else { 
  1719.                                 if(s.correct_state) { this.get_container().children("ul").empty(); }
  1720.                             }
  1721.                         }
  1722.                         if(s_call) { s_call.call(this); }
  1723.                         break;
  1724.                     case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
  1725.                         error_func = function (x, t, e) {
  1726.                             var ef = this.get_settings().json_data.ajax.error; 
  1727.                             if(ef) { ef.call(this, x, t, e); }
  1728.                             if(obj != -1 && obj.length) {
  1729.                                 obj.children("a.jstree-loading").removeClass("jstree-loading");
  1730.                                 obj.removeData("jstree-is-loading");
  1731.                                 if(t === "success" && s.correct_state) { this.correct_state(obj); }
  1732.                             }
  1733.                             else {
  1734.                                 if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
  1735.                             }
  1736.                             if(e_call) { e_call.call(this); }
  1737.                         };
  1738.                         success_func = function (d, t, x) {
  1739.                             var sf = this.get_settings().json_data.ajax.success; 
  1740.                             if(sf) { d = sf.call(this,d,t,x) || d; }
  1741.                             if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "") || (!$.isArray(d) && !$.isPlainObject(d))) {
  1742.                                 return error_func.call(this, x, t, "");
  1743.                             }
  1744.                             d = this._parse_json(d, obj);
  1745.                             if(d) {
  1746.                                 if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
  1747.                                 else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
  1748.                                 this.clean_node(obj);
  1749.                                 if(s_call) { s_call.call(this); }
  1750.                             }
  1751.                             else {
  1752.                                 if(obj === -1 || !obj) {
  1753.                                     if(s.correct_state) { 
  1754.                                         this.get_container().children("ul").empty(); 
  1755.                                         if(s_call) { s_call.call(this); }
  1756.                                     }
  1757.                                 }
  1758.                                 else {
  1759.                                     obj.children("a.jstree-loading").removeClass("jstree-loading");
  1760.                                     obj.removeData("jstree-is-loading");
  1761.                                     if(s.correct_state) { 
  1762.                                         this.correct_state(obj);
  1763.                                         if(s_call) { s_call.call(this); } 
  1764.                                     }
  1765.                                 }
  1766.                             }
  1767.                         };
  1768.                         s.ajax.context = this;
  1769.                         s.ajax.error = error_func;
  1770.                         s.ajax.success = success_func;
  1771.                         if(!s.ajax.dataType) { s.ajax.dataType = "json"; }
  1772.                         if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
  1773.                         if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
  1774.                         $.ajax(s.ajax);
  1775.                         break;
  1776.                 }
  1777.             },
  1778.             _parse_json : function (js, obj, is_callback) {
  1779.                 var d = false, 
  1780.                     p = this._get_settings(),
  1781.                     s = p.json_data,
  1782.                     t = p.core.html_titles,
  1783.                     tmp, i, j, ul1, ul2;
  1784.  
  1785.                 if(!js) { return d; }
  1786.                 if(s.progressive_unload && obj && obj !== -1) { 
  1787.                     obj.data("jstree-children", d);
  1788.                 }
  1789.                 if($.isArray(js)) {
  1790.                     d = $();
  1791.                     if(!js.length) { return false; }
  1792.                     for(i = 0, j = js.length; i < j; i++) {
  1793.                         tmp = this._parse_json(js[i], obj, true);
  1794.                         if(tmp.length) { d = d.add(tmp); }
  1795.                     }
  1796.                 }
  1797.                 else {
  1798.                     if(typeof js == "string") { js = { data : js }; }
  1799.                     if(!js.data && js.data !== "") { return d; }
  1800.                     d = $("<li />");
  1801.                     if(js.attr) { d.attr(js.attr); }
  1802.                     if(js.metadata) { d.data(js.metadata); }
  1803.                     if(js.state) { d.addClass("jstree-" + js.state); }
  1804.                     if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
  1805.                     $.each(js.data, function (i, m) {
  1806.                         tmp = $("<a />");
  1807.                         if($.isFunction(m)) { m = m.call(this, js); }
  1808.                         if(typeof m == "string") { tmp.attr('href','#')[ t ? "html" : "text" ](m); }
  1809.                         else {
  1810.                             if(!m.attr) { m.attr = {}; }
  1811.                             if(!m.attr.href) { m.attr.href = '#'; }
  1812.                             tmp.attr(m.attr)[ t ? "html" : "text" ](m.title);
  1813.                             if(m.language) { tmp.addClass(m.language); }
  1814.                         }
  1815.                         tmp.prepend("<ins class='jstree-icon'> </ins>");
  1816.                         if(!m.icon && js.icon) { m.icon = js.icon; }
  1817.                         if(m.icon) { 
  1818.                             if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
  1819.                             else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
  1820.                         }
  1821.                         d.append(tmp);
  1822.                     });
  1823.                     d.prepend("<ins class='jstree-icon'> </ins>");
  1824.                     if(js.children) { 
  1825.                         if(s.progressive_render && js.state !== "open") {
  1826.                             d.addClass("jstree-closed").data("jstree-children", js.children);
  1827.                         }
  1828.                         else {
  1829.                             if(s.progressive_unload) { d.data("jstree-children", js.children); }
  1830.                             if($.isArray(js.children) && js.children.length) {
  1831.                                 tmp = this._parse_json(js.children, obj, true);
  1832.                                 if(tmp.length) {
  1833.                                     ul2 = $("<ul />");
  1834.                                     ul2.append(tmp);
  1835.                                     d.append(ul2);
  1836.                                 }
  1837.                             }
  1838.                         }
  1839.                     }
  1840.                 }
  1841.                 if(!is_callback) {
  1842.                     ul1 = $("<ul />");
  1843.                     ul1.append(d);
  1844.                     d = ul1;
  1845.                 }
  1846.                 return d;
  1847.             },
  1848.             get_json : function (obj, li_attr, a_attr, is_callback) {
  1849.                 var result = [], 
  1850.                     s = this._get_settings(), 
  1851.                     _this = this,
  1852.                     tmp1, tmp2, li, a, t, lang;
  1853.                 obj = this._get_node(obj);
  1854.                 if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
  1855.                 li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
  1856.                 if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
  1857.                 a_attr = $.isArray(a_attr) ? a_attr : [ ];
  1858.  
  1859.                 obj.each(function () {
  1860.                     li = $(this);
  1861.                     tmp1 = { data : [] };
  1862.                     if(li_attr.length) { tmp1.attr = { }; }
  1863.                     $.each(li_attr, function (i, v) { 
  1864.                         tmp2 = li.attr(v); 
  1865.                         if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*/ig,'').length) {
  1866.                             tmp1.attr[v] = (" " + tmp2).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,""); 
  1867.                         }
  1868.                     });
  1869.                     if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
  1870.                     if(li.hasClass("jstree-closed")) { tmp1.state = "closed"; }
  1871.                     if(li.data()) { tmp1.metadata = li.data(); }
  1872.                     a = li.children("a");
  1873.                     a.each(function () {
  1874.                         t = $(this);
  1875.                         if(
  1876.                             a_attr.length || 
  1877.                             $.inArray("languages", s.plugins) !== -1 || 
  1878.                             t.children("ins").get(0).style.backgroundImage.length || 
  1879.                             (t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
  1880.                         ) { 
  1881.                             lang = false;
  1882.                             if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
  1883.                                 $.each(s.languages, function (l, lv) {
  1884.                                     if(t.hasClass(lv)) {
  1885.                                         lang = lv;
  1886.                                         return false;
  1887.                                     }
  1888.                                 });
  1889.                             }
  1890.                             tmp2 = { attr : { }, title : _this.get_text(t, lang) }; 
  1891.                             $.each(a_attr, function (k, z) {
  1892.                                 tmp2.attr[z] = (" " + (t.attr(z) || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
  1893.                             });
  1894.                             if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
  1895.                                 $.each(s.languages, function (k, z) {
  1896.                                     if(t.hasClass(z)) { tmp2.language = z; return true; }
  1897.                                 });
  1898.                             }
  1899.                             if(t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
  1900.                                 tmp2.icon = t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
  1901.                             }
  1902.                             if(t.children("ins").get(0).style.backgroundImage.length) {
  1903.                                 tmp2.icon = t.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
  1904.                             }
  1905.                         }
  1906.                         else {
  1907.                             tmp2 = _this.get_text(t);
  1908.                         }
  1909.                         if(a.length > 1) { tmp1.data.push(tmp2); }
  1910.                         else { tmp1.data = tmp2; }
  1911.                     });
  1912.                     li = li.find("> ul > li");
  1913.                     if(li.length) { tmp1.children = _this.get_json(li, li_attr, a_attr, true); }
  1914.                     result.push(tmp1);
  1915.                 });
  1916.                 return result;
  1917.             }
  1918.         }
  1919.     });
  1920. })(jQuery);
  1921. //*/
  1922.  
  1923. /* 
  1924.  * jsTree languages plugin
  1925.  * Adds support for multiple language versions in one tree
  1926.  * This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
  1927.  * This is useful for maintaining the same structure in many languages (hence the name of the plugin)
  1928.  */
  1929. (function ($) {
  1930.     $.jstree.plugin("languages", {
  1931.         __init : function () { this._load_css();  },
  1932.         defaults : [],
  1933.         _fn : {
  1934.             set_lang : function (i) { 
  1935.                 var langs = this._get_settings().languages,
  1936.                     st = false,
  1937.                     selector = ".jstree-" + this.get_index() + ' a';
  1938.                 if(!$.isArray(langs) || langs.length === 0) { return false; }
  1939.                 if($.inArray(i,langs) == -1) {
  1940.                     if(!!langs[i]) { i = langs[i]; }
  1941.                     else { return false; }
  1942.                 }
  1943.                 if(i == this.data.languages.current_language) { return true; }
  1944.                 st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, this.data.languages.language_css);
  1945.                 if(st !== false) { st.style.display = "none"; }
  1946.                 st = $.vakata.css.get_css(selector + "." + i, false, this.data.languages.language_css);
  1947.                 if(st !== false) { st.style.display = ""; }
  1948.                 this.data.languages.current_language = i;
  1949.                 this.__callback(i);
  1950.                 return true;
  1951.             },
  1952.             get_lang : function () {
  1953.                 return this.data.languages.current_language;
  1954.             },
  1955.             _get_string : function (key, lang) {
  1956.                 var langs = this._get_settings().languages,
  1957.                     s = this._get_settings().core.strings;
  1958.                 if($.isArray(langs) && langs.length) {
  1959.                     lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
  1960.                 }
  1961.                 if(s[lang] && s[lang][key]) { return s[lang][key]; }
  1962.                 if(s[key]) { return s[key]; }
  1963.                 return key;
  1964.             },
  1965.             get_text : function (obj, lang) {
  1966.                 obj = this._get_node(obj) || this.data.ui.last_selected;
  1967.                 if(!obj.size()) { return false; }
  1968.                 var langs = this._get_settings().languages,
  1969.                     s = this._get_settings().core.html_titles;
  1970.                 if($.isArray(langs) && langs.length) {
  1971.                     lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
  1972.                     obj = obj.children("a." + lang);
  1973.                 }
  1974.                 else { obj = obj.children("a:eq(0)"); }
  1975.                 if(s) {
  1976.                     obj = obj.clone();
  1977.                     obj.children("INS").remove();
  1978.                     return obj.html();
  1979.                 }
  1980.                 else {
  1981.                     obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
  1982.                     return obj.nodeValue;
  1983.                 }
  1984.             },
  1985.             set_text : function (obj, val, lang) {
  1986.                 obj = this._get_node(obj) || this.data.ui.last_selected;
  1987.                 if(!obj.size()) { return false; }
  1988.                 var langs = this._get_settings().languages,
  1989.                     s = this._get_settings().core.html_titles,
  1990.                     tmp;
  1991.                 if($.isArray(langs) && langs.length) {
  1992.                     lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
  1993.                     obj = obj.children("a." + lang);
  1994.                 }
  1995.                 else { obj = obj.children("a:eq(0)"); }
  1996.                 if(s) {
  1997.                     tmp = obj.children("INS").clone();
  1998.                     obj.html(val).prepend(tmp);
  1999.                     this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
  2000.                     return true;
  2001.                 }
  2002.                 else {
  2003.                     obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
  2004.                     this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
  2005.                     return (obj.nodeValue = val);
  2006.                 }
  2007.             },
  2008.             _load_css : function () {
  2009.                 var langs = this._get_settings().languages,
  2010.                     str = "/* languages css */",
  2011.                     selector = ".jstree-" + this.get_index() + ' a',
  2012.                     ln;
  2013.                 if($.isArray(langs) && langs.length) {
  2014.                     this.data.languages.current_language = langs[0];
  2015.                     for(ln = 0; ln < langs.length; ln++) {
  2016.                         str += selector + "." + langs[ln] + " {";
  2017.                         if(langs[ln] != this.data.languages.current_language) { str += " display:none; "; }
  2018.                         str += " } ";
  2019.                     }
  2020.                     this.data.languages.language_css = $.vakata.css.add_sheet({ 'str' : str, 'title' : "jstree-languages" });
  2021.                 }
  2022.             },
  2023.             create_node : function (obj, position, js, callback) {
  2024.                 var t = this.__call_old(true, obj, position, js, function (t) {
  2025.                     var langs = this._get_settings().languages,
  2026.                         a = t.children("a"),
  2027.                         ln;
  2028.                     if($.isArray(langs) && langs.length) {
  2029.                         for(ln = 0; ln < langs.length; ln++) {
  2030.                             if(!a.is("." + langs[ln])) {
  2031.                                 t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
  2032.                             }
  2033.                         }
  2034.                         a.not("." + langs.join(", .")).remove();
  2035.                     }
  2036.                     if(callback) { callback.call(this, t); }
  2037.                 });
  2038.                 return t;
  2039.             }
  2040.         }
  2041.     });
  2042. })(jQuery);
  2043. //*/
  2044.  
  2045. /*
  2046.  * jsTree cookies plugin
  2047.  * Stores the currently opened/selected nodes in a cookie and then restores them
  2048.  * Depends on the jquery.cookie plugin
  2049.  */
  2050. (function ($) {
  2051.     $.jstree.plugin("cookies", {
  2052.         __init : function () {
  2053.             if(typeof $.cookie === "undefined") { throw "jsTree cookie: jQuery cookie plugin not included."; }
  2054.  
  2055.             var s = this._get_settings().cookies,
  2056.                 tmp;
  2057.             if(!!s.save_loaded) {
  2058.                 tmp = $.cookie(s.save_loaded);
  2059.                 if(tmp && tmp.length) { this.data.core.to_load = tmp.split(","); }
  2060.             }
  2061.             if(!!s.save_opened) {
  2062.                 tmp = $.cookie(s.save_opened);
  2063.                 if(tmp && tmp.length) { this.data.core.to_open = tmp.split(","); }
  2064.             }
  2065.             if(!!s.save_selected) {
  2066.                 tmp = $.cookie(s.save_selected);
  2067.                 if(tmp && tmp.length && this.data.ui) { this.data.ui.to_select = tmp.split(","); }
  2068.             }
  2069.             this.get_container()
  2070.                 .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
  2071.                     this.get_container()
  2072.                         .bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) { 
  2073.                                 if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
  2074.                             }, this));
  2075.                 }, this));
  2076.         },
  2077.         defaults : {
  2078.             save_loaded        : "jstree_load",
  2079.             save_opened        : "jstree_open",
  2080.             save_selected    : "jstree_select",
  2081.             auto_save        : true,
  2082.             cookie_options    : {}
  2083.         },
  2084.         _fn : {
  2085.             save_cookie : function (c) {
  2086.                 if(this.data.core.refreshing) { return; }
  2087.                 var s = this._get_settings().cookies;
  2088.                 if(!c) { // if called manually and not by event
  2089.                     if(s.save_loaded) {
  2090.                         this.save_loaded();
  2091.                         $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options);
  2092.                     }
  2093.                     if(s.save_opened) {
  2094.                         this.save_opened();
  2095.                         $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
  2096.                     }
  2097.                     if(s.save_selected && this.data.ui) {
  2098.                         this.save_selected();
  2099.                         $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
  2100.                     }
  2101.                     return;
  2102.                 }
  2103.                 switch(c) {
  2104.                     case "open_node":
  2105.                     case "close_node":
  2106.                         if(!!s.save_opened) { 
  2107.                             this.save_opened(); 
  2108.                             $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options); 
  2109.                         }
  2110.                         if(!!s.save_loaded) { 
  2111.                             this.save_loaded(); 
  2112.                             $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options); 
  2113.                         }
  2114.                         break;
  2115.                     case "select_node":
  2116.                     case "deselect_node":
  2117.                         if(!!s.save_selected && this.data.ui) { 
  2118.                             this.save_selected(); 
  2119.                             $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options); 
  2120.                         }
  2121.                         break;
  2122.                 }
  2123.             }
  2124.         }
  2125.     });
  2126.     // include cookies by default
  2127.     // $.jstree.defaults.plugins.push("cookies");
  2128. })(jQuery);
  2129. //*/
  2130.  
  2131. /*
  2132.  * jsTree sort plugin
  2133.  * Sorts items alphabetically (or using any other function)
  2134.  */
  2135. (function ($) {
  2136.     $.jstree.plugin("sort", {
  2137.         __init : function () {
  2138.             this.get_container()
  2139.                 .bind("load_node.jstree", $.proxy(function (e, data) {
  2140.                         var obj = this._get_node(data.rslt.obj);
  2141.                         obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
  2142.                         this.sort(obj);
  2143.                     }, this))
  2144.                 .bind("rename_node.jstree create_node.jstree create.jstree", $.proxy(function (e, data) {
  2145.                         this.sort(data.rslt.obj.parent());
  2146.                     }, this))
  2147.                 .bind("move_node.jstree", $.proxy(function (e, data) {
  2148.                         var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
  2149.                         this.sort(m.children("ul"));
  2150.                     }, this));
  2151.         },
  2152.         defaults : function (a, b) { return this.get_text(a) > this.get_text(b) ? 1 : -1; },
  2153.         _fn : {
  2154.             sort : function (obj) {
  2155.                 var s = this._get_settings().sort,
  2156.                     t = this;
  2157.                 obj.append($.makeArray(obj.children("li")).sort($.proxy(s, t)));
  2158.                 obj.find("> li > ul").each(function() { t.sort($(this)); });
  2159.                 this.clean_node(obj);
  2160.             }
  2161.         }
  2162.     });
  2163. })(jQuery);
  2164. //*/
  2165.  
  2166. /*
  2167.  * jsTree DND plugin
  2168.  * Drag and drop plugin for moving/copying nodes
  2169.  */
  2170. (function ($) {
  2171.     var o = false,
  2172.         r = false,
  2173.         m = false,
  2174.         ml = false,
  2175.         sli = false,
  2176.         sti = false,
  2177.         dir1 = false,
  2178.         dir2 = false,
  2179.         last_pos = false;
  2180.     $.vakata.dnd = {
  2181.         is_down : false,
  2182.         is_drag : false,
  2183.         helper : false,
  2184.         scroll_spd : 10,
  2185.         init_x : 0,
  2186.         init_y : 0,
  2187.         threshold : 5,
  2188.         helper_left : 5,
  2189.         helper_top : 10,
  2190.         user_data : {},
  2191.  
  2192.         drag_start : function (e, data, html) { 
  2193.             if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
  2194.             try {
  2195.                 e.currentTarget.unselectable = "on";
  2196.                 e.currentTarget.onselectstart = function() { return false; };
  2197.                 if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; }
  2198.             } catch(err) { }
  2199.             $.vakata.dnd.init_x = e.pageX;
  2200.             $.vakata.dnd.init_y = e.pageY;
  2201.             $.vakata.dnd.user_data = data;
  2202.             $.vakata.dnd.is_down = true;
  2203.             $.vakata.dnd.helper = $("<div id='vakata-dragged' />").html(html); //.fadeTo(10,0.25);
  2204.             $(document).bind("mousemove", $.vakata.dnd.drag);
  2205.             $(document).bind("mouseup", $.vakata.dnd.drag_stop);
  2206.             return false;
  2207.         },
  2208.         drag : function (e) { 
  2209.             if(!$.vakata.dnd.is_down) { return; }
  2210.             if(!$.vakata.dnd.is_drag) {
  2211.                 if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) { 
  2212.                     $.vakata.dnd.helper.appendTo("body");
  2213.                     $.vakata.dnd.is_drag = true;
  2214.                     $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
  2215.                 }
  2216.                 else { return; }
  2217.             }
  2218.  
  2219.             // maybe use a scrolling parent element instead of document?
  2220.             if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
  2221.                 var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
  2222.                 if(e.pageY - t < 20) { 
  2223.                     if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
  2224.                     if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
  2225.                 }
  2226.                 else { 
  2227.                     if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
  2228.                 }
  2229.                 if($(window).height() - (e.pageY - t) < 20) {
  2230.                     if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
  2231.                     if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
  2232.                 }
  2233.                 else { 
  2234.                     if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
  2235.                 }
  2236.  
  2237.                 if(e.pageX - l < 20) {
  2238.                     if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
  2239.                     if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
  2240.                 }
  2241.                 else { 
  2242.                     if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
  2243.                 }
  2244.                 if($(window).width() - (e.pageX - l) < 20) {
  2245.                     if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
  2246.                     if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
  2247.                 }
  2248.                 else { 
  2249.                     if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
  2250.                 }
  2251.             }
  2252.  
  2253.             $.vakata.dnd.helper.css({ left : (e.pageX + $.vakata.dnd.helper_left) + "px", top : (e.pageY + $.vakata.dnd.helper_top) + "px" });
  2254.             $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
  2255.         },
  2256.         drag_stop : function (e) {
  2257.             if(sli) { clearInterval(sli); }
  2258.             if(sti) { clearInterval(sti); }
  2259.             $(document).unbind("mousemove", $.vakata.dnd.drag);
  2260.             $(document).unbind("mouseup", $.vakata.dnd.drag_stop);
  2261.             $(document).triggerHandler("drag_stop.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
  2262.             $.vakata.dnd.helper.remove();
  2263.             $.vakata.dnd.init_x = 0;
  2264.             $.vakata.dnd.init_y = 0;
  2265.             $.vakata.dnd.user_data = {};
  2266.             $.vakata.dnd.is_down = false;
  2267.             $.vakata.dnd.is_drag = false;
  2268.         }
  2269.     };
  2270.     $(function() {
  2271.         var css_string = '#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; top:-2000px; line-height:16px; z-index:10000; } ';
  2272.         $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
  2273.     });
  2274.  
  2275.     $.jstree.plugin("dnd", {
  2276.         __init : function () {
  2277.             this.data.dnd = {
  2278.                 active : false,
  2279.                 after : false,
  2280.                 inside : false,
  2281.                 before : false,
  2282.                 off : false,
  2283.                 prepared : false,
  2284.                 w : 0,
  2285.                 to1 : false,
  2286.                 to2 : false,
  2287.                 cof : false,
  2288.                 cw : false,
  2289.                 ch : false,
  2290.                 i1 : false,
  2291.                 i2 : false,
  2292.                 mto : false
  2293.             };
  2294.             this.get_container()
  2295.                 .bind("mouseenter.jstree", $.proxy(function (e) {
  2296.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2297.                             if(this.data.themes) {
  2298.                                 m.attr("class", "jstree-" + this.data.themes.theme); 
  2299.                                 if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
  2300.                                 $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
  2301.                             }
  2302.                             //if($(e.currentTarget).find("> ul > li").length === 0) {
  2303.                             if(e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
  2304.                                 var tr = $.jstree._reference(e.target), dc;
  2305.                                 if(tr.data.dnd.foreign) {
  2306.                                     dc = tr._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
  2307.                                     if(dc === true || dc.inside === true || dc.before === true || dc.after === true) {
  2308.                                         $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
  2309.                                     }
  2310.                                 }
  2311.                                 else {
  2312.                                     tr.prepare_move(o, tr.get_container(), "last");
  2313.                                     if(tr.check_move()) {
  2314.                                         $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
  2315.                                     }
  2316.                                 }
  2317.                             }
  2318.                         }
  2319.                     }, this))
  2320.                 .bind("mouseup.jstree", $.proxy(function (e) {
  2321.                         //if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && $(e.currentTarget).find("> ul > li").length === 0) {
  2322.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
  2323.                             var tr = $.jstree._reference(e.currentTarget), dc;
  2324.                             if(tr.data.dnd.foreign) {
  2325.                                 dc = tr._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
  2326.                                 if(dc === true || dc.inside === true || dc.before === true || dc.after === true) {
  2327.                                     tr._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
  2328.                                 }
  2329.                             }
  2330.                             else {
  2331.                                 tr.move_node(o, tr.get_container(), "last", e[tr._get_settings().dnd.copy_modifier + "Key"]);
  2332.                             }
  2333.                         }
  2334.                     }, this))
  2335.                 .bind("mouseleave.jstree", $.proxy(function (e) {
  2336.                         if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
  2337.                             return false; 
  2338.                         }
  2339.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2340.                             if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
  2341.                             if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
  2342.                             if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
  2343.                             if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
  2344.                             if($.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
  2345.                                 $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
  2346.                             }
  2347.                         }
  2348.                     }, this))
  2349.                 .bind("mousemove.jstree", $.proxy(function (e) {
  2350.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2351.                             var cnt = this.get_container()[0];
  2352.  
  2353.                             // Horizontal scroll
  2354.                             if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
  2355.                                 if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
  2356.                                 this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
  2357.                             }
  2358.                             else if(e.pageX - 24 < this.data.dnd.cof.left) {
  2359.                                 if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
  2360.                                 this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= $.vakata.dnd.scroll_spd; }, cnt), 100);
  2361.                             }
  2362.                             else {
  2363.                                 if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
  2364.                             }
  2365.  
  2366.                             // Vertical scroll
  2367.                             if(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
  2368.                                 if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
  2369.                                 this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
  2370.                             }
  2371.                             else if(e.pageY - 24 < this.data.dnd.cof.top) {
  2372.                                 if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
  2373.                                 this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= $.vakata.dnd.scroll_spd; }, cnt), 100);
  2374.                             }
  2375.                             else {
  2376.                                 if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
  2377.                             }
  2378.  
  2379.                         }
  2380.                     }, this))
  2381.                 .bind("scroll.jstree", $.proxy(function (e) { 
  2382.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && m && ml) {
  2383.                             m.hide();
  2384.                             ml.hide();
  2385.                         }
  2386.                     }, this))
  2387.                 .delegate("a", "mousedown.jstree", $.proxy(function (e) { 
  2388.                         if(e.which === 1) {
  2389.                             this.start_drag(e.currentTarget, e);
  2390.                             return false;
  2391.                         }
  2392.                     }, this))
  2393.                 .delegate("a", "mouseenter.jstree", $.proxy(function (e) { 
  2394.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2395.                             this.dnd_enter(e.currentTarget);
  2396.                         }
  2397.                     }, this))
  2398.                 .delegate("a", "mousemove.jstree", $.proxy(function (e) { 
  2399.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2400.                             if(!r || !r.length || r.children("a")[0] !== e.currentTarget) {
  2401.                                 this.dnd_enter(e.currentTarget);
  2402.                             }
  2403.                             if(typeof this.data.dnd.off.top === "undefined") { this.data.dnd.off = $(e.target).offset(); }
  2404.                             this.data.dnd.w = (e.pageY - (this.data.dnd.off.top || 0)) % this.data.core.li_height;
  2405.                             if(this.data.dnd.w < 0) { this.data.dnd.w += this.data.core.li_height; }
  2406.                             this.dnd_show();
  2407.                         }
  2408.                     }, this))
  2409.                 .delegate("a", "mouseleave.jstree", $.proxy(function (e) { 
  2410.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2411.                             if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
  2412.                                 return false; 
  2413.                             }
  2414.                                 if(m) { m.hide(); }
  2415.                                 if(ml) { ml.hide(); }
  2416.                             /*
  2417.                             var ec = $(e.currentTarget).closest("li"), 
  2418.                                 er = $(e.relatedTarget).closest("li");
  2419.                             if(er[0] !== ec.prev()[0] && er[0] !== ec.next()[0]) {
  2420.                                 if(m) { m.hide(); }
  2421.                                 if(ml) { ml.hide(); }
  2422.                             }
  2423.                             */
  2424.                             this.data.dnd.mto = setTimeout( 
  2425.                                 (function (t) { return function () { t.dnd_leave(e); }; })(this),
  2426.                             0);
  2427.                         }
  2428.                     }, this))
  2429.                 .delegate("a", "mouseup.jstree", $.proxy(function (e) { 
  2430.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
  2431.                             this.dnd_finish(e);
  2432.                         }
  2433.                     }, this));
  2434.  
  2435.             $(document)
  2436.                 .bind("drag_stop.vakata", $.proxy(function () {
  2437.                         if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
  2438.                         if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
  2439.                         if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
  2440.                         if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
  2441.                         this.data.dnd.after        = false;
  2442.                         this.data.dnd.before    = false;
  2443.                         this.data.dnd.inside    = false;
  2444.                         this.data.dnd.off        = false;
  2445.                         this.data.dnd.prepared    = false;
  2446.                         this.data.dnd.w            = false;
  2447.                         this.data.dnd.to1        = false;
  2448.                         this.data.dnd.to2        = false;
  2449.                         this.data.dnd.i1        = false;
  2450.                         this.data.dnd.i2        = false;
  2451.                         this.data.dnd.active    = false;
  2452.                         this.data.dnd.foreign    = false;
  2453.                         if(m) { m.css({ "top" : "-2000px" }); }
  2454.                         if(ml) { ml.css({ "top" : "-2000px" }); }
  2455.                     }, this))
  2456.                 .bind("drag_start.vakata", $.proxy(function (e, data) {
  2457.                         if(data.data.jstree) { 
  2458.                             var et = $(data.event.target);
  2459.                             if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
  2460.                                 this.dnd_enter(et);
  2461.                             }
  2462.                         }
  2463.                     }, this));
  2464.                 /*
  2465.                 .bind("keydown.jstree-" + this.get_index() + " keyup.jstree-" + this.get_index(), $.proxy(function(e) {
  2466.                         if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && !this.data.dnd.foreign) {
  2467.                             var h = $.vakata.dnd.helper.children("ins");
  2468.                             if(e[this._get_settings().dnd.copy_modifier + "Key"] && h.hasClass("jstree-ok")) {
  2469.                                 h.parent().html(h.parent().html().replace(/ \(Copy\)$/, "") + " (Copy)");
  2470.                             } 
  2471.                             else {
  2472.                                 h.parent().html(h.parent().html().replace(/ \(Copy\)$/, ""));
  2473.                             }
  2474.                         }
  2475.                     }, this)); */
  2476.  
  2477.  
  2478.  
  2479.             var s = this._get_settings().dnd;
  2480.             if(s.drag_target) {
  2481.                 $(document)
  2482.                     .delegate(s.drag_target, "mousedown.jstree-" + this.get_index(), $.proxy(function (e) {
  2483.                         o = e.target;
  2484.                         $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
  2485.                         if(this.data.themes) { 
  2486.                             if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
  2487.                             if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
  2488.                             $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme); 
  2489.                         }
  2490.                         $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
  2491.                         var cnt = this.get_container();
  2492.                         this.data.dnd.cof = cnt.offset();
  2493.                         this.data.dnd.cw = parseInt(cnt.width(),10);
  2494.                         this.data.dnd.ch = parseInt(cnt.height(),10);
  2495.                         this.data.dnd.foreign = true;
  2496.                         e.preventDefault();
  2497.                     }, this));
  2498.             }
  2499.             if(s.drop_target) {
  2500.                 $(document)
  2501.                     .delegate(s.drop_target, "mouseenter.jstree-" + this.get_index(), $.proxy(function (e) {
  2502.                             if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target), "e" : e })) {
  2503.                                 $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
  2504.                             }
  2505.                         }, this))
  2506.                     .delegate(s.drop_target, "mouseleave.jstree-" + this.get_index(), $.proxy(function (e) {
  2507.                             if(this.data.dnd.active) {
  2508.                                 $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
  2509.                             }
  2510.                         }, this))
  2511.                     .delegate(s.drop_target, "mouseup.jstree-" + this.get_index(), $.proxy(function (e) {
  2512.                             if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
  2513.                                 this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target), "e" : e });
  2514.                             }
  2515.                         }, this));
  2516.             }
  2517.         },
  2518.         defaults : {
  2519.             copy_modifier    : "ctrl",
  2520.             check_timeout    : 100,
  2521.             open_timeout    : 500,
  2522.             drop_target        : ".jstree-drop",
  2523.             drop_check        : function (data) { return true; },
  2524.             drop_finish        : $.noop,
  2525.             drag_target        : ".jstree-draggable",
  2526.             drag_finish        : $.noop,
  2527.             drag_check        : function (data) { return { after : false, before : false, inside : true }; }
  2528.         },
  2529.         _fn : {
  2530.             dnd_prepare : function () {
  2531.                 if(!r || !r.length) { return; }
  2532.                 this.data.dnd.off = r.offset();
  2533.                 if(this._get_settings().core.rtl) {
  2534.                     this.data.dnd.off.right = this.data.dnd.off.left + r.width();
  2535.                 }
  2536.                 if(this.data.dnd.foreign) {
  2537.                     var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
  2538.                     this.data.dnd.after = a.after;
  2539.                     this.data.dnd.before = a.before;
  2540.                     this.data.dnd.inside = a.inside;
  2541.                     this.data.dnd.prepared = true;
  2542.                     return this.dnd_show();
  2543.                 }
  2544.                 this.prepare_move(o, r, "before");
  2545.                 this.data.dnd.before = this.check_move();
  2546.                 this.prepare_move(o, r, "after");
  2547.                 this.data.dnd.after = this.check_move();
  2548.                 if(this._is_loaded(r)) {
  2549.                     this.prepare_move(o, r, "inside");
  2550.                     this.data.dnd.inside = this.check_move();
  2551.                 }
  2552.                 else {
  2553.                     this.data.dnd.inside = false;
  2554.                 }
  2555.                 this.data.dnd.prepared = true;
  2556.                 return this.dnd_show();
  2557.             },
  2558.             dnd_show : function () {
  2559.                 if(!this.data.dnd.prepared) { return; }
  2560.                 var o = ["before","inside","after"],
  2561.                     r = false,
  2562.                     rtl = this._get_settings().core.rtl,
  2563.                     pos;
  2564.                 if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
  2565.                 else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
  2566.                     o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
  2567.                 }
  2568.                 else { o = ["after","inside","before"]; }
  2569.                 $.each(o, $.proxy(function (i, val) { 
  2570.                     if(this.data.dnd[val]) {
  2571.                         $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
  2572.                         r = val;
  2573.                         return false;
  2574.                     }
  2575.                 }, this));
  2576.                 if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
  2577.                 
  2578.                 pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
  2579.                 switch(r) {
  2580.                     case "before":
  2581.                         m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
  2582.                         if(ml) { ml.css({ "left" : (pos + 8) + "px", "top" : (this.data.dnd.off.top - 1) + "px" }).show(); }
  2583.                         break;
  2584.                     case "after":
  2585.                         m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 6) + "px" }).show();
  2586.                         if(ml) { ml.css({ "left" : (pos + 8) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 1) + "px" }).show(); }
  2587.                         break;
  2588.                     case "inside":
  2589.                         m.css({ "left" : pos + ( rtl ? -4 : 4) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
  2590.                         if(ml) { ml.hide(); }
  2591.                         break;
  2592.                     default:
  2593.                         m.hide();
  2594.                         if(ml) { ml.hide(); }
  2595.                         break;
  2596.                 }
  2597.                 last_pos = r;
  2598.                 return r;
  2599.             },
  2600.             dnd_open : function () {
  2601.                 this.data.dnd.to2 = false;
  2602.                 this.open_node(r, $.proxy(this.dnd_prepare,this), true);
  2603.             },
  2604.             dnd_finish : function (e) {
  2605.                 if(this.data.dnd.foreign) {
  2606.                     if(this.data.dnd.after || this.data.dnd.before || this.data.dnd.inside) {
  2607.                         this._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : r, "p" : last_pos });
  2608.                     }
  2609.                 }
  2610.                 else {
  2611.                     this.dnd_prepare();
  2612.                     this.move_node(o, r, last_pos, e[this._get_settings().dnd.copy_modifier + "Key"]);
  2613.                 }
  2614.                 o = false;
  2615.                 r = false;
  2616.                 m.hide();
  2617.                 if(ml) { ml.hide(); }
  2618.             },
  2619.             dnd_enter : function (obj) {
  2620.                 if(this.data.dnd.mto) { 
  2621.                     clearTimeout(this.data.dnd.mto);
  2622.                     this.data.dnd.mto = false;
  2623.                 }
  2624.                 var s = this._get_settings().dnd;
  2625.                 this.data.dnd.prepared = false;
  2626.                 r = this._get_node(obj);
  2627.                 if(s.check_timeout) { 
  2628.                     // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
  2629.                     if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
  2630.                     this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout); 
  2631.                 }
  2632.                 else { 
  2633.                     this.dnd_prepare(); 
  2634.                 }
  2635.                 if(s.open_timeout) { 
  2636.                     if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
  2637.                     if(r && r.length && r.hasClass("jstree-closed")) { 
  2638.                         // if the node is closed - open it, then recalculate
  2639.                         this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
  2640.                     }
  2641.                 }
  2642.                 else {
  2643.                     if(r && r.length && r.hasClass("jstree-closed")) { 
  2644.                         this.dnd_open();
  2645.                     }
  2646.                 }
  2647.             },
  2648.             dnd_leave : function (e) {
  2649.                 this.data.dnd.after        = false;
  2650.                 this.data.dnd.before    = false;
  2651.                 this.data.dnd.inside    = false;
  2652.                 $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
  2653.                 m.hide();
  2654.                 if(ml) { ml.hide(); }
  2655.                 if(r && r[0] === e.target.parentNode) {
  2656.                     if(this.data.dnd.to1) {
  2657.                         clearTimeout(this.data.dnd.to1);
  2658.                         this.data.dnd.to1 = false;
  2659.                     }
  2660.                     if(this.data.dnd.to2) {
  2661.                         clearTimeout(this.data.dnd.to2);
  2662.                         this.data.dnd.to2 = false;
  2663.                     }
  2664.                 }
  2665.             },
  2666.             start_drag : function (obj, e) {
  2667.                 o = this._get_node(obj);
  2668.                 if(this.data.ui && this.is_selected(o)) { o = this._get_node(null, true); }
  2669.                 var dt = o.length > 1 ? this._get_string("multiple_selection") : this.get_text(o),
  2670.                     cnt = this.get_container();
  2671.                 if(!this._get_settings().core.html_titles) { dt = dt.replace(/</ig,"<").replace(/>/ig,">"); }
  2672.                 $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + dt );
  2673.                 if(this.data.themes) { 
  2674.                     if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
  2675.                     if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
  2676.                     $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme); 
  2677.                 }
  2678.                 this.data.dnd.cof = cnt.offset();
  2679.                 this.data.dnd.cw = parseInt(cnt.width(),10);
  2680.                 this.data.dnd.ch = parseInt(cnt.height(),10);
  2681.                 this.data.dnd.active = true;
  2682.             }
  2683.         }
  2684.     });
  2685.     $(function() {
  2686.         var css_string = '' + 
  2687.             '#vakata-dragged ins { display:block; text-decoration:none; width:16px; height:16px; margin:0 0 0 0; padding:0; position:absolute; top:4px; left:4px; ' + 
  2688.             ' -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; ' +
  2689.             '} ' + 
  2690.             '#vakata-dragged .jstree-ok { background:green; } ' + 
  2691.             '#vakata-dragged .jstree-invalid { background:red; } ' + 
  2692.             '#jstree-marker { padding:0; margin:0; font-size:12px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10001; background-repeat:no-repeat; display:none; background-color:transparent; text-shadow:1px 1px 1px white; color:black; line-height:10px; } ' + 
  2693.             '#jstree-marker-line { padding:0; margin:0; line-height:0%; font-size:1px; overflow:hidden; height:1px; width:100px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:#456c43; ' + 
  2694.             ' cursor:pointer; border:1px solid #eeeeee; border-left:0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666; ' + 
  2695.             ' -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; ' +
  2696.             '}' + 
  2697.             '';
  2698.         $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
  2699.         m = $("<div />").attr({ id : "jstree-marker" }).hide().html("»")
  2700.             .bind("mouseleave mouseenter", function (e) { 
  2701.                 m.hide();
  2702.                 ml.hide();
  2703.                 e.preventDefault(); 
  2704.                 e.stopImmediatePropagation(); 
  2705.                 return false; 
  2706.             })
  2707.             .appendTo("body");
  2708.         ml = $("<div />").attr({ id : "jstree-marker-line" }).hide()
  2709.             .bind("mouseup", function (e) { 
  2710.                 if(r && r.length) { 
  2711.                     r.children("a").trigger(e); 
  2712.                     e.preventDefault(); 
  2713.                     e.stopImmediatePropagation(); 
  2714.                     return false; 
  2715.                 } 
  2716.             })
  2717.             .bind("mouseleave", function (e) { 
  2718.                 var rt = $(e.relatedTarget);
  2719.                 if(rt.is(".jstree") || rt.closest(".jstree").length === 0) {
  2720.                     if(r && r.length) { 
  2721.                         r.children("a").trigger(e); 
  2722.                         m.hide();
  2723.                         ml.hide();
  2724.                         e.preventDefault(); 
  2725.                         e.stopImmediatePropagation(); 
  2726.                         return false; 
  2727.                     }
  2728.                 }
  2729.             })
  2730.             .appendTo("body");
  2731.         $(document).bind("drag_start.vakata", function (e, data) {
  2732.             if(data.data.jstree) { m.show(); if(ml) { ml.show(); } }
  2733.         });
  2734.         $(document).bind("drag_stop.vakata", function (e, data) {
  2735.             if(data.data.jstree) { m.hide(); if(ml) { ml.hide(); } }
  2736.         });
  2737.     });
  2738. })(jQuery);
  2739. //*/
  2740.  
  2741. /*
  2742.  * jsTree checkbox plugin
  2743.  * Inserts checkboxes in front of every node
  2744.  * Depends on the ui plugin
  2745.  * DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
  2746.  */
  2747. (function ($) {
  2748.     $.jstree.plugin("checkbox", {
  2749.         __init : function () {
  2750.             this.data.checkbox.noui = this._get_settings().checkbox.override_ui;
  2751.             if(this.data.ui && this.data.checkbox.noui) {
  2752.                 this.select_node = this.deselect_node = this.deselect_all = $.noop;
  2753.                 this.get_selected = this.get_checked;
  2754.             }
  2755.  
  2756.             this.get_container()
  2757.                 .bind("open_node.jstree create_node.jstree clean_node.jstree refresh.jstree", $.proxy(function (e, data) { 
  2758.                         this._prepare_checkboxes(data.rslt.obj);
  2759.                     }, this))
  2760.                 .bind("loaded.jstree", $.proxy(function (e) {
  2761.                         this._prepare_checkboxes();
  2762.                     }, this))
  2763.                 .delegate( (this.data.ui && this.data.checkbox.noui ? "a" : "ins.jstree-checkbox") , "click.jstree", $.proxy(function (e) {
  2764.                         e.preventDefault();
  2765.                         if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
  2766.                         else { this.check_node(e.target); }
  2767.                         if(this.data.ui && this.data.checkbox.noui) {
  2768.                             this.save_selected();
  2769.                             if(this.data.cookies) { this.save_cookie("select_node"); }
  2770.                         }
  2771.                         else {
  2772.                             e.stopImmediatePropagation();
  2773.                             return false;
  2774.                         }
  2775.                     }, this));
  2776.         },
  2777.         defaults : {
  2778.             override_ui : false,
  2779.             two_state : false,
  2780.             real_checkboxes : false,
  2781.             checked_parent_open : true,
  2782.             real_checkboxes_names : function (n) { return [ ("check_" + (n[0].id || Math.ceil(Math.random() * 10000))) , 1]; }
  2783.         },
  2784.         __destroy : function () {
  2785.             this.get_container()
  2786.                 .find("input.jstree-real-checkbox").removeClass("jstree-real-checkbox").end()
  2787.                 .find("ins.jstree-checkbox").remove();
  2788.         },
  2789.         _fn : {
  2790.             _checkbox_notify : function (n, data) {
  2791.                 if(data.checked) {
  2792.                     this.check_node(n, false);
  2793.                 }
  2794.             },
  2795.             _prepare_checkboxes : function (obj) {
  2796.                 obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj);
  2797.                 if(obj === false) { return; } // added for removing root nodes
  2798.                 var c, _this = this, t, ts = this._get_settings().checkbox.two_state, rc = this._get_settings().checkbox.real_checkboxes, rcn = this._get_settings().checkbox.real_checkboxes_names;
  2799.                 obj.each(function () {
  2800.                     t = $(this);
  2801.                     c = t.is("li") && (t.hasClass("jstree-checked") || (rc && t.children(":checked").length)) ? "jstree-checked" : "jstree-unchecked";
  2802.                     t.find("li").andSelf().each(function () {
  2803.                         var $t = $(this), nm;
  2804.                         $t.children("a" + (_this.data.languages ? "" : ":eq(0)") ).not(":has(.jstree-checkbox)").prepend("<ins class='jstree-checkbox'> </ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass( ts ? "jstree-unchecked" : c );
  2805.                         if(rc) {
  2806.                             if(!$t.children(":checkbox").length) {
  2807.                                 nm = rcn.call(_this, $t);
  2808.                                 $t.prepend("<input type='checkbox' class='jstree-real-checkbox' id='" + nm[0] + "' name='" + nm[0] + "' value='" + nm[1] + "' />");
  2809.                             }
  2810.                             else {
  2811.                                 $t.children(":checkbox").addClass("jstree-real-checkbox");
  2812.                             }
  2813.                             if(c === "jstree-checked") { 
  2814.                                 $t.children(":checkbox").attr("checked","checked"); 
  2815.                             }
  2816.                         }
  2817.                         if(c === "jstree-checked" && !ts) {
  2818.                             $t.find("li").addClass("jstree-checked");
  2819.                         }
  2820.                     });
  2821.                 });
  2822.                 if(!ts) {
  2823.                     if(obj.length === 1 && obj.is("li")) { this._repair_state(obj); }
  2824.                     if(obj.is("li")) { obj.each(function () { _this._repair_state(this); }); }
  2825.                     else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
  2826.                     obj.find(".jstree-checked").parent().parent().each(function () { _this._repair_state(this); }); 
  2827.                 }
  2828.             },
  2829.             change_state : function (obj, state) {
  2830.                 obj = this._get_node(obj);
  2831.                 var coll = false, rc = this._get_settings().checkbox.real_checkboxes;
  2832.                 if(!obj || obj === -1) { return false; }
  2833.                 state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
  2834.                 if(this._get_settings().checkbox.two_state) {
  2835.                     if(state) { 
  2836.                         obj.removeClass("jstree-checked").addClass("jstree-unchecked"); 
  2837.                         if(rc) { obj.children(":checkbox").removeAttr("checked"); }
  2838.                     }
  2839.                     else { 
  2840.                         obj.removeClass("jstree-unchecked").addClass("jstree-checked"); 
  2841.                         if(rc) { obj.children(":checkbox").attr("checked","checked"); }
  2842.                     }
  2843.                 }
  2844.                 else {
  2845.                     if(state) { 
  2846.                         coll = obj.find("li").andSelf();
  2847.                         if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; }
  2848.                         coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); 
  2849.                         if(rc) { coll.children(":checkbox").removeAttr("checked"); }
  2850.                     }
  2851.                     else { 
  2852.                         coll = obj.find("li").andSelf();
  2853.                         if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; }
  2854.                         coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked"); 
  2855.                         if(rc) { coll.children(":checkbox").attr("checked","checked"); }
  2856.                         if(this.data.ui) { this.data.ui.last_selected = obj; }
  2857.                         this.data.checkbox.last_selected = obj;
  2858.                     }
  2859.                     obj.parentsUntil(".jstree", "li").each(function () {
  2860.                         var $this = $(this);
  2861.                         if(state) {
  2862.                             if($this.children("ul").children("li.jstree-checked, li.jstree-undetermined").length) {
  2863.                                 $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
  2864.                                 if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
  2865.                                 return false;
  2866.                             }
  2867.                             else {
  2868.                                 $this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
  2869.                                 if(rc) { $this.children(":checkbox").removeAttr("checked"); }
  2870.                             }
  2871.                         }
  2872.                         else {
  2873.                             if($this.children("ul").children("li.jstree-unchecked, li.jstree-undetermined").length) {
  2874.                                 $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
  2875.                                 if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
  2876.                                 return false;
  2877.                             }
  2878.                             else {
  2879.                                 $this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
  2880.                                 if(rc) { $this.children(":checkbox").attr("checked","checked"); }
  2881.                             }
  2882.                         }
  2883.                     });
  2884.                 }
  2885.                 if(this.data.ui && this.data.checkbox.noui) { this.data.ui.selected = this.get_checked(); }
  2886.                 this.__callback(obj);
  2887.                 return true;
  2888.             },
  2889.             check_node : function (obj) {
  2890.                 if(this.change_state(obj, false)) { 
  2891.                     obj = this._get_node(obj);
  2892.                     if(this._get_settings().checkbox.checked_parent_open) {
  2893.                         var t = this;
  2894.                         obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
  2895.                     }
  2896.                     this.__callback({ "obj" : obj }); 
  2897.                 }
  2898.             },
  2899.             uncheck_node : function (obj) {
  2900.                 if(this.change_state(obj, true)) { this.__callback({ "obj" : this._get_node(obj) }); }
  2901.             },
  2902.             check_all : function () {
  2903.                 var _this = this, 
  2904.                     coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
  2905.                 coll.each(function () {
  2906.                     _this.change_state(this, false);
  2907.                 });
  2908.                 this.__callback();
  2909.             },
  2910.             uncheck_all : function () {
  2911.                 var _this = this,
  2912.                     coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
  2913.                 coll.each(function () {
  2914.                     _this.change_state(this, true);
  2915.                 });
  2916.                 this.__callback();
  2917.             },
  2918.  
  2919.             is_checked : function(obj) {
  2920.                 obj = this._get_node(obj);
  2921.                 return obj.length ? obj.is(".jstree-checked") : false;
  2922.             },
  2923.             get_checked : function (obj, get_all) {
  2924.                 obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
  2925.                 return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-checked") : obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
  2926.             },
  2927.             get_unchecked : function (obj, get_all) { 
  2928.                 obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
  2929.                 return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-unchecked") : obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
  2930.             },
  2931.  
  2932.             show_checkboxes : function () { this.get_container().children("ul").removeClass("jstree-no-checkboxes"); },
  2933.             hide_checkboxes : function () { this.get_container().children("ul").addClass("jstree-no-checkboxes"); },
  2934.  
  2935.             _repair_state : function (obj) {
  2936.                 obj = this._get_node(obj);
  2937.                 if(!obj.length) { return; }
  2938.                 var rc = this._get_settings().checkbox.real_checkboxes,
  2939.                     a = obj.find("> ul > .jstree-checked").length,
  2940.                     b = obj.find("> ul > .jstree-undetermined").length,
  2941.                     c = obj.find("> ul > li").length;
  2942.                 if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.change_state(obj, false); } }
  2943.                 else if(a === 0 && b === 0) { this.change_state(obj, true); }
  2944.                 else if(a === c) { this.change_state(obj, false); }
  2945.                 else { 
  2946.                     obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
  2947.                     if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
  2948.                 }
  2949.             },
  2950.             reselect : function () {
  2951.                 if(this.data.ui && this.data.checkbox.noui) { 
  2952.                     var _this = this,
  2953.                         s = this.data.ui.to_select;
  2954.                     s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
  2955.                     this.deselect_all();
  2956.                     $.each(s, function (i, val) { _this.check_node(val); });
  2957.                     this.__callback();
  2958.                 }
  2959.                 else { 
  2960.                     this.__call_old(); 
  2961.                 }
  2962.             },
  2963.             save_loaded : function () {
  2964.                 var _this = this;
  2965.                 this.data.core.to_load = [];
  2966.                 this.get_container_ul().find("li.jstree-closed.jstree-undetermined").each(function () {
  2967.                     if(this.id) { _this.data.core.to_load.push("#" + this.id); }
  2968.                 });
  2969.             }
  2970.         }
  2971.     });
  2972.     $(function() {
  2973.         var css_string = '.jstree .jstree-real-checkbox { display:none; } ';
  2974.         $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
  2975.     });
  2976. })(jQuery);
  2977. //*/
  2978.  
  2979. /* 
  2980.  * jsTree XML plugin
  2981.  * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
  2982.  */
  2983. (function ($) {
  2984.     $.vakata.xslt = function (xml, xsl, callback) {
  2985.         var rs = "", xm, xs, processor, support;
  2986.         // TODO: IE9 no XSLTProcessor, no document.recalc
  2987.         if(document.recalc) {
  2988.             xm = document.createElement('xml');
  2989.             xs = document.createElement('xml');
  2990.             xm.innerHTML = xml;
  2991.             xs.innerHTML = xsl;
  2992.             $("body").append(xm).append(xs);
  2993.             setTimeout( (function (xm, xs, callback) {
  2994.                 return function () {
  2995.                     callback.call(null, xm.transformNode(xs.XMLDocument));
  2996.                     setTimeout( (function (xm, xs) { return function () { $(xm).remove(); $(xs).remove(); }; })(xm, xs), 200);
  2997.                 };
  2998.             })(xm, xs, callback), 100);
  2999.             return true;
  3000.         }
  3001.         if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor === "undefined") {
  3002.             xml = new DOMParser().parseFromString(xml, "text/xml");
  3003.             xsl = new DOMParser().parseFromString(xsl, "text/xml");
  3004.             // alert(xml.transformNode());
  3005.             // callback.call(null, new XMLSerializer().serializeToString(rs));
  3006.             
  3007.         }
  3008.         if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
  3009.             processor = new XSLTProcessor();
  3010.             support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
  3011.             if(!support) { return false; }
  3012.             xml = new DOMParser().parseFromString(xml, "text/xml");
  3013.             xsl = new DOMParser().parseFromString(xsl, "text/xml");
  3014.             if($.isFunction(processor.transformDocument)) {
  3015.                 rs = document.implementation.createDocument("", "", null);
  3016.                 processor.transformDocument(xml, xsl, rs, null);
  3017.                 callback.call(null, new XMLSerializer().serializeToString(rs));
  3018.                 return true;
  3019.             }
  3020.             else {
  3021.                 processor.importStylesheet(xsl);
  3022.                 rs = processor.transformToFragment(xml, document);
  3023.                 callback.call(null, $("<div />").append(rs).html());
  3024.                 return true;
  3025.             }
  3026.         }
  3027.         return false;
  3028.     };
  3029.     var xsl = {
  3030.         'nest' : '<' + '?xml version="1.0" encoding="utf-8" ?<?vlc print '>'?>' +
  3031.             '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' + 
  3032.             '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' + 
  3033.             '<xsl:template match="/">' + 
  3034.             '    <xsl:call-template name="nodes">' + 
  3035.             '        <xsl:with-param name="node" select="/root" />' + 
  3036.             '    </xsl:call-template>' + 
  3037.             '</xsl:template>' + 
  3038.             '<xsl:template name="nodes">' + 
  3039.             '    <xsl:param name="node" />' + 
  3040.             '    <ul>' + 
  3041.             '    <xsl:for-each select="$node/item">' + 
  3042.             '        <xsl:variable name="children" select="count(./item) > 0" />' + 
  3043.             '        <li>' + 
  3044.             '            <xsl:attribute name="class">' + 
  3045.             '                <xsl:if test="position() = last()">jstree-last </xsl:if>' + 
  3046.             '                <xsl:choose>' + 
  3047.             '                    <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' + 
  3048.             '                    <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' + 
  3049.             '                    <xsl:otherwise>jstree-leaf </xsl:otherwise>' + 
  3050.             '                </xsl:choose>' + 
  3051.             '                <xsl:value-of select="@class" />' + 
  3052.             '            </xsl:attribute>' + 
  3053.             '            <xsl:for-each select="@*">' + 
  3054.             '                <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' + 
  3055.             '                    <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' + 
  3056.             '                </xsl:if>' + 
  3057.             '            </xsl:for-each>' + 
  3058.             '    <ins class="jstree-icon"><xsl:text> </xsl:text></ins>' + 
  3059.             '            <xsl:for-each select="content/name">' + 
  3060.             '                <a>' + 
  3061.             '                <xsl:attribute name="href">' + 
  3062.             '                    <xsl:choose>' + 
  3063.             '                    <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' + 
  3064.             '                    <xsl:otherwise>#</xsl:otherwise>' + 
  3065.             '                    </xsl:choose>' + 
  3066.             '                </xsl:attribute>' + 
  3067.             '                <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' + 
  3068.             '                <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' + 
  3069.             '                <xsl:for-each select="@*">' + 
  3070.             '                    <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' + 
  3071.             '                        <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' + 
  3072.             '                    </xsl:if>' + 
  3073.             '                </xsl:for-each>' + 
  3074.             '                    <ins>' + 
  3075.             '                        <xsl:attribute name="class">jstree-icon ' + 
  3076.             '                            <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' + 
  3077.             '                        </xsl:attribute>' + 
  3078.             '                        <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' + 
  3079.             '                        <xsl:text> </xsl:text>' + 
  3080.             '                    </ins>' + 
  3081.             '                    <xsl:copy-of select="./child::node()" />' + 
  3082.             '                </a>' + 
  3083.             '            </xsl:for-each>' + 
  3084.             '            <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' + 
  3085.             '        </li>' + 
  3086.             '    </xsl:for-each>' + 
  3087.             '    </ul>' + 
  3088.             '</xsl:template>' + 
  3089.             '</xsl:stylesheet>',
  3090.  
  3091.         'flat' : '<' + '?xml version="1.0" encoding="utf-8" ?<?vlc print '>'?>' +
  3092.             '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' + 
  3093.             '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' + 
  3094.             '<xsl:template match="/">' + 
  3095.             '    <ul>' + 
  3096.             '    <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
  3097.             '        <xsl:call-template name="nodes">' + 
  3098.             '            <xsl:with-param name="node" select="." />' + 
  3099.             '            <xsl:with-param name="is_last" select="number(position() = last())" />' + 
  3100.             '        </xsl:call-template>' + 
  3101.             '    </xsl:for-each>' + 
  3102.             '    </ul>' + 
  3103.             '</xsl:template>' + 
  3104.             '<xsl:template name="nodes">' + 
  3105.             '    <xsl:param name="node" />' + 
  3106.             '    <xsl:param name="is_last" />' + 
  3107.             '    <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) > 0" />' + 
  3108.             '    <li>' + 
  3109.             '    <xsl:attribute name="class">' + 
  3110.             '        <xsl:if test="$is_last = true()">jstree-last </xsl:if>' + 
  3111.             '        <xsl:choose>' + 
  3112.             '            <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' + 
  3113.             '            <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' + 
  3114.             '            <xsl:otherwise>jstree-leaf </xsl:otherwise>' + 
  3115.             '        </xsl:choose>' + 
  3116.             '        <xsl:value-of select="@class" />' + 
  3117.             '    </xsl:attribute>' + 
  3118.             '    <xsl:for-each select="@*">' + 
  3119.             '        <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' + 
  3120.             '        <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' + 
  3121.             '        </xsl:if>' + 
  3122.             '    </xsl:for-each>' + 
  3123.             '    <ins class="jstree-icon"><xsl:text> </xsl:text></ins>' + 
  3124.             '    <xsl:for-each select="content/name">' + 
  3125.             '        <a>' + 
  3126.             '        <xsl:attribute name="href">' + 
  3127.             '            <xsl:choose>' + 
  3128.             '            <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' + 
  3129.             '            <xsl:otherwise>#</xsl:otherwise>' + 
  3130.             '            </xsl:choose>' + 
  3131.             '        </xsl:attribute>' + 
  3132.             '        <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' + 
  3133.             '        <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' + 
  3134.             '        <xsl:for-each select="@*">' + 
  3135.             '            <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' + 
  3136.             '                <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' + 
  3137.             '            </xsl:if>' + 
  3138.             '        </xsl:for-each>' + 
  3139.             '            <ins>' + 
  3140.             '                <xsl:attribute name="class">jstree-icon ' + 
  3141.             '                    <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' + 
  3142.             '                </xsl:attribute>' + 
  3143.             '                <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' + 
  3144.             '                <xsl:text> </xsl:text>' + 
  3145.             '            </ins>' + 
  3146.             '            <xsl:copy-of select="./child::node()" />' + 
  3147.             '        </a>' + 
  3148.             '    </xsl:for-each>' + 
  3149.             '    <xsl:if test="$children">' + 
  3150.             '        <ul>' + 
  3151.             '        <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' + 
  3152.             '            <xsl:call-template name="nodes">' + 
  3153.             '                <xsl:with-param name="node" select="." />' + 
  3154.             '                <xsl:with-param name="is_last" select="number(position() = last())" />' + 
  3155.             '            </xsl:call-template>' + 
  3156.             '        </xsl:for-each>' + 
  3157.             '        </ul>' + 
  3158.             '    </xsl:if>' + 
  3159.             '    </li>' + 
  3160.             '</xsl:template>' + 
  3161.             '</xsl:stylesheet>'
  3162.     },
  3163.     escape_xml = function(string) {
  3164.         return string
  3165.             .toString()
  3166.             .replace(/&/g, '&')
  3167.             .replace(/</g, '<')
  3168.             .replace(/>/g, '>')
  3169.             .replace(/"/g, '"')
  3170.             .replace(/'/g, ''');
  3171.     };
  3172.     $.jstree.plugin("xml_data", {
  3173.         defaults : { 
  3174.             data : false,
  3175.             ajax : false,
  3176.             xsl : "flat",
  3177.             clean_node : false,
  3178.             correct_state : true,
  3179.             get_skip_empty : false,
  3180.             get_include_preamble : true
  3181.         },
  3182.         _fn : {
  3183.             load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
  3184.             _is_loaded : function (obj) { 
  3185.                 var s = this._get_settings().xml_data;
  3186.                 obj = this._get_node(obj);
  3187.                 return obj == -1 || !obj || (!s.ajax && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
  3188.             },
  3189.             load_node_xml : function (obj, s_call, e_call) {
  3190.                 var s = this.get_settings().xml_data,
  3191.                     error_func = function () {},
  3192.                     success_func = function () {};
  3193.  
  3194.                 obj = this._get_node(obj);
  3195.                 if(obj && obj !== -1) {
  3196.                     if(obj.data("jstree-is-loading")) { return; }
  3197.                     else { obj.data("jstree-is-loading",true); }
  3198.                 }
  3199.                 switch(!0) {
  3200.                     case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
  3201.                     case ($.isFunction(s.data)):
  3202.                         s.data.call(this, obj, $.proxy(function (d) {
  3203.                             this.parse_xml(d, $.proxy(function (d) {
  3204.                                 if(d) {
  3205.                                     d = d.replace(/ ?xmlns="[^"]*"/ig, "");
  3206.                                     if(d.length > 10) {
  3207.                                         d = $(d);
  3208.                                         if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
  3209.                                         else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
  3210.                                         if(s.clean_node) { this.clean_node(obj); }
  3211.                                         if(s_call) { s_call.call(this); }
  3212.                                     }
  3213.                                     else {
  3214.                                         if(obj && obj !== -1) { 
  3215.                                             obj.children("a.jstree-loading").removeClass("jstree-loading");
  3216.                                             obj.removeData("jstree-is-loading");
  3217.                                             if(s.correct_state) { 
  3218.                                                 this.correct_state(obj);
  3219.                                                 if(s_call) { s_call.call(this); } 
  3220.                                             }
  3221.                                         }
  3222.                                         else {
  3223.                                             if(s.correct_state) { 
  3224.                                                 this.get_container().children("ul").empty();
  3225.                                                 if(s_call) { s_call.call(this); } 
  3226.                                             }
  3227.                                         }
  3228.                                     }
  3229.                                 }
  3230.                             }, this));
  3231.                         }, this));
  3232.                         break;
  3233.                     case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
  3234.                         if(!obj || obj == -1) {
  3235.                             this.parse_xml(s.data, $.proxy(function (d) {
  3236.                                 if(d) {
  3237.                                     d = d.replace(/ ?xmlns="[^"]*"/ig, "");
  3238.                                     if(d.length > 10) {
  3239.                                         d = $(d);
  3240.                                         this.get_container().children("ul").empty().append(d.children());
  3241.                                         if(s.clean_node) { this.clean_node(obj); }
  3242.                                         if(s_call) { s_call.call(this); }
  3243.                                     }
  3244.                                 }
  3245.                                 else { 
  3246.                                     if(s.correct_state) { 
  3247.                                         this.get_container().children("ul").empty(); 
  3248.                                         if(s_call) { s_call.call(this); }
  3249.                                     }
  3250.                                 }
  3251.                             }, this));
  3252.                         }
  3253.                         break;
  3254.                     case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
  3255.                         error_func = function (x, t, e) {
  3256.                             var ef = this.get_settings().xml_data.ajax.error; 
  3257.                             if(ef) { ef.call(this, x, t, e); }
  3258.                             if(obj !== -1 && obj.length) {
  3259.                                 obj.children("a.jstree-loading").removeClass("jstree-loading");
  3260.                                 obj.removeData("jstree-is-loading");
  3261.                                 if(t === "success" && s.correct_state) { this.correct_state(obj); }
  3262.                             }
  3263.                             else {
  3264.                                 if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
  3265.                             }
  3266.                             if(e_call) { e_call.call(this); }
  3267.                         };
  3268.                         success_func = function (d, t, x) {
  3269.                             d = x.responseText;
  3270.                             var sf = this.get_settings().xml_data.ajax.success; 
  3271.                             if(sf) { d = sf.call(this,d,t,x) || d; }
  3272.                             if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
  3273.                                 return error_func.call(this, x, t, "");
  3274.                             }
  3275.                             this.parse_xml(d, $.proxy(function (d) {
  3276.                                 if(d) {
  3277.                                     d = d.replace(/ ?xmlns="[^"]*"/ig, "");
  3278.                                     if(d.length > 10) {
  3279.                                         d = $(d);
  3280.                                         if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
  3281.                                         else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
  3282.                                         if(s.clean_node) { this.clean_node(obj); }
  3283.                                         if(s_call) { s_call.call(this); }
  3284.                                     }
  3285.                                     else {
  3286.                                         if(obj && obj !== -1) { 
  3287.                                             obj.children("a.jstree-loading").removeClass("jstree-loading");
  3288.                                             obj.removeData("jstree-is-loading");
  3289.                                             if(s.correct_state) { 
  3290.                                                 this.correct_state(obj);
  3291.                                                 if(s_call) { s_call.call(this); } 
  3292.                                             }
  3293.                                         }
  3294.                                         else {
  3295.                                             if(s.correct_state) { 
  3296.                                                 this.get_container().children("ul").empty();
  3297.                                                 if(s_call) { s_call.call(this); } 
  3298.                                             }
  3299.                                         }
  3300.                                     }
  3301.                                 }
  3302.                             }, this));
  3303.                         };
  3304.                         s.ajax.context = this;
  3305.                         s.ajax.error = error_func;
  3306.                         s.ajax.success = success_func;
  3307.                         if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
  3308.                         if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
  3309.                         if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
  3310.                         $.ajax(s.ajax);
  3311.                         break;
  3312.                 }
  3313.             },
  3314.             parse_xml : function (xml, callback) {
  3315.                 var s = this._get_settings().xml_data;
  3316.                 $.vakata.xslt(xml, xsl[s.xsl], callback);
  3317.             },
  3318.             get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
  3319.                 var result = "", 
  3320.                     s = this._get_settings(), 
  3321.                     _this = this,
  3322.                     tmp1, tmp2, li, a, lang;
  3323.                 if(!tp) { tp = "flat"; }
  3324.                 if(!is_callback) { is_callback = 0; }
  3325.                 obj = this._get_node(obj);
  3326.                 if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
  3327.                 li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
  3328.                 if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
  3329.  
  3330.                 a_attr = $.isArray(a_attr) ? a_attr : [ ];
  3331.  
  3332.                 if(!is_callback) { 
  3333.                     if(s.xml_data.get_include_preamble) { 
  3334.                         result += '<' + '?xml version="1.0" encoding="UTF-8"?' + '>'; 
  3335.                     }
  3336.                     result += "<root>"; 
  3337.                 }
  3338.                 obj.each(function () {
  3339.                     result += "<item";
  3340.                     li = $(this);
  3341.                     $.each(li_attr, function (i, v) { 
  3342.                         var t = li.attr(v);
  3343.                         if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
  3344.                             result += " " + v + "=\"" + escape_xml((" " + (t || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"")) + "\""; 
  3345.                         }
  3346.                     });
  3347.                     if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
  3348.                     if(li.hasClass("jstree-closed")) { result += " state=\"closed\""; }
  3349.                     if(tp === "flat") { result += " parent_id=\"" + escape_xml(is_callback) + "\""; }
  3350.                     result += ">";
  3351.                     result += "<content>";
  3352.                     a = li.children("a");
  3353.                     a.each(function () {
  3354.                         tmp1 = $(this);
  3355.                         lang = false;
  3356.                         result += "<name";
  3357.                         if($.inArray("languages", s.plugins) !== -1) {
  3358.                             $.each(s.languages, function (k, z) {
  3359.                                 if(tmp1.hasClass(z)) { result += " lang=\"" + escape_xml(z) + "\""; lang = z; return false; }
  3360.                             });
  3361.                         }
  3362.                         if(a_attr.length) { 
  3363.                             $.each(a_attr, function (k, z) {
  3364.                                 var t = tmp1.attr(z);
  3365.                                 if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
  3366.                                     result += " " + z + "=\"" + escape_xml((" " + t || "").replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"")) + "\"";
  3367.                                 }
  3368.                             });
  3369.                         }
  3370.                         if(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
  3371.                             result += ' icon="' + escape_xml(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"")) + '"';
  3372.                         }
  3373.                         if(tmp1.children("ins").get(0).style.backgroundImage.length) {
  3374.                             result += ' icon="' + escape_xml(tmp1.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","").replace(/'/ig,"").replace(/"/ig,"")) + '"';
  3375.                         }
  3376.                         result += ">";
  3377.                         result += "<![CDATA[" + _this.get_text(tmp1, lang) + "]]>";
  3378.                         result += "</name>";
  3379.                     });
  3380.                     result += "</content>";
  3381.                     tmp2 = li[0].id || true;
  3382.                     li = li.find("> ul > li");
  3383.                     if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
  3384.                     else { tmp2 = ""; }
  3385.                     if(tp == "nest") { result += tmp2; }
  3386.                     result += "</item>";
  3387.                     if(tp == "flat") { result += tmp2; }
  3388.                 });
  3389.                 if(!is_callback) { result += "</root>"; }
  3390.                 return result;
  3391.             }
  3392.         }
  3393.     });
  3394. })(jQuery);
  3395. //*/
  3396.  
  3397. /*
  3398.  * jsTree search plugin
  3399.  * Enables both sync and async search on the tree
  3400.  * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
  3401.  */
  3402. (function ($) {
  3403.     $.expr[':'].jstree_contains = function(a,i,m){
  3404.         return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
  3405.     };
  3406.     $.expr[':'].jstree_title_contains = function(a,i,m) {
  3407.         return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
  3408.     };
  3409.     $.jstree.plugin("search", {
  3410.         __init : function () {
  3411.             this.data.search.str = "";
  3412.             this.data.search.result = $();
  3413.             if(this._get_settings().search.show_only_matches) {
  3414.                 this.get_container()
  3415.                     .bind("search.jstree", function (e, data) {
  3416.                         $(this).children("ul").find("li").hide().removeClass("jstree-last");
  3417.                         data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
  3418.                             .filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); });
  3419.                     })
  3420.                     .bind("clear_search.jstree", function () {
  3421.                         $(this).children("ul").find("li").css("display","").end().end().jstree("clean_node", -1);
  3422.                     });
  3423.             }
  3424.         },
  3425.         defaults : {
  3426.             ajax : false,
  3427.             search_method : "jstree_contains", // for case insensitive - jstree_contains
  3428.             show_only_matches : false
  3429.         },
  3430.         _fn : {
  3431.             search : function (str, skip_async) {
  3432.                 if($.trim(str) === "") { this.clear_search(); return; }
  3433.                 var s = this.get_settings().search, 
  3434.                     t = this,
  3435.                     error_func = function () { },
  3436.                     success_func = function () { };
  3437.                 this.data.search.str = str;
  3438.  
  3439.                 if(!skip_async && s.ajax !== false && this.get_container_ul().find("li.jstree-closed:not(:has(ul)):eq(0)").length > 0) {
  3440.                     this.search.supress_callback = true;
  3441.                     error_func = function () { };
  3442.                     success_func = function (d, t, x) {
  3443.                         var sf = this.get_settings().search.ajax.success; 
  3444.                         if(sf) { d = sf.call(this,d,t,x) || d; }
  3445.                         this.data.search.to_open = d;
  3446.                         this._search_open();
  3447.                     };
  3448.                     s.ajax.context = this;
  3449.                     s.ajax.error = error_func;
  3450.                     s.ajax.success = success_func;
  3451.                     if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, str); }
  3452.                     if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
  3453.                     if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
  3454.                     if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
  3455.                     $.ajax(s.ajax);
  3456.                     return;
  3457.                 }
  3458.                 if(this.data.search.result.length) { this.clear_search(); }
  3459.                 this.data.search.result = this.get_container().find("a" + (this.data.languages ? "." + this.get_lang() : "" ) + ":" + (s.search_method) + "(" + this.data.search.str + ")");
  3460.                 this.data.search.result.addClass("jstree-search").parent().parents(".jstree-closed").each(function () {
  3461.                     t.open_node(this, false, true);
  3462.                 });
  3463.                 this.__callback({ nodes : this.data.search.result, str : str });
  3464.             },
  3465.             clear_search : function (str) {
  3466.                 this.data.search.result.removeClass("jstree-search");
  3467.                 this.__callback(this.data.search.result);
  3468.                 this.data.search.result = $();
  3469.             },
  3470.             _search_open : function (is_callback) {
  3471.                 var _this = this,
  3472.                     done = true,
  3473.                     current = [],
  3474.                     remaining = [];
  3475.                 if(this.data.search.to_open.length) {
  3476.                     $.each(this.data.search.to_open, function (i, val) {
  3477.                         if(val == "#") { return true; }
  3478.                         if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
  3479.                         else { remaining.push(val); }
  3480.                     });
  3481.                     if(current.length) {
  3482.                         this.data.search.to_open = remaining;
  3483.                         $.each(current, function (i, val) { 
  3484.                             _this.open_node(val, function () { _this._search_open(true); }); 
  3485.                         });
  3486.                         done = false;
  3487.                     }
  3488.                 }
  3489.                 if(done) { this.search(this.data.search.str, true); }
  3490.             }
  3491.         }
  3492.     });
  3493. })(jQuery);
  3494. //*/
  3495.  
  3496. /* 
  3497.  * jsTree contextmenu plugin
  3498.  */
  3499. (function ($) {
  3500.     $.vakata.context = {
  3501.         hide_on_mouseleave : false,
  3502.  
  3503.         cnt        : $("<div id='vakata-contextmenu' />"),
  3504.         vis        : false,
  3505.         tgt        : false,
  3506.         par        : false,
  3507.         func    : false,
  3508.         data    : false,
  3509.         rtl        : false,
  3510.         show    : function (s, t, x, y, d, p, rtl) {
  3511.             $.vakata.context.rtl = !!rtl;
  3512.             var html = $.vakata.context.parse(s), h, w;
  3513.             if(!html) { return; }
  3514.             $.vakata.context.vis = true;
  3515.             $.vakata.context.tgt = t;
  3516.             $.vakata.context.par = p || t || null;
  3517.             $.vakata.context.data = d || null;
  3518.             $.vakata.context.cnt
  3519.                 .html(html)
  3520.                 .css({ "visibility" : "hidden", "display" : "block", "left" : 0, "top" : 0 });
  3521.  
  3522.             if($.vakata.context.hide_on_mouseleave) {
  3523.                 $.vakata.context.cnt
  3524.                     .one("mouseleave", function(e) { $.vakata.context.hide(); });
  3525.             }
  3526.  
  3527.             h = $.vakata.context.cnt.height();
  3528.             w = $.vakata.context.cnt.width();
  3529.             if(x + w > $(document).width()) { 
  3530.                 x = $(document).width() - (w + 5); 
  3531.                 $.vakata.context.cnt.find("li > ul").addClass("right"); 
  3532.             }
  3533.             if(y + h > $(document).height()) { 
  3534.                 y = y - (h + t[0].offsetHeight); 
  3535.                 $.vakata.context.cnt.find("li > ul").addClass("bottom"); 
  3536.             }
  3537.  
  3538.             $.vakata.context.cnt
  3539.                 .css({ "left" : x, "top" : y })
  3540.                 .find("li:has(ul)")
  3541.                     .bind("mouseenter", function (e) { 
  3542.                         var w = $(document).width(),
  3543.                             h = $(document).height(),
  3544.                             ul = $(this).children("ul").show(); 
  3545.                         if(w !== $(document).width()) { ul.toggleClass("right"); }
  3546.                         if(h !== $(document).height()) { ul.toggleClass("bottom"); }
  3547.                     })
  3548.                     .bind("mouseleave", function (e) { 
  3549.                         $(this).children("ul").hide(); 
  3550.                     })
  3551.                     .end()
  3552.                 .css({ "visibility" : "visible" })
  3553.                 .show();
  3554.             $(document).triggerHandler("context_show.vakata");
  3555.         },
  3556.         hide    : function () {
  3557.             $.vakata.context.vis = false;
  3558.             $.vakata.context.cnt.attr("class","").css({ "visibility" : "hidden" });
  3559.             $(document).triggerHandler("context_hide.vakata");
  3560.         },
  3561.         parse    : function (s, is_callback) {
  3562.             if(!s) { return false; }
  3563.             var str = "",
  3564.                 tmp = false,
  3565.                 was_sep = true;
  3566.             if(!is_callback) { $.vakata.context.func = {}; }
  3567.             str += "<ul>";
  3568.             $.each(s, function (i, val) {
  3569.                 if(!val) { return true; }
  3570.                 $.vakata.context.func[i] = val.action;
  3571.                 if(!was_sep && val.separator_before) {
  3572.                     str += "<li class='vakata-separator vakata-separator-before'></li>";
  3573.                 }
  3574.                 was_sep = false;
  3575.                 str += "<li class='" + (val._class || "") + (val._disabled ? " jstree-contextmenu-disabled " : "") + "'><ins ";
  3576.                 if(val.icon && val.icon.indexOf("/") === -1) { str += " class='" + val.icon + "' "; }
  3577.                 if(val.icon && val.icon.indexOf("/") !== -1) { str += " style='background:url(" + val.icon + ") center center no-repeat;' "; }
  3578.                 str += "> </ins><a href='#' rel='" + i + "'>";
  3579.                 if(val.submenu) {
  3580.                     str += "<span style='float:" + ($.vakata.context.rtl ? "left" : "right") + ";'>»</span>";
  3581.                 }
  3582.                 str += val.label + "</a>";
  3583.                 if(val.submenu) {
  3584.                     tmp = $.vakata.context.parse(val.submenu, true);
  3585.                     if(tmp) { str += tmp; }
  3586.                 }
  3587.                 str += "</li>";
  3588.                 if(val.separator_after) {
  3589.                     str += "<li class='vakata-separator vakata-separator-after'></li>";
  3590.                     was_sep = true;
  3591.                 }
  3592.             });
  3593.             str = str.replace(/<li class\='vakata-separator vakata-separator-after'\><\/li\>$/,"");
  3594.             str += "</ul>";
  3595.             $(document).triggerHandler("context_parse.vakata");
  3596.             return str.length > 10 ? str : false;
  3597.         },
  3598.         exec    : function (i) {
  3599.             if($.isFunction($.vakata.context.func[i])) {
  3600.                 // if is string - eval and call it!
  3601.                 $.vakata.context.func[i].call($.vakata.context.data, $.vakata.context.par);
  3602.                 return true;
  3603.             }
  3604.             else { return false; }
  3605.         }
  3606.     };
  3607.     $(function () {
  3608.         var css_string = '' + 
  3609.             '#vakata-contextmenu { display:block; visibility:hidden; left:0; top:-200px; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' + 
  3610.             '#vakata-contextmenu ul { min-width:180px; *width:180px; } ' + 
  3611.             '#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' + 
  3612.             '#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' + 
  3613.             '#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' + 
  3614.             '#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' + 
  3615.             '#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' + 
  3616.             '#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' + 
  3617.             '#vakata-contextmenu .right { right:100%; left:auto; } ' + 
  3618.             '#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' + 
  3619.             '#vakata-contextmenu li.vakata-separator { min-height:0; height:1px; line-height:1px; font-size:1px; overflow:hidden; margin:0 2px; background:silver; /* border-top:1px solid #fefefe; */ padding:0; } ';
  3620.         $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
  3621.         $.vakata.context.cnt
  3622.             .delegate("a","click", function (e) { e.preventDefault(); })
  3623.             .delegate("a","mouseup", function (e) {
  3624.                 if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
  3625.                     $.vakata.context.hide();
  3626.                 }
  3627.                 else { $(this).blur(); }
  3628.             })
  3629.             .delegate("a","mouseover", function () {
  3630.                 $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
  3631.             })
  3632.             .appendTo("body");
  3633.         $(document).bind("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
  3634.         if(typeof $.hotkeys !== "undefined") {
  3635.             $(document)
  3636.                 .bind("keydown", "up", function (e) { 
  3637.                     if($.vakata.context.vis) { 
  3638.                         var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
  3639.                         if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
  3640.                         o.addClass("vakata-hover");
  3641.                         e.stopImmediatePropagation(); 
  3642.                         e.preventDefault();
  3643.                     } 
  3644.                 })
  3645.                 .bind("keydown", "down", function (e) { 
  3646.                     if($.vakata.context.vis) { 
  3647.                         var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
  3648.                         if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
  3649.                         o.addClass("vakata-hover");
  3650.                         e.stopImmediatePropagation(); 
  3651.                         e.preventDefault();
  3652.                     } 
  3653.                 })
  3654.                 .bind("keydown", "right", function (e) { 
  3655.                     if($.vakata.context.vis) { 
  3656.                         $.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
  3657.                         e.stopImmediatePropagation(); 
  3658.                         e.preventDefault();
  3659.                     } 
  3660.                 })
  3661.                 .bind("keydown", "left", function (e) { 
  3662.                     if($.vakata.context.vis) { 
  3663.                         $.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
  3664.                         e.stopImmediatePropagation(); 
  3665.                         e.preventDefault();
  3666.                     } 
  3667.                 })
  3668.                 .bind("keydown", "esc", function (e) { 
  3669.                     $.vakata.context.hide(); 
  3670.                     e.preventDefault();
  3671.                 })
  3672.                 .bind("keydown", "space", function (e) { 
  3673.                     $.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
  3674.                     e.preventDefault();
  3675.                 });
  3676.         }
  3677.     });
  3678.  
  3679.     $.jstree.plugin("contextmenu", {
  3680.         __init : function () {
  3681.             this.get_container()
  3682.                 .delegate("a", "contextmenu.jstree", $.proxy(function (e) {
  3683.                         e.preventDefault();
  3684.                         if(!$(e.currentTarget).hasClass("jstree-loading")) {
  3685.                             this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
  3686.                         }
  3687.                     }, this))
  3688.                 .delegate("a", "click.jstree", $.proxy(function (e) {
  3689.                         if(this.data.contextmenu) {
  3690.                             $.vakata.context.hide();
  3691.                         }
  3692.                     }, this))
  3693.                 .bind("destroy.jstree", $.proxy(function () {
  3694.                         // TODO: move this to descruct method
  3695.                         if(this.data.contextmenu) {
  3696.                             $.vakata.context.hide();
  3697.                         }
  3698.                     }, this));
  3699.             $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
  3700.         },
  3701.         defaults : { 
  3702.             select_node : false, // requires UI plugin
  3703.             show_at_node : true,
  3704.             items : { // Could be a function that should return an object like this one
  3705.                 "create" : {
  3706.                     "separator_before"    : false,
  3707.                     "separator_after"    : true,
  3708.                     "label"                : "Create",
  3709.                     "action"            : function (obj) { this.create(obj); }
  3710.                 },
  3711.                 "rename" : {
  3712.                     "separator_before"    : false,
  3713.                     "separator_after"    : false,
  3714.                     "label"                : "Rename",
  3715.                     "action"            : function (obj) { this.rename(obj); }
  3716.                 },
  3717.                 "remove" : {
  3718.                     "separator_before"    : false,
  3719.                     "icon"                : false,
  3720.                     "separator_after"    : false,
  3721.                     "label"                : "Delete",
  3722.                     "action"            : function (obj) { if(this.is_selected(obj)) { this.remove(); } else { this.remove(obj); } }
  3723.                 },
  3724.                 "ccp" : {
  3725.                     "separator_before"    : true,
  3726.                     "icon"                : false,
  3727.                     "separator_after"    : false,
  3728.                     "label"                : "Edit",
  3729.                     "action"            : false,
  3730.                     "submenu" : { 
  3731.                         "cut" : {
  3732.                             "separator_before"    : false,
  3733.                             "separator_after"    : false,
  3734.                             "label"                : "Cut",
  3735.                             "action"            : function (obj) { this.cut(obj); }
  3736.                         },
  3737.                         "copy" : {
  3738.                             "separator_before"    : false,
  3739.                             "icon"                : false,
  3740.                             "separator_after"    : false,
  3741.                             "label"                : "Copy",
  3742.                             "action"            : function (obj) { this.copy(obj); }
  3743.                         },
  3744.                         "paste" : {
  3745.                             "separator_before"    : false,
  3746.                             "icon"                : false,
  3747.                             "separator_after"    : false,
  3748.                             "label"                : "Paste",
  3749.                             "action"            : function (obj) { this.paste(obj); }
  3750.                         }
  3751.                     }
  3752.                 }
  3753.             }
  3754.         },
  3755.         _fn : {
  3756.             show_contextmenu : function (obj, x, y) {
  3757.                 obj = this._get_node(obj);
  3758.                 var s = this.get_settings().contextmenu,
  3759.                     a = obj.children("a:visible:eq(0)"),
  3760.                     o = false,
  3761.                     i = false;
  3762.                 if(s.select_node && this.data.ui && !this.is_selected(obj)) {
  3763.                     this.deselect_all();
  3764.                     this.select_node(obj, true);
  3765.                 }
  3766.                 if(s.show_at_node || typeof x === "undefined" || typeof y === "undefined") {
  3767.                     o = a.offset();
  3768.                     x = o.left;
  3769.                     y = o.top + this.data.core.li_height;
  3770.                 }
  3771.                 i = obj.data("jstree") && obj.data("jstree").contextmenu ? obj.data("jstree").contextmenu : s.items;
  3772.                 if($.isFunction(i)) { i = i.call(this, obj); }
  3773.                 this.data.contextmenu = true;
  3774.                 $.vakata.context.show(i, a, x, y, this, obj, this._get_settings().core.rtl);
  3775.                 if(this.data.themes) { $.vakata.context.cnt.attr("class", "jstree-" + this.data.themes.theme + "-context"); }
  3776.             }
  3777.         }
  3778.     });
  3779. })(jQuery);
  3780. //*/
  3781.  
  3782. /* 
  3783.  * jsTree types plugin
  3784.  * Adds support types of nodes
  3785.  * You can set an attribute on each li node, that represents its type.
  3786.  * According to the type setting the node may get custom icon/validation rules
  3787.  */
  3788. (function ($) {
  3789.     $.jstree.plugin("types", {
  3790.         __init : function () {
  3791.             var s = this._get_settings().types;
  3792.             this.data.types.attach_to = [];
  3793.             this.get_container()
  3794.                 .bind("init.jstree", $.proxy(function () { 
  3795.                         var types = s.types, 
  3796.                             attr  = s.type_attr, 
  3797.                             icons_css = "", 
  3798.                             _this = this;
  3799.  
  3800.                         $.each(types, function (i, tp) {
  3801.                             $.each(tp, function (k, v) { 
  3802.                                 if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
  3803.                             });
  3804.                             if(!tp.icon) { return true; }
  3805.                             if( tp.icon.image || tp.icon.position) {
  3806.                                 if(i == "default")    { icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
  3807.                                 else                { icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
  3808.                                 if(tp.icon.image)    { icons_css += ' background-image:url(' + tp.icon.image + '); '; }
  3809.                                 if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
  3810.                                 else                { icons_css += ' background-position:0 0; '; }
  3811.                                 icons_css += '} ';
  3812.                             }
  3813.                         });
  3814.                         if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
  3815.                     }, this))
  3816.                 .bind("before.jstree", $.proxy(function (e, data) { 
  3817.                         var s, t, 
  3818.                             o = this._get_settings().types.use_data ? this._get_node(data.args[0]) : false, 
  3819.                             d = o && o !== -1 && o.length ? o.data("jstree") : false;
  3820.                         if(d && d.types && d.types[data.func] === false) { e.stopImmediatePropagation(); return false; }
  3821.                         if($.inArray(data.func, this.data.types.attach_to) !== -1) {
  3822.                             if(!data.args[0] || (!data.args[0].tagName && !data.args[0].jquery)) { return; }
  3823.                             s = this._get_settings().types.types;
  3824.                             t = this._get_type(data.args[0]);
  3825.                             if(
  3826.                                 ( 
  3827.                                     (s[t] && typeof s[t][data.func] !== "undefined") || 
  3828.                                     (s["default"] && typeof s["default"][data.func] !== "undefined") 
  3829.                                 ) && this._check(data.func, data.args[0]) === false
  3830.                             ) {
  3831.                                 e.stopImmediatePropagation();
  3832.                                 return false;
  3833.                             }
  3834.                         }
  3835.                     }, this));
  3836.             if(is_ie6) {
  3837.                 this.get_container()
  3838.                     .bind("load_node.jstree set_type.jstree", $.proxy(function (e, data) {
  3839.                             var r = data && data.rslt && data.rslt.obj && data.rslt.obj !== -1 ? this._get_node(data.rslt.obj).parent() : this.get_container_ul(),
  3840.                                 c = false,
  3841.                                 s = this._get_settings().types;
  3842.                             $.each(s.types, function (i, tp) {
  3843.                                 if(tp.icon && (tp.icon.image || tp.icon.position)) {
  3844.                                     c = i === "default" ? r.find("li > a > .jstree-icon") : r.find("li[" + s.type_attr + "='" + i + "'] > a > .jstree-icon");
  3845.                                     if(tp.icon.image) { c.css("backgroundImage","url(" + tp.icon.image + ")"); }
  3846.                                     c.css("backgroundPosition", tp.icon.position || "0 0");
  3847.                                 }
  3848.                             });
  3849.                         }, this));
  3850.             }
  3851.         },
  3852.         defaults : {
  3853.             // defines maximum number of root nodes (-1 means unlimited, -2 means disable max_children checking)
  3854.             max_children        : -1,
  3855.             // defines the maximum depth of the tree (-1 means unlimited, -2 means disable max_depth checking)
  3856.             max_depth            : -1,
  3857.             // defines valid node types for the root nodes
  3858.             valid_children        : "all",
  3859.  
  3860.             // whether to use $.data
  3861.             use_data : false, 
  3862.             // where is the type stores (the rel attribute of the LI element)
  3863.             type_attr : "rel",
  3864.             // a list of types
  3865.             types : {
  3866.                 // the default type
  3867.                 "default" : {
  3868.                     "max_children"    : -1,
  3869.                     "max_depth"        : -1,
  3870.                     "valid_children": "all"
  3871.  
  3872.                     // Bound functions - you can bind any other function here (using boolean or function)
  3873.                     //"select_node"    : true
  3874.                 }
  3875.             }
  3876.         },
  3877.         _fn : {
  3878.             _types_notify : function (n, data) {
  3879.                 if(data.type && this._get_settings().types.use_data) {
  3880.                     this.set_type(data.type, n);
  3881.                 }
  3882.             },
  3883.             _get_type : function (obj) {
  3884.                 obj = this._get_node(obj);
  3885.                 return (!obj || !obj.length) ? false : obj.attr(this._get_settings().types.type_attr) || "default";
  3886.             },
  3887.             set_type : function (str, obj) {
  3888.                 obj = this._get_node(obj);
  3889.                 var ret = (!obj.length || !str) ? false : obj.attr(this._get_settings().types.type_attr, str);
  3890.                 if(ret) { this.__callback({ obj : obj, type : str}); }
  3891.                 return ret;
  3892.             },
  3893.             _check : function (rule, obj, opts) {
  3894.                 obj = this._get_node(obj);
  3895.                 var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types, data = false;
  3896.                 if(obj === -1) { 
  3897.                     if(!!s[rule]) { v = s[rule]; }
  3898.                     else { return; }
  3899.                 }
  3900.                 else {
  3901.                     if(t === false) { return; }
  3902.                     data = s.use_data ? obj.data("jstree") : false;
  3903.                     if(data && data.types && typeof data.types[rule] !== "undefined") { v = data.types[rule]; }
  3904.                     else if(!!s.types[t] && typeof s.types[t][rule] !== "undefined") { v = s.types[t][rule]; }
  3905.                     else if(!!s.types["default"] && typeof s.types["default"][rule] !== "undefined") { v = s.types["default"][rule]; }
  3906.                 }
  3907.                 if($.isFunction(v)) { v = v.call(this, obj); }
  3908.                 if(rule === "max_depth" && obj !== -1 && opts !== false && s.max_depth !== -2 && v !== 0) {
  3909.                     // also include the node itself - otherwise if root node it is not checked
  3910.                     obj.children("a:eq(0)").parentsUntil(".jstree","li").each(function (i) {
  3911.                         // check if current depth already exceeds global tree depth
  3912.                         if(s.max_depth !== -1 && s.max_depth - (i + 1) <= 0) { v = 0; return false; }
  3913.                         d = (i === 0) ? v : _this._check(rule, this, false);
  3914.                         // check if current node max depth is already matched or exceeded
  3915.                         if(d !== -1 && d - (i + 1) <= 0) { v = 0; return false; }
  3916.                         // otherwise - set the max depth to the current value minus current depth
  3917.                         if(d >= 0 && (d - (i + 1) < v || v < 0) ) { v = d - (i + 1); }
  3918.                         // if the global tree depth exists and it minus the nodes calculated so far is less than `v` or `v` is unlimited
  3919.                         if(s.max_depth >= 0 && (s.max_depth - (i + 1) < v || v < 0) ) { v = s.max_depth - (i + 1); }
  3920.                     });
  3921.                 }
  3922.                 return v;
  3923.             },
  3924.             check_move : function () {
  3925.                 if(!this.__call_old()) { return false; }
  3926.                 var m  = this._get_move(),
  3927.                     s  = m.rt._get_settings().types,
  3928.                     mc = m.rt._check("max_children", m.cr),
  3929.                     md = m.rt._check("max_depth", m.cr),
  3930.                     vc = m.rt._check("valid_children", m.cr),
  3931.                     ch = 0, d = 1, t;
  3932.  
  3933.                 if(vc === "none") { return false; } 
  3934.                 if($.isArray(vc) && m.ot && m.ot._get_type) {
  3935.                     m.o.each(function () {
  3936.                         if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
  3937.                     });
  3938.                     if(d === false) { return false; }
  3939.                 }
  3940.                 if(s.max_children !== -2 && mc !== -1) {
  3941.                     ch = m.cr === -1 ? this.get_container().find("> ul > li").not(m.o).length : m.cr.find("> ul > li").not(m.o).length;
  3942.                     if(ch + m.o.length > mc) { return false; }
  3943.                 }
  3944.                 if(s.max_depth !== -2 && md !== -1) {
  3945.                     d = 0;
  3946.                     if(md === 0) { return false; }
  3947.                     if(typeof m.o.d === "undefined") {
  3948.                         // TODO: deal with progressive rendering and async when checking max_depth (how to know the depth of the moved node)
  3949.                         t = m.o;
  3950.                         while(t.length > 0) {
  3951.                             t = t.find("> ul > li");
  3952.                             d ++;
  3953.                         }
  3954.                         m.o.d = d;
  3955.                     }
  3956.                     if(md - m.o.d < 0) { return false; }
  3957.                 }
  3958.                 return true;
  3959.             },
  3960.             create_node : function (obj, position, js, callback, is_loaded, skip_check) {
  3961.                 if(!skip_check && (is_loaded || this._is_loaded(obj))) {
  3962.                     var p  = (typeof position == "string" && position.match(/^before|after$/i) && obj !== -1) ? this._get_parent(obj) : this._get_node(obj),
  3963.                         s  = this._get_settings().types,
  3964.                         mc = this._check("max_children", p),
  3965.                         md = this._check("max_depth", p),
  3966.                         vc = this._check("valid_children", p),
  3967.                         ch;
  3968.                     if(typeof js === "string") { js = { data : js }; }
  3969.                     if(!js) { js = {}; }
  3970.                     if(vc === "none") { return false; } 
  3971.                     if($.isArray(vc)) {
  3972.                         if(!js.attr || !js.attr[s.type_attr]) { 
  3973.                             if(!js.attr) { js.attr = {}; }
  3974.                             js.attr[s.type_attr] = vc[0]; 
  3975.                         }
  3976.                         else {
  3977.                             if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
  3978.                         }
  3979.                     }
  3980.                     if(s.max_children !== -2 && mc !== -1) {
  3981.                         ch = p === -1 ? this.get_container().find("> ul > li").length : p.find("> ul > li").length;
  3982.                         if(ch + 1 > mc) { return false; }
  3983.                     }
  3984.                     if(s.max_depth !== -2 && md !== -1 && (md - 1) < 0) { return false; }
  3985.                 }
  3986.                 return this.__call_old(true, obj, position, js, callback, is_loaded, skip_check);
  3987.             }
  3988.         }
  3989.     });
  3990. })(jQuery);
  3991. //*/
  3992.  
  3993. /* 
  3994.  * jsTree HTML plugin
  3995.  * The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
  3996.  */
  3997. (function ($) {
  3998.     $.jstree.plugin("html_data", {
  3999.         __init : function () { 
  4000.             // this used to use html() and clean the whitespace, but this way any attached data was lost
  4001.             this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
  4002.             // remove white space from LI node - otherwise nodes appear a bit to the right
  4003.             this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
  4004.         },
  4005.         defaults : { 
  4006.             data : false,
  4007.             ajax : false,
  4008.             correct_state : true
  4009.         },
  4010.         _fn : {
  4011.             load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
  4012.             _is_loaded : function (obj) { 
  4013.                 obj = this._get_node(obj); 
  4014.                 return obj == -1 || !obj || (!this._get_settings().html_data.ajax && !$.isFunction(this._get_settings().html_data.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
  4015.             },
  4016.             load_node_html : function (obj, s_call, e_call) {
  4017.                 var d,
  4018.                     s = this.get_settings().html_data,
  4019.                     error_func = function () {},
  4020.                     success_func = function () {};
  4021.                 obj = this._get_node(obj);
  4022.                 if(obj && obj !== -1) {
  4023.                     if(obj.data("jstree-is-loading")) { return; }
  4024.                     else { obj.data("jstree-is-loading",true); }
  4025.                 }
  4026.                 switch(!0) {
  4027.                     case ($.isFunction(s.data)):
  4028.                         s.data.call(this, obj, $.proxy(function (d) {
  4029.                             if(d && d !== "" && d.toString && d.toString().replace(/^[\s\n]+$/,"") !== "") {
  4030.                                 d = $(d);
  4031.                                 if(!d.is("ul")) { d = $("<ul />").append(d); }
  4032.                                 if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
  4033.                                 else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d).children("ul").find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.removeData("jstree-is-loading"); }
  4034.                                 this.clean_node(obj);
  4035.                                 if(s_call) { s_call.call(this); }
  4036.                             }
  4037.                             else {
  4038.                                 if(obj && obj !== -1) {
  4039.                                     obj.children("a.jstree-loading").removeClass("jstree-loading");
  4040.                                     obj.removeData("jstree-is-loading");
  4041.                                     if(s.correct_state) { 
  4042.                                         this.correct_state(obj);
  4043.                                         if(s_call) { s_call.call(this); } 
  4044.                                     }
  4045.                                 }
  4046.                                 else {
  4047.                                     if(s.correct_state) { 
  4048.                                         this.get_container().children("ul").empty();
  4049.                                         if(s_call) { s_call.call(this); } 
  4050.                                     }
  4051.                                 }
  4052.                             }
  4053.                         }, this));
  4054.                         break;
  4055.                     case (!s.data && !s.ajax):
  4056.                         if(!obj || obj == -1) {
  4057.                             this.get_container()
  4058.                                 .children("ul").empty()
  4059.                                 .append(this.data.html_data.original_container_html)
  4060.                                 .find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end()
  4061.                                 .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
  4062.                             this.clean_node();
  4063.                         }
  4064.                         if(s_call) { s_call.call(this); }
  4065.                         break;
  4066.                     case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
  4067.                         if(!obj || obj == -1) {
  4068.                             d = $(s.data);
  4069.                             if(!d.is("ul")) { d = $("<ul />").append(d); }
  4070.                             this.get_container()
  4071.                                 .children("ul").empty().append(d.children())
  4072.                                 .find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end()
  4073.                                 .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
  4074.                             this.clean_node();
  4075.                         }
  4076.                         if(s_call) { s_call.call(this); }
  4077.                         break;
  4078.                     case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
  4079.                         obj = this._get_node(obj);
  4080.                         error_func = function (x, t, e) {
  4081.                             var ef = this.get_settings().html_data.ajax.error; 
  4082.                             if(ef) { ef.call(this, x, t, e); }
  4083.                             if(obj != -1 && obj.length) {
  4084.                                 obj.children("a.jstree-loading").removeClass("jstree-loading");
  4085.                                 obj.removeData("jstree-is-loading");
  4086.                                 if(t === "success" && s.correct_state) { this.correct_state(obj); }
  4087.                             }
  4088.                             else {
  4089.                                 if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
  4090.                             }
  4091.                             if(e_call) { e_call.call(this); }
  4092.                         };
  4093.                         success_func = function (d, t, x) {
  4094.                             var sf = this.get_settings().html_data.ajax.success; 
  4095.                             if(sf) { d = sf.call(this,d,t,x) || d; }
  4096.                             if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
  4097.                                 return error_func.call(this, x, t, "");
  4098.                             }
  4099.                             if(d) {
  4100.                                 d = $(d);
  4101.                                 if(!d.is("ul")) { d = $("<ul />").append(d); }
  4102.                                 if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
  4103.                                 else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d).children("ul").find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'> </ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.removeData("jstree-is-loading"); }
  4104.                                 this.clean_node(obj);
  4105.                                 if(s_call) { s_call.call(this); }
  4106.                             }
  4107.                             else {
  4108.                                 if(obj && obj !== -1) {
  4109.                                     obj.children("a.jstree-loading").removeClass("jstree-loading");
  4110.                                     obj.removeData("jstree-is-loading");
  4111.                                     if(s.correct_state) { 
  4112.                                         this.correct_state(obj);
  4113.                                         if(s_call) { s_call.call(this); } 
  4114.                                     }
  4115.                                 }
  4116.                                 else {
  4117.                                     if(s.correct_state) { 
  4118.                                         this.get_container().children("ul").empty();
  4119.                                         if(s_call) { s_call.call(this); } 
  4120.                                     }
  4121.                                 }
  4122.                             }
  4123.                         };
  4124.                         s.ajax.context = this;
  4125.                         s.ajax.error = error_func;
  4126.                         s.ajax.success = success_func;
  4127.                         if(!s.ajax.dataType) { s.ajax.dataType = "html"; }
  4128.                         if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
  4129.                         if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
  4130.                         $.ajax(s.ajax);
  4131.                         break;
  4132.                 }
  4133.             }
  4134.         }
  4135.     });
  4136.     // include the HTML data plugin by default
  4137.     $.jstree.defaults.plugins.push("html_data");
  4138. })(jQuery);
  4139. //*/
  4140.  
  4141. /* 
  4142.  * jsTree themeroller plugin
  4143.  * Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
  4144.  */
  4145. (function ($) {
  4146.     $.jstree.plugin("themeroller", {
  4147.         __init : function () {
  4148.             var s = this._get_settings().themeroller;
  4149.             this.get_container()
  4150.                 .addClass("ui-widget-content")
  4151.                 .addClass("jstree-themeroller")
  4152.                 .delegate("a","mouseenter.jstree", function (e) {
  4153.                     if(!$(e.currentTarget).hasClass("jstree-loading")) {
  4154.                         $(this).addClass(s.item_h);
  4155.                     }
  4156.                 })
  4157.                 .delegate("a","mouseleave.jstree", function () {
  4158.                     $(this).removeClass(s.item_h);
  4159.                 })
  4160.                 .bind("init.jstree", $.proxy(function (e, data) { 
  4161.                         data.inst.get_container().find("> ul > li > .jstree-loading > ins").addClass("ui-icon-refresh");
  4162.                         this._themeroller(data.inst.get_container().find("> ul > li"));
  4163.                     }, this))
  4164.                 .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) { 
  4165.                         this._themeroller(data.rslt.obj);
  4166.                     }, this))
  4167.                 .bind("loaded.jstree refresh.jstree", $.proxy(function (e) {
  4168.                         this._themeroller();
  4169.                     }, this))
  4170.                 .bind("close_node.jstree", $.proxy(function (e, data) {
  4171.                         this._themeroller(data.rslt.obj);
  4172.                     }, this))
  4173.                 .bind("delete_node.jstree", $.proxy(function (e, data) {
  4174.                         this._themeroller(data.rslt.parent);
  4175.                     }, this))
  4176.                 .bind("correct_state.jstree", $.proxy(function (e, data) {
  4177.                         data.rslt.obj
  4178.                             .children("ins.jstree-icon").removeClass(s.opened + " " + s.closed + " ui-icon").end()
  4179.                             .find("> a > ins.ui-icon")
  4180.                                 .filter(function() { 
  4181.                                     return this.className.toString()
  4182.                                         .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
  4183.                                         .indexOf("ui-icon-") === -1; 
  4184.                                 }).removeClass(s.item_open + " " + s.item_clsd).addClass(s.item_leaf || "jstree-no-icon");
  4185.                     }, this))
  4186.                 .bind("select_node.jstree", $.proxy(function (e, data) {
  4187.                         data.rslt.obj.children("a").addClass(s.item_a);
  4188.                     }, this))
  4189.                 .bind("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
  4190.                         this.get_container()
  4191.                             .find("a." + s.item_a).removeClass(s.item_a).end()
  4192.                             .find("a.jstree-clicked").addClass(s.item_a);
  4193.                     }, this))
  4194.                 .bind("dehover_node.jstree", $.proxy(function (e, data) {
  4195.                         data.rslt.obj.children("a").removeClass(s.item_h);
  4196.                     }, this))
  4197.                 .bind("hover_node.jstree", $.proxy(function (e, data) {
  4198.                         this.get_container()
  4199.                             .find("a." + s.item_h).not(data.rslt.obj).removeClass(s.item_h);
  4200.                         data.rslt.obj.children("a").addClass(s.item_h);
  4201.                     }, this))
  4202.                 .bind("move_node.jstree", $.proxy(function (e, data) {
  4203.                         this._themeroller(data.rslt.o);
  4204.                         this._themeroller(data.rslt.op);
  4205.                     }, this));
  4206.         },
  4207.         __destroy : function () {
  4208.             var s = this._get_settings().themeroller,
  4209.                 c = [ "ui-icon" ];
  4210.             $.each(s, function (i, v) {
  4211.                 v = v.split(" ");
  4212.                 if(v.length) { c = c.concat(v); }
  4213.             });
  4214.             this.get_container()
  4215.                 .removeClass("ui-widget-content")
  4216.                 .find("." + c.join(", .")).removeClass(c.join(" "));
  4217.         },
  4218.         _fn : {
  4219.             _themeroller : function (obj) {
  4220.                 var s = this._get_settings().themeroller;
  4221.                 obj = !obj || obj == -1 ? this.get_container_ul() : this._get_node(obj).parent();
  4222.                 obj
  4223.                     .find("li.jstree-closed")
  4224.                         .children("ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
  4225.                         .children("a").addClass(s.item)
  4226.                             .children("ins.jstree-icon").addClass("ui-icon")
  4227.                                 .filter(function() { 
  4228.                                     return this.className.toString()
  4229.                                         .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
  4230.                                         .indexOf("ui-icon-") === -1; 
  4231.                                 }).removeClass(s.item_leaf + " " + s.item_open).addClass(s.item_clsd || "jstree-no-icon")
  4232.                                 .end()
  4233.                             .end()
  4234.                         .end()
  4235.                     .end()
  4236.                     .find("li.jstree-open")
  4237.                         .children("ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
  4238.                         .children("a").addClass(s.item)
  4239.                             .children("ins.jstree-icon").addClass("ui-icon")
  4240.                                 .filter(function() { 
  4241.                                     return this.className.toString()
  4242.                                         .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
  4243.                                         .indexOf("ui-icon-") === -1; 
  4244.                                 }).removeClass(s.item_leaf + " " + s.item_clsd).addClass(s.item_open || "jstree-no-icon")
  4245.                                 .end()
  4246.                             .end()
  4247.                         .end()
  4248.                     .end()
  4249.                     .find("li.jstree-leaf")
  4250.                         .children("ins.jstree-icon").removeClass(s.closed + " ui-icon " + s.opened).end()
  4251.                         .children("a").addClass(s.item)
  4252.                             .children("ins.jstree-icon").addClass("ui-icon")
  4253.                                 .filter(function() { 
  4254.                                     return this.className.toString()
  4255.                                         .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
  4256.                                         .indexOf("ui-icon-") === -1; 
  4257.                                 }).removeClass(s.item_clsd + " " + s.item_open).addClass(s.item_leaf || "jstree-no-icon");
  4258.             }
  4259.         },
  4260.         defaults : {
  4261.             "opened"    : "ui-icon-triangle-1-se",
  4262.             "closed"    : "ui-icon-triangle-1-e",
  4263.             "item"        : "ui-state-default",
  4264.             "item_h"    : "ui-state-hover",
  4265.             "item_a"    : "ui-state-active",
  4266.             "item_open"    : "ui-icon-folder-open",
  4267.             "item_clsd"    : "ui-icon-folder-collapsed",
  4268.             "item_leaf"    : "ui-icon-document"
  4269.         }
  4270.     });
  4271.     $(function() {
  4272.         var css_string = '' + 
  4273.             '.jstree-themeroller .ui-icon { overflow:visible; } ' + 
  4274.             '.jstree-themeroller a { padding:0 2px; } ' + 
  4275.             '.jstree-themeroller .jstree-no-icon { display:none; }';
  4276.         $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
  4277.     });
  4278. })(jQuery);
  4279. //*/
  4280.  
  4281. /* 
  4282.  * jsTree unique plugin
  4283.  * Forces different names amongst siblings (still a bit experimental)
  4284.  * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
  4285.  */
  4286. (function ($) {
  4287.     $.jstree.plugin("unique", {
  4288.         __init : function () {
  4289.             this.get_container()
  4290.                 .bind("before.jstree", $.proxy(function (e, data) { 
  4291.                         var nms = [], res = true, p, t;
  4292.                         if(data.func == "move_node") {
  4293.                             // obj, ref, position, is_copy, is_prepared, skip_check
  4294.                             if(data.args[4] === true) {
  4295.                                 if(data.args[0].o && data.args[0].o.length) {
  4296.                                     data.args[0].o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
  4297.                                     res = this._check_unique(nms, data.args[0].np.find("> ul > li").not(data.args[0].o), "move_node");
  4298.                                 }
  4299.                             }
  4300.                         }
  4301.                         if(data.func == "create_node") {
  4302.                             // obj, position, js, callback, is_loaded
  4303.                             if(data.args[4] || this._is_loaded(data.args[0])) {
  4304.                                 p = this._get_node(data.args[0]);
  4305.                                 if(data.args[1] && (data.args[1] === "before" || data.args[1] === "after")) {
  4306.                                     p = this._get_parent(data.args[0]);
  4307.                                     if(!p || p === -1) { p = this.get_container(); }
  4308.                                 }
  4309.                                 if(typeof data.args[2] === "string") { nms.push(data.args[2]); }
  4310.                                 else if(!data.args[2] || !data.args[2].data) { nms.push(this._get_string("new_node")); }
  4311.                                 else { nms.push(data.args[2].data); }
  4312.                                 res = this._check_unique(nms, p.find("> ul > li"), "create_node");
  4313.                             }
  4314.                         }
  4315.                         if(data.func == "rename_node") {
  4316.                             // obj, val
  4317.                             nms.push(data.args[1]);
  4318.                             t = this._get_node(data.args[0]);
  4319.                             p = this._get_parent(t);
  4320.                             if(!p || p === -1) { p = this.get_container(); }
  4321.                             res = this._check_unique(nms, p.find("> ul > li").not(t), "rename_node");
  4322.                         }
  4323.                         if(!res) {
  4324.                             e.stopPropagation();
  4325.                             return false;
  4326.                         }
  4327.                     }, this));
  4328.         },
  4329.         defaults : { 
  4330.             error_callback : $.noop
  4331.         },
  4332.         _fn : { 
  4333.             _check_unique : function (nms, p, func) {
  4334.                 var cnms = [];
  4335.                 p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
  4336.                 if(!cnms.length || !nms.length) { return true; }
  4337.                 cnms = cnms.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
  4338.                 if((cnms.length + nms.length) != cnms.concat(nms).sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",").length) {
  4339.                     this._get_settings().unique.error_callback.call(null, nms, p, func);
  4340.                     return false;
  4341.                 }
  4342.                 return true;
  4343.             },
  4344.             check_move : function () {
  4345.                 if(!this.__call_old()) { return false; }
  4346.                 var p = this._get_move(), nms = [];
  4347.                 if(p.o && p.o.length) {
  4348.                     p.o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
  4349.                     return this._check_unique(nms, p.np.find("> ul > li").not(p.o), "check_move");
  4350.                 }
  4351.                 return true;
  4352.             }
  4353.         }
  4354.     });
  4355. })(jQuery);
  4356. //*/
  4357.  
  4358. /*
  4359.  * jsTree wholerow plugin
  4360.  * Makes select and hover work on the entire width of the node
  4361.  * MAY BE HEAVY IN LARGE DOM
  4362.  */
  4363. (function ($) {
  4364.     $.jstree.plugin("wholerow", {
  4365.         __init : function () {
  4366.             if(!this.data.ui) { throw "jsTree wholerow: jsTree UI plugin not included."; }
  4367.             this.data.wholerow.html = false;
  4368.             this.data.wholerow.to = false;
  4369.             this.get_container()
  4370.                 .bind("init.jstree", $.proxy(function (e, data) { 
  4371.                         this._get_settings().core.animation = 0;
  4372.                     }, this))
  4373.                 .bind("open_node.jstree create_node.jstree clean_node.jstree loaded.jstree", $.proxy(function (e, data) { 
  4374.                         this._prepare_wholerow_span( data && data.rslt && data.rslt.obj ? data.rslt.obj : -1 );
  4375.                     }, this))
  4376.                 .bind("search.jstree clear_search.jstree reopen.jstree after_open.jstree after_close.jstree create_node.jstree delete_node.jstree clean_node.jstree", $.proxy(function (e, data) { 
  4377.                         if(this.data.to) { clearTimeout(this.data.to); }
  4378.                         this.data.to = setTimeout( (function (t, o) { return function() { t._prepare_wholerow_ul(o); }; })(this,  data && data.rslt && data.rslt.obj ? data.rslt.obj : -1), 0);
  4379.                     }, this))
  4380.                 .bind("deselect_all.jstree", $.proxy(function (e, data) { 
  4381.                         this.get_container().find(" > .jstree-wholerow .jstree-clicked").removeClass("jstree-clicked " + (this.data.themeroller ? this._get_settings().themeroller.item_a : "" ));
  4382.                     }, this))
  4383.                 .bind("select_node.jstree deselect_node.jstree ", $.proxy(function (e, data) { 
  4384.                         data.rslt.obj.each(function () { 
  4385.                             var ref = data.inst.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt((($(this).offset().top - data.inst.get_container().offset().top + data.inst.get_container()[0].scrollTop) / data.inst.data.core.li_height),10)) + ")");
  4386.                             // ref.children("a")[e.type === "select_node" ? "addClass" : "removeClass"]("jstree-clicked");
  4387.                             ref.children("a").attr("class",data.rslt.obj.children("a").attr("class"));
  4388.                         });
  4389.                     }, this))
  4390.                 .bind("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) { 
  4391.                         this.get_container().find(" > .jstree-wholerow .jstree-hovered").removeClass("jstree-hovered " + (this.data.themeroller ? this._get_settings().themeroller.item_h : "" ));
  4392.                         if(e.type === "hover_node") {
  4393.                             var ref = this.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt(((data.rslt.obj.offset().top - this.get_container().offset().top + this.get_container()[0].scrollTop) / this.data.core.li_height),10)) + ")");
  4394.                             // ref.children("a").addClass("jstree-hovered");
  4395.                             ref.children("a").attr("class",data.rslt.obj.children(".jstree-hovered").attr("class"));
  4396.                         }
  4397.                     }, this))
  4398.                 .delegate(".jstree-wholerow-span, ins.jstree-icon, li", "click.jstree", function (e) {
  4399.                         var n = $(e.currentTarget);
  4400.                         if(e.target.tagName === "A" || (e.target.tagName === "INS" && n.closest("li").is(".jstree-open, .jstree-closed"))) { return; }
  4401.                         n.closest("li").children("a:visible:eq(0)").click();
  4402.                         e.stopImmediatePropagation();
  4403.                     })
  4404.                 .delegate("li", "mouseover.jstree", $.proxy(function (e) {
  4405.                         e.stopImmediatePropagation();
  4406.                         if($(e.currentTarget).children(".jstree-hovered, .jstree-clicked").length) { return false; }
  4407.                         this.hover_node(e.currentTarget);
  4408.                         return false;
  4409.                     }, this))
  4410.                 .delegate("li", "mouseleave.jstree", $.proxy(function (e) {
  4411.                         if($(e.currentTarget).children("a").hasClass("jstree-hovered").length) { return; }
  4412.                         this.dehover_node(e.currentTarget);
  4413.                     }, this));
  4414.             if(is_ie7 || is_ie6) {
  4415.                 $.vakata.css.add_sheet({ str : ".jstree-" + this.get_index() + " { position:relative; } ", title : "jstree" });
  4416.             }
  4417.         },
  4418.         defaults : {
  4419.         },
  4420.         __destroy : function () {
  4421.             this.get_container().children(".jstree-wholerow").remove();
  4422.             this.get_container().find(".jstree-wholerow-span").remove();
  4423.         },
  4424.         _fn : {
  4425.             _prepare_wholerow_span : function (obj) {
  4426.                 obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj);
  4427.                 if(obj === false) { return; } // added for removing root nodes
  4428.                 obj.each(function () {
  4429.                     $(this).find("li").andSelf().each(function () {
  4430.                         var $t = $(this);
  4431.                         if($t.children(".jstree-wholerow-span").length) { return true; }
  4432.                         $t.prepend("<span class='jstree-wholerow-span' style='width:" + ($t.parentsUntil(".jstree","li").length * 18) + "px;'> </span>");
  4433.                     });
  4434.                 });
  4435.             },
  4436.             _prepare_wholerow_ul : function () {
  4437.                 var o = this.get_container().children("ul").eq(0), h = o.html();
  4438.                 o.addClass("jstree-wholerow-real");
  4439.                 if(this.data.wholerow.last_html !== h) {
  4440.                     this.data.wholerow.last_html = h;
  4441.                     this.get_container().children(".jstree-wholerow").remove();
  4442.                     this.get_container().append(
  4443.                         o.clone().removeClass("jstree-wholerow-real")
  4444.                             .wrapAll("<div class='jstree-wholerow' />").parent()
  4445.                             .width(o.parent()[0].scrollWidth)
  4446.                             .css("top", (o.height() + ( is_ie7 ? 5 : 0)) * -1 )
  4447.                             .find("li[id]").each(function () { this.removeAttribute("id"); }).end()
  4448.                     );
  4449.                 }
  4450.             }
  4451.         }
  4452.     });
  4453.     $(function() {
  4454.         var css_string = '' + 
  4455.             '.jstree .jstree-wholerow-real { position:relative; z-index:1; } ' + 
  4456.             '.jstree .jstree-wholerow-real li { cursor:pointer; } ' + 
  4457.             '.jstree .jstree-wholerow-real a { border-left-color:transparent !important; border-right-color:transparent !important; } ' + 
  4458.             '.jstree .jstree-wholerow { position:relative; z-index:0; height:0; } ' + 
  4459.             '.jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width:100%; } ' + 
  4460.             '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin:0 !important; padding:0 !important; } ' + 
  4461.             '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background:transparent !important; }' + 
  4462.             '.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display:none !important; }' + 
  4463.             '.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent:-9999px; !important; width:100%; padding:0 !important; border-right-width:0px !important; border-left-width:0px !important; } ' + 
  4464.             '.jstree .jstree-wholerow-span { position:absolute; left:0; margin:0px; padding:0; height:18px; border-width:0; padding:0; z-index:0; }';
  4465.         if(is_ff2) {
  4466.             css_string += '' + 
  4467.                 '.jstree .jstree-wholerow a { display:block; height:18px; margin:0; padding:0; border:0; } ' + 
  4468.                 '.jstree .jstree-wholerow-real a { border-color:transparent !important; } ';
  4469.         }
  4470.         if(is_ie7 || is_ie6) {
  4471.             css_string += '' + 
  4472.                 '.jstree .jstree-wholerow, .jstree .jstree-wholerow li, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow a { margin:0; padding:0; line-height:18px; } ' + 
  4473.                 '.jstree .jstree-wholerow a { display:block; height:18px; line-height:18px; overflow:hidden; } ';
  4474.         }
  4475.         $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
  4476.     });
  4477. })(jQuery);
  4478. //*/
  4479.  
  4480. /*
  4481. * jsTree model plugin
  4482. * This plugin gets jstree to use a class model to retrieve data, creating great dynamism
  4483. */
  4484. (function ($) {
  4485.     var nodeInterface = ["getChildren","getChildrenCount","getAttr","getName","getProps"],
  4486.         validateInterface = function(obj, inter) {
  4487.             var valid = true;
  4488.             obj = obj || {};
  4489.             inter = [].concat(inter);
  4490.             $.each(inter, function (i, v) {
  4491.                 if(!$.isFunction(obj[v])) { valid = false; return false; }
  4492.             });
  4493.             return valid;
  4494.         };
  4495.     $.jstree.plugin("model", {
  4496.         __init : function () {
  4497.             if(!this.data.json_data) { throw "jsTree model: jsTree json_data plugin not included."; }
  4498.             this._get_settings().json_data.data = function (n, b) {
  4499.                 var obj = (n == -1) ? this._get_settings().model.object : n.data("jstree_model");
  4500.                 if(!validateInterface(obj, nodeInterface)) { return b.call(null, false); }
  4501.                 if(this._get_settings().model.async) {
  4502.                     obj.getChildren($.proxy(function (data) {
  4503.                         this.model_done(data, b);
  4504.                     }, this));
  4505.                 }
  4506.                 else {
  4507.                     this.model_done(obj.getChildren(), b);
  4508.                 }
  4509.             };
  4510.         },
  4511.         defaults : {
  4512.             object : false,
  4513.             id_prefix : false,
  4514.             async : false
  4515.         },
  4516.         _fn : {
  4517.             model_done : function (data, callback) {
  4518.                 var ret = [], 
  4519.                     s = this._get_settings(),
  4520.                     _this = this;
  4521.  
  4522.                 if(!$.isArray(data)) { data = [data]; }
  4523.                 $.each(data, function (i, nd) {
  4524.                     var r = nd.getProps() || {};
  4525.                     r.attr = nd.getAttr() || {};
  4526.                     if(nd.getChildrenCount()) { r.state = "closed"; }
  4527.                     r.data = nd.getName();
  4528.                     if(!$.isArray(r.data)) { r.data = [r.data]; }
  4529.                     if(_this.data.types && $.isFunction(nd.getType)) {
  4530.                         r.attr[s.types.type_attr] = nd.getType();
  4531.                     }
  4532.                     if(r.attr.id && s.model.id_prefix) { r.attr.id = s.model.id_prefix + r.attr.id; }
  4533.                     if(!r.metadata) { r.metadata = { }; }
  4534.                     r.metadata.jstree_model = nd;
  4535.                     ret.push(r);
  4536.                 });
  4537.                 callback.call(null, ret);
  4538.             }
  4539.         }
  4540.     });
  4541. })(jQuery);
  4542. //*/
  4543.  
  4544. })();