Commit 360c83bf authored by Akikonata's avatar Akikonata

added _getCommand&&getQuery

parent 8b8945db
......@@ -11,7 +11,7 @@
"kity",
"MinderNode",
"MinderEvent",
"KityMinder",
"Minder",
"require",
"km",
"console",
......
var KITYMINDER_CONFIG = window.KITYMINDER_CONFIG = {
};
\ No newline at end of file
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 ) {
var me = this;
var _commands = this._commands;
var _action = new _commands[ name.toLowerCase() ]();
var cmdArgs = Array.prototype.slice.call( arguments, 1 );
......@@ -27,35 +48,15 @@ kity.extendClass( Minder, {
if ( _action.isSelectionChanged() ) {
me._firePharse( new MinderEvent( 'selectionchange' ) );
}
me._firePharse( new MinderEvent( 'interactchange' ) );
}
},
queryCommandState: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) {
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryState ) {
return _query[ name ].queryState( this );
} else {
return 0;
}
return this._queryCommand( name, "State" );
},
queryCommandValue: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) {
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryValue ) {
return _query[ name ].queryValue( this );
} else {
return 0;
}
return this._queryCommand( name, "Value" );
}
} );
\ No newline at end of file
// 模块声明周期维护
kity.extendClass( Minder, {
_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 ) {
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 );
......
kity.extendClass( KityMinder, {
kity.extendClass( Minder, {
getRoot: function () {
return this._root;
......@@ -28,4 +28,5 @@ kity.extendClass( KityMinder, {
this.execCommand( 'renderroot', node );
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