Commit b08e5af3 authored by Akikonata's avatar Akikonata

publish

parent 6e8a71ae
/*! /*!
* ==================================================== * ====================================================
* kityminder - v1.0.0 - 2014-04-11 * kityminder - v1.0.0 - 2014-04-15
* https://github.com/fex-team/kityminder * https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git * GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT * Copyright (c) 2014 f-cube @ FEX; Licensed MIT
...@@ -792,7 +792,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -792,7 +792,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initContextmenu(); this._initContextmenu();
this._initModules(); this._initModules();
if(this.getOptions('readOnly') === true){ if ( this.getOptions( 'readOnly' ) === true ) {
this.setDisabled(); this.setDisabled();
} }
this.fire( 'ready' ); this.fire( 'ready' );
...@@ -952,45 +952,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -952,45 +952,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getStatus: function () { getStatus: function () {
return this._status; return this._status;
}, },
setDisabled : function(){ setDisabled: function () {
var me = this; var me = this;
//禁用命令 //禁用命令
me.bkqueryCommandState = me.queryCommandState; me.bkqueryCommandState = me.queryCommandState;
me.bkqueryCommandValue = me.queryCommandValue; me.bkqueryCommandValue = me.queryCommandValue;
me.queryCommandState = function (type) { me.queryCommandState = function ( type ) {
var cmd = this._getCommand(type); var cmd = this._getCommand( type );
if(cmd && cmd.enableReadOnly === false){ if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandState.apply(me, arguments); return me.bkqueryCommandState.apply( me, arguments );
} }
return -1; return -1;
}; };
me.queryCommandValue = function (type) { me.queryCommandValue = function ( type ) {
var cmd = this._getCommand(type); var cmd = this._getCommand( type );
if(cmd && cmd.enableReadOnly === false){ if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandValue.apply(me, arguments); return me.bkqueryCommandValue.apply( me, arguments );
} }
return null; return null;
}; };
this.setStatus('readonly'); this.setStatus( 'readonly' );
me.fire('interactchange'); me.fire( 'interactchange' );
}, },
setEnabled : function(){ setEnabled: function () {
var me = this; var me = this;
if (me.bkqueryCommandState) { if ( me.bkqueryCommandState ) {
me.queryCommandState = me.bkqueryCommandState; me.queryCommandState = me.bkqueryCommandState;
delete me.bkqueryCommandState; delete me.bkqueryCommandState;
} }
if (me.bkqueryCommandValue) { if ( me.bkqueryCommandValue ) {
me.queryCommandValue = me.bkqueryCommandValue; me.queryCommandValue = me.bkqueryCommandValue;
delete me.bkqueryCommandValue; delete me.bkqueryCommandValue;
} }
this.rollbackStatus(); this.rollbackStatus();
me.fire('interactchange'); me.fire( 'interactchange' );
} }
} ); } );
...@@ -5125,75 +5125,74 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -5125,75 +5125,74 @@ Minder.Selection = kity.createClass( 'Selection', {
KityMinder.registerModule( "basestylemodule", function () { KityMinder.registerModule( "basestylemodule", function () {
var km = this; var km = this;
return { return {
"commands": { "commands": {
"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;
} }
} ) } )
...@@ -5205,12 +5204,12 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -5205,12 +5204,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' );
} }
} }
} }
...@@ -7121,8 +7120,11 @@ utils.extend( KityMinder, function () { ...@@ -7121,8 +7120,11 @@ utils.extend( KityMinder, function () {
} ); } );
btns.length && $toolbar.kmui().appendToBtnmenu( btns ); btns.length && $toolbar.kmui().appendToBtnmenu( btns );
} ); } );
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
}else{
$toolbar.hide()
} }
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
}, },
_createStatusbar: function ( $statusbar, km ) { _createStatusbar: function ( $statusbar, km ) {
...@@ -7523,7 +7525,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -7523,7 +7525,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
}); });
//实例化 //实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 ); $combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui(); var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value ); me.execCommand( name, res.value );
...@@ -7538,6 +7540,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -7538,6 +7540,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
var state = this.queryCommandState( name ), var state = this.queryCommandState( name ),
value = this.queryCommandValue( name ); value = this.queryCommandValue( name );
//设置按钮状态 //设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 ); comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if ( value ) { if ( value ) {
...@@ -7545,6 +7548,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -7545,6 +7548,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ ); value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value ); comboboxWidget.selectItemByLabel( value );
} }
} ); } );
var data = []; var data = [];
...@@ -7591,7 +7595,7 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -7591,7 +7595,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
//实例化 //实例化
$combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 ); $combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui(); var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value, new MinderNode( me.getLang().topic ), true ); me.execCommand( res.value, new MinderNode( me.getLang().topic ), true );
...@@ -7609,7 +7613,20 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -7609,7 +7613,20 @@ KM.registerToolbarUI( 'node', function ( name ) {
} }
} ) } )
} ); } );
//状态反射
me.on( 'interactchange', function () {
var state = 0;
utils.each(shortcutKeys,function(k){
state = me.queryCommandState(k);
if(state!=-1){
return false;
}
});
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
} );
//comboboxWidget.button().kmui().disabled(-1);
return comboboxWidget.button().addClass( 'kmui-combobox' ); return comboboxWidget.button().addClass( 'kmui-combobox' );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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