Commit 6ea9d9cc authored by Akikonata's avatar Akikonata

dev

parent 7bd268cf
KityMinder.registerModule( "LayoutModule", function () { KityMinder.registerModule( "LayoutModule", function () {
var CreateChildNodeCommand = kity.createClass( "CreateChildNodeCommand", ( function () { var createChildNode = function ( km, parent ) {
return {
base: Command,
execute: function ( km, parent ) {
var _node = new MinderNode(); var _node = new MinderNode();
_node.setData( "y", Math.random() * 300 + 100 ); _node.setData( "y", Math.random() * 300 + 100 );
_node.setData( "text", "New Node" ); _node.setData( "text", "New Node" );
...@@ -27,16 +24,24 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -27,16 +24,24 @@ KityMinder.registerModule( "LayoutModule", function () {
parent.insertChild( _node ); parent.insertChild( _node );
km.execCommand( 'rendernode', _node ); km.execCommand( 'rendernode', _node );
return _node; return _node;
} };
var CreateChildNodeCommand = kity.createClass( "CreateChildNodeCommand", ( function () {
return {
base: Command,
execute: createChildNode
}; };
} )() ); } )() );
var CreateSiblingNodeCommand = kity.createClass( "CreateSiblingNodeCommand", ( function () { var CreateSiblingNodeCommand = kity.createClass( "CreateSiblingNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, sibling, node ) { execute: function ( km, sibling ) {
console.log( sibling );
var parent = sibling.getParent(); var parent = sibling.getParent();
parent.insertChild( node ); if ( parent ) {
createChildNode( km, 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