Commit 0c2f404e authored by techird's avatar techird

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents 4b354b10 6a6855a2
Subproject commit b6f3e9996353a089e7b78f603a66668a6a7354a3 Subproject commit 7f8b3b2743aa0ce609a3e8406d9efe8aa117accc
...@@ -2,32 +2,25 @@ var mindermoduleDefaultTest = function(){ ...@@ -2,32 +2,25 @@ var mindermoduleDefaultTest = function(){
console.log("test loaded"); console.log("test loaded");
var stroredData="stored"; var stroredData="stored";
var TestCommand = kity.createClass({
});
TestCommand.queryState = function() {};
return { return {
"commands": { "commands": {
//todo:command字典,name-action 键值对模式编写 //todo:command字典,name-action 键值对模式编写
"testCommand":kity.createClass("testCommand",{ "testCommand":kity.createClass("testCommand",{
base:Command, base:Command,
"execute":function(km,arg1,arg2,arg3){ "execute":function(km,arg1,arg2,arg3){
console.log(arg1,arg2,arg3); console.log(arg1,arg2,arg3);
} }
} })
) },
},
"events": { "events": {
//todo:事件响应函数绑定列表,事件名-响应函数 键值对模式编写 //todo:事件响应函数绑定列表,事件名-响应函数 键值对模式编写
"click": function(e){ "click": function(e){
}, },
"keydown keyup": function(e){ "keydown keyup": function(e){
} }
} }
} };
} };
\ No newline at end of file \ No newline at end of file
...@@ -4,8 +4,8 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", { ...@@ -4,8 +4,8 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
constructor: function (id, option) { constructor: function (id, option) {
// 初始化 // 初始化
this._initMinder(id, option || {}); this._initMinder(id, option || {});
this._initModules();
this._initEvents(); this._initEvents();
this._initModules();
}, },
_initMinder: function(id, option) { _initMinder: function(id, option) {
...@@ -22,9 +22,10 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", { ...@@ -22,9 +22,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(){
...@@ -36,7 +37,6 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", { ...@@ -36,7 +37,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();
...@@ -64,11 +64,7 @@ kity.extendClass(KityMinder, (function(){ ...@@ -64,11 +64,7 @@ kity.extendClass(KityMinder, (function(){
var moduleDealsEvents = moduleDeals.events; var moduleDealsEvents = moduleDeals.events;
if(moduleDealsEvents){ if(moduleDealsEvents){
for(var _keyE in moduleDealsEvents){ for(var _keyE in moduleDealsEvents){
var bindEvs = _keyE.split(" "); me.on(_keyE,moduleDealsEvents[_keyE]);
var func = moduleDealsEvents[_keyE];
for (var _i = 0; _i < bindEvs.length; _i++){
me.on(bindEvs[_i],func);
}
} }
} }
...@@ -76,15 +72,16 @@ kity.extendClass(KityMinder, (function(){ ...@@ -76,15 +72,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