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
bc465b0b
Commit
bc465b0b
authored
Jan 06, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
ea53ce0d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
11 deletions
+79
-11
node.js
src/core/node.js
+11
-1
connect.js
src/module/connect.js
+17
-5
keyboard.js
src/module/keyboard.js
+43
-2
layout.js
src/module/layout.js
+8
-3
No files found.
src/core/node.js
View file @
bc465b0b
...
...
@@ -12,6 +12,16 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
this
.
parent
;
},
getDepth
:
function
()
{
var
depth
=
0
,
p
=
this
.
parent
;
while
(
p
)
{
p
=
p
.
parent
;
depth
++
;
}
return
depth
;
},
getRoot
:
function
()
{
var
root
=
this
;
while
(
root
.
parent
)
{
...
...
@@ -45,7 +55,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
getIndex
:
function
()
{
return
this
.
parent
?
this
.
parent
.
indexOf
(
this
)
:
-
1
;
return
this
.
parent
?
this
.
parent
.
children
.
indexOf
(
this
)
:
-
1
;
},
insertChild
:
function
(
node
,
index
)
{
...
...
src/module/connect.js
View file @
bc465b0b
...
...
@@ -136,6 +136,7 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () {
"events"
:
{
"command"
:
function
(
e
)
{
var
command
=
e
;
var
minder
=
this
;
switch
(
command
.
commandName
)
{
case
"rendernode"
:
(
function
()
{
...
...
@@ -165,13 +166,24 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () {
break
;
case
"removenode"
:
(
function
()
{
var
node
=
command
.
commandArgs
[
0
];
node
.
getData
(
"connect"
).
remove
();
var
nodes
=
command
.
commandArgs
[
0
];
if
(
(
nodes
instanceof
Array
)
===
false
)
{
nodes
=
[
nodes
];
}
function
removeConnect
(
node
)
{
var
connect
=
node
.
getData
(
"connect"
);
if
(
connect
&&
connect
.
remove
)
{
connect
.
remove
();
}
}
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
nodes
[
i
].
traverse
(
removeConnect
);
}
}
)();
default
:
break
;
};
}
}
}
};
}
);
\ No newline at end of file
src/module/keyboard.js
View file @
bc465b0b
...
...
@@ -46,6 +46,20 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
);
}
function
findMinDepthNode
(
nodes
)
{
var
depth
,
minDepth
=
Number
.
MAX_VALUE
,
minDepthNode
=
null
;
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
depth
=
nodes
[
i
].
getDepth
();
if
(
depth
<
minDepth
)
{
minDepth
=
depth
;
minDepthNode
=
nodes
[
i
];
}
}
return
minDepthNode
;
}
var
KBCreateAndEditCommand
=
kity
.
createClass
(
{
base
:
Command
,
execute
:
function
(
km
,
type
,
referNode
)
{
...
...
@@ -73,11 +87,37 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
}
);
var
KBRemoveCommand
=
kity
.
createClass
(
{
base
:
Command
,
execute
:
function
(
km
,
nodes
)
{
km
.
clearSelect
(
nodes
);
var
select
=
this
.
getNextSelection
(
km
,
nodes
);
km
.
execCommand
(
'removeNode'
,
nodes
);
km
.
select
(
select
);
km
.
execCommand
(
'rendernode'
,
select
);
},
getNextSelection
:
function
(
km
,
removeNodes
)
{
var
minDepthNode
=
findMinDepthNode
(
removeNodes
);
var
parent
=
minDepthNode
.
getParent
();
if
(
!
parent
)
{
return
km
.
getRoot
();
}
var
length
=
parent
.
getChildren
().
length
;
if
(
length
>
1
)
{
var
index
=
minDepthNode
.
getIndex
()
+
1
;
return
parent
.
getChild
(
index
%
length
);
}
else
{
return
parent
;
}
}
}
);
return
{
// private usage
"commands"
:
{
'kbCreateAndEdit'
:
KBCreateAndEditCommand
,
'kbNavigate'
:
KBNavigateCommand
'kbNavigate'
:
KBNavigateCommand
,
'kbRemove'
:
KBRemoveCommand
},
"events"
:
{
contentchange
:
function
()
{
...
...
@@ -108,10 +148,11 @@ KityMinder.registerModule( "KeyboardModule", function () {
this
.
execCommand
(
'kbCreateAndEdit'
,
'child'
,
sNodes
[
0
]
);
}
break
;
case
8
:
case
46
:
// Backspace or Delete
this
.
execCommand
(
'
removeNod
e'
,
sNodes
);
this
.
execCommand
(
'
kbRemov
e'
,
sNodes
);
break
;
case
37
:
...
...
src/module/layout.js
View file @
bc465b0b
...
...
@@ -57,9 +57,14 @@ KityMinder.registerModule( "LayoutModule", function () {
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
parent
=
node
.
getParent
();
parent
.
removeChild
(
node
);
execute
:
function
(
km
,
nodes
)
{
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
var
parent
=
nodes
[
i
].
getParent
();
if
(
parent
)
{
parent
.
removeChild
(
nodes
[
i
]
);
}
}
this
.
setContentChanged
(
true
);
}
};
}
)()
);
...
...
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