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
9f991aea
Commit
9f991aea
authored
Jul 02, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:fex-team/kityminder into dev
parents
7094dbce
fbb1b81e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
121 additions
and
32 deletions
+121
-32
import.js
import.js
+1
-0
keymap.js
src/core/keymap.js
+3
-1
minder.node.js
src/core/minder.node.js
+3
-1
minder.select.js
src/core/minder.select.js
+2
-2
node.js
src/core/node.js
+33
-5
render.js
src/core/render.js
+3
-0
utils.js
src/core/utils.js
+3
-0
history.js
src/module/history.js
+6
-21
paste.js
src/module/paste.js
+67
-2
No files found.
import.js
View file @
9f991aea
...
...
@@ -59,6 +59,7 @@
'module/zoom.js'
,
'module/hyperlink.js'
,
'module/arrange.js'
,
'module/paste.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/widget.js'
,
'ui/button.js'
,
...
...
src/core/keymap.js
View file @
9f991aea
...
...
@@ -51,9 +51,11 @@ var keymap = KityMinder.keymap = (function(origin) {
//回退
'z'
:
90
,
'y'
:
89
,
//粘贴
//复制粘贴
'v'
:
86
,
'x'
:
88
,
'c'
:
67
,
's'
:
83
,
...
...
src/core/minder.node.js
View file @
9f991aea
...
...
@@ -40,6 +40,7 @@ kity.extendClass(Minder, {
handelNodeCreate
:
function
(
node
)
{
var
rc
=
this
.
_rc
;
node
.
traverse
(
function
(
current
)
{
current
.
attached
=
true
;
rc
.
addShape
(
current
.
getRenderContainer
());
});
rc
.
addShape
(
node
.
getRenderContainer
());
...
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
handelNodeRemove
:
function
(
node
)
{
var
rc
=
this
.
_rc
;
node
.
traverse
(
function
(
current
)
{
current
.
attached
=
false
;
rc
.
removeShape
(
current
.
getRenderContainer
());
});
},
...
...
@@ -60,6 +62,6 @@ kity.extendClass(Minder, {
kity
.
extendClass
(
MinderNode
,
{
getMinder
:
function
()
{
return
this
.
root
.
minder
;
return
this
.
getRoot
()
.
minder
;
}
});
\ No newline at end of file
src/core/minder.select.js
View file @
9f991aea
...
...
@@ -81,14 +81,14 @@ kity.extendClass(Minder, {
return
this
.
_selectedNodes
.
length
==
1
;
},
getSelectedAncestors
:
function
()
{
getSelectedAncestors
:
function
(
includeRoot
)
{
var
nodes
=
this
.
getSelectedNodes
().
slice
(
0
),
ancestors
=
[],
judge
;
// 根节点不参与计算
var
rootIndex
=
nodes
.
indexOf
(
this
.
getRoot
());
if
(
~
rootIndex
)
{
if
(
~
rootIndex
&&
!
includeRoot
)
{
nodes
.
splice
(
rootIndex
,
1
);
}
...
...
src/core/node.js
View file @
9f991aea
...
...
@@ -185,6 +185,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
if
(
index
>=
0
)
{
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
.
parent
=
null
;
removed
.
root
=
removed
;
}
},
...
...
@@ -255,22 +256,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
return
cloneNode
(
null
,
this
);
},
equals
:
function
(
node
)
{
equals
:
function
(
node
,
ignoreSelected
)
{
var
me
=
this
;
function
restoreSelected
(){
if
(
isSelectedA
){
me
.
setSelectedFlag
();
}
if
(
isSelectedB
){
node
.
setSelectedFlag
();
}
}
if
(
ignoreSelected
){
var
isSelectedA
=
false
;
var
isSelectedB
=
false
;
if
(
me
.
isSelected
()){
isSelectedA
=
true
;
me
.
clearSelectedFlag
();
}
if
(
node
.
isSelected
()){
isSelectedB
=
true
;
node
.
clearSelectedFlag
();
}
}
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
restoreSelected
();
return
false
;
}
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getData
(),
me
.
getData
())
===
false
)
{
restoreSelected
();
return
false
;
}
if
(
utils
.
compareObject
(
node
.
getTmpData
(),
this
.
getTmpData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getTmpData
(),
me
.
getTmpData
())
===
false
)
{
restoreSelected
();
return
false
;
}
for
(
var
i
=
0
,
ci
;
(
ci
=
this
.
children
[
i
]);
i
++
)
{
if
(
ci
.
equals
(
node
.
children
[
i
])
===
false
)
{
(
ci
=
me
.
children
[
i
]);
i
++
)
{
if
(
ci
.
equals
(
node
.
children
[
i
],
ignoreSelected
)
===
false
)
{
restoreSelected
();
return
false
;
}
}
restoreSelected
();
return
true
;
},
...
...
src/core/render.js
View file @
9f991aea
...
...
@@ -27,6 +27,7 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
kity
.
extendClass
(
Minder
,
{
_createRendererForNode
:
function
(
node
)
{
var
registered
=
this
.
_renderers
;
var
renderers
=
[];
...
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
},
renderNode
:
function
(
node
)
{
var
rendererClasses
=
this
.
_renderers
;
var
g
=
KityMinder
.
Geometry
;
var
i
,
latestBox
,
renderer
;
...
...
@@ -107,6 +109,7 @@ kity.extendClass(Minder, {
kity
.
extendClass
(
MinderNode
,
{
render
:
function
()
{
if
(
!
this
.
attached
)
return
;
this
.
getMinder
().
renderNode
(
this
);
return
this
;
},
...
...
src/core/utils.js
View file @
9f991aea
...
...
@@ -268,6 +268,9 @@ var utils = Utils = KityMinder.Utils = {
}[
a
]
}
})
:
''
;
},
cloneArr
:
function
(
arr
){
return
[].
concat
(
arr
);
}
};
...
...
src/module/history.js
View file @
9f991aea
...
...
@@ -14,27 +14,8 @@ KityMinder.registerModule("HistoryModule", function() {
return
this
.
getData
().
clone
();
},
equals
:
function
(
scene
)
{
var
nodeA
=
scene
.
getData
(),
isSelectedA
=
false
;
var
nodeB
=
this
.
getData
(),
isSelectedB
=
false
;
if
(
nodeA
.
isSelected
()){
isSelectedA
=
true
;
nodeA
.
clearSelectedFlag
();
}
if
(
nodeB
.
isSelected
()){
isSelectedB
=
true
;
nodeB
.
clearSelectedFlag
();
}
var
result
=
nodeB
.
equals
(
nodeA
);
if
(
isSelectedA
){
nodeA
.
setSelectedFlag
();
}
return
this
.
getData
().
equals
(
scene
.
getData
());
if
(
isSelectedB
){
nodeB
.
setSelectedFlag
();
}
return
result
;
},
isInputStatus
:
function
(){
return
this
.
inputStatus
;
...
...
@@ -110,7 +91,9 @@ KityMinder.registerModule("HistoryModule", function() {
}
km
.
appendNode
(
child
,
parent
);
child
.
render
();
for
(
var
i
=
0
,
ci
;
ci
=
child
.
children
[
i
++
];)
{
var
children
=
utils
.
cloneArr
(
child
.
children
);
for
(
var
i
=
0
,
ci
;
ci
=
children
[
i
++
];)
{
appendChildNode
(
child
,
ci
);
}
}
...
...
@@ -140,8 +123,10 @@ KityMinder.registerModule("HistoryModule", function() {
traverseNode
(
km
.
getRoot
(),
target
);
km
.
layout
();
km
.
select
(
selectedNodes
,
true
);
selectedNodes
=
[];
},
restore
:
function
(
index
)
{
...
...
src/module/paste.js
View file @
9f991aea
KityMinder
.
registerModule
(
"pasteModule"
,
function
()
{
var
km
=
this
;
//getSelectedTopNodes
var
km
=
this
,
_cacheNodes
=
[],
_selectedNodes
=
[],
_copystatus
=
false
,
_curstatus
=
false
;
function
appendChildNode
(
parent
,
child
)
{
_selectedNodes
.
push
(
child
);
km
.
appendNode
(
child
,
parent
);
child
.
render
();
child
.
setLayoutOffset
(
null
);
var
children
=
utils
.
cloneArr
(
child
.
children
);
for
(
var
i
=
0
,
ci
;
ci
=
children
[
i
++
];
)
{
appendChildNode
(
child
,
ci
);
}
}
function
getNodes
(
arr
,
isCut
){
_cacheNodes
=
[];
for
(
var
i
=
0
,
ni
;
ni
=
arr
[
i
++
];){
_cacheNodes
.
push
(
ni
.
clone
());
if
(
isCut
&&
!
ni
.
isRoot
()){
km
.
removeNode
(
ni
);
}
}
}
return
{
'events'
:
{
'normal.keydown'
:
function
(
e
)
{
var
keys
=
KityMinder
.
keymap
;
var
keyEvent
=
e
.
originEvent
;
if
(
keyEvent
.
ctrlKey
||
keyEvent
.
metaKey
)
{
switch
(
keyEvent
.
keyCode
)
{
case
keys
.
c
:
getNodes
(
km
.
getSelectedAncestors
(
true
));
_copystatus
=
true
;
break
;
case
keys
.
x
:
getNodes
(
km
.
getSelectedAncestors
(),
true
);
_curstatus
=
true
;
break
;
case
keys
.
v
:
if
(
_cacheNodes
.
length
){
var
node
=
km
.
getSelectedNode
();
if
(
node
){
km
.
fire
(
'saveScene'
);
for
(
var
i
=
0
,
ni
;
ni
=
_cacheNodes
[
i
++
];){
appendChildNode
(
node
,
ni
);
}
km
.
layout
(
300
);
km
.
select
(
_selectedNodes
,
true
);
_selectedNodes
=
[];
km
.
fire
(
'saveScene'
);
}
}
}
}
}
}
};
}
);
\ 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