Commit 32e7742d authored by campaign's avatar campaign

minder.node把svg的维护分理出去

parent bd842160
......@@ -28,7 +28,6 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper.addShape( this._rc );
this._paper.getNode().setAttribute( 'contenteditable', true );
this._root = new MinderNode();
this._root.setNotifyHandler(this);
this._rc.addShape( this._root.getRenderContainer() );
if ( this._options.renderTo ) {
......
......@@ -10,12 +10,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
}
this.rc = new kity.Group();
this.rc.minderNode = this;
this.root = null;
},
//在创建root时给定handler
setNotifyHandler:function(treeNotifyHandler){
this.tnh = treeNotifyHandler;
},
getParent: function () {
return this.parent;
},
......@@ -31,7 +27,11 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
getRoot: function () {
return this.root;
var root = this;
while(root.parent){
root = root.parent;
}
return root;
},
preTraverse: function ( fn ) {
......@@ -73,16 +73,16 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node.root = parent.root;
this.children.splice( index, 0, node );
this.handelInsert( node );
},
// this.handelInsert( node );
handelInsert: function ( node ) {
var root = this.getRoot();
if ( root.tnh ) {
root.tnh.handelNodeInsert.call( root.tnh, node );
}
},
//
// handelInsert: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node );
// }
// },
appendChild: function ( node ) {
return this.insertChild( node );
......@@ -101,16 +101,16 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if ( index >= 0 ) {
removed = this.children.splice( index, 1 )[ 0 ];
removed.parent = null;
this.handelRemove( removed );
// this.handelRemove( removed );
}
},
handelRemove: function ( node ) {
var root = this.getRoot();
if ( root.tnh ) {
root.tnh.handelNodeRemove.call( root.tnh, node );
}
},
// handelRemove: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeRemove.call( root.tnh, node );
// }
// },
getChild: function ( index ) {
return this.children[ index ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment