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
05069fe2
Commit
05069fe2
authored
Dec 23, 2013
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
8b8945db
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
91 additions
and
41 deletions
+91
-41
.jshintrc
.jshintrc
+7
-5
kityminder.js
src/core/kityminder.js
+4
-0
minder.command.js
src/core/minder.command.js
+26
-15
minder.data.js
src/core/minder.data.js
+4
-1
minder.event.js
src/core/minder.event.js
+4
-11
minder.js
src/core/minder.js
+37
-7
minder.node.js
src/core/minder.node.js
+1
-1
minder.select.js
src/core/minder.select.js
+1
-1
utils.js
src/core/utils.js
+7
-0
No files found.
.jshintrc
View file @
05069fe2
...
...
@@ -8,13 +8,15 @@
"white": false,
"quotmark": false,
"predef" : [
"require",
"console",
"kity",
"KityMinder",
"Minder",
"MinderNode",
"MinderEvent",
"KityMinder",
"require",
"km",
"console",
"Command"
"Command",
"KITYMINDER_CONFIG",
"Utils"
]
}
\ No newline at end of file
src/core/k
m
.js
→
src/core/k
ityminder
.js
View file @
05069fe2
...
...
@@ -4,4 +4,8 @@ KityMinder.version = '1.0.0.0';
KityMinder
.
createMinder
=
function
(
id
,
option
)
{
};
KityMinder
.
getMinder
=
function
(
id
)
{
};
\ No newline at end of file
src/core/minder.command.js
View file @
05069fe2
kity
.
extendClass
(
Minder
,
{
execCommand
:
function
(
name
)
{
var
me
=
this
;
var
_action
=
new
_commands
[
name
.
toLowerCase
()
]();
var
TargetCommand
,
command
,
cmdArgs
,
eventParams
,
stoped
;
var
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
TargetCommand
=
this
.
_getCommand
(
name
);
command
=
new
TargetCommand
();
var
eventParams
=
{
command
:
_action
,
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
eventParams
=
{
command
:
command
,
commandName
:
name
.
toLowerCase
(),
commandArgs
:
cmdArgs
};
var
stoped
=
me
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
true
)
)
;
this
.
_executingCommand
=
this
.
_executingCommand
||
command
;
if
(
!
stope
d
)
{
if
(
this
.
_executingCommand
==
comman
d
)
{
me
.
_fire
(
new
MinderEvent
(
"precommand"
,
eventParams
,
fals
e
)
);
stoped
=
this
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
tru
e
)
);
_action
.
execute
.
apply
(
_action
,
[
this
].
concat
(
cmdArgs
)
);
if
(
!
stoped
)
{
me
.
_fire
(
new
MinderEvent
(
"
command"
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
"pre
command"
,
eventParams
,
false
)
);
if
(
_action
.
isContentChanged
()
)
{
me
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
}
if
(
_action
.
isSelectionChanged
()
)
{
me
.
_firePharse
(
new
MinderEvent
(
'selectionchange'
)
);
command
.
execute
.
apply
(
command
,
[
this
].
concat
(
cmdArgs
)
);
this
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
if
(
command
.
isContentChanged
()
)
{
this
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
}
if
(
command
.
isSelectionChanged
()
)
{
this
.
_firePharse
(
new
MinderEvent
(
'selectionchange'
)
);
}
}
this
.
_executingCommand
=
null
;
}
else
{
command
.
execute
.
apply
(
command
,
[
this
].
concat
(
cmdArgs
)
);
}
},
...
...
src/core/minder.data.js
View file @
05069fe2
// 导入导出
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
exportData
:
function
(
node
)
{
var
exported
=
{};
node
=
node
||
this
.
getRoot
();
...
...
@@ -49,6 +49,9 @@ kity.extendClass( KityMinder, {
this
.
_firePharse
(
{
type
:
'contentchange'
}
);
this
.
_firePharse
(
{
type
:
'interactchange'
}
);
return
this
;
}
}
);
\ No newline at end of file
src/core/minder.event.js
View file @
05069fe2
// 事件机制
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
_initEvents
:
function
()
{
this
.
_eventCallbacks
=
{};
this
.
_bindPaperEvents
();
...
...
@@ -12,16 +12,9 @@ kity.extendClass( KityMinder, {
},
_bindKeyboardEvents
:
function
()
{
var
minder
=
this
;
var
listen
=
function
(
name
,
callback
)
{
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
name
,
callback
);
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
name
,
callback
);
}
};
var
events
=
'keydown keyup keypress'
.
split
(
' '
);
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
listen
(
events
[
i
],
this
.
_firePharse
.
bind
(
this
)
);
Utils
.
listen
(
events
[
i
],
this
.
_firePharse
.
bind
(
this
)
);
}
},
_firePharse
:
function
(
e
)
{
...
...
@@ -40,8 +33,8 @@ kity.extendClass( KityMinder, {
},
_interactChange
:
function
(
e
)
{
var
minder
=
this
;
clearTimeout
(
this
.
interactTimeout
);
this
.
interactTimeout
=
setTimeout
(
function
()
{
clearTimeout
(
this
.
_
interactTimeout
);
this
.
_
interactTimeout
=
setTimeout
(
function
()
{
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
if
(
stoped
)
{
return
;
...
...
src/core/minder.js
View file @
05069fe2
/**
* @require <kityminder.js>
* @require <module.js>
* @require <event.js>
* @require <node.js>
* @reuqire <command.js>
* @require <utils.js>
*
* @description KityMinder 使用类
*/
var
MinderDefaultOptions
=
{};
var
Minder
=
KityMinder
.
Minder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
id
,
option
)
{
constructor
:
function
(
options
)
{
options
=
Utils
.
extend
(
KITYMINDER_CONFIG
||
{},
MinderDefaultOptions
,
options
||
{}
);
// 初始化
this
.
_initMinder
(
id
,
option
||
{}
);
this
.
_initEvents
();
this
.
_initModules
();
this
.
_initMinder
(
options
);
this
.
_initModules
(
options
);
},
_initMinder
:
function
(
id
,
option
)
{
_initMinder
:
function
(
option
)
{
this
.
_rc
=
new
kity
.
Group
();
this
.
_paper
=
new
kity
.
Paper
(
option
.
renderTo
||
document
.
body
);
this
.
_paper
=
new
kity
.
Paper
();
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_root
=
new
MinderNode
(
this
);
this
.
_rc
.
addShape
(
this
.
_root
.
getRenderContainer
()
);
if
(
option
.
renderTo
)
{
this
.
renderTo
(
this
.
_renderTarget
=
option
.
renderTo
);
}
},
renderTo
:
function
(
target
)
{
this
.
_paper
.
renderTo
(
target
);
this
.
_initEvents
();
},
getRenderContainer
:
function
()
{
...
...
@@ -23,4 +45,12 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getPaper
:
function
()
{
return
this
.
_paper
;
}
}
);
\ No newline at end of file
}
);
/**
* @include <minder.data.js>
* @include <minder.event.js>
* @include <minder.module.js>
* @include <minder.node.js>
* @include <minder.select.js>
*/
\ No newline at end of file
src/core/minder.node.js
View file @
05069fe2
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
getRoot
:
function
()
{
return
this
.
_root
;
...
...
src/core/minder.select.js
View file @
05069fe2
// 选区管理
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
getSelectedNodes
:
function
()
{
return
this
.
_selectedNodes
||
(
this
.
_selectedNodes
=
[]
);
},
...
...
src/core/utils.js
0 → 100644
View file @
05069fe2
var
Utils
=
KityMinder
.
Utils
=
{};
Utils
.
extend
=
kity
.
Utils
.
extend
;
Utils
.
listen
=
function
(
element
,
type
,
callback
)
{
(
element
.
addEventListener
||
element
.
attachEvent
)(
name
,
callback
);
};
\ 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