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
Show 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 @@
...
@@ -59,6 +59,7 @@
'module/zoom.js'
,
'module/zoom.js'
,
'module/hyperlink.js'
,
'module/hyperlink.js'
,
'module/arrange.js'
,
'module/arrange.js'
,
'module/paste.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/widget.js'
,
'ui/widget.js'
,
'ui/button.js'
,
'ui/button.js'
,
...
...
src/core/keymap.js
View file @
9f991aea
...
@@ -51,9 +51,11 @@ var keymap = KityMinder.keymap = (function(origin) {
...
@@ -51,9 +51,11 @@ var keymap = KityMinder.keymap = (function(origin) {
//回退
//回退
'z'
:
90
,
'z'
:
90
,
'y'
:
89
,
'y'
:
89
,
//粘贴
//复制粘贴
'v'
:
86
,
'v'
:
86
,
'x'
:
88
,
'x'
:
88
,
'c'
:
67
,
's'
:
83
,
's'
:
83
,
...
...
src/core/minder.node.js
View file @
9f991aea
...
@@ -40,6 +40,7 @@ kity.extendClass(Minder, {
...
@@ -40,6 +40,7 @@ kity.extendClass(Minder, {
handelNodeCreate
:
function
(
node
)
{
handelNodeCreate
:
function
(
node
)
{
var
rc
=
this
.
_rc
;
var
rc
=
this
.
_rc
;
node
.
traverse
(
function
(
current
)
{
node
.
traverse
(
function
(
current
)
{
current
.
attached
=
true
;
rc
.
addShape
(
current
.
getRenderContainer
());
rc
.
addShape
(
current
.
getRenderContainer
());
});
});
rc
.
addShape
(
node
.
getRenderContainer
());
rc
.
addShape
(
node
.
getRenderContainer
());
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
handelNodeRemove
:
function
(
node
)
{
handelNodeRemove
:
function
(
node
)
{
var
rc
=
this
.
_rc
;
var
rc
=
this
.
_rc
;
node
.
traverse
(
function
(
current
)
{
node
.
traverse
(
function
(
current
)
{
current
.
attached
=
false
;
rc
.
removeShape
(
current
.
getRenderContainer
());
rc
.
removeShape
(
current
.
getRenderContainer
());
});
});
},
},
...
@@ -60,6 +62,6 @@ kity.extendClass(Minder, {
...
@@ -60,6 +62,6 @@ kity.extendClass(Minder, {
kity
.
extendClass
(
MinderNode
,
{
kity
.
extendClass
(
MinderNode
,
{
getMinder
:
function
()
{
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, {
...
@@ -81,14 +81,14 @@ kity.extendClass(Minder, {
return
this
.
_selectedNodes
.
length
==
1
;
return
this
.
_selectedNodes
.
length
==
1
;
},
},
getSelectedAncestors
:
function
()
{
getSelectedAncestors
:
function
(
includeRoot
)
{
var
nodes
=
this
.
getSelectedNodes
().
slice
(
0
),
var
nodes
=
this
.
getSelectedNodes
().
slice
(
0
),
ancestors
=
[],
ancestors
=
[],
judge
;
judge
;
// 根节点不参与计算
// 根节点不参与计算
var
rootIndex
=
nodes
.
indexOf
(
this
.
getRoot
());
var
rootIndex
=
nodes
.
indexOf
(
this
.
getRoot
());
if
(
~
rootIndex
)
{
if
(
~
rootIndex
&&
!
includeRoot
)
{
nodes
.
splice
(
rootIndex
,
1
);
nodes
.
splice
(
rootIndex
,
1
);
}
}
...
...
src/core/node.js
View file @
9f991aea
...
@@ -185,6 +185,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
...
@@ -185,6 +185,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
.
parent
=
null
;
removed
.
parent
=
null
;
removed
.
root
=
removed
;
}
}
},
},
...
@@ -255,22 +256,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
...
@@ -255,22 +256,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
return
cloneNode
(
null
,
this
);
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
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
restoreSelected
();
return
false
;
return
false
;
}
}
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getData
(),
me
.
getData
())
===
false
)
{
restoreSelected
();
return
false
;
return
false
;
}
}
if
(
utils
.
compareObject
(
node
.
getTmpData
(),
this
.
getTmpData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getTmpData
(),
me
.
getTmpData
())
===
false
)
{
restoreSelected
();
return
false
;
return
false
;
}
}
for
(
var
i
=
0
,
ci
;
for
(
var
i
=
0
,
ci
;
(
ci
=
this
.
children
[
i
]);
i
++
)
{
(
ci
=
me
.
children
[
i
]);
i
++
)
{
if
(
ci
.
equals
(
node
.
children
[
i
])
===
false
)
{
if
(
ci
.
equals
(
node
.
children
[
i
],
ignoreSelected
)
===
false
)
{
restoreSelected
();
return
false
;
return
false
;
}
}
}
}
restoreSelected
();
return
true
;
return
true
;
},
},
...
...
src/core/render.js
View file @
9f991aea
...
@@ -27,6 +27,7 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
...
@@ -27,6 +27,7 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
kity
.
extendClass
(
Minder
,
{
kity
.
extendClass
(
Minder
,
{
_createRendererForNode
:
function
(
node
)
{
_createRendererForNode
:
function
(
node
)
{
var
registered
=
this
.
_renderers
;
var
registered
=
this
.
_renderers
;
var
renderers
=
[];
var
renderers
=
[];
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
...
@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
},
},
renderNode
:
function
(
node
)
{
renderNode
:
function
(
node
)
{
var
rendererClasses
=
this
.
_renderers
;
var
rendererClasses
=
this
.
_renderers
;
var
g
=
KityMinder
.
Geometry
;
var
g
=
KityMinder
.
Geometry
;
var
i
,
latestBox
,
renderer
;
var
i
,
latestBox
,
renderer
;
...
@@ -107,6 +109,7 @@ kity.extendClass(Minder, {
...
@@ -107,6 +109,7 @@ kity.extendClass(Minder, {
kity
.
extendClass
(
MinderNode
,
{
kity
.
extendClass
(
MinderNode
,
{
render
:
function
()
{
render
:
function
()
{
if
(
!
this
.
attached
)
return
;
this
.
getMinder
().
renderNode
(
this
);
this
.
getMinder
().
renderNode
(
this
);
return
this
;
return
this
;
},
},
...
...
src/core/utils.js
View file @
9f991aea
...
@@ -268,6 +268,9 @@ var utils = Utils = KityMinder.Utils = {
...
@@ -268,6 +268,9 @@ var utils = Utils = KityMinder.Utils = {
}[
a
]
}[
a
]
}
}
})
:
''
;
})
:
''
;
},
cloneArr
:
function
(
arr
){
return
[].
concat
(
arr
);
}
}
};
};
...
...
src/module/history.js
View file @
9f991aea
...
@@ -14,27 +14,8 @@ KityMinder.registerModule("HistoryModule", function() {
...
@@ -14,27 +14,8 @@ KityMinder.registerModule("HistoryModule", function() {
return
this
.
getData
().
clone
();
return
this
.
getData
().
clone
();
},
},
equals
:
function
(
scene
)
{
equals
:
function
(
scene
)
{
var
nodeA
=
scene
.
getData
(),
isSelectedA
=
false
;
return
this
.
getData
().
equals
(
scene
.
getData
());
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
();
}
if
(
isSelectedB
){
nodeB
.
setSelectedFlag
();
}
return
result
;
},
},
isInputStatus
:
function
(){
isInputStatus
:
function
(){
return
this
.
inputStatus
;
return
this
.
inputStatus
;
...
@@ -110,7 +91,9 @@ KityMinder.registerModule("HistoryModule", function() {
...
@@ -110,7 +91,9 @@ KityMinder.registerModule("HistoryModule", function() {
}
}
km
.
appendNode
(
child
,
parent
);
km
.
appendNode
(
child
,
parent
);
child
.
render
();
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
);
appendChildNode
(
child
,
ci
);
}
}
}
}
...
@@ -140,8 +123,10 @@ KityMinder.registerModule("HistoryModule", function() {
...
@@ -140,8 +123,10 @@ KityMinder.registerModule("HistoryModule", function() {
traverseNode
(
km
.
getRoot
(),
target
);
traverseNode
(
km
.
getRoot
(),
target
);
km
.
layout
();
km
.
layout
();
km
.
select
(
selectedNodes
,
true
);
km
.
select
(
selectedNodes
,
true
);
selectedNodes
=
[];
},
},
restore
:
function
(
index
)
{
restore
:
function
(
index
)
{
...
...
src/module/paste.js
View file @
9f991aea
KityMinder
.
registerModule
(
"pasteModule"
,
function
()
{
KityMinder
.
registerModule
(
"pasteModule"
,
function
()
{
var
km
=
this
;
var
km
=
this
,
//getSelectedTopNodes
_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
{
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