").html(html).css("opacity", "0.75");
- $(document).bind("mousemove", $.vakata.dnd.drag);
- $(document).bind("mouseup", $.vakata.dnd.drag_stop);
- return false;
- },
- drag : function (e) {
- if(!$.vakata.dnd.is_down) { return; }
- if(!$.vakata.dnd.is_drag) {
- if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
- $.vakata.dnd.helper.appendTo("body");
- $.vakata.dnd.is_drag = true;
- $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
- }
- else { return; }
- }
-
- // maybe use a scrolling parent element instead of document?
- if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
- var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
- if(e.pageY - t < 20) {
- if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
- if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
- }
- else {
- if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
- }
- if($(window).height() - (e.pageY - t) < 20) {
- if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
- if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
- }
- else {
- if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
- }
-
- if(e.pageX - l < 20) {
- if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
- if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
- }
- else {
- if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
- }
- if($(window).width() - (e.pageX - l) < 20) {
- if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
- if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
- }
- else {
- if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
- }
- }
-
- $.vakata.dnd.helper.css({ left : (e.pageX + 5) + "px", top : (e.pageY + 10) + "px" });
- $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
- },
- drag_stop : function (e) {
- $(document).unbind("mousemove", $.vakata.dnd.drag);
- $(document).unbind("mouseup", $.vakata.dnd.drag_stop);
- $(document).triggerHandler("drag_stop.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
- $.vakata.dnd.helper.remove();
- $.vakata.dnd.init_x = 0;
- $.vakata.dnd.init_y = 0;
- $.vakata.dnd.user_data = {};
- $.vakata.dnd.is_down = false;
- $.vakata.dnd.is_drag = false;
- }
- };
- $(function() {
- 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; } ';
- $.vakata.css.add_sheet({ str : css_string });
- });
-
- $.jstree.plugin("dnd", {
- __init : function () {
- this.data.dnd = {
- active : false,
- after : false,
- inside : false,
- before : false,
- off : false,
- prepared : false,
- w : 0,
- to1 : false,
- to2 : false,
- cof : false,
- cw : false,
- ch : false,
- i1 : false,
- i2 : false
- };
- this.get_container()
- .bind("mouseenter.jstree", $.proxy(function () {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && this.data.themes) {
- m.attr("class", "jstree-" + this.data.themes.theme);
- $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
- }
- }, this))
- .bind("mouseleave.jstree", $.proxy(function () {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
- if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
- }
- }, this))
- .bind("mousemove.jstree", $.proxy(function (e) {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- var cnt = this.get_container()[0];
-
- // Horizontal scroll
- if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
- if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
- this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
- }
- else if(e.pageX - 24 < this.data.dnd.cof.left) {
- if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
- this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= $.vakata.dnd.scroll_spd; }, cnt), 100);
- }
- else {
- if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
- }
-
- // Vertical scroll
- if(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
- if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
- this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
- }
- else if(e.pageY - 24 < this.data.dnd.cof.top) {
- if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
- this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= $.vakata.dnd.scroll_spd; }, cnt), 100);
- }
- else {
- if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
- }
-
- }
- }, this))
- .delegate("a", "mousedown.jstree", $.proxy(function (e) {
- if(e.which === 1) {
- this.start_drag(e.currentTarget, e);
- return false;
- }
- }, this))
- .delegate("a", "mouseenter.jstree", $.proxy(function (e) {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- this.dnd_enter(e.currentTarget);
- }
- }, this))
- .delegate("a", "mousemove.jstree", $.proxy(function (e) {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- if(typeof this.data.dnd.off.top === "undefined") { this.data.dnd.off = $(e.target).offset(); }
- this.data.dnd.w = (e.pageY - (this.data.dnd.off.top || 0)) % this.data.core.li_height;
- if(this.data.dnd.w < 0) { this.data.dnd.w += this.data.core.li_height; }
- this.dnd_show();
- }
- }, this))
- .delegate("a", "mouseleave.jstree", $.proxy(function (e) {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- this.data.dnd.after = false;
- this.data.dnd.before = false;
- this.data.dnd.inside = false;
- $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
- m.hide();
- if(r && r[0] === e.target.parentNode) {
- if(this.data.dnd.to1) {
- clearTimeout(this.data.dnd.to1);
- this.data.dnd.to1 = false;
- }
- if(this.data.dnd.to2) {
- clearTimeout(this.data.dnd.to2);
- this.data.dnd.to2 = false;
- }
- }
- }
- }, this))
- .delegate("a", "mouseup.jstree", $.proxy(function (e) {
- if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
- this.dnd_finish(e);
- }
- }, this));
-
- $(document)
- .bind("drag_stop.vakata", $.proxy(function () {
- this.data.dnd.after = false;
- this.data.dnd.before = false;
- this.data.dnd.inside = false;
- this.data.dnd.off = false;
- this.data.dnd.prepared = false;
- this.data.dnd.w = false;
- this.data.dnd.to1 = false;
- this.data.dnd.to2 = false;
- this.data.dnd.active = false;
- this.data.dnd.foreign = false;
- if(m) { m.css({ "top" : "-2000px" }); }
- }, this))
- .bind("drag_start.vakata", $.proxy(function (e, data) {
- if(data.data.jstree) {
- var et = $(data.event.target);
- if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
- this.dnd_enter(et);
- }
- }
- }, this));
-
- var s = this._get_settings().dnd;
- if(s.drag_target) {
- $(document)
- .delegate(s.drag_target, "mousedown.jstree", $.proxy(function (e) {
- o = e.target;
- $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "
" + $(e.target).text() );
- if(this.data.themes) {
- m.attr("class", "jstree-" + this.data.themes.theme);
- $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
- }
- $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
- var cnt = this.get_container();
- this.data.dnd.cof = cnt.offset();
- this.data.dnd.cw = parseInt(cnt.width(),10);
- this.data.dnd.ch = parseInt(cnt.height(),10);
- this.data.dnd.foreign = true;
- return false;
- }, this));
- }
- if(s.drop_target) {
- $(document)
- .delegate(s.drop_target, "mouseenter.jstree", $.proxy(function (e) {
- if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target) })) {
- $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
- }
- }, this))
- .delegate(s.drop_target, "mouseleave.jstree", $.proxy(function (e) {
- if(this.data.dnd.active) {
- $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
- }
- }, this))
- .delegate(s.drop_target, "mouseup.jstree", $.proxy(function (e) {
- if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
- this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target) });
- }
- }, this));
- }
- },
- defaults : {
- copy_modifier : "ctrl",
- check_timeout : 200,
- open_timeout : 500,
- drop_target : ".jstree-drop",
- drop_check : function (data) { return true; },
- drop_finish : $.noop,
- drag_target : ".jstree-draggable",
- drag_finish : $.noop,
- drag_check : function (data) { return { after : false, before : false, inside : true }; }
- },
- _fn : {
- dnd_prepare : function () {
- if(!r || !r.length) { return; }
- this.data.dnd.off = r.offset();
- if(this._get_settings().core.rtl) {
- this.data.dnd.off.right = this.data.dnd.off.left + r.width();
- }
- if(this.data.dnd.foreign) {
- var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
- this.data.dnd.after = a.after;
- this.data.dnd.before = a.before;
- this.data.dnd.inside = a.inside;
- this.data.dnd.prepared = true;
- return this.dnd_show();
- }
- this.prepare_move(o, r, "before");
- this.data.dnd.before = this.check_move();
- this.prepare_move(o, r, "after");
- this.data.dnd.after = this.check_move();
- if(this._is_loaded(r)) {
- this.prepare_move(o, r, "inside");
- this.data.dnd.inside = this.check_move();
- }
- else {
- this.data.dnd.inside = false;
- }
- this.data.dnd.prepared = true;
- return this.dnd_show();
- },
- dnd_show : function () {
- if(!this.data.dnd.prepared) { return; }
- var o = ["before","inside","after"],
- r = false,
- rtl = this._get_settings().core.rtl,
- pos;
- if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
- else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
- o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
- }
- else { o = ["after","inside","before"]; }
- $.each(o, $.proxy(function (i, val) {
- if(this.data.dnd[val]) {
- $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
- r = val;
- return false;
- }
- }, this));
- if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
-
- pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
- switch(r) {
- case "before":
- m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
- break;
- case "after":
- m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 7) + "px" }).show();
- break;
- case "inside":
- m.css({ "left" : pos + ( rtl ? -4 : 4) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
- break;
- default:
- m.hide();
- break;
- }
- return r;
- },
- dnd_open : function () {
- this.data.dnd.to2 = false;
- this.open_node(r, $.proxy(this.dnd_prepare,this), true);
- },
- dnd_finish : function (e) {
- if(this.data.dnd.foreign) {
- if(this.data.dnd.after || this.data.dnd.before || this.data.dnd.inside) {
- this._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : r });
- }
- }
- else {
- this.dnd_prepare();
- this.move_node(o, r, this.dnd_show(), e[this._get_settings().dnd.copy_modifier + "Key"]);
- }
- o = false;
- r = false;
- m.hide();
- },
- dnd_enter : function (obj) {
- var s = this._get_settings().dnd;
- this.data.dnd.prepared = false;
- r = this._get_node(obj);
- if(s.check_timeout) {
- // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
- if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
- this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
- }
- else {
- this.dnd_prepare();
- }
- if(s.open_timeout) {
- if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
- if(r && r.length && r.hasClass("jstree-closed")) {
- // if the node is closed - open it, then recalculate
- this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
- }
- }
- else {
- if(r && r.length && r.hasClass("jstree-closed")) {
- this.dnd_open();
- }
- }
- },
- start_drag : function (obj, e) {
- o = this._get_node(obj);
- if(this.data.ui && this.is_selected(o)) { o = this._get_node(null, true); }
- $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "
" + (o.length > 1 ? "Multiple selection" : this.get_text(o)) );
- if(this.data.themes) {
- m.attr("class", "jstree-" + this.data.themes.theme);
- $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
- }
- var cnt = this.get_container();
- this.data.dnd.cof = cnt.children("ul").offset();
- this.data.dnd.cw = parseInt(cnt.width(),10);
- this.data.dnd.ch = parseInt(cnt.height(),10);
- this.data.dnd.active = true;
- }
- }
- });
- $(function() {
- var css_string = '' +
- '#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; } ' +
- '#vakata-dragged .jstree-ok { background:green; } ' +
- '#vakata-dragged .jstree-invalid { background:red; } ' +
- '#jstree-marker { padding:0; margin:0; line-height:12px; font-size:1px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:silver; } ';
- $.vakata.css.add_sheet({ str : css_string });
- m = $("
").attr({ id : "jstree-marker" }).hide().appendTo("body");
- $(document).bind("drag_start.vakata", function (e, data) {
- if(data.data.jstree) {
- m.show();
- }
- });
- $(document).bind("drag_stop.vakata", function (e, data) {
- if(data.data.jstree) { m.hide(); }
- });
- });
-})(jQuery);
-//*/
-
-/*
- * jsTree checkbox plugin 1.0
- * Inserts checkboxes in front of every node
- * Depends on the ui plugin
- * DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
- */
-(function ($) {
- $.jstree.plugin("checkbox", {
- __init : function () {
- this.select_node = this.deselect_node = this.deselect_all = $.noop;
- this.get_selected = this.get_checked;
-
- this.get_container()
- .bind("open_node.jstree create_node.jstree clean_node.jstree", $.proxy(function (e, data) {
- this._prepare_checkboxes(data.rslt.obj);
- }, this))
- .bind("loaded.jstree", $.proxy(function (e) {
- this._prepare_checkboxes();
- }, this))
- .delegate("a", "click.jstree", $.proxy(function (e) {
- if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
- else { this.check_node(e.target); }
- if(this.data.ui) { this.save_selected(); }
- if(this.data.cookies) { this.save_cookie("select_node"); }
- e.preventDefault();
- }, this));
- },
- __destroy : function () {
- this.get_container().find(".jstree-checkbox").remove();
- },
- _fn : {
- _prepare_checkboxes : function (obj) {
- obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj);
- var c, _this = this, t;
- obj.each(function () {
- t = $(this);
- c = t.is("li") && t.hasClass("jstree-checked") ? "jstree-checked" : "jstree-unchecked";
- t.find("a").not(":has(.jstree-checkbox)").prepend("
").parent().not(".jstree-checked, .jstree-unchecked").addClass(c);
- });
- if(obj.is("li")) { this._repair_state(obj); }
- else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
- },
- change_state : function (obj, state) {
- obj = this._get_node(obj);
- state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
- if(state) { obj.find("li").andSelf().removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); }
- else {
- obj.find("li").andSelf().removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
- if(this.data.ui) { this.data.ui.last_selected = obj; }
- this.data.checkbox.last_selected = obj;
- }
- obj.parentsUntil(".jstree", "li").each(function () {
- var $this = $(this);
- if(state) {
- if($this.children("ul").children(".jstree-checked, .jstree-undetermined").length) {
- $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- return false;
- }
- else {
- $this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
- }
- }
- else {
- if($this.children("ul").children(".jstree-unchecked, .jstree-undetermined").length) {
- $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- return false;
- }
- else {
- $this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
- }
- }
- });
- if(this.data.ui) { this.data.ui.selected = this.get_checked(); }
- this.__callback(obj);
- },
- check_node : function (obj) {
- this.change_state(obj, false);
- },
- uncheck_node : function (obj) {
- this.change_state(obj, true);
- },
- check_all : function () {
- var _this = this;
- this.get_container().children("ul").children("li").each(function () {
- _this.check_node(this, false);
- });
- },
- uncheck_all : function () {
- var _this = this;
- this.get_container().children("ul").children("li").each(function () {
- _this.change_state(this, true);
- });
- },
-
- is_checked : function(obj) {
- obj = this._get_node(obj);
- return obj.length ? obj.is(".jstree-checked") : false;
- },
- get_checked : function (obj) {
- obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
- return obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
- },
- get_unchecked : function (obj) {
- obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
- return obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
- },
-
- show_checkboxes : function () { this.get_container().children("ul").removeClass("jstree-no-checkboxes"); },
- hide_checkboxes : function () { this.get_container().children("ul").addClass("jstree-no-checkboxes"); },
-
- _repair_state : function (obj) {
- obj = this._get_node(obj);
- if(!obj.length) { return; }
- var a = obj.find("> ul > .jstree-checked").length,
- b = obj.find("> ul > .jstree-undetermined").length,
- c = obj.find("> ul > li").length;
-
- if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.check_node(obj); } }
- else if(a === 0 && b === 0) { this.uncheck_node(obj); }
- else if(a === c) { this.check_node(obj); }
- else {
- obj.parentsUntil(".jstree","li").removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- }
- },
- reselect : function () {
- if(this.data.ui) {
- var _this = this,
- s = this.data.ui.to_select;
- s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
- this.deselect_all();
- $.each(s, function (i, val) { _this.check_node(val); });
- this.__callback();
- }
- }
- }
- });
-})(jQuery);
-//*/
-
-/*
- * jsTree XML 1.0
- * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
- */
-(function ($) {
- $.vakata.xslt = function (xml, xsl, callback) {
- var rs = "", xm, xs, processor, support;
- if(document.recalc) {
- xm = document.createElement('xml');
- xs = document.createElement('xml');
- xm.innerHTML = xml;
- xs.innerHTML = xsl;
- $("body").append(xm).append(xs);
- setTimeout( (function (xm, xs, callback) {
- return function () {
- callback.call(null, xm.transformNode(xs.XMLDocument));
- setTimeout( (function (xm, xs) { return function () { jQuery("body").remove(xm).remove(xs); }; })(xm, xs), 200);
- };
- }) (xm, xs, callback), 100);
- return true;
- }
- if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
- processor = new XSLTProcessor();
- support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
- if(!support) { return false; }
- xml = new DOMParser().parseFromString(xml, "text/xml");
- xsl = new DOMParser().parseFromString(xsl, "text/xml");
- if($.isFunction(processor.transformDocument)) {
- rs = document.implementation.createDocument("", "", null);
- processor.transformDocument(xml, xsl, rs, null);
- callback.call(null, XMLSerializer().serializeToString(rs));
- return true;
- }
- else {
- processor.importStylesheet(xsl);
- rs = processor.transformToFragment(xml, document);
- callback.call(null, $("
").append(rs).html());
- return true;
- }
- }
- return false;
- };
- var xsl = {
- 'nest' : '' +
- '
' +
- '' +
- '' +
- ' ' +
- ' ' +
- ' ' +
- '' +
- '' +
- ' ' +
- ' ' +
- '' +
- '',
-
- 'flat' : '' +
- '
' +
- '' +
- '' +
- ' ' +
- ' ' + /* the last `or` may be removed */
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '
' +
- '' +
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' jstree-last ' +
- ' ' +
- ' jstree-open ' +
- ' jstree-closed ' +
- ' jstree-leaf ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' #' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' jstree-icon ' +
- ' ' +
- ' ' +
- ' background:url() center center no-repeat;' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '
' +
- ' ' +
- ' ' +
- '' +
- ''
- };
- $.jstree.plugin("xml_data", {
- defaults : {
- data : false,
- ajax : false,
- xsl : "flat",
- clean_node : false,
- correct_state : true
- },
- _fn : {
- load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
- _is_loaded : function (obj) {
- var s = this._get_settings().xml_data;
- obj = this._get_node(obj);
- return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
- },
- load_node_xml : function (obj, s_call, e_call) {
- var s = this.get_settings().xml_data,
- error_func = function () {},
- success_func = function () {};
-
- obj = this._get_node(obj);
- if(obj && obj !== -1) {
- if(obj.data("jstree-is-loading")) { return; }
- else { obj.data("jstree-is-loading",true); }
- }
- switch(!0) {
- case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
- case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
- if(!obj || obj == -1) {
- this.parse_xml(s.data, $.proxy(function (d) {
- if(d) {
- d = d.replace(/ ?xmlns="[^"]*"/ig, "");
- if(d.length > 10) {
- d = $(d);
- this.get_container().children("ul").empty().append(d.children());
- if(s.clean_node) { this.clean_node(obj); }
- if(s_call) { s_call.call(this); }
- }
- }
- else {
- if(s.correct_state) {
- this.get_container().children("ul").empty();
- if(s_call) { s_call.call(this); }
- }
- }
- }, this));
- }
- break;
- case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
- error_func = function (x, t, e) {
- var ef = this.get_settings().xml_data.ajax.error;
- if(ef) { ef.call(this, x, t, e); }
- if(obj !== -1 && obj.length) {
- obj.children(".jstree-loading").removeClass("jstree-loading");
- obj.data("jstree-is-loading",false);
- if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
- }
- else {
- if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
- }
- if(e_call) { e_call.call(this); }
- };
- success_func = function (d, t, x) {
- d = x.responseText;
- var sf = this.get_settings().xml_data.ajax.success;
- if(sf) { d = sf.call(this,d,t,x) || d; }
- if(d == "") {
- return error_func.call(this, x, t, "");
- }
- this.parse_xml(d, $.proxy(function (d) {
- if(d) {
- d = d.replace(/ ?xmlns="[^"]*"/ig, "");
- if(d.length > 10) {
- d = $(d);
- if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
- else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.data("jstree-is-loading",false); }
- if(s.clean_node) { this.clean_node(obj); }
- if(s_call) { s_call.call(this); }
- }
- else {
- if(obj && obj !== -1) {
- obj.children(".jstree-loading").removeClass("jstree-loading");
- obj.data("jstree-is-loading",false);
- if(s.correct_state) {
- obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
- if(s_call) { s_call.call(this); }
- }
- }
- else {
- if(s.correct_state) {
- this.get_container().children("ul").empty();
- if(s_call) { s_call.call(this); }
- }
- }
- }
- }
- }, this));
- };
- s.ajax.context = this;
- s.ajax.error = error_func;
- s.ajax.success = success_func;
- if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
- if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
- if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
- $.ajax(s.ajax);
- break;
- }
- },
- parse_xml : function (xml, callback) {
- var s = this._get_settings().xml_data;
- $.vakata.xslt(xml, xsl[s.xsl], callback);
- },
- get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
- var result = "",
- s = this._get_settings(),
- _this = this,
- tmp1, tmp2, li, a, lang;
- if(!tp) { tp = "flat"; }
- if(!is_callback) { is_callback = 0; }
- obj = this._get_node(obj);
- if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
- li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
- if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
-
- a_attr = $.isArray(a_attr) ? a_attr : [ ];
-
- if(!is_callback) { result += "
"; }
- obj.each(function () {
- result += "- ";
- result += "";
- a = li.children("a");
- a.each(function () {
- tmp1 = $(this);
- lang = false;
- result += "";
- result += "";
- result += "";
- });
- result += "";
- tmp2 = li[0].id;
- li = li.find("> ul > li");
- if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
- else { tmp2 = ""; }
- if(tp == "nest") { result += tmp2; }
- result += "
";
- if(tp == "flat") { result += tmp2; }
- });
- if(!is_callback) { result += ""; }
- return result;
- }
- }
- });
-})(jQuery);
-//*/
-
-/*
- * jsTree search plugin 1.0
- * Enables both sync and async search on the tree
- * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
- */
-(function ($) {
- $.expr[':'].jstree_contains = function(a,i,m){
- return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
- };
- $.jstree.plugin("search", {
- __init : function () {
- this.data.search.str = "";
- this.data.search.result = $();
- },
- defaults : {
- ajax : false, // OR ajax object
- case_insensitive : false
- },
- _fn : {
- search : function (str, skip_async) {
- if(str === "") { return; }
- var s = this.get_settings().search,
- t = this,
- error_func = function () { },
- success_func = function () { };
- this.data.search.str = str;
-
- if(!skip_async && s.ajax !== false && this.get_container().find(".jstree-closed:eq(0)").length > 0) {
- this.search.supress_callback = true;
- error_func = function () { };
- success_func = function (d, t, x) {
- var sf = this.get_settings().search.ajax.success;
- if(sf) { d = sf.call(this,d,t,x) || d; }
- this.data.search.to_open = d;
- this._search_open();
- };
- s.ajax.context = this;
- s.ajax.error = error_func;
- s.ajax.success = success_func;
- if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, str); }
- if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
- if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
- if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
- $.ajax(s.ajax);
- return;
- }
- if(this.data.search.result.length) { this.clear_search(); }
- this.data.search.result = this.get_container().find("a" + (this.data.languages ? "." + this.get_lang() : "" ) + ":" + (s.case_insensitive ? "jstree_contains" : "contains") + "(" + this.data.search.str + ")");
- this.data.search.result.addClass("jstree-search").parents(".jstree-closed").each(function () {
- t.open_node(this, false, true);
- });
- this.__callback({ nodes : this.data.search.result, str : str });
- },
- clear_search : function (str) {
- this.data.search.result.removeClass("jstree-search");
- this.__callback(this.data.search.result);
- this.data.search.result = $();
- },
- _search_open : function (is_callback) {
- var _this = this,
- done = true,
- current = [],
- remaining = [];
- if(this.data.search.to_open.length) {
- $.each(this.data.search.to_open, function (i, val) {
- if(val == "#") { return true; }
- if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
- else { remaining.push(val); }
- });
- if(current.length) {
- this.data.search.to_open = remaining;
- $.each(current, function (i, val) {
- _this.open_node(val, function () { _this._search_open(true); });
- });
- done = false;
- }
- }
- if(done) { this.search(this.data.search.str, true); }
- }
- }
- });
-})(jQuery);
-//*/
-
-/*
- * jsTree contextmenu plugin 1.0
- */
-(function ($) {
- $.vakata.context = {
- cnt : $("