Commit 6b68f6ec authored by Akikonata's avatar Akikonata

fixed the bug of beforeRenderNode

parent 6438da2d
......@@ -30,9 +30,9 @@
minder.execCommand("switchlayout",val);
},false);
minder.select(minder.getRoot());
// var node = new KM.MinderNode('test');
// node.setData('fontcolor','red');
// minder.execCommand('appendChildNode',node);
var node = new KM.MinderNode('test');
node.setData('fontcolor','red');
minder.execCommand('appendChildNode',node);
// var b = new kity.Bezier([new kity.BezierPoint(0,0).setVertex(100,100),new kity.BezierPoint(100,0).setVertex(100,100)]);
// minder.getRenderContainer().addShape(b.stroke("white"));
</script>
......
......@@ -32,7 +32,7 @@ kity.extendClass( Minder, {
this._fire( preEvent );
this._fire( executeEvent );
this._fire(new MinderEvent('after' + e.type,e,false));
this._fire( new MinderEvent( 'after' + e.type, e, false ) );
if ( ~'mousedown mouseup keydown keyup'.indexOf( e.type ) ) {
this._interactChange( e );
......
......@@ -37,7 +37,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper = new kity.Paper();
this._paper.addShape( this._rc );
this._paper.getNode().setAttribute( 'contenteditable', true );
this._root = new MinderNode();
this._root = new MinderNode( "Main Topic" );
this._root.setType( "root" );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
......
......@@ -6,24 +6,24 @@ KityMinder.registerModule( "fontmodule", function () {
"fontcolor": kity.createClass( "fontcolorCommand", {
base: Command,
execute: function ( km,color ) {
execute: function ( km, color ) {
var nodes = km.getSelectedNodes();
utils.each(nodes,function(i,n){
n.setData('fontcolor',color);
n.getTextShape().fill(color)
})
utils.each( nodes, function ( i, n ) {
n.setData( 'fontcolor', color );
n.getTextShape().fill( color )
} )
}
} ),
"fontfamily": kity.createClass( "fontfamilyCommand", {
base: Command,
execute: function ( km,family) {
execute: function ( km, family ) {
var nodes = km.getSelectedNodes();
utils.each(nodes,function(i,n){
n.setData('fontfamily',family);
n.getTextShape().setAttr('font-family',family);
})
utils.each( nodes, function ( i, n ) {
n.setData( 'fontfamily', family );
n.getTextShape().setAttr( 'font-family', family );
} )
}
} )
},
......@@ -31,11 +31,11 @@ KityMinder.registerModule( "fontmodule", function () {
"events": {
"beforeRenderNode": function ( e ) {
var val;
if(val = e.node.getData('fontfamily')){
e.node.getTextShape().setAttr('font-family',val);
if ( val = e.node.getData( 'fontfamily' ) ) {
e.node.getTextShape().setAttr( 'font-family', val );
}
if(val = e.node.getData('fontcolor')){
e.node.getTextShape().fill(val);
if ( val = e.node.getData( 'fontcolor' ) ) {
e.node.getTextShape().fill( val );
}
}
}
......
......@@ -380,7 +380,34 @@ KityMinder.registerModule( "LayoutBottom", function () {
},
removeNode: function ( nodes ) {
var root = this.getRoot();
for ( var i = 0; i < nodes.length; i++ ) {
var parent = nodes[ i ].getParent();
if ( parent ) {
var _buffer = [ nodes[ i ] ];
var parentLayout = parent.getData( "layout" );
while ( _buffer.length !== 0 ) {
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer[ 0 ].getData( "layout" ).shape.clear();
_buffer[ 0 ].getRenderContainer().remove();
var prt = _buffer[ 0 ].getParent();
prt.removeChild( _buffer[ 0 ] );
_buffer.shift();
}
if ( parent === root ) {
var Layout = nodes[ i ].getData( "layout" );
var appendside = Layout.appendside;
var sideList = parentLayout[ appendside + "List" ];
var idx = sideList.indexOf( nodes[ i ] );
sideList.splice( idx, 1 );
}
parent.removeChild( nodes[ i ] );
var set = updateLayoutHorizon( nodes[ i ], parent, "remove" );
for ( var j = 0; j < set.length; j++ ) {
translateNode( set[ j ] );
}
}
}
}
};
this.addLayoutStyle( "bottom", _style );
......
......@@ -92,10 +92,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
update: function () {
var rect = this._rect;
var node = this._node;
var txt = node.getTextShape();
var contRC = node.getContRc();
var Layout = node.getData( "layout" );
txt.setContent( node.getData( "text" ) ).fill( Layout.color );
var _contRCWidth = contRC.getWidth();
var _contRCHeight = contRC.getHeight();
var _rectWidth = _contRCWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ];
......@@ -168,22 +166,21 @@ KityMinder.registerModule( "LayoutDefault", function () {
},
update: function () {
var node = this._node;
var contRc = node.getContRc();
var Layout = node.getData( "layout" );
var underline = this._underline;
var highlightshape = this._highlightshape;
var txt = node.getTextShape();
txt.setContent( node.getData( "text" ) ).fill( Layout.color ).setSize( Layout.fontSize );
var _txtWidth = txt.getWidth();
var _txtHeight = txt.getHeight();
var sY = Layout.padding[ 0 ] + _txtHeight / 2;
var _contWidth = contRc.getWidth();
var _contHeight = contRc.getHeight();
var sY = Layout.padding[ 0 ] + _contHeight / 2;
underline.getDrawer()
.clear()
.moveTo( 0, _txtHeight + Layout.padding[ 2 ] + Layout.padding[ 0 ] )
.lineTo( _txtWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ], _txtHeight + Layout.padding[ 2 ] + Layout.padding[ 0 ] );
.moveTo( 0, _contHeight + Layout.padding[ 2 ] + Layout.padding[ 0 ] )
.lineTo( _contWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ], _contHeight + Layout.padding[ 2 ] + Layout.padding[ 0 ] );
underline.stroke( Layout.stroke );
highlightshape
.setWidth( _txtWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ] )
.setHeight( _txtHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ] )
.setWidth( _contWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ] )
.setHeight( _contHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ] )
.setOpacity( node.getData( "highlight" ) ? 1 : 0 );
this.updateConnect();
this.updateShIcon();
......@@ -262,12 +259,10 @@ KityMinder.registerModule( "LayoutDefault", function () {
},
update: function () {
var node = this._node;
var txt = node.getTextShape();
var contRC = node.getContRc();
var rect = this._rect;
var connect = this._connect;
var Layout = node.getData( "layout" );
txt.setContent( node.getData( "text" ) ).fill( Layout.color );
var _contRCWidth = contRC.getWidth();
var _contRCHeight = contRC.getHeight();
var _rectWidth = _contRCWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ];
......@@ -515,7 +510,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.appendside = parentLayout.appendside;
childbranch = new SubBranch( node );
}
this._fire( new MinderEvent( "afterRenderNode", {
this._fire( new MinderEvent( "RenderNode", {
node: node
}, false ) );
var set1 = updateLayoutVertical( node, parent, "append" );
......
......@@ -152,7 +152,7 @@ KityMinder.registerModule( "LayoutModule", function () {
}
},
"defaultOptions": {
"layoutstyle": "bottom"
"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