Commit ea78ac1d authored by Akikonata's avatar Akikonata

added event

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