Commit 6b68f6ec authored by Akikonata's avatar Akikonata

fixed the bug of beforeRenderNode

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