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
fb4cc971
Commit
fb4cc971
authored
Jan 17, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加方向键
parent
8d5c3ca6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
85 deletions
+33
-85
minder.select.js
src/core/minder.select.js
+3
-0
keyboard.js
src/module/keyboard.js
+30
-85
No files found.
src/core/minder.select.js
View file @
fb4cc971
...
...
@@ -63,6 +63,9 @@ kity.extendClass( Minder, function () {
highlightNode
(
me
,
n
)
}
);
this
.
_selectedNodes
=
nodes
;
},
isSingleSelect
:
function
(){
return
this
.
getSelectedNodes
().
length
==
1
}
}
}()
);
\ No newline at end of file
src/module/keyboard.js
View file @
fb4cc971
...
...
@@ -46,61 +46,13 @@ 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
KBNavigateCommand
=
kity
.
createClass
(
{
base
:
Command
,
execute
:
function
(
km
,
direction
,
referNode
)
{
var
nextNode
=
referNode
.
_nearestNodes
[
direction
];
function
KBNavigate
(
km
,
direction
){
var
nextNode
=
km
.
getSelectedNode
().
_nearestNodes
[
direction
];
if
(
nextNode
)
{
km
.
toggleSelect
(
[
referNode
,
nextNode
]
);
km
.
execCommand
(
'rendernode'
,
[
referNode
,
nextNode
]
);
}
this
.
setContentChanged
(
false
);
}
}
);
var
KBRemoveCommand
=
kity
.
createClass
(
{
base
:
Command
,
execute
:
function
(
km
,
nodes
)
{
if
(
!
nodes
.
length
)
{
return
;
km
.
select
(
nextNode
);
}
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
{
"events"
:
{
...
...
@@ -119,28 +71,21 @@ KityMinder.registerModule( "KeyboardModule", function () {
// Tab
this
.
execCommand
(
'appendChildNode'
,
new
MinderNode
(
'Topic'
));
break
;
case
8
:
case
46
:
// Backspace or Delete
var
rootIndex
=
sNodes
.
indexOf
(
this
.
getRoot
()
);
if
(
rootIndex
!=
-
1
)
{
sNodes
.
splice
(
rootIndex
,
1
);
}
this
.
execCommand
(
'kbRemove'
,
sNodes
);
this
.
execCommand
(
'removenode'
);
break
;
case
37
:
case
38
:
case
39
:
case
40
:
if
(
isSingleSelected
)
{
this
.
execCommand
(
'kbNavigate'
,
{
if
(
this
.
isSingleSelect
()
)
{
KBNavigate
(
this
,
{
37
:
'left'
,
38
:
'top'
,
39
:
'right'
,
40
:
'down'
}[
e
.
originEvent
.
keyCode
],
sNodes
[
0
]
);
}[
e
.
originEvent
.
keyCode
]
);
}
break
;
}
...
...
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