Commit ae46c37d authored by Akikonata's avatar Akikonata

fixed the undo and redo

parent 5e59c39c
...@@ -182,7 +182,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -182,7 +182,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
}; };
} )() ); } )() );
var root = this.getRoot();
//更新连线 //更新连线
var updateConnect = function ( minder, node, action ) { var updateConnect = function ( minder, node, action ) {
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
...@@ -288,7 +287,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -288,7 +287,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
prt = prt.getParent(); prt = prt.getParent();
} while ( prt ); } while ( prt );
//遍历 //遍历
var _buffer = [ root ]; var _buffer = [ minder.getRoot() ];
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
_buffer = _buffer.concat( countY( _buffer[ 0 ], appendside ) ); _buffer = _buffer.concat( countY( _buffer[ 0 ], appendside ) );
effectSet.push( _buffer[ 0 ] ); effectSet.push( _buffer[ 0 ] );
...@@ -369,10 +368,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -369,10 +368,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
drawNode( node ); drawNode( node );
}, },
initStyle: function () { initStyle: function () {
//清空节点上附加的数据; //绘制root并且调整到正确位置
var _root = this.getRoot();
this.getRenderContainer().clear().addShape( _root.getRenderContainer().clear() );
var minder = this; var minder = this;
var _root = minder.getRoot(); _root.setData( "text", _root.getData( "text" ) || "I am the root" );
_root.setData( 'layout', {} ); _root.setData("layout",{});
var Layout = _root.getData( "layout" ); var Layout = _root.getData( "layout" );
Layout.style = { Layout.style = {
radius: 10, radius: 10,
...@@ -409,6 +410,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -409,6 +410,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
}, },
appendChildNode: function ( parent, node, index ) { appendChildNode: function ( parent, node, index ) {
var _root = this.getRoot();
if ( !node.getData( "layout" ) ) node.setData( "layout", {} ); if ( !node.getData( "layout" ) ) node.setData( "layout", {} );
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
var parentLayout = parent.getData( "layout" ); var parentLayout = parent.getData( "layout" );
...@@ -418,7 +420,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -418,7 +420,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
else parent.insertChild( node, index ); else parent.insertChild( node, index );
} }
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
if ( parent === root ) { if ( parent === _root ) {
var leftList = parentLayout.leftList; var leftList = parentLayout.leftList;
var rightList = parentLayout.rightList; var rightList = parentLayout.rightList;
var sibling = parent.getChildren(); var sibling = parent.getChildren();
......
...@@ -182,7 +182,6 @@ KityMinder.registerModule( "LayoutGreen", function () { ...@@ -182,7 +182,6 @@ KityMinder.registerModule( "LayoutGreen", function () {
} }
}; };
} )() ); } )() );
var root = this.getRoot();
//更新连线 //更新连线
var updateConnect = function ( minder, node, action ) { var updateConnect = function ( minder, node, action ) {
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
...@@ -262,7 +261,7 @@ KityMinder.registerModule( "LayoutGreen", function () { ...@@ -262,7 +261,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
prt = prt.getParent(); prt = prt.getParent();
} }
var _buffer = [ root ]; var _buffer = [minder.getRoot()];
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
var childrenC = _buffer[ 0 ].getChildren(); var childrenC = _buffer[ 0 ].getChildren();
var parentLayout = _buffer[ 0 ].getData( "layout" ); var parentLayout = _buffer[ 0 ].getData( "layout" );
...@@ -306,8 +305,10 @@ KityMinder.registerModule( "LayoutGreen", function () { ...@@ -306,8 +305,10 @@ KityMinder.registerModule( "LayoutGreen", function () {
initStyle: function () { initStyle: function () {
//绘制root并且调整到正确位置 //绘制root并且调整到正确位置
var _root = this.getRoot(); var _root = this.getRoot();
this.getRenderContainer().clear().addShape( _root.getRenderContainer().clear() );
var minder = this; var minder = this;
_root.setData( "text", _root.getData( "text" ) || "I am the root" ); _root.setData( "text", _root.getData( "text" ) || "I am the root" );
_root.setData("layout",{});
var Layout = _root.getData( "layout" ); var Layout = _root.getData( "layout" );
Layout.style = { Layout.style = {
radius: 20, radius: 20,
...@@ -330,12 +331,13 @@ KityMinder.registerModule( "LayoutGreen", function () { ...@@ -330,12 +331,13 @@ KityMinder.registerModule( "LayoutGreen", function () {
var parent = _buffer[ 0 ].getParent(); var parent = _buffer[ 0 ].getParent();
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer[ 0 ].children = []; _buffer[ 0 ].children = [];
_buffer[0].setData("layout",{});
this.appendChildNode( parent, _buffer[ 0 ] ); this.appendChildNode( parent, _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
} }
}, },
appendChildNode: function ( parent, node, index ) { appendChildNode: function ( parent, node, index ) {
if ( !node.getData( "layout" ) ) node.setData( "layout", {} ); node.setData("layout",{});
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
var parentLayout = parent.getData( "layout" ); var parentLayout = parent.getData( "layout" );
var minder = this; var minder = this;
......
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