Commit 7bb40a8f authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

parents e4c96c31 d8902d2c
...@@ -17,5 +17,9 @@ ...@@ -17,5 +17,9 @@
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("switchlayout","default"); minder.execCommand("switchlayout","default");
minder.execCommand("appendchildnode",new MinderNode()); minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendsiblingnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendsiblingnode",new MinderNode());
minder.execCommand("appendsiblingnode",new MinderNode());
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -140,6 +140,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -140,6 +140,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
radius: 10, radius: 10,
fill: "skyblue", fill: "skyblue",
stroke: "orange", stroke: "orange",
strokeWidth: 1,
color: "black", color: "black",
padding: [ 5, 10, 5, 10 ], padding: [ 5, 10, 5, 10 ],
fontSize: 20, fontSize: 20,
...@@ -174,6 +175,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -174,6 +175,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
rect.fill( _style.fill ).stroke( _style.stroke ).setRadius( _style.radius ).setWidth( _rectWidth ).setHeight( _rectHeight ); rect.fill( _style.fill ).stroke( _style.stroke ).setRadius( _style.radius ).setWidth( _rectWidth ).setHeight( _rectHeight );
if ( node.getData( "highlight" ) ) { if ( node.getData( "highlight" ) ) {
rect.stroke( new kity.Pen( "white", 3 ) ); rect.stroke( new kity.Pen( "white", 3 ) );
} else {
rect.stroke( new kity.Pen( _style.stroke, _style.strokeWidth ) );
} }
} }
}; };
...@@ -216,6 +219,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -216,6 +219,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
else shape.update(); else shape.update();
updateConnect( minder, node ); updateConnect( minder, node );
}; };
//调整node的位置 //调整node的位置
var translateNode = function ( node ) { var translateNode = function ( node ) {
var _style = node._style; var _style = node._style;
...@@ -375,6 +379,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -375,6 +379,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
//如果是从其他style切过来的,需要重新布局 //如果是从其他style切过来的,需要重新布局
if ( children.length !== 0 ) { if ( children.length !== 0 ) {
_root.setData( "leftList", [] );
_root.setData( "rightList", [] );
var leftList = _root.getData( "leftList" ); var leftList = _root.getData( "leftList" );
var rightList = _root.getData( "rightList" ); var rightList = _root.getData( "rightList" );
for ( var i = 0; i < children.length; i++ ) { for ( var i = 0; i < children.length; i++ ) {
...@@ -385,10 +391,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -385,10 +391,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
leftList.push( children[ i ] ); leftList.push( children[ i ] );
children[ i ].setData( "appendside", "left" ); children[ i ].setData( "appendside", "left" );
} }
drawNode( children[ i ] );
updateArrangement( children[ i ] );
} }
} }
}, },
appendChildNode: function ( parent, node ) { appendChildNode: function ( parent, node, index ) {
var appendside = parent.getData( "appendside" ); var appendside = parent.getData( "appendside" );
if ( parent === root ) { if ( parent === root ) {
var leftList = parent.getData( "leftList" ); var leftList = parent.getData( "leftList" );
...@@ -403,21 +411,22 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -403,21 +411,22 @@ KityMinder.registerModule( "LayoutDefault", function () {
node.setData( "appendside", appendside ); node.setData( "appendside", appendside );
parent.getData( appendside + "List" ).push( node ); parent.getData( appendside + "List" ).push( node );
} }
node.setData( "appendside", appendside );
if ( appendside === "left" ) { if ( appendside === "left" ) {
node.setData( "align", "right" ); node.setData( "align", "right" );
} else { } else {
node.setData( "align", "left" ); node.setData( "align", "left" );
} }
if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node ); if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node, index );
drawNode( node ); drawNode( node );
updateArrangement( node, "append" ); updateArrangement( node, "append" );
}, },
appendSiblingNode: function ( sibling, node ) { appendSiblingNode: function ( sibling, node ) {
var parent = sibling.getParent(); var parent = sibling.getParent();
var index = sibling.getIndex() + 1; var index = sibling.getIndex() + 1;
parent.appendChild( node, index ); var appendside = sibling.getData( "appendside" );
drawNode( node ); node.setData( "appendside", appendside );
updateArrangement( node, "append" ); this.appendChildNode( parent, node, index );
}, },
removeNode: function ( nodes ) { removeNode: function ( nodes ) {
var root = this.getRoot(); var root = this.getRoot();
......
This diff is collapsed.
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