Commit 59ce68ec authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 42b1b86a dfc2cebe
Subproject commit e144ccd9270712497804915d13ec92f6593299b0
Subproject commit 741dc07c2094ea45a1d622763a64f4c021476dc1
......@@ -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();
}
......
......@@ -5,11 +5,15 @@ KityMinder.registerModule( "IconModule", function () {
var _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 );
var _rc = new kity.Group();
_rc.addShapes( [ _bg, _number ] );
node.getIconRc().addShape( _rc );
node.getContRc().addShape( _rc );
_number.setTransform( new kity.Matrix().translate( 6, 15 ) );
var rcHeight = _rc.getHeight();
_rc.setTransform( new kity.Matrix().translate( 0, -rcHeight / 2 ) );
};
var renderProgressIcon = function ( node, val, left ) {
var renderProgressIcon = function ( node, val ) {
var _rc = new kity.Group();
var _contRc = node.getContRc();
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) );
var _percent, d;
if ( val < 5 ) {
......@@ -18,8 +22,7 @@ KityMinder.registerModule( "IconModule", function () {
d.moveTo( 0, 0 ).lineTo( 6, 0 );
} else _percent = new kity.Group();
_rc.addShapes( [ _bg, _percent ] );
node.getIconRc().addShape( _rc );
_rc.setTransform( new kity.Matrix().translate( left, 10 ) );
_contRc.addShape( _rc );
switch ( val ) {
case 1:
break;
......@@ -41,6 +44,7 @@ KityMinder.registerModule( "IconModule", function () {
}
if ( val < 5 ) d.close();
_percent.fill( "#29A6BD" );
_rc.setTransform( new kity.Matrix().translate( _contRc.getWidth() + 5, 0 ) );
};
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
return {
......@@ -91,26 +95,16 @@ KityMinder.registerModule( "IconModule", function () {
},
"events": {
"RenderNodeLeft": function ( e ) {
// var node = e.node;
// var iconRc = new kity.Group();
// var contRc = node.getContRc();
// var PriorityIconVal = node.getData( "PriorityIcon" );
// var ProgressIconVal = node.getData( "ProgressIcon" );
// //依次排布图标、文字
// //iconRc.clear();
// var PriorityIconWidth = 0;
// if ( PriorityIconVal ) {
// renderPriorityIcon( node, PriorityIconVal );
// PriorityIconWidth = 22;
// }
// if ( ProgressIconVal ) {
// renderProgressIcon( node, ProgressIconVal, PriorityIconWidth + 10 );
// }
// var iconWidth = iconRc.getWidth();
// //var textShape = node.getTextShape();
// //if ( iconWidth ) textShape.setTransform( new kity.Matrix().translate( iconWidth + 5, 0 ) );
// //else textShape.setTransform( new kity.Matrix().translate( 0, 0 ) );
// iconRc.setTransform( new kity.Matrix().translate( 0, -( iconRc.getHeight() + textShape.getHeight() ) / 2 ) );
var node = e.node;
var PriorityIconVal = node.getData( "PriorityIcon" );
var ProgressIconVal = node.getData( "ProgressIcon" );
var contRc = node.getContRc();
if ( PriorityIconVal ) {
renderPriorityIcon( node, PriorityIconVal );
}
if ( ProgressIconVal ) {
renderProgressIcon( node, ProgressIconVal );
}
}
}
};
......
......@@ -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();
}
......@@ -498,37 +523,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutHorizon( _root );
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 ];
}
_buffer[ 0 ].clearChildren();
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] );
_buffer.shift();
}
if ( historyPoint ) {
_root.setPoint( historyPoint );
var mains = _root.getChildren();
for ( var i = 0; i < mains.length; i++ ) {
this.appendChildNode( _root, mains[ i ] );
}
// var j = 0;
// var me = this;
// var ITV = window.setInterval( function () {
// for ( var k = 0; k < 0; k++ ) {
// me.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
// j++;
// if ( j === _cleanbuffer.length ) break;
// }
// if ( j === _cleanbuffer.length ) {
// window.clearInterval( ITV );
// }
// }, 0 );
//重组结构
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
for ( var j = 0; j < mains.length; j++ ) {
var c = mains[ j ].getChildren();
if ( c.length < 10 && c.length !== 0 ) {
this.expandNode( mains[ j ] );
}
}
_root.setPoint( _root.getLayout().x, _root.getLayout().y );
},
......@@ -536,14 +539,22 @@ KityMinder.registerModule( "LayoutDefault", function () {
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;
if ( parent.getType() === "root" ) {
minder.handelNodeInsert( node );
var len = parent.getChildren().length;
if ( len < 7 ) {
if ( len % 2 ) {
......@@ -563,7 +574,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 ) {
......@@ -591,7 +602,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else {
idx1 = parent.getChildren().length;
}
parent.insertChild( node, idx1 );
if ( !exist ) parent.insertChild( node, idx1 );
}
}
//设置分支类型
......@@ -603,12 +614,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
//计算位置等流程
updateBg( node );
initLayout( node );
// this._fire( new MinderEvent( "beforeRenderNode", {
// node: node
// }, false ) );
// this._fire( new MinderEvent( "RenderNode", {
// node: node
// }, false ) );
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: node
}, false ) );
......@@ -696,33 +701,22 @@ 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++ ) {
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