vendor/assets/javascripts/jquery.jstree/jquery.jstree.js in spree_backend-3.2.5 vs vendor/assets/javascripts/jquery.jstree/jquery.jstree.js in spree_backend-3.2.6
- old
+ new
@@ -11,11 +11,11 @@
* $Date: 2011-02-09 01:17:14 +0200 (ср, 09 февр 2011) $
* $Revision: 236 $
*/
/*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */
-/*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
+/*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false, ActiveXObject: false */
"use strict";
// top wrapper to prevent multiple inclusion (is this OK?)
(function () { if(jQuery && jQuery.jstree) { return; }
@@ -112,19 +112,19 @@
// if a method call execute the method on all selected instances
if(isMethodCall) {
if(settings.substring(0, 1) == '_') { return returnValue; }
this.each(function() {
- var instance = instances[$.data(this, "jstree-instance-id")],
+ var instance = instances[$.data(this, "jstree_instance_id")],
methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance;
if(typeof methodValue !== "undefined" && (settings.indexOf("is_") === 0 || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; }
});
}
else {
this.each(function() {
// extend settings and allow for multiple hashes and $.data
- var instance_id = $.data(this, "jstree-instance-id"),
+ var instance_id = $.data(this, "jstree_instance_id"),
a = [],
b = settings ? $.extend({}, true, settings) : {},
c = $(this),
s = false,
t = [];
@@ -135,11 +135,11 @@
// if an instance already exists, destroy it first
if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); }
// push a new empty object to the instances array
instance_id = parseInt(instances.push({}),10) - 1;
// store the jstree instance id to the container element
- $.data(this, "jstree-instance-id", instance_id);
+ $.data(this, "jstree_instance_id", instance_id);
// clean up all plugins
b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice();
b.plugins.unshift("core");
// only unique plugins
b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
@@ -157,11 +157,11 @@
instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
// init all activated plugins for this instance
$.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
$.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
// initialize the instance
- setTimeout(function() { instances[instance_id].init(); }, 0);
+ setTimeout(function() { if(instances[instance_id]) { instances[instance_id].init(); } }, 0);
});
}
// return the jquery selection (or if it was a method call that returned a value - the returned value)
return returnValue;
};
@@ -176,11 +176,11 @@
if(instances[needle]) { return instances[needle]; }
// get by DOM (if still no luck - return null
var o = $(needle);
if(!o.length && typeof needle === "string") { o = $("#" + needle); }
if(!o.length) { return null; }
- return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
+ return instances[o.closest(".jstree").data("jstree_instance_id")] || null;
},
_instance : function (index, container, settings) {
// for plugins to store data in
this.data = { core : {} };
this.get_settings = function () { return $.extend(true, {}, settings); };
@@ -354,11 +354,12 @@
this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;
this.get_container()
.delegate("li > ins", "click.jstree", $.proxy(function (event) {
var trgt = $(event.target);
- if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
+ // if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
+ this.toggle_node(trgt);
}, this))
.bind("mousedown.jstree", $.proxy(function () {
this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
}, this))
.bind("dblclick.jstree", function (event) {
@@ -431,13 +432,13 @@
if(n === focused_instance) { focused_instance = -1; }
// remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
this.get_container()
.unbind(".jstree")
.undelegate(".jstree")
- .removeData("jstree-instance-id")
+ .removeData("jstree_instance_id")
.find("[class^='jstree']")
- .andSelf()
+ .addBack()
.attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
$(document)
.unbind(".jstree-" + n)
.undelegate(".jstree-" + n);
// remove the actual data
@@ -676,11 +677,11 @@
if(original_obj) {
obj = obj.find("li.jstree-closed");
}
else {
original_obj = obj;
- if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
+ if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").addBack(); }
else { obj = obj.find("li.jstree-closed"); }
}
var _this = this;
obj.each(function () {
var __this = this;
@@ -692,16 +693,16 @@
},
close_all : function (obj, do_animation) {
var _this = this;
obj = obj ? this._get_node(obj) : this.get_container();
if(!obj || obj === -1) { obj = this.get_container_ul(); }
- obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this, !do_animation); });
+ obj.find("li.jstree-open").addBack().each(function () { _this.close_node(this, !do_animation); });
this.__callback({ "obj" : obj });
},
clean_node : function (obj) {
obj = obj && obj != -1 ? $(obj) : this.get_container_ul();
- obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
+ obj = obj.is("li") ? obj.find("li").addBack() : obj.find("li");
obj.removeClass("jstree-last")
.filter("li:last-child").addClass("jstree-last").end()
.filter(":has(li)")
.not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();
@@ -750,10 +751,11 @@
if(!m.attr.href) { m.attr.href = '#'; }
tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
if(m.language) { tmp.addClass(m.language); }
}
tmp.prepend("<ins class='jstree-icon'> </ins>");
+ if(!m.icon && js.icon) { m.icon = js.icon; }
if(m.icon) {
if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
}
d.append(tmp);
@@ -918,14 +920,16 @@
if(cb) { cb.call(this, prepared_move); }
},
check_move : function () {
var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r;
if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; }
- if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
- obj.o.each(function () {
- if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
- });
+ if(!obj.cy) {
+ if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
+ obj.o.each(function () {
+ if(r.parentsUntil(".jstree", "li").addBack().index(this) !== -1) { ret = false; return false; }
+ });
+ }
return ret;
},
move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
if(!is_prepared) {
return this.prepare_move(obj, ref, position, function (p) {
@@ -939,11 +943,11 @@
this.__rollback();
var o = false;
if(is_copy) {
o = obj.o.clone(true);
- o.find("*[id]").andSelf().each(function () {
+ o.find("*[id]").addBack().each(function () {
if(this.id) { this.id = "copy_" + this.id; }
});
}
else { o = obj.o; }
@@ -1136,11 +1140,11 @@
}
proceed = false;
switch(!0) {
case (is_range):
this.data.ui.last_selected.addClass("jstree-last-selected");
- obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").andSelf();
+ obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").addBack();
if(s.select_limit == -1 || obj.length < s.select_limit) {
this.data.ui.last_selected.removeClass("jstree-last-selected");
this.data.ui.selected.each(function () {
if(this !== t.data.ui.last_selected[0]) { t.deselect_node(this); }
});
@@ -1240,11 +1244,11 @@
__init : function () {
this.get_container()
.bind("move_node.jstree", $.proxy(function (e, data) {
if(this._get_settings().crrm.move.open_onmove) {
var t = this;
- data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
+ data.rslt.np.parentsUntil(".jstree").addBack().filter(".jstree-closed").each(function () {
t.open_node(this, false, true);
});
}
}, this));
},
@@ -1656,34 +1660,34 @@
},
refresh : function (obj) {
obj = this._get_node(obj);
var s = this._get_settings().json_data;
if(obj && obj !== -1 && s.progressive_unload && ($.isFunction(s.data) || !!s.ajax)) {
- obj.removeData("jstree-children");
+ obj.removeData("jstree_children");
}
return this.__call_old();
},
load_node_json : function (obj, s_call, e_call) {
var s = this.get_settings().json_data, d,
error_func = function () {},
success_func = function () {};
obj = this._get_node(obj);
- 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")) {
- d = this._parse_json(obj.data("jstree-children"), obj);
+ 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")) {
+ d = this._parse_json(obj.data("jstree_children"), obj);
if(d) {
obj.append(d);
- if(!s.progressive_unload) { obj.removeData("jstree-children"); }
+ if(!s.progressive_unload) { obj.removeData("jstree_children"); }
}
this.clean_node(obj);
if(s_call) { s_call.call(this); }
return;
}
if(obj && obj !== -1) {
- if(obj.data("jstree-is-loading")) { return; }
- else { obj.data("jstree-is-loading",true); }
+ 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.";
// function option added here for easier model integration (also supporting async - see callback)
case ($.isFunction(s.data)):
@@ -1693,18 +1697,18 @@
if(obj === -1 || !obj) {
if(s.correct_state) { this.get_container().children("ul").empty(); }
}
else {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) { this.correct_state(obj); }
}
if(e_call) { e_call.call(this); }
}
else {
if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
- else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
+ else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); }
this.clean_node(obj);
if(s_call) { s_call.call(this); }
}
}, this));
break;
@@ -1725,11 +1729,11 @@
error_func = function (x, t, e) {
var ef = this.get_settings().json_data.ajax.error;
if(ef) { ef.call(this, x, t, e); }
if(obj != -1 && obj.length) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(t === "success" && s.correct_state) { this.correct_state(obj); }
}
else {
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
}
@@ -1742,11 +1746,11 @@
return error_func.call(this, x, t, "");
}
d = this._parse_json(d, obj);
if(d) {
if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
- else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
+ else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); }
this.clean_node(obj);
if(s_call) { s_call.call(this); }
}
else {
if(obj === -1 || !obj) {
@@ -1755,11 +1759,11 @@
if(s_call) { s_call.call(this); }
}
}
else {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) {
this.correct_state(obj);
if(s_call) { s_call.call(this); }
}
}
@@ -1782,18 +1786,20 @@
t = p.core.html_titles,
tmp, i, j, ul1, ul2;
if(!js) { return d; }
if(s.progressive_unload && obj && obj !== -1) {
- obj.data("jstree-children", d);
+ obj.data("jstree_children", d);
}
if($.isArray(js)) {
d = $('<ul>');
if(!js.length) { return false; }
for(i = 0, j = js.length; i < j; i++) {
tmp = this._parse_json(js[i], obj, true);
- if(tmp.length) { d = d.append(tmp); }
+ if(tmp.length) {
+ d = d.append(tmp);
+ }
}
d = d.children();
}
else {
if(typeof js == "string") { js = { data : js }; }
@@ -1822,14 +1828,14 @@
d.append(tmp);
});
d.prepend("<ins class='jstree-icon'> </ins>");
if(js.children) {
if(s.progressive_render && js.state !== "open") {
- d.addClass("jstree-closed").data("jstree-children", js.children);
+ d.addClass("jstree-closed").data("jstree_children", js.children);
}
else {
- if(s.progressive_unload) { d.data("jstree-children", js.children); }
+ if(s.progressive_unload) { d.data("jstree_children", js.children); }
if($.isArray(js.children) && js.children.length) {
tmp = this._parse_json(js.children, obj, true);
if(tmp.length) {
ul2 = $("<ul />");
ul2.append(tmp);
@@ -1926,10 +1932,11 @@
* Adds support for multiple language versions in one tree
* This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
* This is useful for maintaining the same structure in many languages (hence the name of the plugin)
*/
(function ($) {
+ var sh = false;
$.jstree.plugin("languages", {
__init : function () { this._load_css(); },
defaults : [],
_fn : {
set_lang : function (i) {
@@ -1940,13 +1947,13 @@
if($.inArray(i,langs) == -1) {
if(!!langs[i]) { i = langs[i]; }
else { return false; }
}
if(i == this.data.languages.current_language) { return true; }
- st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, this.data.languages.language_css);
+ st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, sh);
if(st !== false) { st.style.display = "none"; }
- st = $.vakata.css.get_css(selector + "." + i, false, this.data.languages.language_css);
+ st = $.vakata.css.get_css(selector + "." + i, false, sh);
if(st !== false) { st.style.display = ""; }
this.data.languages.current_language = i;
this.__callback(i);
return true;
},
@@ -2016,11 +2023,11 @@
for(ln = 0; ln < langs.length; ln++) {
str += selector + "." + langs[ln] + " {";
if(langs[ln] != this.data.languages.current_language) { str += " display:none; "; }
str += " } ";
}
- this.data.languages.language_css = $.vakata.css.add_sheet({ 'str' : str, 'title' : "jstree-languages" });
+ sh = $.vakata.css.add_sheet({ 'str' : str, 'title' : "jstree-languages" });
}
},
create_node : function (obj, position, js, callback) {
var t = this.__call_old(true, obj, position, js, function (t) {
var langs = this._get_settings().languages,
@@ -2684,18 +2691,18 @@
}
});
$(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; ' +
- ' border-radius:4px; -webkit-border-radius:4px; ' +
+ ' -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; ' +
'} ' +
'#vakata-dragged .jstree-ok { background:green; } ' +
'#vakata-dragged .jstree-invalid { background:red; } ' +
'#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; } ' +
'#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; ' +
' 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; ' +
- ' border-radius:1px; -webkit-border-radius:1px; ' +
+ ' -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; ' +
'}' +
'';
$.vakata.css.add_sheet({ str : css_string, title : "jstree" });
m = $("<div />").attr({ id : "jstree-marker" }).hide().html("»")
.bind("mouseleave mouseenter", function (e) {
@@ -2798,34 +2805,35 @@
if(obj === false) { return; } // added for removing root nodes
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;
obj.each(function () {
t = $(this);
c = t.is("li") && (t.hasClass("jstree-checked") || (rc && t.children(":checked").length)) ? "jstree-checked" : "jstree-unchecked";
- t.find("li").andSelf().each(function () {
+ t.find("li").addBack().each(function () {
var $t = $(this), nm;
$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 );
if(rc) {
if(!$t.children(":checkbox").length) {
nm = rcn.call(_this, $t);
$t.prepend("<input type='checkbox' class='jstree-real-checkbox' id='" + nm[0] + "' name='" + nm[0] + "' value='" + nm[1] + "' />");
}
else {
$t.children(":checkbox").addClass("jstree-real-checkbox");
}
- if(c === "jstree-checked") {
- $t.children(":checkbox").attr("checked","checked");
+ }
+ if(!ts) {
+ if(c === "jstree-checked" || $t.hasClass("jstree-checked") || $t.children(':checked').length) {
+ $t.find("li").addBack().addClass("jstree-checked").children(":checkbox").prop("checked", true);
}
}
- if(c === "jstree-checked" && !ts) {
- $t.find("li").addClass("jstree-checked");
+ else {
+ if($t.hasClass("jstree-checked") || $t.children(':checked').length) {
+ $t.addClass("jstree-checked").children(":checkbox").prop("checked", true);
+ }
}
});
});
if(!ts) {
- if(obj.length === 1 && obj.is("li")) { this._repair_state(obj); }
- if(obj.is("li")) { obj.each(function () { _this._repair_state(this); }); }
- else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
obj.find(".jstree-checked").parent().parent().each(function () { _this._repair_state(this); });
}
},
change_state : function (obj, state) {
obj = this._get_node(obj);
@@ -2833,54 +2841,54 @@
if(!obj || obj === -1) { return false; }
state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
if(this._get_settings().checkbox.two_state) {
if(state) {
obj.removeClass("jstree-checked").addClass("jstree-unchecked");
- if(rc) { obj.children(":checkbox").removeAttr("checked"); }
+ if(rc) { obj.children(":checkbox").prop("checked", false); }
}
else {
obj.removeClass("jstree-unchecked").addClass("jstree-checked");
- if(rc) { obj.children(":checkbox").attr("checked","checked"); }
+ if(rc) { obj.children(":checkbox").prop("checked", true); }
}
}
else {
if(state) {
- coll = obj.find("li").andSelf();
+ coll = obj.find("li").addBack();
if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; }
coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
- if(rc) { coll.children(":checkbox").removeAttr("checked"); }
+ if(rc) { coll.children(":checkbox").prop("checked", false); }
}
else {
- coll = obj.find("li").andSelf();
+ coll = obj.find("li").addBack();
if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; }
coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
- if(rc) { coll.children(":checkbox").attr("checked","checked"); }
+ if(rc) { coll.children(":checkbox").prop("checked", true); }
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("li.jstree-checked, li.jstree-undetermined").length) {
- $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
+ $this.parentsUntil(".jstree", "li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
+ if(rc) { $this.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
return false;
}
else {
$this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
- if(rc) { $this.children(":checkbox").removeAttr("checked"); }
+ if(rc) { $this.children(":checkbox").prop("checked", false); }
}
}
else {
if($this.children("ul").children("li.jstree-unchecked, li.jstree-undetermined").length) {
- $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
+ $this.parentsUntil(".jstree", "li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
+ if(rc) { $this.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
return false;
}
else {
$this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
- if(rc) { $this.children(":checkbox").attr("checked","checked"); }
+ if(rc) { $this.children(":checkbox").prop("checked", true); }
}
}
});
}
if(this.data.ui && this.data.checkbox.noui) { this.data.ui.selected = this.get_checked(); }
@@ -2934,20 +2942,24 @@
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; }
+ if(this._get_settings().checkbox.two_state) {
+ obj.find('li').addBack().not('.jstree-checked').removeClass('jstree-undetermined').addClass('jstree-unchecked').children(':checkbox').prop('checked', true);
+ return;
+ }
var rc = this._get_settings().checkbox.real_checkboxes,
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.change_state(obj, false); } }
else if(a === 0 && b === 0) { this.change_state(obj, true); }
else if(a === c) { this.change_state(obj, false); }
else {
- obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
- if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
+ obj.parentsUntil(".jstree","li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
+ if(rc) { obj.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
}
},
reselect : function () {
if(this.data.ui && this.data.checkbox.noui) {
var _this = this,
@@ -2981,53 +2993,41 @@
* jsTree XML plugin
* 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;
- // TODO: IE9 no XSLTProcessor, no document.recalc
- 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 () { $(xm).remove(); $(xs).remove(); }; })(xm, xs), 200);
- };
- })(xm, xs, callback), 100);
- return true;
+ var r = false, p, q, s;
+ // IE9
+ if(r === false && (window.ActiveXObject || "ActiveXObject" in window)) {
+ try {
+ r = new ActiveXObject("Msxml2.XSLTemplate");
+ q = new ActiveXObject("Msxml2.DOMDocument");
+ q.loadXML(xml);
+ s = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
+ s.loadXML(xsl);
+ r.stylesheet = s;
+ p = r.createProcessor();
+ p.input = q;
+ p.transform();
+ r = p.output;
+ }
+ catch (e) { }
}
- if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor === "undefined") {
- xml = new DOMParser().parseFromString(xml, "text/xml");
- xsl = new DOMParser().parseFromString(xsl, "text/xml");
- // alert(xml.transformNode());
- // callback.call(null, new XMLSerializer().serializeToString(rs));
-
+ xml = $.parseXML(xml);
+ xsl = $.parseXML(xsl);
+ // FF, Chrome
+ if(r === false && typeof (XSLTProcessor) !== "undefined") {
+ p = new XSLTProcessor();
+ p.importStylesheet(xsl);
+ r = p.transformToFragment(xml, document);
+ r = $('<div />').append(r).html();
}
- 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, new XMLSerializer().serializeToString(rs));
- return true;
- }
- else {
- processor.importStylesheet(xsl);
- rs = processor.transformToFragment(xml, document);
- callback.call(null, $("<div />").append(rs).html());
- return true;
- }
+ // OLD IE
+ if(r === false && typeof (xml.transformNode) !== "undefined") {
+ r = xml.transformNode(xsl);
}
- return false;
+ callback.call(null, r);
};
var xsl = {
'nest' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
'<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
@@ -3192,12 +3192,12 @@
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); }
+ 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 ($.isFunction(s.data)):
s.data.call(this, obj, $.proxy(function (d) {
@@ -3205,18 +3205,18 @@
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("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree_is_loading"); }
if(s.clean_node) { this.clean_node(obj); }
if(s_call) { s_call.call(this); }
}
else {
if(obj && obj !== -1) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) {
this.correct_state(obj);
if(s_call) { s_call.call(this); }
}
}
@@ -3256,11 +3256,11 @@
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("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(t === "success" && s.correct_state) { this.correct_state(obj); }
}
else {
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
}
@@ -3277,18 +3277,18 @@
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("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree_is_loading"); }
if(s.clean_node) { this.clean_node(obj); }
if(s_call) { s_call.call(this); }
}
else {
if(obj && obj !== -1) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) {
this.correct_state(obj);
if(s_call) { s_call.call(this); }
}
}
@@ -3399,25 +3399,39 @@
* jsTree search plugin
* 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;
- };
- $.expr[':'].jstree_title_contains = function(a,i,m) {
- return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
- };
+ if($().jquery.split('.')[1] >= 8) {
+ $.expr[':'].jstree_contains = $.expr.createPseudo(function(search) {
+ return function(a) {
+ return (a.textContent || a.innerText || "").toLowerCase().indexOf(search.toLowerCase())>=0;
+ };
+ });
+ $.expr[':'].jstree_title_contains = $.expr.createPseudo(function(search) {
+ return function(a) {
+ return (a.getAttribute("title") || "").toLowerCase().indexOf(search.toLowerCase())>=0;
+ };
+ });
+ }
+ else {
+ $.expr[':'].jstree_contains = function(a,i,m){
+ return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
+ };
+ $.expr[':'].jstree_title_contains = function(a,i,m) {
+ return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
+ };
+ }
$.jstree.plugin("search", {
__init : function () {
this.data.search.str = "";
this.data.search.result = $();
if(this._get_settings().search.show_only_matches) {
this.get_container()
.bind("search.jstree", function (e, data) {
$(this).children("ul").find("li").hide().removeClass("jstree-last");
- data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
+ data.rslt.nodes.parentsUntil(".jstree").addBack().show()
.filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); });
})
.bind("clear_search.jstree", function () {
$(this).children("ul").find("li").css("display","").end().end().jstree("clean_node", -1);
});
@@ -3684,10 +3698,15 @@
e.preventDefault();
if(!$(e.currentTarget).hasClass("jstree-loading")) {
this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
}
}, this))
+ .delegate("a", "click.jstree", $.proxy(function (e) {
+ if(this.data.contextmenu) {
+ $.vakata.context.hide();
+ }
+ }, this))
.bind("destroy.jstree", $.proxy(function () {
// TODO: move this to descruct method
if(this.data.contextmenu) {
$.vakata.context.hide();
}
@@ -3994,11 +4013,11 @@
$.jstree.plugin("html_data", {
__init : function () {
// this used to use html() and clean the whitespace, but this way any attached data was lost
this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
// remove white space from LI node - otherwise nodes appear a bit to the right
- this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
+ this.data.html_data.original_container_html.find("li").addBack().contents().filter(function() { return this.nodeType == 3; }).remove();
},
defaults : {
data : false,
ajax : false,
correct_state : true
@@ -4014,28 +4033,28 @@
s = this.get_settings().html_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); }
+ if(obj.data("jstree_is_loading")) { return; }
+ else { obj.data("jstree_is_loading",true); }
}
switch(!0) {
case ($.isFunction(s.data)):
s.data.call(this, obj, $.proxy(function (d) {
if(d && d !== "" && d.toString && d.toString().replace(/^[\s\n]+$/,"") !== "") {
d = $(d);
if(!d.is("ul")) { d = $("<ul />").append(d); }
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"); }
- 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"); }
+ 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"); }
this.clean_node(obj);
if(s_call) { s_call.call(this); }
}
else {
if(obj && obj !== -1) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) {
this.correct_state(obj);
if(s_call) { s_call.call(this); }
}
}
@@ -4076,11 +4095,11 @@
error_func = function (x, t, e) {
var ef = this.get_settings().html_data.ajax.error;
if(ef) { ef.call(this, x, t, e); }
if(obj != -1 && obj.length) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(t === "success" && s.correct_state) { this.correct_state(obj); }
}
else {
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
}
@@ -4094,18 +4113,18 @@
}
if(d) {
d = $(d);
if(!d.is("ul")) { d = $("<ul />").append(d); }
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"); }
- 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"); }
+ 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"); }
this.clean_node(obj);
if(s_call) { s_call.call(this); }
}
else {
if(obj && obj !== -1) {
obj.children("a.jstree-loading").removeClass("jstree-loading");
- obj.removeData("jstree-is-loading");
+ obj.removeData("jstree_is_loading");
if(s.correct_state) {
this.correct_state(obj);
if(s_call) { s_call.call(this); }
}
}
@@ -4212,11 +4231,12 @@
.find("." + c.join(", .")).removeClass(c.join(" "));
},
_fn : {
_themeroller : function (obj) {
var s = this._get_settings().themeroller;
- obj = !obj || obj == -1 ? this.get_container_ul() : this._get_node(obj).parent();
+ obj = (!obj || obj == -1) ? this.get_container_ul() : this._get_node(obj);
+ obj = (!obj || obj == -1) ? this.get_container_ul() : obj.parent();
obj
.find("li.jstree-closed")
.children("ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
.children("a").addClass(s.item)
.children("ins.jstree-icon").addClass("ui-icon")
@@ -4325,19 +4345,23 @@
defaults : {
error_callback : $.noop
},
_fn : {
_check_unique : function (nms, p, func) {
- var cnms = [];
+ var cnms = [], ok = true;
p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
if(!cnms.length || !nms.length) { return true; }
- cnms = cnms.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
- if((cnms.length + nms.length) != cnms.concat(nms).sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",").length) {
+ $.each(nms, function (i, v) {
+ if($.inArray(v, cnms) !== -1) {
+ ok = false;
+ return false;
+ }
+ });
+ if(!ok) {
this._get_settings().unique.error_callback.call(null, nms, p, func);
- return false;
}
- return true;
+ return ok;
},
check_move : function () {
if(!this.__call_old()) { return false; }
var p = this._get_move(), nms = [];
if(p.o && p.o.length) {
@@ -4420,10 +4444,10 @@
_fn : {
_prepare_wholerow_span : function (obj) {
obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj);
if(obj === false) { return; } // added for removing root nodes
obj.each(function () {
- $(this).find("li").andSelf().each(function () {
+ $(this).find("li").addBack().each(function () {
var $t = $(this);
if($t.children(".jstree-wholerow-span").length) { return true; }
$t.prepend("<span class='jstree-wholerow-span' style='width:" + ($t.parentsUntil(".jstree","li").length * 18) + "px;'> </span>");
});
});
\ No newline at end of file