Commit d36bd9e3 authored by Akikonata's avatar Akikonata

fixed readonly

parent 7ddb9c32
...@@ -62,11 +62,12 @@ ...@@ -62,11 +62,12 @@
window.KITYMINDER_CONFIG = { window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath() 'KITYMINDER_HOME_URL': getKMBasePath()
//定义工具栏 //定义工具栏
,toolbars: [ ,
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help' 'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help'
] ],
//只读模式,默认是false //只读模式,默认是false
//readOnly : false //readOnly: true
//设置主题 //设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题 //,defaultlayoutstyle : 'default' //设置默认的主题
......
...@@ -6,70 +6,70 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -6,70 +6,70 @@ KityMinder.registerModule( "basestylemodule", function () {
"bold": kity.createClass( "boldCommand", { "bold": kity.createClass( "boldCommand", {
base: Command, base: Command,
execute: function ( ) { execute: function () {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if(this.queryState('bold') == 1){ if ( this.queryState( 'bold' ) == 1 ) {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('bold'); n.setData( 'bold' );
n.getTextShape().setAttr('font-weight'); n.getTextShape().setAttr( 'font-weight' );
km.updateLayout(n) km.updateLayout( n )
}) } )
}else{ } else {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('bold',true); n.setData( 'bold', true );
n.getTextShape().setAttr('font-weight','bold'); n.getTextShape().setAttr( 'font-weight', 'bold' );
km.updateLayout(n) km.updateLayout( n )
}) } )
} }
}, },
queryState: function ( ) { queryState: function () {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
result = 0; result = 0;
if(nodes.length == 0){ if ( nodes.length == 0 ) {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
if( n && n.getData('bold') ){ if ( n && n.getData( 'bold' ) ) {
result = 1; result = 1;
return false; return false;
} }
}); } );
return result; return result;
} }
} ), } ),
"italic": kity.createClass( "italicCommand", { "italic": kity.createClass( "italicCommand", {
base: Command, base: Command,
execute: function ( ) { execute: function () {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if(this.queryState('italic') == 1){ if ( this.queryState( 'italic' ) == 1 ) {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('italic'); n.setData( 'italic' );
n.getTextShape().setAttr('font-style'); n.getTextShape().setAttr( 'font-style' );
km.updateLayout(n) km.updateLayout( n )
}) } )
}else{ } else {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('italic',true); n.setData( 'italic', true );
n.getTextShape().setAttr('font-style','italic'); n.getTextShape().setAttr( 'font-style', 'italic' );
km.updateLayout(n) km.updateLayout( n )
}) } )
} }
}, },
queryState: function ( ) { queryState: function () {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
result = 0; result = 0;
if(nodes.length == 0){ if ( nodes.length == 0 ) {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
if( n && n.getData('italic') ){ if ( n && n.getData( 'italic' ) ) {
result = 1; result = 1;
return false; return false;
} }
}); } );
return result; return result;
} }
} ) } )
...@@ -81,12 +81,12 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -81,12 +81,12 @@ KityMinder.registerModule( "basestylemodule", function () {
"events": { "events": {
"beforeRenderNode": function ( e ) { "beforeRenderNode": function ( e ) {
//加粗 //加粗
if(e.node.getData('bold')){ if ( e.node.getData( 'bold' ) ) {
e.node.getTextShape().setAttr('font-weight','bold'); e.node.getTextShape().setAttr( 'font-weight', 'bold' );
} }
if(e.node.getData('italic')){ if ( e.node.getData( 'italic' ) ) {
e.node.getTextShape().setAttr('font-style','italic'); e.node.getTextShape().setAttr( 'font-style', 'italic' );
} }
} }
} }
......
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