소스 검색

idTree(BUG): upMove & downMove, preSibling

MaiXinRong 8 년 전
부모
커밋
d3aa29e9f5
1개의 변경된 파일5개의 추가작업 그리고 17개의 파일을 삭제
  1. 5 17
      public/web/id_tree.js

+ 5 - 17
public/web/id_tree.js

@@ -73,10 +73,6 @@ var idTree = {
                 var next = (pre && iIndex + count - 1 < children.length) ? children[iIndex + count] : null;
                 if (pre) {
                     pre.setNextSibling(next);
-                    //pre.nextSibling = next;
-                }
-                if (next) {
-                    next.preSibling = pre;
                 }
                 if (arguments.length === 4) {
                     children.splice(iIndex, count);
@@ -99,10 +95,6 @@ var idTree = {
                 if (pre) {
                     pre.setNextSibling(nodes[0]);
                 }
-                nodes[0].preSibling = pre;
-                if (next) {
-                    next.preSibling = nodes[nodes.length - 1];
-                }
                 nodes[nodes.length - 1].setNextSibling(next);
                 for (i = 0; i < nodes.length; i++) {
                     if (arguments.length === 4) {
@@ -170,6 +162,9 @@ var idTree = {
         };
         Node.prototype.setNextSibling = function (nextSibling) {
             this.nextSibling = nextSibling;
+            if (nextSibling) {
+                nextSibling.preSibling = this;
+            }
             if (this.tree.setting.autoUpdate) {
                 this.data[this.tree.setting.nid] = this.getNextSiblingID();
             }
@@ -250,7 +245,7 @@ var idTree = {
             if (nextSibling) {
                 nextSibling.preSibling = preSibling;
             }
-            this.children.splice(this.children.re)
+            this.children.splice(node.siblingIndex, 1);
         };
 
         Node.prototype.canUpLevel = function () {
@@ -338,8 +333,6 @@ var idTree = {
                     orgPre.preSibling.setNextSibling(this);
                 }
                 orgPre.setNextSibling(this.nextSibling);
-                this.preSibling = orgPre.preSibling;
-                orgPre.preSibling = this;
                 this.setNextSibling(orgPre);
                 belongArray.splice(iIndex, 1);
                 belongArray.splice(iIndex - 1, 0, this);
@@ -370,10 +363,8 @@ var idTree = {
                 if (this.preSibling) {
                     this.preSibling.setNextSibling(orgNext);
                 }
-                orgNext.preSibling = this.preSibling;
                 this.setNextSibling(orgNext.nextSibling);
                 orgNext.setNextSibling(this);
-                this.preSibling = orgNext;
                 belongArray.splice(iIndex, 1);
                 belongArray.splice(iIndex + 1, 0, this);
                 tools.sortTreeItems(this.tree);
@@ -572,9 +563,6 @@ var idTree = {
                 if (node.preSibling) {
                     node.preSibling.setNextSibling(node.nextSibling);
                 }
-                if (node.nextSibling) {
-                    node.nextSibling.preSibling = node.preSibling;
-                }
                 if (node.parent) {
                     node.parent.children.splice(node.siblingIndex(), 1);
                 } else {
@@ -622,4 +610,4 @@ var idTree = {
         return new Tree(setting);
     },
     updateType: {update: 'update', new: 'new', delete: 'delete'}
-};
+};