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
fc92e76f
Commit
fc92e76f
authored
Mar 01, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
0e45f978
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
85 deletions
+84
-85
contextmenu.js
src/adapter/contextmenu.js
+1
-11
event.js
src/core/event.js
+11
-0
minder.event.js
src/core/minder.event.js
+1
-0
editor.js
src/module/editor.js
+13
-15
editor.receiver.js
src/module/editor.receiver.js
+52
-38
keyboard.js
src/module/keyboard.js
+2
-18
select.js
src/module/select.js
+4
-3
No files found.
src/adapter/contextmenu.js
View file @
fc92e76f
...
...
@@ -62,18 +62,8 @@ KM.registerUI( 'contextmenu', function () {
$menu
.
kmui
().
hide
();
});
me
.
on
(
'beforemousedown'
,
function
(
e
){
var
isRightMB
;
if
(
"which"
in
e
.
originEvent
)
// Gecko (Firefox), WebKit (Safari/Chrome) & Opera
isRightMB
=
e
.
originEvent
.
which
==
3
;
else
if
(
"button"
in
e
.
originEvent
)
// IE, Opera
isRightMB
=
e
.
originEvent
.
button
==
2
;
if
(
isRightMB
){
if
(
e
.
isRightMB
()){
e
.
stopPropagationImmediately
();
}
})
}
);
...
...
src/core/event.js
View file @
fc92e76f
...
...
@@ -41,5 +41,16 @@ var MinderEvent = kity.createClass( 'MindEvent', {
},
preventDefault
:
function
(){
this
.
originEvent
.
preventDefault
();
},
isRightMB
:
function
(){
var
isRightMB
=
false
;
if
(
!
this
.
originEvent
){
return
false
;
}
if
(
"which"
in
this
.
originEvent
)
isRightMB
=
this
.
originEvent
.
which
==
3
;
else
if
(
"button"
in
this
.
originEvent
)
isRightMB
=
this
.
originEvent
.
button
==
2
;
return
isRightMB
;
}
}
);
\ No newline at end of file
src/core/minder.event.js
View file @
fc92e76f
...
...
@@ -68,6 +68,7 @@ kity.extendClass( Minder, {
var
callbacks
=
this
.
_eventCallbacks
[
e
.
type
.
toLowerCase
()
]
||
[];
if
(
status
){
callbacks
=
callbacks
.
concat
(
this
.
_eventCallbacks
[
status
+
'.'
+
e
.
type
.
toLowerCase
()
]
||
[]);
}
...
...
src/module/editor.js
View file @
fc92e76f
...
...
@@ -26,17 +26,9 @@ KityMinder.registerModule( "TextEditModule", function () {
this
.
getPaper
().
addShape
(
sel
);
},
"events"
:
{
'normal.beforemousedown'
:
function
(
e
){
'normal.beforemousedown
textedit.beforemousedown
'
:
function
(
e
){
var
isRightMB
;
if
(
"which"
in
e
.
originEvent
)
// Gecko (Firefox), WebKit (Safari/Chrome) & Opera
isRightMB
=
e
.
originEvent
.
which
==
3
;
else
if
(
"button"
in
e
.
originEvent
)
// IE, Opera
isRightMB
=
e
.
originEvent
.
button
==
2
;
if
(
isRightMB
){
if
(
e
.
isRightMB
()){
e
.
stopPropagationImmediately
();
return
;
}
...
...
@@ -49,6 +41,7 @@ KityMinder.registerModule( "TextEditModule", function () {
node
=
selectionShape
.
getData
(
'relatedNode'
);
e
.
stopPropagationImmediately
();
}
km
.
setStatus
(
'normal'
)
}
if
(
node
){
var
textShape
=
node
.
getTextShape
();
...
...
@@ -57,6 +50,7 @@ KityMinder.registerModule( "TextEditModule", function () {
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel
.
collapse
();
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
km
.
setStatus
(
'textedit'
);
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
...
...
@@ -75,10 +69,11 @@ KityMinder.registerModule( "TextEditModule", function () {
sel
.
setShow
();
selectionByClick
=
false
;
}
km
.
setStatus
(
'textedit'
)
}
}
},
'normal.mouseup'
:
function
(
e
){
'normal.mouseup
textedit.mouseup
'
:
function
(
e
){
if
(
mouseDownStatus
){
if
(
!
sel
.
collapsed
){
try
{
...
...
@@ -94,7 +89,7 @@ KityMinder.registerModule( "TextEditModule", function () {
mouseDownStatus
=
false
;
oneTime
=
0
;
},
'
normal
.beforemousemove'
:
function
(
e
){
'
textedit
.beforemousemove'
:
function
(
e
){
if
(
mouseDownStatus
){
e
.
stopPropagationImmediately
();
...
...
@@ -113,7 +108,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'normal.dblclick'
:
function
(
e
){
'normal.dblclick
textedit.dblclick
'
:
function
(
e
){
var
text
=
e
.
kityEvent
.
targetShape
;
if
(
text
.
getType
().
toLowerCase
()
==
'text'
)
{
...
...
@@ -122,8 +117,8 @@ KityMinder.registerModule( "TextEditModule", function () {
sel
.
setEndOffset
(
text
.
getContent
().
length
);
sel
.
setShow
();
receiver
.
setContainerTxt
(
text
.
getContent
()).
updateSelectionShow
(
1
)
.
updateRange
(
range
).
setTextEditStatus
(
true
)
.
updateRange
(
range
).
setTextEditStatus
(
true
)
;
km
.
setStatus
(
'textedit'
);
}
},
'restoreScene'
:
function
(){
...
...
@@ -132,6 +127,7 @@ KityMinder.registerModule( "TextEditModule", function () {
'stopTextEdit'
:
function
(){
sel
.
setHide
();
receiver
.
clear
().
setTextEditStatus
(
false
);
km
.
setStatus
(
'normal'
);
},
"resize"
:
function
(
e
)
{
sel
.
setHide
();
...
...
@@ -149,6 +145,7 @@ KityMinder.registerModule( "TextEditModule", function () {
textShape
.
setStyle
(
'cursor'
,
'default'
);
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
km
.
setStatus
(
'textedit'
);
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
...
...
@@ -188,6 +185,7 @@ KityMinder.registerModule( "TextEditModule", function () {
receiver
.
clear
().
setTextEditStatus
(
false
);
},
'selectionclear'
:
function
(){
km
.
setStatus
(
'normal'
);
receiver
.
setTextEditStatus
(
false
).
clear
()
}
}
...
...
src/module/editor.receiver.js
View file @
fc92e76f
...
...
@@ -21,7 +21,7 @@ Minder.Receiver = kity.createClass('Receiver',{
_div
.
className
=
'km_receiver'
;
this
.
container
=
document
.
body
.
insertBefore
(
_div
,
document
.
body
.
firstChild
);
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}'
);
//
this
.
km
.
on
(
'
beforekeyup
'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
km
.
on
(
'
textedit.beforekeyup textedit.keydown
'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
timer
=
null
;
this
.
index
=
0
;
},
...
...
@@ -72,14 +72,26 @@ Minder.Receiver = kity.createClass('Receiver',{
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
switch
(
e
.
type
){
var
keys
=
KityMinder
.
keymap
;
switch
(
e
.
type
){
case
'keydown'
:
switch
(
e
.
originEvent
.
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Tab
:
this
.
selection
.
setHide
();
this
.
clear
().
setTextEditStatus
(
false
);
this
.
km
.
setStatus
(
'normal'
);
e
.
preventDefault
();
break
;
}
break
;
case
'beforekeyup'
:
if
(
this
.
isTextEditStatus
()){
switch
(
keyCode
){
case
keymap
.
Enter
:
case
keymap
.
Tab
:
if
(
this
.
keydownNode
===
this
.
minderNode
){
this
.
rollbackStatus
();
this
.
setTextEditStatus
(
false
);
this
.
clear
();
}
...
...
@@ -114,9 +126,11 @@ Minder.Receiver = kity.createClass('Receiver',{
me
.
selection
.
setShow
()
},
500
);
return
true
;
}
}
},
updateIndex
:
function
(){
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
...
...
src/module/keyboard.js
View file @
fc92e76f
...
...
@@ -66,26 +66,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
contentchange
:
function
()
{
buildPositionNetwork
(
this
.
getRoot
()
);
},
keydown
:
function
(
e
)
{
"normal.keydown"
:
function
(
e
)
{
var
keys
=
KityMinder
.
keymap
;
if
(
this
.
receiver
.
isTextEditStatus
()
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Tab
:
this
.
fire
(
'stopTextEdit'
);
e
.
preventDefault
();
break
;
case
keys
.
Backspace
:
case
keys
.
Del
:
case
keys
.
Left
:
case
keys
.
Up
:
case
keys
.
Right
:
case
keys
.
Down
:
break
;
}
return
;
}
var
node
=
e
.
getTargetNode
();
this
.
receiver
.
keydownNode
=
node
;
switch
(
e
.
originEvent
.
keyCode
)
{
...
...
src/module/select.js
View file @
fc92e76f
...
...
@@ -93,7 +93,7 @@ KityMinder.registerModule( "Select", function () {
var
lastDownNode
=
null
;
return
{
"events"
:
{
mousedown
:
function
(
e
)
{
"normal.mousedown textedit.mousedown"
:
function
(
e
)
{
var
downNode
=
e
.
getTargetNode
();
// 没有点中节点:
...
...
@@ -101,6 +101,7 @@ KityMinder.registerModule( "Select", function () {
if
(
!
downNode
)
{
this
.
removeAllSelectedNodes
();
marqueeActivator
.
selectStart
(
e
);
this
.
setStatus
(
'normal'
)
}
// 点中了节点,并且按了 shift 键:
...
...
@@ -122,8 +123,8 @@ KityMinder.registerModule( "Select", function () {
lastDownNode
=
downNode
;
}
},
mousemove
:
marqueeActivator
.
selectMove
,
mouseup
:
function
(
e
)
{
"normal.mousemove textedit.mousemove"
:
marqueeActivator
.
selectMove
,
"normal.mouseup textedit.mouseup"
:
function
(
e
)
{
var
upNode
=
e
.
getTargetNode
();
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
...
...
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