Revision f7551e1c
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
js/jquery.jstree.js | ||
---|---|---|
436 | 436 |
.undelegate(".jstree") |
437 | 437 |
.removeData("jstree_instance_id") |
438 | 438 |
.find("[class^='jstree']") |
439 |
.andSelf()
|
|
439 |
.addBack()
|
|
440 | 440 |
.attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); }); |
441 | 441 |
$(document) |
442 | 442 |
.unbind(".jstree-" + n) |
... | ... | |
679 | 679 |
} |
680 | 680 |
else { |
681 | 681 |
original_obj = obj; |
682 |
if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
|
|
682 |
if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").addBack(); }
|
|
683 | 683 |
else { obj = obj.find("li.jstree-closed"); } |
684 | 684 |
} |
685 | 685 |
var _this = this; |
... | ... | |
695 | 695 |
var _this = this; |
696 | 696 |
obj = obj ? this._get_node(obj) : this.get_container(); |
697 | 697 |
if(!obj || obj === -1) { obj = this.get_container_ul(); } |
698 |
obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this, !do_animation); });
|
|
698 |
obj.find("li.jstree-open").addBack().each(function () { _this.close_node(this, !do_animation); });
|
|
699 | 699 |
this.__callback({ "obj" : obj }); |
700 | 700 |
}, |
701 | 701 |
clean_node : function (obj) { |
702 | 702 |
obj = obj && obj != -1 ? $(obj) : this.get_container_ul(); |
703 |
obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
|
|
703 |
obj = obj.is("li") ? obj.find("li").addBack() : obj.find("li");
|
|
704 | 704 |
obj.removeClass("jstree-last") |
705 | 705 |
.filter("li:last-child").addClass("jstree-last").end() |
706 | 706 |
.filter(":has(li)") |
... | ... | |
925 | 925 |
if(!obj.cy) { |
926 | 926 |
if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; } |
927 | 927 |
obj.o.each(function () { |
928 |
if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
|
|
928 |
if(r.parentsUntil(".jstree", "li").addBack().index(this) !== -1) { ret = false; return false; }
|
|
929 | 929 |
}); |
930 | 930 |
} |
931 | 931 |
return ret; |
... | ... | |
945 | 945 |
var o = false; |
946 | 946 |
if(is_copy) { |
947 | 947 |
o = obj.o.clone(true); |
948 |
o.find("*[id]").andSelf().each(function () {
|
|
948 |
o.find("*[id]").addBack().each(function () {
|
|
949 | 949 |
if(this.id) { this.id = "copy_" + this.id; } |
950 | 950 |
}); |
951 | 951 |
} |
... | ... | |
1142 | 1142 |
switch(!0) { |
1143 | 1143 |
case (is_range): |
1144 | 1144 |
this.data.ui.last_selected.addClass("jstree-last-selected"); |
1145 |
obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").andSelf();
|
|
1145 |
obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").addBack();
|
|
1146 | 1146 |
if(s.select_limit == -1 || obj.length < s.select_limit) { |
1147 | 1147 |
this.data.ui.last_selected.removeClass("jstree-last-selected"); |
1148 | 1148 |
this.data.ui.selected.each(function () { |
... | ... | |
1246 | 1246 |
.bind("move_node.jstree", $.proxy(function (e, data) { |
1247 | 1247 |
if(this._get_settings().crrm.move.open_onmove) { |
1248 | 1248 |
var t = this; |
1249 |
data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
|
|
1249 |
data.rslt.np.parentsUntil(".jstree").addBack().filter(".jstree-closed").each(function () {
|
|
1250 | 1250 |
t.open_node(this, false, true); |
1251 | 1251 |
}); |
1252 | 1252 |
} |
... | ... | |
1791 | 1791 |
obj.data("jstree_children", d); |
1792 | 1792 |
} |
1793 | 1793 |
if($.isArray(js)) { |
1794 |
d = $(); |
|
1794 |
d = $('<ul>');
|
|
1795 | 1795 |
if(!js.length) { return false; } |
1796 | 1796 |
for(i = 0, j = js.length; i < j; i++) { |
1797 | 1797 |
tmp = this._parse_json(js[i], obj, true); |
1798 |
if(tmp.length) { d = d.add(tmp); } |
|
1798 |
if(tmp.length) { |
|
1799 |
d = d.append(tmp); |
|
1800 |
} |
|
1799 | 1801 |
} |
1802 |
d = d.children(); |
|
1800 | 1803 |
} |
1801 | 1804 |
else { |
1802 | 1805 |
if(typeof js == "string") { js = { data : js }; } |
... | ... | |
2804 | 2807 |
obj.each(function () { |
2805 | 2808 |
t = $(this); |
2806 | 2809 |
c = t.is("li") && (t.hasClass("jstree-checked") || (rc && t.children(":checked").length)) ? "jstree-checked" : "jstree-unchecked"; |
2807 |
t.find("li").andSelf().each(function () {
|
|
2810 |
t.find("li").addBack().each(function () {
|
|
2808 | 2811 |
var $t = $(this), nm; |
2809 | 2812 |
$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 ); |
2810 | 2813 |
if(rc) { |
... | ... | |
2818 | 2821 |
} |
2819 | 2822 |
if(!ts) { |
2820 | 2823 |
if(c === "jstree-checked" || $t.hasClass("jstree-checked") || $t.children(':checked').length) { |
2821 |
$t.find("li").andSelf().addClass("jstree-checked").children(":checkbox").prop("checked", true);
|
|
2824 |
$t.find("li").addBack().addClass("jstree-checked").children(":checkbox").prop("checked", true);
|
|
2822 | 2825 |
} |
2823 | 2826 |
} |
2824 | 2827 |
else { |
... | ... | |
2849 | 2852 |
} |
2850 | 2853 |
else { |
2851 | 2854 |
if(state) { |
2852 |
coll = obj.find("li").andSelf();
|
|
2855 |
coll = obj.find("li").addBack();
|
|
2853 | 2856 |
if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; } |
2854 | 2857 |
coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); |
2855 | 2858 |
if(rc) { coll.children(":checkbox").prop("checked", false); } |
2856 | 2859 |
} |
2857 | 2860 |
else { |
2858 |
coll = obj.find("li").andSelf();
|
|
2861 |
coll = obj.find("li").addBack();
|
|
2859 | 2862 |
if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; } |
2860 | 2863 |
coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked"); |
2861 | 2864 |
if(rc) { coll.children(":checkbox").prop("checked", true); } |
... | ... | |
2866 | 2869 |
var $this = $(this); |
2867 | 2870 |
if(state) { |
2868 | 2871 |
if($this.children("ul").children("li.jstree-checked, li.jstree-undetermined").length) { |
2869 |
$this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2870 |
if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").prop("checked", false); }
|
|
2872 |
$this.parentsUntil(".jstree", "li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2873 |
if(rc) { $this.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
|
|
2871 | 2874 |
return false; |
2872 | 2875 |
} |
2873 | 2876 |
else { |
... | ... | |
2877 | 2880 |
} |
2878 | 2881 |
else { |
2879 | 2882 |
if($this.children("ul").children("li.jstree-unchecked, li.jstree-undetermined").length) { |
2880 |
$this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2881 |
if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").prop("checked", false); }
|
|
2883 |
$this.parentsUntil(".jstree", "li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2884 |
if(rc) { $this.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
|
|
2882 | 2885 |
return false; |
2883 | 2886 |
} |
2884 | 2887 |
else { |
... | ... | |
2942 | 2945 |
obj = this._get_node(obj); |
2943 | 2946 |
if(!obj.length) { return; } |
2944 | 2947 |
if(this._get_settings().checkbox.two_state) { |
2945 |
obj.find('li').andSelf().not('.jstree-checked').removeClass('jstree-undetermined').addClass('jstree-unchecked').children(':checkbox').prop('checked', true);
|
|
2948 |
obj.find('li').addBack().not('.jstree-checked').removeClass('jstree-undetermined').addClass('jstree-unchecked').children(':checkbox').prop('checked', true);
|
|
2946 | 2949 |
return; |
2947 | 2950 |
} |
2948 | 2951 |
var rc = this._get_settings().checkbox.real_checkboxes, |
... | ... | |
2953 | 2956 |
else if(a === 0 && b === 0) { this.change_state(obj, true); } |
2954 | 2957 |
else if(a === c) { this.change_state(obj, false); } |
2955 | 2958 |
else { |
2956 |
obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2957 |
if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").prop("checked", false); }
|
|
2959 |
obj.parentsUntil(".jstree","li").addBack().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
|
|
2960 |
if(rc) { obj.parentsUntil(".jstree", "li").addBack().children(":checkbox").prop("checked", false); }
|
|
2958 | 2961 |
} |
2959 | 2962 |
}, |
2960 | 2963 |
reselect : function () { |
... | ... | |
3426 | 3429 |
this.get_container() |
3427 | 3430 |
.bind("search.jstree", function (e, data) { |
3428 | 3431 |
$(this).children("ul").find("li").hide().removeClass("jstree-last"); |
3429 |
data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
|
|
3432 |
data.rslt.nodes.parentsUntil(".jstree").addBack().show()
|
|
3430 | 3433 |
.filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); }); |
3431 | 3434 |
}) |
3432 | 3435 |
.bind("clear_search.jstree", function () { |
... | ... | |
4012 | 4015 |
// this used to use html() and clean the whitespace, but this way any attached data was lost |
4013 | 4016 |
this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true); |
4014 | 4017 |
// remove white space from LI node - otherwise nodes appear a bit to the right |
4015 |
this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
|
|
4018 |
this.data.html_data.original_container_html.find("li").addBack().contents().filter(function() { return this.nodeType == 3; }).remove();
|
|
4016 | 4019 |
}, |
4017 | 4020 |
defaults : { |
4018 | 4021 |
data : false, |
... | ... | |
4443 | 4446 |
obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj); |
4444 | 4447 |
if(obj === false) { return; } // added for removing root nodes |
4445 | 4448 |
obj.each(function () { |
4446 |
$(this).find("li").andSelf().each(function () {
|
|
4449 |
$(this).find("li").addBack().each(function () {
|
|
4447 | 4450 |
var $t = $(this); |
4448 | 4451 |
if($t.children(".jstree-wholerow-span").length) { return true; } |
4449 | 4452 |
$t.prepend("<span class='jstree-wholerow-span' style='width:" + ($t.parentsUntil(".jstree","li").length * 18) + "px;'> </span>"); |
Auch abrufbar als: Unified diff
jstree auf v1.0fix2 aktualisiert
Behebt das Problem, dass Items in anderer Reihenfolge angelegt wurden,
als sie im »data«-Array standen.