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
0ec90d2d
Commit
0ec90d2d
authored
Feb 28, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
2173a133
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
16 deletions
+63
-16
minder.event.js
src/core/minder.event.js
+25
-9
minder.js
src/core/minder.js
+20
-0
editor.js
src/module/editor.js
+5
-4
hand.js
src/module/hand.js
+13
-3
No files found.
src/core/minder.event.js
View file @
0ec90d2d
...
...
@@ -27,6 +27,7 @@ kity.extendClass( Minder, {
_firePharse
:
function
(
e
)
{
var
beforeEvent
,
preEvent
,
executeEvent
;
beforeEvent
=
new
MinderEvent
(
'before'
+
e
.
type
,
e
,
true
);
if
(
this
.
_fire
(
beforeEvent
)
)
{
return
;
...
...
@@ -44,6 +45,7 @@ kity.extendClass( Minder, {
},
_interactChange
:
function
(
e
)
{
var
minder
=
this
;
clearTimeout
(
this
.
_interactTimeout
);
this
.
_interactTimeout
=
setTimeout
(
function
()
{
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
...
...
@@ -59,10 +61,22 @@ kity.extendClass( Minder, {
callbacks
.
push
(
callback
);
},
_fire
:
function
(
e
)
{
var
callbacks
=
this
.
_eventCallbacks
[
e
.
type
.
toLowerCase
()
];
if
(
!
callbacks
)
{
return
false
;
var
status
=
this
.
getStatus
();
var
callbacks
=
this
.
_eventCallbacks
[
e
.
type
.
toLowerCase
()
]
||
[];
if
(
status
){
callbacks
=
callbacks
.
concat
(
this
.
_eventCallbacks
[
status
+
'.'
+
e
.
type
.
toLowerCase
()
]
||
[]);
}
if
(
callbacks
.
length
==
0
){
return
;
}
for
(
var
i
=
0
;
i
<
callbacks
.
length
;
i
++
)
{
callbacks
[
i
].
call
(
this
,
e
);
if
(
e
.
shouldStopPropagationImmediately
()
)
{
...
...
@@ -72,17 +86,19 @@ kity.extendClass( Minder, {
return
e
.
shouldStopPropagation
();
},
on
:
function
(
name
,
callback
)
{
var
types
=
name
.
split
(
' '
)
;
for
(
var
i
=
0
;
i
<
types
.
length
;
i
++
)
{
this
.
_listen
(
types
[
i
]
.
toLowerCase
(),
callback
);
}
var
km
=
this
;
utils
.
each
(
name
.
split
(
/
\s
+/
),
function
(
i
,
n
)
{
km
.
_listen
(
n
.
toLowerCase
(),
callback
);
}
);
return
this
;
},
off
:
function
(
name
,
callback
)
{
var
types
=
name
.
split
(
' '
);
var
types
=
name
.
split
(
/
\s
+/
);
var
i
,
j
,
callbacks
,
removeIndex
;
for
(
i
=
0
;
i
<
types
.
length
;
i
++
)
{
callbacks
=
this
.
_eventCallbacks
[
types
[
i
].
toLowerCase
()
];
callbacks
=
this
.
_eventCallbacks
[
types
[
i
].
toLowerCase
()
];
if
(
callbacks
)
{
removeIndex
=
null
;
for
(
j
=
0
;
j
<
callbacks
.
length
;
j
++
)
{
...
...
src/core/minder.js
View file @
0ec90d2d
...
...
@@ -5,6 +5,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_initEvents
();
this
.
_initMinder
();
this
.
_initSelection
();
this
.
_initStatus
();
this
.
_initShortcutKey
();
this
.
_initContextmenu
();
this
.
_initModules
();
...
...
@@ -147,6 +148,25 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
},
getContextmenu
:
function
(){
return
this
.
contextmenus
;
},
_initStatus
:
function
(){
this
.
_status
=
"normal"
;
this
.
_rollbackStatus
=
"normal"
;
},
setStatus
:
function
(
status
){
if
(
status
){
this
.
_rollbackStatus
=
this
.
_status
;
this
.
_status
=
status
;
}
else
{
this
.
_status
=
''
;
}
return
this
;
},
rollbackStatus
:
function
(){
this
.
_status
=
this
.
_rollbackStatus
;
},
getStatus
:
function
(){
return
this
.
_status
;
}
}
);
...
...
src/module/editor.js
View file @
0ec90d2d
...
...
@@ -26,7 +26,8 @@ KityMinder.registerModule( "TextEditModule", function () {
this
.
getPaper
().
addShape
(
sel
);
},
"events"
:
{
'beforemousedown'
:
function
(
e
){
'normal.beforemousedown'
:
function
(
e
){
var
isRightMB
;
...
...
@@ -77,7 +78,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
}
},
'mouseup'
:
function
(
e
){
'
normal.
mouseup'
:
function
(
e
){
if
(
mouseDownStatus
){
if
(
!
sel
.
collapsed
){
try
{
...
...
@@ -93,7 +94,7 @@ KityMinder.registerModule( "TextEditModule", function () {
mouseDownStatus
=
false
;
oneTime
=
0
;
},
'beforemousemove'
:
function
(
e
){
'
normal.
beforemousemove'
:
function
(
e
){
if
(
mouseDownStatus
){
e
.
stopPropagationImmediately
();
...
...
@@ -112,7 +113,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'dblclick'
:
function
(
e
){
'
normal.
dblclick'
:
function
(
e
){
var
text
=
e
.
kityEvent
.
targetShape
;
if
(
text
.
getType
().
toLowerCase
()
==
'text'
)
{
...
...
src/module/hand.js
View file @
0ec90d2d
...
...
@@ -24,7 +24,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
lastPosition
=
null
,
currentPosition
=
null
;
this
.
_minder
.
on
(
'beforemousedown'
,
function
(
e
)
{
this
.
_minder
.
on
(
'
hand.
beforemousedown'
,
function
(
e
)
{
// 已经被用户打开拖放模式
if
(
dragger
.
isEnabled
()
)
{
lastPosition
=
e
.
getPosition
();
...
...
@@ -41,7 +41,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
)
.
on
(
'beforemousemove'
,
function
(
e
)
{
.
on
(
'
hand.
beforemousemove'
,
function
(
e
)
{
if
(
lastPosition
)
{
currentPosition
=
e
.
getPosition
();
...
...
@@ -54,7 +54,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
}
)
.
on
(
'mouseup'
,
function
(
e
)
{
.
on
(
'
hand.
mouseup'
,
function
(
e
)
{
lastPosition
=
null
;
// 临时拖动需要还原状态
...
...
@@ -67,10 +67,20 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
);
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
var
km
=
this
;
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
base
:
Command
,
execute
:
function
(
minder
)
{
minder
.
_viewDragger
.
setEnabled
(
!
minder
.
_viewDragger
.
isEnabled
()
);
if
(
minder
.
_viewDragger
.
isEnabled
()){
minder
.
setStatus
(
'hand'
)
}
else
{
minder
.
rollbackStatus
()
}
},
queryState
:
function
(
minder
)
{
return
minder
.
_viewDragger
.
isEnabled
()
?
1
:
0
;
...
...
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