jstree auf v1.0fix2 aktualisiert
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 22 Jan 2014 13:44:31 +0000 (14:44 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:12:27 +0000 (13:12 +0200)
Behebt das Problem, dass Items in anderer Reihenfolge angelegt wurden,
als sie im »data«-Array standen.

doc/js/README.jstree.txt [new file with mode: 0644]
js/jquery.jstree.js

diff --git a/doc/js/README.jstree.txt b/doc/js/README.jstree.txt
new file mode 100644 (file)
index 0000000..54e7fb7
--- /dev/null
@@ -0,0 +1,15 @@
+To publish jstree 3.0.0 I need your opinion:
+https://groups.google.com/forum/#!topic/jstree/Yabg_OLPuvQ
+
+********************************************************************
+
+jsTree pre1.0
+http://jstree.com/
+
+Copyright (c) 2011 Ivan Bozhanov (vakata.com)
+
+Dual licensed under the MIT and GPL licenses:
+  http://www.opensource.org/licenses/mit-license.php
+  http://www.gnu.org/licenses/gpl.html
+
+This is the latest stable version before switching from GoogleCode to GitHub.
index b4aac3e..c92c2ac 100644 (file)
                                        .undelegate(".jstree")
                                        .removeData("jstree_instance_id")
                                        .find("[class^='jstree']")
-                                               .andSelf()
+                                               .addBack()
                                                .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
                                $(document)
                                        .unbind(".jstree-" + n)
                                }
                                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;
                                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)")
                                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").andSelf().index(this) !== -1) { ret = false; return false; }
+                                               if(r.parentsUntil(".jstree", "li").addBack().index(this) !== -1) { ret = false; return false; }
                                        });
                                }
                                return ret;
                                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; }
                                        });
                                }
                                        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 () {
                                .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);
                                                });
                                        }
                                        obj.data("jstree_children", d);
                                }
                                if($.isArray(js)) {
-                                       d = $();
+                                       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.add(tmp); }
+                                               if(tmp.length) {
+                                                       d = d.append(tmp);
+                                               }
                                        }
+                                       d = d.children();
                                }
                                else {
                                        if(typeof js == "string") { js = { data : js }; }
                                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'>&#160;</ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass( ts ? "jstree-unchecked" : c );
                                                if(rc) {
                                                }
                                                if(!ts) {
                                                        if(c === "jstree-checked" || $t.hasClass("jstree-checked") || $t.children(':checked').length) {
-                                                               $t.find("li").andSelf().addClass("jstree-checked").children(":checkbox").prop("checked", true);
+                                                               $t.find("li").addBack().addClass("jstree-checked").children(":checkbox").prop("checked", true);
                                                        }
                                                }
                                                else {
                                }
                                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").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").prop("checked", true); }
                                                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").prop("checked", false); }
+                                                               $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 {
                                                }
                                                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").prop("checked", false); }
+                                                               $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 {
                                obj = this._get_node(obj);
                                if(!obj.length) { return; }
                                if(this._get_settings().checkbox.two_state) {
-                                       obj.find('li').andSelf().not('.jstree-checked').removeClass('jstree-undetermined').addClass('jstree-unchecked').children(':checkbox').prop('checked', true);
+                                       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,
                                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").prop("checked", false); }
+                                       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 () {
                                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 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,
                                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;'>&#160;</span>");