Commit 65f8ecfd authored by Akikonata's avatar Akikonata

added init style

parent 2bf0eab8
......@@ -8,9 +8,10 @@ kity.extendClass( Minder, {
},
handelNodeInsert: function ( node ) {
var rc = this._rc;
node.traverse( function ( current ) {
rc.addShape( current.getRenderContainer() );
} );
// node.traverse( function ( current ) {
// rc.addShape( current.getRenderContainer() );
// } );
rc.addShape( node.getRenderContainer() );
},
handelNodeRemove: function ( node ) {
var rc = this._rc;
......@@ -29,7 +30,7 @@ kity.extendClass( Minder, {
km.renderNode( nodes );
}
},
getMinderTitle: function() {
getMinderTitle: function () {
return this.getRoot().getText();
}
......
......@@ -33,7 +33,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
minder.getRenderContainer().addShape( iconShape );
iconShape.addShapes( [ circle, plus, dec ] );
this.update();
this.switchState();
//this.switchState();
},
switchState: function () {
if ( !this._show ) {
......@@ -219,7 +219,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
effectSet.push( node );
} else {
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" ) {
Layout.branchheight = countBranchHeight( node );
}
......@@ -243,6 +244,16 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length > 0 ) {
var _buffer0Layout = _buffer[ 0 ].getLayout();
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 );
var sY = _buffer0Layout.y - ( _buffer0Layout[ appendside + "Height" ] || _buffer0Layout.branchheight ) / 2;
for ( var i = 0; i < children.length; i++ ) {
......@@ -250,7 +261,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
childLayout.y = sY + childLayout.branchheight / 2;
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();
}
};
......@@ -272,7 +283,18 @@ KityMinder.registerModule( "LayoutDefault", function () {
var _buffer = [ node ];
while ( _buffer.length !== 0 ) {
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 ) {
Layout.x = getMinderSize().width / 2;
_buffer.shift();
......@@ -389,6 +411,9 @@ KityMinder.registerModule( "LayoutDefault", function () {
if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node );
if ( node.getData( 'expand' ) ) {
Layout.shicon.switchState();
}
}
Layout.shicon.update();
}
......@@ -499,34 +524,35 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutVertical( _root );
translateNode( _root );
var _buffer = [ _root ];
var _cleanbuffer = [];
//打散结构
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 ];
var parent = _buffer[ 0 ];
var Layout = parent.getLayout();
if ( _buffer[ 0 ].getType() === 'root' ) {
for ( var i = 0; i < children.length; i++ ) {
this.appendChildNode( parent, children[ i ] );
}
}
_buffer[ 0 ].clearChildren();
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] );
_buffer = _buffer.concat( children );
_buffer.shift();
}
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 );
},
appendChildNode: function ( parent, node, focus, sibling ) {
minder.handelNodeInsert( node );
node.clearLayout();
node.getContRc().clear();
node.setData( 'expand', false );
if ( parent.getType() !== 'root' ) {
parent.setData( 'expand', true );
}
var Layout = node.getLayout();
Layout.added = true;
var parentLayout = parent.getLayout();
var children = parent.getChildren();
var exist = ( children.indexOf( node ) !== -1 );
if ( sibling ) {
parent.insertChild( node, sibling.getIndex() + 1 );
if ( !exist ) parent.insertChild( node, sibling.getIndex() + 1 );
var siblingLayout = sibling.getLayout();
Layout.appendside = siblingLayout.appendside;
Layout.align = siblingLayout.align;
......@@ -551,7 +577,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var prtLayout = parent.getLayout();
Layout.appendside = prtLayout.appendside;
Layout.align = prtLayout.align;
parent.appendChild( node );
if ( !exist ) parent.appendChild( node );
} else {
var nodeP = node.getPoint();
if ( nodeP && nodeP.x && nodeP.y ) {
......@@ -579,7 +605,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else {
idx1 = parent.getChildren().length;
}
parent.insertChild( node, idx1 );
if ( !exist ) parent.insertChild( node, idx1 );
}
}
//设置分支类型
......@@ -678,33 +704,23 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
node.setData( "expand", isExpand );
var _buffer = node.getChildren();
var _cleanbuffer = [];
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( isExpand ) {
var parent = _buffer[ 0 ].getParent();
Layout.parent = parent;
_cleanbuffer.push( _buffer[ 0 ] );
Layout.connect = null;
Layout.shicon = null;
} else {
try {
if ( isExpand ) {
for ( var j = 0; j < _buffer.length; j++ ) {
debugger;
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();
} catch ( error ) {}
}
//if ( _buffer[ 0 ].getData( "expand" ) !== false )
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_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 ] );
}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift();
}
}
var set = [];
......
......@@ -44,7 +44,7 @@ KityMinder.registerModule( "LayoutModule", function () {
n.clearLayout();
} );
this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire('afterinitstyle');
this.fire( 'afterinitstyle' );
},
appendChildNode: function ( parent, node, focus, index ) {
var curStyle = this.getCurrentStyle();
......@@ -116,7 +116,6 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !parent ) {
return null;
}
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
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