Commit 360c83bf authored by Akikonata's avatar Akikonata

added _getCommand&&getQuery

parent 8b8945db
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"kity", "kity",
"MinderNode", "MinderNode",
"MinderEvent", "MinderEvent",
"KityMinder", "Minder",
"require", "require",
"km", "km",
"console", "console",
......
var KITYMINDER_CONFIG = window.KITYMINDER_CONFIG = {
};
\ No newline at end of file
kity.extendClass( Minder, { kity.extendClass( Minder, {
_getCommand: function ( name ) {
return this._commands[ name.toLowerCase() ];
},
_getQuery: function ( name ) {
if ( !this._query[ name ] ) {
var Cmd = this._getCommand( name );
this._query[ name ] = new Cmd();
}
return this._query[ name ];
},
_queryCommand: function ( name, type ) {
var me = this;
var query = this._getQuery( name );
var queryFunc = query[ name ][ "state" + type ];
if ( queryFunc ) {
return queryFunc( me );
} else {
return 0;
}
},
execCommand: function ( name ) { execCommand: function ( name ) {
var me = this; var me = this;
var _commands = this._commands;
var _action = new _commands[ name.toLowerCase() ](); var _action = new _commands[ name.toLowerCase() ]();
var cmdArgs = Array.prototype.slice.call( arguments, 1 ); var cmdArgs = Array.prototype.slice.call( arguments, 1 );
...@@ -27,35 +48,15 @@ kity.extendClass( Minder, { ...@@ -27,35 +48,15 @@ kity.extendClass( Minder, {
if ( _action.isSelectionChanged() ) { if ( _action.isSelectionChanged() ) {
me._firePharse( new MinderEvent( 'selectionchange' ) ); me._firePharse( new MinderEvent( 'selectionchange' ) );
} }
me._firePharse( new MinderEvent( 'interactchange' ) );
} }
}, },
queryCommandState: function ( name ) { queryCommandState: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) { return this._queryCommand( name, "State" );
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryState ) {
return _query[ name ].queryState( this );
} else {
return 0;
}
}, },
queryCommandValue: function ( name ) { queryCommandValue: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) { return this._queryCommand( name, "Value" );
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryValue ) {
return _query[ name ].queryValue( this );
} else {
return 0;
}
} }
} ); } );
\ No newline at end of file
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass( Minder, { kity.extendClass( Minder, {
_initModules: function () { _initModules: function () {
var _modules = KityMinder.getModules(); this._commands = {};
this._query = {};
var _modules = Minder.getModules();
var _modulesList = ( function () {
var _list = [];
for ( var key in _modules ) {
_list.push( key );
}
} )();
var _configModules = this.option.modules || _modulesList;
var _commands = this._commands;
if ( _modules ) { if ( _modules ) {
var me = this; var me = this;
for ( var key in _modules ) { for ( var i = 0; i < _configModules.length; i++ ) {
var key = _configModules[ i ];
//执行模块初始化,抛出后续处理对象 //执行模块初始化,抛出后续处理对象
var moduleDeals = _modules[ key ].call( me ); var moduleDeals = _modules[ key ].call( me );
......
kity.extendClass( KityMinder, { kity.extendClass( Minder, {
getRoot: function () { getRoot: function () {
return this._root; return this._root;
...@@ -28,4 +28,5 @@ kity.extendClass( KityMinder, { ...@@ -28,4 +28,5 @@ kity.extendClass( KityMinder, {
this.execCommand( 'renderroot', node ); this.execCommand( 'renderroot', node );
return this; return this;
} }
} ); } );
\ 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