Commit b463a316 authored by Akikonata's avatar Akikonata

dev

parent 06a3d4c5
KityMinder.registerModule( "LayoutModule", function () { KityMinder.registerModule( "LayoutModule", function () {
var createChildNode = function ( km, parent ) { var createChildNode = function ( km, parent ) {
var children = parent.getChildren();
var _node = new MinderNode(); var _node = new MinderNode();
_node.setData( "y", Math.random() * 300 + 100 ); _node.setData( "y", Math.random() * 500 + 10 );
_node.setData( "text", "New Node" ); _node.setData( "text", "New Node" );
switch ( parent.branchside ) { switch ( parent.getData( "branchside" ) ) {
case "left": case "left":
_node.setData( "branchside", "left" );
break; break;
case "right": case "right":
_node.setData( "branchside", "right" );
break; break;
default: default:
( function () { ( function () {
var children = parent.getChildren();
if ( children.length < 5 ) { if ( children.length < 5 ) {
_node.setData( "x", parent.getData( "x" ) + 200 ); _node.setData( "x", parent.getData( "x" ) + 200 );
_node.setData( "align", "left" ); _node.setData( "align", "left" );
_node.setData( "branchside", "left" );
} else { } else {
_node.setData( "x", parent.getData( "x" ) - 200 ); _node.setData( "x", parent.getData( "x" ) - 200 );
_node.setData( "align", "right" ); _node.setData( "align", "right" );
_node.setData( "branchside", "right" );
} }
} )(); } )();
break; break;
...@@ -40,7 +44,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -40,7 +44,9 @@ KityMinder.registerModule( "LayoutModule", function () {
console.log( sibling ); console.log( sibling );
var parent = sibling.getParent(); var parent = sibling.getParent();
if ( parent ) { if ( parent ) {
createChildNode( km, parent ); return createChildNode( km, parent );
} else {
return false;
} }
} }
}; };
......
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