Commit ea78ac1d authored by Akikonata's avatar Akikonata

added event

parent 7ee02295
...@@ -11,47 +11,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -11,47 +11,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this._createShapeDom() this._createShapeDom()
}, },
_createShapeDom:function(){ _createShapeDom: function () {
this.rc = new kity.Group(); this.rc = new kity.Group();
this.rc.addClass('km-minderNode'); this.rc.addClass( 'km-minderNode' );
this.rc.minderNode = this; this.rc.minderNode = this;
this._createBgGroup(); this._createBgGroup();
this._createContGroup(); this._createContGroup();
this._createTextShape(); this._createTextShape();
}, },
_createGroup:function(type){ _createGroup: function ( type ) {
var g = new kity.Group(); var g = new kity.Group();
g.setData('rctype',type); g.setData( 'rctype', type );
this.rc.appendShape(g); this.rc.appendShape( g );
}, },
_createBgGroup:function(){ _createBgGroup: function () {
this._createGroup('bgrc') this._createGroup( 'bgrc' )
}, },
_createContGroup:function(){ _createContGroup: function () {
this._createGroup('contrc') this._createGroup( 'contrc' )
}, },
_createTextShape:function(){ _createTextShape: function () {
this.getContRc().appendShape(new kity.Text(this.getData('text')||'')); this.getContRc().appendShape( new kity.Text( this.getData( 'text' ) || '' ) );
}, },
getContRc:function(){ getContRc: function () {
var groups = this.rc.getShapesByType('group'),result; var groups = this.rc.getShapesByType( 'group' ),
utils.each(groups,function(i,p){ result;
if(p.getData('rctype') == 'contrc'){ utils.each( groups, function ( i, p ) {
if ( p.getData( 'rctype' ) == 'contrc' ) {
result = p; result = p;
return false; return false;
} }
}); } );
return result return result
}, },
getBgRc:function(){ getBgRc: function () {
var groups = this.rc.getShapesByType('group'),result; var groups = this.rc.getShapesByType( 'group' ),
utils.each(groups,function(i,p){ result;
if(p.getData('rctype') == 'bgrc'){ utils.each( groups, function ( i, p ) {
if ( p.getData( 'rctype' ) == 'bgrc' ) {
result = p; result = p;
return false; return false;
} }
}); } );
return result return result
}, },
setPoint: function ( x, y ) { setPoint: function ( x, y ) {
...@@ -258,10 +260,10 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -258,10 +260,10 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return true; return true;
}, },
getTextShape:function(){ getTextShape: function () {
return this.getContRc().getShapesByType('text')[0] return this.getContRc().getShapesByType( 'text' )[ 0 ]
}, },
isSelected : function(){ isSelected: function () {
return this.getData( 'highlight' ) === true return this.getData( 'highlight' ) === true
} }
} ); } );
\ No newline at end of file
...@@ -233,10 +233,10 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -233,10 +233,10 @@ KityMinder.registerModule( "LayoutDefault", function () {
var RootShape = kity.createClass( "DefaultRootShape", ( function () { var RootShape = kity.createClass( "DefaultRootShape", ( function () {
return { return {
constructor: function ( node ) { constructor: function ( node ) {
var container = node.getRenderContainer(); var bgRC = node.getBgRc();
var txt = this._txt = new kity.Text(); var contRC = node.getContRc();
var rect = this._rect = new kity.Rect(); var rect = this._rect = new kity.Rect();
container.addShapes( [ rect, txt ] ); bgRC.addShape( rect );
this._node = node; this._node = node;
var Layout = { var Layout = {
shape: this, shape: this,
...@@ -256,20 +256,21 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -256,20 +256,21 @@ KityMinder.registerModule( "LayoutDefault", function () {
}; };
node.setData( "layout", Layout ); node.setData( "layout", Layout );
node.setData( "text", "Minder Root" ); node.setData( "text", "Minder Root" );
txt.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 15 ); contRC.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 15 );
this.update(); this.update();
}, },
update: function () { update: function () {
var txt = this._txt; var node = this._node;
var txt = node.getTextShape();
var contRC = node.getContRc();
var rect = this._rect; var rect = this._rect;
var connect = this._connect; var connect = this._connect;
var node = this._node;
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
txt.setContent( node.getData( "text" ) ).fill( Layout.color ); txt.setContent( node.getData( "text" ) ).fill( Layout.color );
var _txtWidth = txt.getWidth(); var _contRCWidth = contRC.getWidth();
var _txtHeight = txt.getHeight(); var _contRCHeight = contRC.getHeight();
var _rectWidth = _txtWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ]; var _rectWidth = _contRCWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ];
var _rectHeight = _txtHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ]; var _rectHeight = _contRCHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ];
rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius ); rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius );
}, },
clear: function () { clear: function () {
...@@ -548,7 +549,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -548,7 +549,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer[ 0 ].getData( "layout" ).shape.clear(); _buffer[ 0 ].getData( "layout" ).shape.clear();
_buffer[ 0 ].handelNodeRemove();
var prt = _buffer[ 0 ].getParent(); var prt = _buffer[ 0 ].getParent();
prt.removeChild( _buffer[ 0 ] ); prt.removeChild( _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
......
...@@ -73,7 +73,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -73,7 +73,7 @@ KityMinder.registerModule( "LayoutModule", function () {
_root.preTraverse( function ( n ) { _root.preTraverse( function ( n ) {
n.clearLayout(); n.clearLayout();
n.setPoint(); n.setPoint();
n.getRenderContainer().clear(); n.getBgRc().clear();
} ); } );
km.setCurrentStyle( style ); km.setCurrentStyle( style );
km.initStyle(); km.initStyle();
...@@ -152,7 +152,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -152,7 +152,7 @@ KityMinder.registerModule( "LayoutModule", function () {
} }
}, },
"defaultOptions": { "defaultOptions": {
"layoutstyle": "green" "layoutstyle": "default"
} }
}; };
} ); } );
\ No newline at end of file
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