Commit a0ecff6d authored by Akikonata's avatar Akikonata

recover the layout

parent afec1e6f
...@@ -47,11 +47,11 @@ KityMinder.registerModule( "Expand", function () { ...@@ -47,11 +47,11 @@ KityMinder.registerModule( "Expand", function () {
node.setData( EXPAND_STATE_DATA, STATE_COLLAPSE ); node.setData( EXPAND_STATE_DATA, STATE_COLLAPSE );
}, },
isExpanded: function () { isExpanded: function () {
return node.getData( EXPAND_STATE_DATA ) === STATE_EXPAND; //return this.getData( EXPAND_STATE_DATA ) === STATE_EXPAND;
return true;
} }
} ); } );
return { return {
'commands': { 'commands': {}
}
}; };
} ); } );
\ No newline at end of file
...@@ -423,9 +423,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -423,9 +423,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
if ( nodeType !== "root" && node.getChildren().length !== 0 ) { if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) { if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node ); Layout.shicon = new ShIcon( node );
if ( Layout.expand ) {
Layout.shicon.switchState();
}
} }
Layout.shicon.update(); Layout.shicon.update();
} }
...@@ -546,7 +543,13 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -546,7 +543,13 @@ KityMinder.registerModule( "LayoutDefault", function () {
var mains = _root.getChildren(); var mains = _root.getChildren();
for ( var i = 0; i < mains.length; i++ ) { for ( var i = 0; i < mains.length; i++ ) {
this.appendChildNode( _root, mains[ i ] ); this.appendChildNode( _root, mains[ i ] );
//console.log( mains[ i ].isExpanded() );
if ( mains[ i ].isExpanded() && mains[ i ].getChildren().length > 0 ) {
debugger;
minder.expandNode( mains[ i ] );
}
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
expandNode: function ( ico ) { expandNode: function ( ico ) {
var isExpand, node; var isExpand, node;
...@@ -557,15 +560,24 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -557,15 +560,24 @@ KityMinder.registerModule( "LayoutDefault", function () {
isExpand = ico.icon.switchState(); isExpand = ico.icon.switchState();
node = ico.icon._node; node = ico.icon._node;
} }
var Layout = node.getLayout(); var _buffer;
Layout.expand = isExpand;
var _buffer = node.getChildren();
if ( isExpand ) { if ( isExpand ) {
for ( var j = 0; j < _buffer.length; j++ ) { //遍历子树展开需要展开的节点
minder.appendChildNode( node, _buffer[ j ] ); _buffer = [ node ];
debugger;
while ( _buffer.length !== 0 ) {
var c = _buffer[ 0 ].getChildren();
if ( _buffer[ 0 ].isExpanded() && c.length !== 0 ) {
for ( var x = 0; x < c.length; x++ ) {
minder.appendChildNode( _buffer[ 0 ], c[ x ] );
}
_buffer = _buffer.concat( c );
}
_buffer.shift();
} }
} else { } else {
var _buffer = node.getChildren(); //遍历子树移除需要移除的节点
_buffer = node.getChildren();
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout(); var Layout = _buffer[ 0 ].getLayout();
if ( Layout.added ) { if ( Layout.added ) {
...@@ -577,85 +589,38 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -577,85 +589,38 @@ KityMinder.registerModule( "LayoutDefault", function () {
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
} }
var set = updateLayoutVertical( node, node.getParent(), "contract" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
} }
var set = []; // var _buffer = node.getChildren();
if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" ); // if ( isExpand ) {
for ( var i = 0; i < set.length; i++ ) { // for ( var j = 0; j < _buffer.length; j++ ) {
translateNode( set[ i ] ); // minder.appendChildNode( node, _buffer[ j ] );
updateConnectAndshIcon( set[ i ] ); // }
} // } else {
// var _buffer = node.getChildren();
// while ( _buffer.length !== 0 ) {
// var Layout = _buffer[ 0 ].getLayout();
// if ( Layout.added ) {
// Layout.added = false;
// _buffer[ 0 ].getRenderContainer().remove();
// Layout.connect.remove();
// if ( Layout.shicon ) Layout.shicon.remove();
// }
// _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
// _buffer.shift();
// }
// }
// var set = [];
// if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
// for ( var i = 0; i < set.length; i++ ) {
// translateNode( set[ i ] );
// updateConnectAndshIcon( set[ i ] );
// }
}, },
// initStyle: function ( expandall ) {
// var _root = minder.getRoot();
// var historyPoint = _root.getPoint();
// if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) );
// minder.handelNodeInsert( _root );
// //设置root的align
// _root.getLayout().align = "center";
// updateBg( _root );
// initLayout( _root );
// _root.getContRc().clear();
// this._firePharse( new MinderEvent( "RenderNodeLeft", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeCenter", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeRight", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeBottom", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeTop", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNode", {
// node: _root
// }, false ) );
// updateShapeByCont( _root );
// updateLayoutHorizon( _root );
// updateLayoutVertical( _root );
// translateNode( _root );
// if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y );
// var expandoptions = minder.getOptions( 'defaultExpand' );
// var cur_layer = 0;
// var expand_layer = expandoptions.defaultLayer;
// var mains = _root.getChildren();
// for ( var i = 0; i < mains.length; i++ ) {
// this.appendChildNode( _root, mains[ i ] );
// }
// cur_layer++;
// var clonelayer0 = function () {
// var items = [];
// for ( var i = 0; i < mains.length; i++ ) {
// items.push( mains[ i ] );
// }
// return items;
// };
// //创建一级节点的副本
// var _buffer = clonelayer0();
// next = [];
// var layer_nolimit = expandall || ( expand_layer < 1 ) || false;
// var sub_nolimit = expandall || ( expandoptions.defaultSubShow < 1 ) || false;
// while ( _buffer.length !== 0 ) {
// cur_layer++;
// var layer_len = _buffer.length;
// for ( var j = 0; j < layer_len; j++ ) {
// var c = _buffer[ j ].getChildren();
// if (
// (
// ( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && ( layer_nolimit || ( cur_layer <= expand_layer ) ) ) ||
// _buffer[ j ].getLayout().expand
// ) && c.length !== 0 ) {
// this.expandNode( _buffer[ j ] );
// _buffer = _buffer.concat( _buffer[ j ].getChildren() );
// }
// }
// _buffer.splice( 0, layer_len );
// }
// _root.setPoint( _root.getLayout().x, _root.getLayout().y );
// },
appendChildNode: function ( parent, node, focus, sibling ) { appendChildNode: function ( parent, node, focus, sibling ) {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
var Layout = node.getLayout(); var Layout = node.getLayout();
...@@ -810,48 +775,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -810,48 +775,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
_buffer.shift(); _buffer.shift();
} }
} }
},
expandNode: function ( ico ) {
} }
//,
// expandNode: function ( ico ) {
// var isExpand, node;
// if ( ico instanceof MinderNode ) {
// node = ico;
// isExpand = node.getLayout().shicon.switchState();
// } else {
// isExpand = ico.icon.switchState();
// node = ico.icon._node;
// }
// var Layout = node.getLayout();
// Layout.expand = isExpand;
// var _buffer = node.getChildren();
// if ( isExpand ) {
// for ( var j = 0; j < _buffer.length; j++ ) {
// minder.appendChildNode( node, _buffer[ j ] );
// }
// } else {
// var _buffer = node.getChildren();
// while ( _buffer.length !== 0 ) {
// var Layout = _buffer[ 0 ].getLayout();
// if ( Layout.added ) {
// Layout.added = false;
// _buffer[ 0 ].getRenderContainer().remove();
// Layout.connect.remove();
// if ( Layout.shicon ) Layout.shicon.remove();
// }
// _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
// _buffer.shift();
// }
// }
// var set = [];
// if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
// for ( var i = 0; i < set.length; i++ ) {
// translateNode( set[ i ] );
// updateConnectAndshIcon( set[ i ] );
// }
// }
}; };
this.addLayoutStyle( "default", _style ); this.addLayoutStyle( "default", _style );
return {}; return {};
......
...@@ -38,7 +38,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -38,7 +38,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).highlightNode.call( this, node ); this.getLayoutStyle( curStyle ).highlightNode.call( this, node );
}, },
initStyle: function ( expandall ) { initStyle: function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this._rc.remove(); this._rc.remove();
this._rc = new kity.Group(); this._rc = new kity.Group();
...@@ -46,10 +46,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -46,10 +46,9 @@ KityMinder.registerModule( "LayoutModule", function () {
var _root = this.getRoot(); var _root = this.getRoot();
_root.preTraverse( function ( n ) { _root.preTraverse( function ( n ) {
var oldLayout = n.getLayout();
n.clearLayout(); n.clearLayout();
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this, expandall ); this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire( 'afterinitstyle' ); this.fire( 'afterinitstyle' );
}, },
restoreStyle: function () { restoreStyle: function () {
...@@ -127,7 +126,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -127,7 +126,7 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !parent ) { if ( !parent ) {
return null; return null;
} }
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getLayout().expand === false ) { if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && !parent.isExpanded() ) {
km.expandNode( parent ); km.expandNode( parent );
} }
......
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