Commit 9a703d20 authored by techird's avatar techird

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

parents 8569f75a 87230381
var mindermoduleDefaultTest = function(){
console.log("test loaded");
var stroredData="stored";
return {
"commands": {
//todo:command字典,name-action 键值对模式编写
"testCommand":kity.createClass("testCommand",{
"execute":function(km,arg1,arg2,arg3){
console.log(arg1,arg2,arg3);
}
}
)
},
"events": {
//todo:事件响应函数绑定列表,事件名-响应函数 键值对模式编写
"click": function(e){
},
"keydown keyup": function(e){
}
}
}
}
\ No newline at end of file
var mindermoduleTest = function(){
console.log("test loaded");
var stroredData="stored";
return {
"ready": function(){
//todo:基本的初始化工作
console.log(stroredData);
},
"commands": {
//todo:command字典,name-action 键值对模式编写
"testCommand":function(km,arg){
console.log(arg);
}
},
"events": {
//todo:事件响应函数绑定列表,事件名-响应函数 键值对模式编写
"click": function(e){
},
"keydown keyup": function(e){
}
}
}
}
\ No newline at end of file
var Command = kity.createClass( "Command", {
execute: function (minder, args) {
constructor:function(){
},
revert: function() {
},
queryState: function() {
execute: function (minder, args) {
},
queryValue: function() {
revert: function() {
},
setContentChanged: function() {
setContentChanged: function( val ) {
},
isContentChanged: function() {
return false;
},
setSelectionChanged: function() {
setSelectionChanged: function(val) {
},
isSelectionChanged: function() {
return false;
}
});
Command.queryState: function(km) {
return 0;
}
Command.queryValue: function(km) {
return 0;
}
\ No newline at end of file
......@@ -30,8 +30,8 @@ KityMinder.registerModule = function( name, module ) {
kity.extendClass(KityMinder, {
_initModules: function() {
var me = this;
//在对象上挂接command池子
me.commands = {};
me.commands = {};//command池子
me.actions = [];//操作记录栈
var _modules = KityMinder._modules;
if(_modules){
for(var key in _modules){
......@@ -55,7 +55,6 @@ kity.extendClass(KityMinder, {
if(moduleDealsEvents){
for(var _key in moduleDealsEvents){
var bindEvs = _key.split(" ");
console.log(bindEvs);
var func = moduleDealsEvents[_key];
for (var _i = 0; _i < bindEvs.length; _i++){
me.on(bindEvs[_i],func);
......@@ -143,15 +142,20 @@ kity.extendClass(KityMinder, {
// 命令机制
kity.extendClass(KityMinder, {
execCommand: function( name ) {
var _action = new this.commands[name]();
console.log(_action);
var args = arguments;
arguments[0] = this;
_action["execute"]&&_action["execute"].apply(null,args);
this.actions.push(_action);
},
queryCommandState: function( name ) {
this.commands[name].queryState(this);
},
queryCommandValue: function( name ) {
this.commands[name].queryValue(this);
}
});
......
<!DOCTYPE html>
<html>
<head>
<title>KM Loader</title>
<style>
body, div, html {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
</body>
<script src="../kity/dist/kitygraph.all.js"></script>
<script src="../src/core/command.js"></script>
<script src="../minder_module/module.test.js"></script>
<script src="../minder_module/module.default.test.js"></script>
<script src="../src/core/km.js"></script>
<script src="../src/core/minderevent.js"></script>
<script src="../src/core/mindernode.js"></script>
<script src="../src/core/kityminder.js"></script>
<script>
KityMinder.registerModule("test",mindermoduleTest);
KityMinder.registerModule("defaulttest",mindermoduleDefaultTest);
var myMinder = new KityMinder();
myMinder.execCommand("testCommand","test1",function(){alert(a)},{a:1,b:2});
myMinder.queryCommandState("testCommand");
myMinder.queryCommandValue("testCommand");
</script>
</html>
\ 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