Commit fffdc644 authored by techird's avatar techird

Merge branch 'dev' into kity-2.0

parents 9c45c334 348f7e12
...@@ -8,9 +8,10 @@ kity.extendClass( Minder, { ...@@ -8,9 +8,10 @@ kity.extendClass( Minder, {
}, },
handelNodeInsert: function ( node ) { handelNodeInsert: function ( node ) {
var rc = this._rc; var rc = this._rc;
node.traverse( function ( current ) { // node.traverse( function ( current ) {
rc.addShape( current.getRenderContainer() ); // rc.addShape( current.getRenderContainer() );
} ); // } );
rc.addShape( node.getRenderContainer() );
}, },
handelNodeRemove: function ( node ) { handelNodeRemove: function ( node ) {
var rc = this._rc; var rc = this._rc;
...@@ -29,7 +30,7 @@ kity.extendClass( Minder, { ...@@ -29,7 +30,7 @@ kity.extendClass( Minder, {
km.renderNode( nodes ); km.renderNode( nodes );
} }
}, },
getMinderTitle: function() { getMinderTitle: function () {
return this.getRoot().getText(); return this.getRoot().getText();
} }
......
...@@ -33,7 +33,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -33,7 +33,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
minder.getRenderContainer().addShape( iconShape ); minder.getRenderContainer().addShape( iconShape );
iconShape.addShapes( [ circle, plus, dec ] ); iconShape.addShapes( [ circle, plus, dec ] );
this.update(); this.update();
this.switchState(); //this.switchState();
}, },
switchState: function () { switchState: function () {
if ( !this._show ) { if ( !this._show ) {
...@@ -219,7 +219,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -219,7 +219,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
effectSet.push( node ); effectSet.push( node );
} else { } else {
if ( action === "append" || action === "contract" ) { if ( action === "append" || action === "contract" ) {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ]; var nodeHeight = node.getRenderContainer().getHeight() || ( node.getContRc().getHeight() + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ] );
Layout.branchheight = nodeHeight + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ];
} else if ( action === "change" ) { } else if ( action === "change" ) {
Layout.branchheight = countBranchHeight( node ); Layout.branchheight = countBranchHeight( node );
} }
...@@ -243,6 +244,16 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -243,6 +244,16 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length > 0 ) { while ( _buffer.length > 0 ) {
var _buffer0Layout = _buffer[ 0 ].getLayout(); var _buffer0Layout = _buffer[ 0 ].getLayout();
var children = _buffer0Layout[ appendside + "List" ] || _buffer[ 0 ].getChildren(); var children = _buffer0Layout[ appendside + "List" ] || _buffer[ 0 ].getChildren();
var children = ( function () {
var result = [];
for ( var len = 0; len < children.length; len++ ) {
var l = children[ len ].getLayout();
if ( l.added ) {
result.push( children[ len ] );
}
}
return result;
} )();
_buffer = _buffer.concat( children ); _buffer = _buffer.concat( children );
var sY = _buffer0Layout.y - ( _buffer0Layout[ appendside + "Height" ] || _buffer0Layout.branchheight ) / 2; var sY = _buffer0Layout.y - ( _buffer0Layout[ appendside + "Height" ] || _buffer0Layout.branchheight ) / 2;
for ( var i = 0; i < children.length; i++ ) { for ( var i = 0; i < children.length; i++ ) {
...@@ -250,7 +261,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -250,7 +261,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
childLayout.y = sY + childLayout.branchheight / 2; childLayout.y = sY + childLayout.branchheight / 2;
sY += childLayout.branchheight; sY += childLayout.branchheight;
} }
if ( _buffer[ 0 ] !== root ) effectSet.push( _buffer[ 0 ] ); if ( _buffer[ 0 ] !== root && _buffer[ 0 ].getLayout().added ) effectSet.push( _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
} }
}; };
...@@ -272,7 +283,18 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -272,7 +283,18 @@ KityMinder.registerModule( "LayoutDefault", function () {
var _buffer = [ node ]; var _buffer = [ node ];
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
var prt = _buffer[ 0 ].getParent(); var prt = _buffer[ 0 ].getParent();
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); var children = _buffer[ 0 ].getChildren();
children = ( function () {
var result = [];
for ( var len = 0; len < children.length; len++ ) {
var l = children[ len ].getLayout();
if ( l.added ) {
result.push( children[ len ] );
}
}
return result;
} )();
_buffer = _buffer.concat( children );
if ( !prt ) { if ( !prt ) {
Layout.x = getMinderSize().width / 2; Layout.x = getMinderSize().width / 2;
_buffer.shift(); _buffer.shift();
...@@ -389,6 +411,9 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -389,6 +411,9 @@ 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 ( node.getData( 'expand' ) ) {
Layout.shicon.switchState();
}
} }
Layout.shicon.update(); Layout.shicon.update();
} }
...@@ -498,24 +523,15 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -498,24 +523,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutHorizon( _root ); updateLayoutHorizon( _root );
updateLayoutVertical( _root ); updateLayoutVertical( _root );
translateNode( _root ); translateNode( _root );
var _buffer = [ _root ]; var mains = _root.getChildren();
var _cleanbuffer = []; for ( var i = 0; i < mains.length; i++ ) {
//打散结构 this.appendChildNode( _root, mains[ i ] );
while ( _buffer.length !== 0 ) {
var children = _buffer[ 0 ].getChildren();
_buffer = _buffer.concat( children );
for ( var i = 0; i < children.length; i++ ) {
children[ i ].getLayout().parent = _buffer[ 0 ];
} }
_buffer[ 0 ].clearChildren(); for ( var j = 0; j < mains.length; j++ ) {
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] ); var c = mains[ j ].getChildren();
_buffer.shift(); if ( c.length < 10 && c.length !== 0 ) {
} this.expandNode( mains[ j ] );
if ( historyPoint ) {
_root.setPoint( historyPoint );
} }
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y ); _root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
...@@ -523,10 +539,17 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -523,10 +539,17 @@ KityMinder.registerModule( "LayoutDefault", function () {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
node.clearLayout(); node.clearLayout();
node.getContRc().clear(); node.getContRc().clear();
node.setData( 'expand', false );
if ( parent.getType() !== 'root' ) {
parent.setData( 'expand', true );
}
var Layout = node.getLayout(); var Layout = node.getLayout();
Layout.added = true;
var parentLayout = parent.getLayout(); var parentLayout = parent.getLayout();
var children = parent.getChildren();
var exist = ( children.indexOf( node ) !== -1 );
if ( sibling ) { if ( sibling ) {
parent.insertChild( node, sibling.getIndex() + 1 ); if ( !exist ) parent.insertChild( node, sibling.getIndex() + 1 );
var siblingLayout = sibling.getLayout(); var siblingLayout = sibling.getLayout();
Layout.appendside = siblingLayout.appendside; Layout.appendside = siblingLayout.appendside;
Layout.align = siblingLayout.align; Layout.align = siblingLayout.align;
...@@ -551,7 +574,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -551,7 +574,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var prtLayout = parent.getLayout(); var prtLayout = parent.getLayout();
Layout.appendside = prtLayout.appendside; Layout.appendside = prtLayout.appendside;
Layout.align = prtLayout.align; Layout.align = prtLayout.align;
parent.appendChild( node ); if ( !exist ) parent.appendChild( node );
} else { } else {
var nodeP = node.getPoint(); var nodeP = node.getPoint();
if ( nodeP && nodeP.x && nodeP.y ) { if ( nodeP && nodeP.x && nodeP.y ) {
...@@ -579,7 +602,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -579,7 +602,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else { } else {
idx1 = parent.getChildren().length; idx1 = parent.getChildren().length;
} }
parent.insertChild( node, idx1 ); if ( !exist ) parent.insertChild( node, idx1 );
} }
} }
//设置分支类型 //设置分支类型
...@@ -678,34 +701,23 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -678,34 +701,23 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
node.setData( "expand", isExpand ); node.setData( "expand", isExpand );
var _buffer = node.getChildren(); var _buffer = node.getChildren();
var _cleanbuffer = [];
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( isExpand ) { if ( isExpand ) {
var parent = _buffer[ 0 ].getParent(); for ( var j = 0; j < _buffer.length; j++ ) {
Layout.parent = parent; minder.appendChildNode( node, _buffer[ j ] );
_cleanbuffer.push( _buffer[ 0 ] ); }
Layout.connect = null;
Layout.shicon = null;
} else { } else {
try { var _buffer = node.getChildren();
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( Layout.added ) {
Layout.added = false;
_buffer[ 0 ].getRenderContainer().remove(); _buffer[ 0 ].getRenderContainer().remove();
Layout.connect.remove(); Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove(); if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
} }
//if ( _buffer[ 0 ].getData( "expand" ) !== false )
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
} }
if ( isExpand ) {
node.clearChildren();
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
//if ( _cleanbuffer[ j ].getData( "expand" ) !== false )
_cleanbuffer[ j ].clearChildren();
minder.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
}
} }
var set = []; var set = [];
if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" ); if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
......
...@@ -43,7 +43,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -43,7 +43,7 @@ KityMinder.registerModule( "LayoutModule", function () {
n.clearLayout(); n.clearLayout();
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this ); this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire('afterinitstyle'); this.fire( 'afterinitstyle' );
}, },
appendChildNode: function ( parent, node, focus, index ) { appendChildNode: function ( parent, node, focus, index ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
...@@ -115,7 +115,6 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -115,7 +115,6 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !parent ) { if ( !parent ) {
return null; return null;
} }
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) { if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
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