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
Show 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 @@
...
@@ -8,13 +8,15 @@
"white": false,
"white": false,
"quotmark": false,
"quotmark": false,
"predef" : [
"predef" : [
"require",
"console",
"kity",
"kity",
"KityMinder",
"Minder",
"MinderNode",
"MinderNode",
"MinderEvent",
"MinderEvent",
"KityMinder",
"Command",
"require",
"KITYMINDER_CONFIG",
"km",
"Utils"
"console",
"Command"
]
]
}
}
\ No newline at end of file
src/core/k
m
.js
→
src/core/k
ityminder
.js
View file @
05069fe2
...
@@ -5,3 +5,7 @@ KityMinder.version = '1.0.0.0';
...
@@ -5,3 +5,7 @@ KityMinder.version = '1.0.0.0';
KityMinder
.
createMinder
=
function
(
id
,
option
)
{
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
,
{
kity
.
extendClass
(
Minder
,
{
execCommand
:
function
(
name
)
{
execCommand
:
function
(
name
)
{
var
me
=
this
;
var
TargetCommand
,
command
,
cmdArgs
,
eventParams
,
stoped
;
var
_action
=
new
_commands
[
name
.
toLowerCase
()
]();
var
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
TargetCommand
=
this
.
_getCommand
(
name
);
command
=
new
TargetCommand
();
var
eventParams
=
{
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
command
:
_action
,
eventParams
=
{
command
:
command
,
commandName
:
name
.
toLowerCase
(),
commandName
:
name
.
toLowerCase
(),
commandArgs
:
cmdArgs
commandArgs
:
cmdArgs
};
};
var
stoped
=
me
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
true
)
);
this
.
_executingCommand
=
this
.
_executingCommand
||
command
;
if
(
this
.
_executingCommand
==
command
)
{
stoped
=
this
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
true
)
);
if
(
!
stoped
)
{
if
(
!
stoped
)
{
me
.
_fire
(
new
MinderEvent
(
"precommand"
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
"precommand"
,
eventParams
,
false
)
);
_action
.
execute
.
apply
(
_action
,
[
this
].
concat
(
cmdArgs
)
);
command
.
execute
.
apply
(
command
,
[
this
].
concat
(
cmdArgs
)
);
me
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
if
(
_action
.
isContentChanged
()
)
{
if
(
command
.
isContentChanged
()
)
{
me
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
this
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
}
}
if
(
_action
.
isSelectionChanged
()
)
{
if
(
command
.
isSelectionChanged
()
)
{
me
.
_firePharse
(
new
MinderEvent
(
'selectionchange'
)
);
this
.
_firePharse
(
new
MinderEvent
(
'selectionchange'
)
);
}
}
}
}
this
.
_executingCommand
=
null
;
}
else
{
command
.
execute
.
apply
(
command
,
[
this
].
concat
(
cmdArgs
)
);
}
},
},
queryCommandState
:
function
(
name
)
{
queryCommandState
:
function
(
name
)
{
...
...
src/core/minder.data.js
View file @
05069fe2
// 导入导出
// 导入导出
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
exportData
:
function
(
node
)
{
exportData
:
function
(
node
)
{
var
exported
=
{};
var
exported
=
{};
node
=
node
||
this
.
getRoot
();
node
=
node
||
this
.
getRoot
();
...
@@ -49,6 +49,9 @@ kity.extendClass( KityMinder, {
...
@@ -49,6 +49,9 @@ kity.extendClass( KityMinder, {
this
.
_firePharse
(
{
this
.
_firePharse
(
{
type
:
'contentchange'
type
:
'contentchange'
}
);
}
);
this
.
_firePharse
(
{
type
:
'interactchange'
}
);
return
this
;
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
()
{
_initEvents
:
function
()
{
this
.
_eventCallbacks
=
{};
this
.
_eventCallbacks
=
{};
this
.
_bindPaperEvents
();
this
.
_bindPaperEvents
();
...
@@ -12,16 +12,9 @@ kity.extendClass( KityMinder, {
...
@@ -12,16 +12,9 @@ kity.extendClass( KityMinder, {
},
},
_bindKeyboardEvents
:
function
()
{
_bindKeyboardEvents
:
function
()
{
var
minder
=
this
;
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
(
' '
);
var
events
=
'keydown keyup keypress'
.
split
(
' '
);
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
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
)
{
_firePharse
:
function
(
e
)
{
...
@@ -40,8 +33,8 @@ kity.extendClass( KityMinder, {
...
@@ -40,8 +33,8 @@ kity.extendClass( KityMinder, {
},
},
_interactChange
:
function
(
e
)
{
_interactChange
:
function
(
e
)
{
var
minder
=
this
;
var
minder
=
this
;
clearTimeout
(
this
.
interactTimeout
);
clearTimeout
(
this
.
_
interactTimeout
);
this
.
interactTimeout
=
setTimeout
(
function
()
{
this
.
_
interactTimeout
=
setTimeout
(
function
()
{
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
if
(
stoped
)
{
if
(
stoped
)
{
return
;
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"
,
{
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
.
_initMinder
(
options
);
this
.
_initEvents
();
this
.
_initModules
(
options
);
this
.
_initModules
();
},
},
_initMinder
:
function
(
id
,
option
)
{
_initMinder
:
function
(
option
)
{
this
.
_rc
=
new
kity
.
Group
();
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
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_root
=
new
MinderNode
(
this
);
this
.
_root
=
new
MinderNode
(
this
);
this
.
_rc
.
addShape
(
this
.
_root
.
getRenderContainer
()
);
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
()
{
getRenderContainer
:
function
()
{
...
@@ -24,3 +46,11 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -24,3 +46,11 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
return
this
.
_paper
;
return
this
.
_paper
;
}
}
}
);
}
);
/**
* @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
()
{
getRoot
:
function
()
{
return
this
.
_root
;
return
this
.
_root
;
...
...
src/core/minder.select.js
View file @
05069fe2
// 选区管理
// 选区管理
kity
.
extendClass
(
Kity
Minder
,
{
kity
.
extendClass
(
Minder
,
{
getSelectedNodes
:
function
()
{
getSelectedNodes
:
function
()
{
return
this
.
_selectedNodes
||
(
this
.
_selectedNodes
=
[]
);
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