Commit 14fba533 authored by Akikonata's avatar Akikonata

added delete and a new style

parent 7c798280
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</body> </body>
<script> <script>
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("appendchildnode",new MinderNode('dsf')); //minder.execCommand("switchlayout","green");
minder.execCommand("appendsiblingnode",new MinderNode('sdf')); minder.execCommand("appendchildnode",new MinderNode("test"));
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -3,21 +3,21 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -3,21 +3,21 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this.parent = null; this.parent = null;
this.children = []; this.children = [];
this.data = {}; this.data = {};
if(utils.isString(options)){ if ( utils.isString( options ) ) {
this.setData('text',options) this.setData( 'text', options )
}else{ } else {
this.setData(options); this.setData( options );
} }
this.rc = new kity.Group(); this.rc = new kity.Group();
this.rc.minderNode = this; this.rc.minderNode = this;
}, },
setText:function(text){ setText: function ( text ) {
this.setData('text',text) this.setData( 'text', text )
}, },
getText:function(){ getText: function () {
return this.getData('text') return this.getData( 'text' )
}, },
isRoot:function(){ isRoot: function () {
return this.getParent() == null ? true : false; return this.getParent() == null ? true : false;
}, },
getParent: function () { getParent: function () {
...@@ -36,8 +36,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -36,8 +36,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getRoot: function () { getRoot: function () {
var root = this; var root = this;
while(root.parent){ while ( root.parent ) {
root = root.parent; root = root.parent;
} }
return root; return root;
}, },
...@@ -84,13 +84,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -84,13 +84,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
// this.handelInsert( node ); // this.handelInsert( node );
}, },
// //
// handelInsert: function ( node ) { // handelInsert: function ( node ) {
// var root = this.getRoot(); // var root = this.getRoot();
// if ( root.tnh ) { // if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node ); // root.tnh.handelNodeInsert.call( root.tnh, node );
// } // }
// }, // },
appendChild: function ( node ) { appendChild: function ( node ) {
return this.insertChild( node ); return this.insertChild( node );
...@@ -109,25 +109,25 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -109,25 +109,25 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if ( index >= 0 ) { if ( index >= 0 ) {
removed = this.children.splice( index, 1 )[ 0 ]; removed = this.children.splice( index, 1 )[ 0 ];
removed.parent = null; removed.parent = null;
// this.handelRemove( removed ); // this.handelRemove( removed );
} }
}, },
// handelRemove: function ( node ) { // handelRemove: function ( node ) {
// var root = this.getRoot(); // var root = this.getRoot();
// if ( root.tnh ) { // if ( root.tnh ) {
// root.tnh.handelNodeRemove.call( root.tnh, node ); // root.tnh.handelNodeRemove.call( root.tnh, node );
// } // }
// }, // },
getChild: function ( index ) { getChild: function ( index ) {
return this.children[ index ]; return this.children[ index ];
}, },
getFirstChild:function(){ getFirstChild: function () {
return this.children[0] return this.children[ 0 ]
}, },
getLastChild:function(){ getLastChild: function () {
return this.children[this.children.length-1] return this.children[ this.children.length - 1 ]
}, },
getData: function ( name ) { getData: function ( name ) {
if ( name === undefined ) { if ( name === undefined ) {
...@@ -148,36 +148,36 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -148,36 +148,36 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getRenderContainer: function () { getRenderContainer: function () {
return this.rc; return this.rc;
}, },
getCommonAncestor:function(node){ getCommonAncestor: function ( node ) {
if(this === node){ if ( this === node ) {
return this.parent return this.parent
} }
if(this.contains(node)){ if ( this.contains( node ) ) {
return this return this
} }
if(node.contains(this)){ if ( node.contains( this ) ) {
return node return node
} }
var parent = node.parent; var parent = node.parent;
while(!parent.contains(node)){ while ( !parent.contains( node ) ) {
parent = parent.parentNode; parent = parent.parentNode;
} }
return parent; return parent;
}, },
contains:function(node){ contains: function ( node ) {
if(this === node){ if ( this === node ) {
return true; return true;
} }
if(this === node.parent){ if ( this === node.parent ) {
return true; return true;
} }
var isContain = false; var isContain = false;
utils.each(this.getChildren(),function(i,n){ utils.each( this.getChildren(), function ( i, n ) {
isContain = n.contains(node); isContain = n.contains( node );
if(isContain === true){ if ( isContain === true ) {
return false return false
} }
}); } );
return isContain; return isContain;
} }
......
...@@ -47,10 +47,10 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -47,10 +47,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
} }
function KBNavigate(km,direction){ function KBNavigate( km, direction ) {
var nextNode = km.getSelectedNode()._nearestNodes[ direction ]; var nextNode = km.getSelectedNode()._nearestNodes[ direction ];
if ( nextNode ) { if ( nextNode ) {
km.select(nextNode); km.select( nextNode );
} }
} }
return { return {
...@@ -63,34 +63,35 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -63,34 +63,35 @@ KityMinder.registerModule( "KeyboardModule", function () {
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case 13: case 13:
// Enter // Enter
this.execCommand('appendSiblingNode',new MinderNode('Topic')); this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) );
e.preventDefault(); e.preventDefault();
break; break;
case 9: case 9:
// Tab // Tab
this.execCommand('appendChildNode',new MinderNode('Topic')); this.execCommand( 'appendChildNode', new MinderNode( 'Topic' ) );
e.preventDefault(); e.preventDefault();
break; break;
case 8: case 8:
case 46: case 46:
this.execCommand('removenode'); this.execCommand( 'removenode' );
break; e.preventDefault();
case 37: break;
case 38: case 37:
case 39: case 38:
case 40: case 39:
if ( this.isSingleSelect() ) { case 40:
KBNavigate(this,{ if ( this.isSingleSelect() ) {
37: 'left', KBNavigate( this, {
38: 'top', 37: 'left',
39: 'right', 38: 'top',
40: 'down' 39: 'right',
}[ e.originEvent.keyCode ]); 40: 'down'
} }[ e.originEvent.keyCode ] );
e.preventDefault(); }
break; e.preventDefault();
break;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -11,7 +11,8 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -11,7 +11,8 @@ KityMinder.registerModule( "LayoutModule", function () {
var _root = km.getRoot(); var _root = km.getRoot();
_root.preTraverse( function ( node ) { _root.preTraverse( function ( node ) {
node.clearData(); node.setData( "style", {} );
node.setData( "shape", null );
node.getRenderContainer().clear(); node.getRenderContainer().clear();
} ); } );
km.initStyle(); km.initStyle();
......
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