Commit 0b314a0c authored by techird's avatar techird

Merge branch 'dev' of github.com:kitygraph/kityminder into dev

parents 6d69960d 5d59055b
......@@ -39,8 +39,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var transform = renderContainer.getTransform();
renderContainer.resetTransform();
var svg = $( svghtml ).attr( {
width: renderBox.x + renderBox.width,
height: renderBox.y + renderBox.height,
width: renderBox.width,
height: renderBox.height,
viewBox: null
} );
var div = $( "<div></div>" ).append( svg );
......
......@@ -26,6 +26,9 @@ KityMinder.registerModule( "basestylemodule", function () {
queryState: function ( ) {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
return -1;
}
utils.each(nodes,function(i,n){
if(n.getData('bold')){
result = 1;
......@@ -58,6 +61,9 @@ KityMinder.registerModule( "basestylemodule", function () {
queryState: function ( ) {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
return -1;
}
utils.each(nodes,function(i,n){
if(n.getData('italic')){
result = 1;
......
......@@ -51,6 +51,9 @@ KityMinder.registerModule( "fontmodule", function () {
n.setData( 'fontcolor', color );
n.getTextShape().fill( color )
} )
},
queryState:function(km){
return km.getSelectedNodes().length == 0 ? -1 : 0
}
} ),
......@@ -64,6 +67,9 @@ KityMinder.registerModule( "fontmodule", function () {
n.getTextShape().setAttr( 'font-family', family );
km.updateLayout( n )
} )
},
queryState:function(km){
return km.getSelectedNodes().length == 0 ? -1 : 0
}
} ),
"fontsize": kity.createClass( "fontsizeCommand", {
......@@ -76,6 +82,9 @@ KityMinder.registerModule( "fontmodule", function () {
n.getTextShape().setSize( size );
km.updateLayout( n )
} )
},
queryState:function(km){
return km.getSelectedNodes().length == 0 ? -1 : 0
}
} )
},
......
......@@ -408,9 +408,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
appendChildNode: function ( parent, node, sibling ) {
node.clearLayout();
var parentLayout = parent.getLayout();
var expand = parent.getData( "expand" );
//设置分支类型
if ( parent.getType() === "root" ) {
node.setType( "main" );
node.setData( "expand", true );
minder.handelNodeInsert( node );
} else {
node.setType( "sub" );
......@@ -490,8 +492,15 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
},
expandNode: function ( ico ) {
var isExpand = ico.icon.switchState();
var node = ico.icon._node;
var isExpand, node;
if ( ico instanceof MinderNode ) {
node = ico;
isExpand = node.getLayout().shicon.switchState();
} else {
isExpand = ico.icon.switchState();
node = ico.icon._node;
}
node.setData( "expand", isExpand );
var _buffer = node.getChildren();
var _cleanbuffer = [];
......
......@@ -537,6 +537,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
node.setType( "main" );
} else {
node.setType( "sub" );
//var isExpand = parent.getData( "expand" );
}
//计算位置等流程
updateBg( node );
......@@ -600,8 +601,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
},
expandNode: function ( ico ) {
var isExpand = ico.icon.switchState();
var node = ico.icon._node;
var isExpand, node;
if ( ico instanceof MinderNode ) {
node = ico;
isExpand = node.getLayout().shicon.switchState();
} else {
isExpand = ico.icon.switchState();
node = ico.icon._node;
}
node.setData( "expand", isExpand );
var _buffer = node.getChildren();
var _cleanbuffer = [];
......
......@@ -106,6 +106,9 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command,
execute: function ( km, node ) {
var parent = km.getSelectedNode();
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
km.expandNode( parent );
}
km.appendChildNode( parent, node );
km.select( node, true );
return node;
......@@ -129,7 +132,6 @@ KityMinder.registerModule( "LayoutModule", function () {
node.setType( "main" );
km.appendChildNode( selectedNode, node );
} else {
node.setType( "sub" );
km.appendSiblingNode( selectedNode, node );
}
km.select( node, true );
......@@ -203,26 +205,23 @@ KityMinder.registerModule( "LayoutModule", function () {
this.initStyle( this.getRoot() );
}
},
'contextmenu':[
{
label:this.getLang('node.appendsiblingnode'),
exec:function(){
this.execCommand('appendsiblingnode',new MinderNode(this.getLang('topic')))
},
cmdName:'appendsiblingnode'
},
{
label:this.getLang('node.appendchildnode'),
exec:function(){
this.execCommand('appendchildnode',new MinderNode(this.getLang('topic')))
'contextmenu': [ {
label: this.getLang( 'node.appendsiblingnode' ),
exec: function () {
this.execCommand( 'appendsiblingnode', new MinderNode( this.getLang( 'topic' ) ) )
},
cmdName:'appendchildnode'
cmdName: 'appendsiblingnode'
}, {
label: this.getLang( 'node.appendchildnode' ),
exec: function () {
this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
},
{
label:this.getLang('node.removenode'),
cmdName:'removenode'
},{
divider:1
cmdName: 'appendchildnode'
}, {
label: this.getLang( 'node.removenode' ),
cmdName: 'removenode'
}, {
divider: 1
}
],
......
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