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
94a01e2e
Commit
94a01e2e
authored
Dec 19, 2013
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added closure
parent
31f3519a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
80 deletions
+85
-80
kityminder.js
src/core/kityminder.js
+85
-80
No files found.
src/core/kityminder.js
View file @
94a01e2e
var
KityMinder
=
km
.
KityMinder
=
kity
.
createClass
(
"KityMinder"
,
{
var
KityMinder
=
km
.
KityMinder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
id
,
option
)
{
constructor
:
function
(
id
,
option
)
{
// 初始化
// 初始化
this
.
_initMinder
(
id
,
option
||
{});
this
.
_initMinder
(
id
,
option
||
{});
...
@@ -19,57 +18,101 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
...
@@ -19,57 +18,101 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
}
}
});
});
// 模块注册
//模块注册&暴露模块接口
KityMinder
.
registerModule
=
function
(
name
,
module
)
{
(
function
(){
//初始化模块列表
var
_modules
=
{};
this
.
_modules
=
this
.
_modules
||
{};
KityMinder
.
registerModule
=
function
(
name
,
module
)
{
this
.
_modules
[
name
]
=
module
;
//初始化模块列表
};
_modules
[
name
]
=
module
;
};
KityMinder
.
getModules
=
function
(){
return
_modules
;
};
})();
// 模块维护
// 模块维护
kity
.
extendClass
(
KityMinder
,
{
kity
.
extendClass
(
KityMinder
,
(
function
()
{
_initModules
:
function
()
{
var
_commands
=
{};
//command池子
var
me
=
this
;
var
_query
=
{};
//query池子
me
.
commands
=
{};
//command池子
me
.
_query
=
{};
//query池子
return
{
me
.
actions
=
[];
//操作记录栈
_initModules
:
function
()
{
var
_modules
=
KityMinder
.
_modules
;
var
_modules
=
KityMinder
.
getModules
()
;
if
(
_modules
){
if
(
_modules
){
for
(
var
key
in
_modules
){
var
me
=
this
;
//执行模块初始化,抛出后续处理对象
for
(
var
key
in
_modules
){
var
moduleDeals
=
//执行模块初始化,抛出后续处理对象
_modules
[
key
].
call
(
me
);
var
moduleDeals
=
_modules
[
key
].
call
(
me
);
console
.
log
(
moduleDeals
);
console
.
log
(
moduleDeals
);
if
(
moduleDeals
.
ready
)
if
(
moduleDeals
.
ready
)
{
{
moduleDeals
.
ready
.
call
(
me
);
moduleDeals
.
ready
.
call
(
me
);
}
}
//command加入命令池子
//command加入命令池子
var
moduleDealsCommands
=
moduleDeals
.
commands
;
var
moduleDealsCommands
=
moduleDeals
.
commands
;
if
(
moduleDealsCommands
){
if
(
moduleDealsCommands
){
for
(
var
_keyC
in
moduleDealsCommands
){
for
(
var
_keyC
in
moduleDealsCommands
){
me
.
commands
[
_keyC
]
=
moduleDealsCommands
[
_keyC
];
_commands
[
_keyC
]
=
moduleDealsCommands
[
_keyC
];
}
}
}
}
//绑定事件
//绑定事件
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
(
" "
);
var
bindEvs
=
_keyE
.
split
(
" "
)
;
var
func
=
moduleDealsEvents
[
_keyE
]
;
var
func
=
moduleDealsEvents
[
_keyE
];
for
(
var
_i
=
0
;
_i
<
bindEvs
.
length
;
_i
++
){
for
(
var
_i
=
0
;
_i
<
bindEvs
.
length
;
_i
++
){
me
.
on
(
bindEvs
[
_i
],
func
);
me
.
on
(
bindEvs
[
_i
],
func
);
}
}
}
}
}
}
}
}
},
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
,
{
kity
.
extendClass
(
KityMinder
,
{
...
@@ -143,44 +186,6 @@ kity.extendClass(KityMinder, {
...
@@ -143,44 +186,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
)
{
if
(
!
this
.
commands
[
name
]){
return
false
;}
if
(
!
this
.
_query
[
name
]){
this
.
_query
[
name
]
=
new
this
.
commands
[
name
]();
}
if
(
this
.
_query
[
name
].
queryState
){
return
this
.
_query
[
name
].
queryState
(
this
);
}
else
{
return
0
;
}
},
queryCommandValue
:
function
(
name
)
{
if
(
!
this
.
commands
[
name
]){
return
false
;}
if
(
!
this
.
_query
[
name
]){
this
.
_query
[
name
]
=
new
this
.
commands
[
name
]();
}
if
(
this
.
_query
[
name
].
queryValue
){
return
this
.
_query
[
name
].
queryValue
(
this
);
}
else
{
return
0
;
}
}
});
// 导入导出
// 导入导出
kity
.
extendClass
(
KityMinder
,
{
kity
.
extendClass
(
KityMinder
,
{
...
...
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