Commit 87a53298 authored by Akikonata's avatar Akikonata

added closure

parent 94a01e2e
...@@ -20,9 +20,10 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", { ...@@ -20,9 +20,10 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
//模块注册&暴露模块接口 //模块注册&暴露模块接口
(function(){ (function(){
var _modules = {}; var _modules;
KityMinder.registerModule = function( name, module ) { KityMinder.registerModule = function( name, module ) {
//初始化模块列表 //初始化模块列表
if(!_modules){_modules = {};}
_modules[name] = module; _modules[name] = module;
}; };
KityMinder.getModules = function(){ KityMinder.getModules = function(){
...@@ -34,7 +35,6 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", { ...@@ -34,7 +35,6 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
kity.extendClass(KityMinder, (function(){ kity.extendClass(KityMinder, (function(){
var _commands = {};//command池子 var _commands = {};//command池子
var _query = {};//query池子 var _query = {};//query池子
return { return {
_initModules: function() { _initModules: function() {
var _modules = KityMinder.getModules(); var _modules = KityMinder.getModules();
...@@ -74,15 +74,16 @@ kity.extendClass(KityMinder, (function(){ ...@@ -74,15 +74,16 @@ kity.extendClass(KityMinder, (function(){
} }
}, },
execCommand: function( name ) { execCommand: function( name ) {
var me = this;
var _action = new _commands[name](); var _action = new _commands[name]();
console.log(_action); console.log(_action);
var args = arguments; var args = arguments;
args[0] = this; args[0] = this;
if(_action.execute){ if(_action.execute){
_action.fire("beforecommand"); me.fire("beforecommand",_action);
_action.on("precommand",function(e){ me.on("precommand",function(e){
_action.execute.apply(null,args); if(e.target===_action){_action.execute.apply(null,args);}
_action.fire("command"); me.fire("command",_action);
}); });
} }
}, },
......
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