Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
d9a86469
Commit
d9a86469
authored
Dec 19, 2013
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
494627a3
94a01e2e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
72 deletions
+95
-72
command.js
src/core/command.js
+8
-7
kityminder.js
src/core/kityminder.js
+85
-63
index.html
testcase/index.html
+2
-2
No files found.
src/core/command.js
View file @
d9a86469
...
...
@@ -26,13 +26,14 @@ var Command = kity.createClass( "Command", {
isSelectionChanged
:
function
()
{
return
false
;
}
});
},
Command
.
queryState
=
function
(
km
)
{
queryState
:
function
(
km
)
{
return
0
;
}
}
,
Command
.
queryValue
=
function
(
km
)
{
queryValue
:
function
(
km
)
{
return
0
;
}
});
src/core/kityminder.js
View file @
d9a86469
var
KityMinder
=
km
.
KityMinder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
id
,
option
)
{
// 初始化
this
.
_initMinder
(
id
,
option
||
{});
...
...
@@ -19,25 +18,31 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
}
});
// 模块注册
KityMinder
.
registerModule
=
function
(
name
,
module
)
{
//模块注册&暴露模块接口
(
function
(){
var
_modules
=
{};
KityMinder
.
registerModule
=
function
(
name
,
module
)
{
//初始化模块列表
this
.
_modules
=
this
.
_modules
||
{};
this
.
_modules
[
name
]
=
module
;
};
_modules
[
name
]
=
module
;
};
KityMinder
.
getModules
=
function
(){
return
_modules
;
};
})();
// 模块维护
kity
.
extendClass
(
KityMinder
,
{
kity
.
extendClass
(
KityMinder
,
(
function
(){
var
_commands
=
{};
//command池子
var
_query
=
{};
//query池子
return
{
_initModules
:
function
()
{
var
me
=
this
;
me
.
commands
=
{};
//command池子
me
.
actions
=
[];
//操作记录栈
var
_modules
=
KityMinder
.
_modules
;
var
_modules
=
KityMinder
.
getModules
();
if
(
_modules
){
var
me
=
this
;
for
(
var
key
in
_modules
){
//执行模块初始化,抛出后续处理对象
var
moduleDeals
=
_modules
[
key
].
call
(
me
);
var
moduleDeals
=
_modules
[
key
].
call
(
me
);
console
.
log
(
moduleDeals
);
if
(
moduleDeals
.
ready
)
...
...
@@ -49,7 +54,7 @@ kity.extendClass(KityMinder, {
var
moduleDealsCommands
=
moduleDeals
.
commands
;
if
(
moduleDealsCommands
){
for
(
var
_keyC
in
moduleDealsCommands
){
me
.
commands
[
_keyC
]
=
moduleDealsCommands
[
_keyC
];
_
commands
[
_keyC
]
=
moduleDealsCommands
[
_keyC
];
}
}
...
...
@@ -67,8 +72,47 @@ kity.extendClass(KityMinder, {
}
}
},
execCommand
:
function
(
name
)
{
var
_action
=
new
_commands
[
name
]();
console
.
log
(
_action
);
var
args
=
arguments
;
args
[
0
]
=
this
;
if
(
_action
.
execute
){
_action
.
fire
(
"beforecommand"
);
_action
.
on
(
"precommand"
,
function
(
e
){
_action
.
execute
.
apply
(
null
,
args
);
_action
.
fire
(
"command"
);
});
}
});
},
queryCommandState
:
function
(
name
)
{
if
(
!
_commands
[
name
]){
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
)
{
if
(
!
_commands
[
name
]){
return
false
;}
if
(
!
_query
[
name
]){
_query
[
name
]
=
new
_commands
[
name
]();
}
if
(
_query
[
name
].
queryValue
){
return
_query
[
name
].
queryValue
(
this
);
}
else
{
return
0
;
}
}
};
})());
// 节点控制
kity
.
extendClass
(
KityMinder
,
{
...
...
@@ -224,28 +268,6 @@ kity.extendClass(KityMinder, {
}
});
// 命令机制
kity
.
extendClass
(
KityMinder
,
{
execCommand
:
function
(
name
)
{
var
_action
=
new
this
.
commands
[
name
]();
console
.
log
(
_action
);
var
args
=
arguments
;
args
[
0
]
=
this
;
if
(
_action
.
execute
){
_action
.
execute
.
apply
(
null
,
args
);
}
this
.
actions
.
push
(
_action
);
},
queryCommandState
:
function
(
name
)
{
console
.
log
(
this
.
commands
[
name
]);
(
this
.
commands
[
name
].
queryState
||
Command
.
queryState
)(
this
);
},
queryCommandValue
:
function
(
name
)
{
(
this
.
commands
[
name
].
queryValue
||
Command
.
queryValue
)(
this
);
}
});
// 导入导出
kity
.
extendClass
(
KityMinder
,
{
...
...
testcase/index.html
View file @
d9a86469
...
...
@@ -25,7 +25,7 @@
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"
);
console
.
log
(
myMinder
.
queryCommandState
(
"testCommand"
)
);
console
.
log
(
myMinder
.
queryCommandValue
(
"testCommand"
)
);
</script>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment