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
2dda4048
Commit
2dda4048
authored
Mar 02, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
4a844e22
ee406ba3
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
292 additions
and
216 deletions
+292
-216
dev.html
demo/dev.html
+0
-35
markers.js
dialogs/markers/markers.js
+1
-1
dev.js
dist/dev.js
+100
-69
dev.php
dist/dev.php
+2
-1
social.js
dist/social.js
+16
-4
kity
kity
+1
-1
contextmenu.js
src/adapter/contextmenu.js
+1
-11
event.js
src/core/event.js
+11
-0
minder.event.js
src/core/minder.event.js
+26
-9
minder.js
src/core/minder.js
+22
-4
node.js
src/core/node.js
+1
-1
editor.js
src/module/editor.js
+16
-14
editor.receiver.js
src/module/editor.receiver.js
+53
-38
hand.js
src/module/hand.js
+35
-6
keyboard.js
src/module/keyboard.js
+2
-18
select.js
src/module/select.js
+4
-3
widget.js
src/ui/widget.js
+1
-1
No files found.
demo/dev.html
deleted
100644 → 0
View file @
4a844e22
<!DOCTYPE html>
<html>
<head>
<script
src=
"../dist/jquery-2.1.0.min.js"
></script>
<script
src=
"../kity/dist/kitygraph.all.js"
></script>
<script
src=
"../configure.js"
></script>
<script
src=
"../dist/dev.js"
></script>
<script
src=
"../lang/zh-cn/zh-cn.js"
charset=
"utf-8"
></script>
<link
href=
"../themes/default/css/import.css"
type=
"text/css"
rel=
"stylesheet"
>
<style>
.km_receiver
{
width
:
0
;
height
:
0
;
}
.km-minderNode
{
cursor
:
default
;
}
.kmui-container
{
height
:
100%
;
}
html
,
body
,
div
{
margin
:
0
;
padding
:
0
;
}
</style>
</head>
<body
>
<div
id=
"kityminder"
style=
"height:100%;width:100%"
onselectstart=
"return false"
>
</div>
</body>
<script>
window
.
km
=
KM
.
getKityMinder
(
'kityminder'
);
</script>
</html>
\ No newline at end of file
dialogs/markers/markers.js
View file @
2dda4048
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
},
},
'cancel'
:
{}
'cancel'
:
{}
},
},
width
:
200
,
width
:
200
}
)
}
)
}
)();
}
)();
\ No newline at end of file
dist/dev.js
View file @
2dda4048
...
@@ -533,7 +533,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -533,7 +533,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node
.
parent
.
removeChild
(
node
);
node
.
parent
.
removeChild
(
node
);
}
}
node
.
parent
=
this
;
node
.
parent
=
this
;
node
.
root
=
parent
.
root
;
node
.
root
=
node
.
parent
.
root
;
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
children
.
splice
(
index
,
0
,
node
);
},
},
...
@@ -789,6 +789,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -789,6 +789,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_paper
=
new
kity
.
Paper
();
this
.
_paper
=
new
kity
.
Paper
();
this
.
_paper
.
getNode
().
setAttribute
(
'contenteditable'
,
true
);
this
.
_paper
.
getNode
().
setAttribute
(
'contenteditable'
,
true
);
this
.
_paper
.
getNode
().
ondragstart
=
function
(
e
)
{
e
.
preventDefault
();
};
this
.
_addRenderContainer
();
this
.
_addRenderContainer
();
...
@@ -3201,9 +3204,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
...
@@ -3201,9 +3204,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
Layout
.
connect
=
null
;
Layout
.
connect
=
null
;
Layout
.
shicon
=
null
;
Layout
.
shicon
=
null
;
}
else
{
}
else
{
_buffer
[
0
].
getRenderContainer
().
remove
();
try
{
Layout
.
connect
.
remove
();
_buffer
[
0
].
getRenderContainer
().
remove
();
if
(
Layout
.
shicon
)
Layout
.
shicon
.
remove
();
Layout
.
connect
.
remove
();
if
(
Layout
.
shicon
)
Layout
.
shicon
.
remove
();
}
catch
(
error
)
{}
}
}
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
_buffer
.
shift
();
...
@@ -3352,6 +3357,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -3352,6 +3357,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
this
.
_enabled
=
value
;
this
.
_enabled
=
value
;
},
},
move
:
function
(
offset
)
{
this
.
_minder
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
},
_bind
:
function
()
{
_bind
:
function
()
{
var
dragger
=
this
,
var
dragger
=
this
,
...
@@ -3368,7 +3376,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -3368,7 +3376,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
}
// 点击未选中的根节点临时开启
// 点击未选中的根节点临时开启
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
())
)
{
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
()
)
)
{
lastPosition
=
e
.
getPosition
();
lastPosition
=
e
.
getPosition
();
dragger
.
setEnabled
(
true
);
dragger
.
setEnabled
(
true
);
isRootDrag
=
true
;
isRootDrag
=
true
;
...
@@ -3382,8 +3390,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -3382,8 +3390,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
// 当前偏移加上历史偏移
// 当前偏移加上历史偏移
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
dragger
.
move
(
offset
);
this
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
e
.
stopPropagation
();
e
.
stopPropagation
();
lastPosition
=
currentPosition
;
lastPosition
=
currentPosition
;
}
}
...
@@ -3425,6 +3432,23 @@ KityMinder.registerModule( 'Hand', function () {
...
@@ -3425,6 +3432,23 @@ KityMinder.registerModule( 'Hand', function () {
this
.
execCommand
(
'hand'
);
this
.
execCommand
(
'hand'
);
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
mousewheel
:
function
(
e
)
{
var
dx
=
e
.
originEvent
.
wheelDeltaX
||
e
.
originEvent
.
wheelDelta
,
dy
=
e
.
originEvent
.
wheelDeltaY
||
0
;
this
.
_viewDragger
.
move
(
{
x
:
dx
/
2.5
,
y
:
dy
/
2.5
}
);
e
.
originEvent
.
preventDefault
();
},
dblclick
:
function
()
{
var
viewport
=
this
.
getPaper
().
getViewPort
();
var
offset
=
this
.
getRoot
().
getRenderContainer
(
this
.
getRenderContainer
()).
getTransform
().
getTranslate
();
var
dx
=
viewport
.
center
.
x
-
offset
.
x
,
dy
=
viewport
.
center
.
y
-
offset
.
y
;
this
.
getRenderContainer
().
fxTranslate
(
dx
,
dy
,
300
);
}
}
}
}
};
};
...
@@ -4465,7 +4489,9 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -4465,7 +4489,9 @@ Minder.Receiver = kity.createClass('Receiver',{
var
text
=
this
.
container
.
firstChild
;
var
text
=
this
.
container
.
firstChild
;
this
.
range
=
range
;
this
.
range
=
range
;
range
.
setStart
(
text
||
this
.
container
,
this
.
index
).
collapse
(
true
);
range
.
setStart
(
text
||
this
.
container
,
this
.
index
).
collapse
(
true
);
var
me
=
this
;
setTimeout
(
function
(){
setTimeout
(
function
(){
me
.
container
.
focus
();
range
.
select
()
range
.
select
()
});
});
return
this
;
return
this
;
...
@@ -4523,7 +4549,7 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -4523,7 +4549,7 @@ Minder.Receiver = kity.createClass('Receiver',{
return
;
return
;
}
}
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
)
.
replace
(
/
\u
200b/g
,
''
);
var
text
=
this
.
container
.
textContent
.
replace
(
/
\u
200b/g
,
''
);
if
(
this
.
textShape
.
getOpacity
()
==
0
){
if
(
this
.
textShape
.
getOpacity
()
==
0
){
this
.
textShape
.
setOpacity
(
1
);
this
.
textShape
.
setOpacity
(
1
);
...
@@ -5464,16 +5490,16 @@ KM.ui.define('menu',{
...
@@ -5464,16 +5490,16 @@ KM.ui.define('menu',{
});
});
//dropmenu 类
//dropmenu 类
KM
.
ui
.
define
(
'dropmenu'
,
{
KM
.
ui
.
define
(
'dropmenu'
,
{
tmpl
:
'<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >'
+
tmpl
:
'<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >'
+
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>'
+
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>'
+
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>'
+
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>'
+
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active||
\'\'
%> <%=ci.disabled||
\'\'
%>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">'
+
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active||
\'\'
%> <%=ci.disabled||
\'\'
%>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">'
+
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>'
+
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>'
+
'</li><%}}%>'
+
'</li><%}}%>'
+
'<%}%>'
+
'<%}%>'
+
'</ul>'
,
'</ul>'
,
subTmpl
:
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>'
+
subTmpl
:
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>'
+
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>'
+
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>'
+
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active||
\'\'
%> <%=ci.disabled||
\'\'
%>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">'
+
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active||
\'\'
%> <%=ci.disabled||
\'\'
%>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">'
+
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>'
+
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>'
+
...
@@ -5481,33 +5507,32 @@ KM.ui.define( 'dropmenu', {
...
@@ -5481,33 +5507,32 @@ KM.ui.define( 'dropmenu', {
'<%}%>'
,
'<%}%>'
,
defaultOpt
:
{
defaultOpt
:
{
data
:
[],
data
:
[],
click
:
function
()
{}
click
:
function
()
{
}
},
},
setData
:
function
(
items
)
{
setData
:
function
(
items
)
{
this
.
root
().
html
(
$
.
parseTmpl
(
this
.
subTmpl
,
items
)
);
this
.
root
().
html
(
$
.
parseTmpl
(
this
.
subTmpl
,
items
)
);
return
this
;
return
this
;
},
},
position
:
function
(
offset
)
{
position
:
function
(
offset
)
{
this
.
root
().
css
(
{
this
.
root
().
css
({
left
:
offset
.
x
,
left
:
offset
.
x
,
top
:
offset
.
y
top
:
offset
.
y
}
);
});
return
this
;
return
this
;
},
},
show
:
function
()
{
show
:
function
()
{
if
(
this
.
trigger
(
'beforeshow'
)
===
false
)
{
if
(
this
.
trigger
(
'beforeshow'
)
===
false
)
{
return
;
return
;
}
else
{
}
else
{
this
.
root
().
css
(
{
this
.
root
().
css
({
display
:
'block'
});
display
:
'block'
this
.
trigger
(
'aftershow'
);
}
);
this
.
trigger
(
'aftershow'
);
}
}
return
this
;
return
this
;
},
},
init
:
function
(
options
)
{
init
:
function
(
options
)
{
var
me
=
this
;
var
me
=
this
;
var
eventName
=
{
var
eventName
=
{
click
:
1
,
click
:
1
,
...
@@ -5515,48 +5540,54 @@ KM.ui.define( 'dropmenu', {
...
@@ -5515,48 +5540,54 @@ KM.ui.define( 'dropmenu', {
mouseout
:
1
mouseout
:
1
};
};
this
.
root
(
$
(
$
.
parseTmpl
(
this
.
tmpl
,
options
)
)
).
on
(
'click'
,
'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]'
,
function
(
evt
)
{
this
.
root
(
$
(
$
.
parseTmpl
(
this
.
tmpl
,
options
))).
on
(
'click'
,
'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]'
,
function
(
evt
)
{
$
.
proxy
(
options
.
click
,
me
,
evt
,
$
(
this
).
data
(
'value'
),
$
(
this
).
data
(
'label'
),
$
(
this
)
)()
$
.
proxy
(
options
.
click
,
me
,
evt
,
$
(
this
).
data
(
'value'
),
$
(
this
).
data
(
'label'
),
$
(
this
)
)()
}
).
find
(
'li'
).
each
(
function
(
i
,
el
)
{
}
).
find
(
'li'
).
each
(
function
(
i
,
el
)
{
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
if
(
!
$this
.
hasClass
(
"kmui-disabled kmui-divider kmui-dropdown-submenu"
)
)
{
if
(
!
$this
.
hasClass
(
"kmui-disabled kmui-divider kmui-dropdown-submenu"
)
)
{
var
data
=
options
.
data
[
i
];
var
data
=
options
.
data
[
i
];
$
.
each
(
eventName
,
function
(
k
)
{
$
.
each
(
eventName
,
function
(
k
)
{
data
[
k
]
&&
$this
[
k
](
function
(
evt
)
{
data
[
k
]
&&
$this
[
k
](
function
(
evt
)
{
$
.
proxy
(
data
[
k
],
el
)(
evt
,
data
,
me
.
root
)
$
.
proxy
(
data
[
k
],
el
)(
evt
,
data
,
me
.
root
)
}
)
}
)
}
)
}
)
}
}
}
)
});
},
},
disabled
:
function
(
cb
)
{
_initEvent
:
function
(){
$
(
'li[class!=kmui-divider]'
,
this
.
root
()
).
each
(
function
()
{
this
.
root
().
on
(
'mouseover'
,
'li[class="kmui-dropdown-submenu'
,
function
(
e
){
var
$el
=
$
(
this
);
var
$submenu
=
$
(
this
).
data
(
'widget'
);
if
(
cb
===
true
)
{
$submenu
.
kmui
().
show
(
$
(
this
),
'right'
,
'position'
,
5
,
2
)
$el
.
addClass
(
'kmui-disabled'
)
});
}
else
if
(
$
.
isFunction
(
cb
)
)
{
},
$el
.
toggleClass
(
'kmui-disabled'
,
cb
(
li
)
)
disabled
:
function
(
cb
)
{
$
(
'li[class!=kmui-divider]'
,
this
.
root
()).
each
(
function
()
{
var
$el
=
$
(
this
);
if
(
cb
===
true
)
{
$el
.
addClass
(
'kmui-disabled'
)
}
else
if
(
$
.
isFunction
(
cb
))
{
$el
.
toggleClass
(
'kmui-disabled'
,
cb
(
li
))
}
else
{
}
else
{
$el
.
removeClass
(
'kmui-disabled'
)
$el
.
removeClass
(
'kmui-disabled'
)
}
}
}
);
});
},
},
val
:
function
(
val
)
{
val
:
function
(
val
)
{
var
currentVal
;
var
currentVal
;
$
(
'li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]'
,
this
.
root
()
).
each
(
function
()
{
$
(
'li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]'
,
this
.
root
()).
each
(
function
()
{
var
$el
=
$
(
this
);
var
$el
=
$
(
this
);
if
(
val
===
undefined
)
{
if
(
val
===
undefined
)
{
if
(
$el
.
find
(
'em.kmui-dropmenu-checked'
).
length
)
{
if
(
$el
.
find
(
'em.kmui-dropmenu-checked'
).
length
)
{
currentVal
=
$el
.
data
(
'value'
);
currentVal
=
$el
.
data
(
'value'
);
return
false
return
false
}
}
}
else
{
}
else
{
$el
.
find
(
'em'
).
toggleClass
(
'kmui-dropmenu-checked'
,
$el
.
data
(
'value'
)
==
val
)
$el
.
find
(
'em'
).
toggleClass
(
'kmui-dropmenu-checked'
,
$el
.
data
(
'value'
)
==
val
)
}
}
}
);
});
if
(
val
===
undefined
)
{
if
(
val
===
undefined
)
{
return
currentVal
return
currentVal
}
}
},
},
...
@@ -5569,21 +5600,21 @@ KM.ui.define( 'dropmenu', {
...
@@ -5569,21 +5600,21 @@ KM.ui.define( 'dropmenu', {
var
$item
=
$
(
html
).
click
(
item
.
click
);
var
$item
=
$
(
html
).
click
(
item
.
click
);
this
.
root
().
append
(
$item
);
this
.
root
().
append
(
$item
);
},
},
addSubmenu
:
function
(
label
,
menu
,
index
)
{
addSubmenu
:
function
(
label
,
menu
,
index
)
{
index
=
index
||
0
;
index
=
index
||
0
;
var
$list
=
$
(
'li[class!=kmui-divider]'
,
this
.
root
()
);
var
$list
=
$
(
'li[class!=kmui-divider]'
,
this
.
root
()
);
var
$node
=
$
(
'<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">'
+
label
+
'</a></li>'
).
append
(
menu
);
var
$node
=
$
(
'<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">'
+
label
+
'</a></li>'
).
append
(
menu
);
$node
.
data
(
'widget'
,
menu
);
if
(
index
>=
0
&&
index
<
$list
.
length
)
{
if
(
index
>=
0
&&
index
<
$list
.
length
)
{
$node
.
insertBefore
(
$list
[
index
]
);
$node
.
insertBefore
(
$list
[
index
]
);
}
else
if
(
index
<
0
)
{
}
else
if
(
index
<
0
)
{
$node
.
insertBefore
(
$list
[
0
]
);
$node
.
insertBefore
(
$list
[
0
]
);
}
else
if
(
index
>=
$list
.
length
)
{
}
else
if
(
index
>=
$list
.
length
)
{
$node
.
appendTo
(
$list
);
$node
.
appendTo
(
$list
);
}
}
}
}
},
'menu'
);
},
'menu'
);
//splitbutton 类
//splitbutton 类
///import button
///import button
...
...
dist/dev.php
View file @
2dda4048
<?php
<?php
$dependency
=
Array
(
$dependency
=
Array
(
'src/core/kityminder.js'
'src/core/kityminder.js'
,
'src/core/utils.js'
,
'src/core/utils.js'
,
'src/core/command.js'
,
'src/core/command.js'
,
'src/core/node.js'
,
'src/core/node.js'
...
@@ -71,6 +71,7 @@ $dependency = Array(
...
@@ -71,6 +71,7 @@ $dependency = Array(
,
'src/protocal/svg.js'
,
'src/protocal/svg.js'
);
);
$content
=
""
;
$content
=
""
;
...
...
dist/social.js
View file @
2dda4048
...
@@ -91,7 +91,7 @@ $( function () {
...
@@ -91,7 +91,7 @@ $( function () {
var
options
=
{
var
options
=
{
response_type
:
'token'
,
response_type
:
'token'
,
media_type
:
'baidu'
,
media_type
:
'baidu'
,
redirect_uri
:
baseUrl
+
'index.html'
,
redirect_uri
:
window
.
location
.
href
,
client_type
:
'web'
client_type
:
'web'
};
};
baidu
.
frontia
.
social
.
login
(
options
);
baidu
.
frontia
.
social
.
login
(
options
);
...
@@ -129,7 +129,7 @@ $( function () {
...
@@ -129,7 +129,7 @@ $( function () {
by
:
'time'
,
by
:
'time'
,
success
:
function
(
result
)
{
success
:
function
(
result
)
{
if
(
result
.
list
.
length
)
{
if
(
result
.
list
.
length
)
{
if
(
!
isShareLink
)
{
if
(
!
isShareLink
&&
!
thisMapFilename
)
{
loadPersonal
(
result
.
list
[
0
].
path
);
loadPersonal
(
result
.
list
[
0
].
path
);
}
else
{
}
else
{
$user_btn
.
loading
(
false
);
$user_btn
.
loading
(
false
);
...
@@ -141,7 +141,7 @@ $( function () {
...
@@ -141,7 +141,7 @@ $( function () {
}
}
function
addToRecentMenu
(
list
)
{
function
addToRecentMenu
(
list
)
{
list
.
splice
(
8
);
list
.
splice
(
8
);
list
.
forEach
(
function
(
file
)
{
list
.
forEach
(
function
(
file
)
{
$user_menu
.
appendItem
(
{
$user_menu
.
appendItem
(
{
item
:
{
item
:
{
...
@@ -290,7 +290,7 @@ $( function () {
...
@@ -290,7 +290,7 @@ $( function () {
function
loadShare
()
{
function
loadShare
()
{
var
pattern
=
/share_id=
(\w
+
)([
&#
]
|$
)
/
;
var
pattern
=
/share_id=
(\w
+
)([
&#
]
|$
)
/
;
var
match
=
pattern
.
exec
(
window
.
location
.
href
);
var
match
=
pattern
.
exec
(
window
.
location
)
||
pattern
.
exec
(
document
.
referrer
);
if
(
!
match
)
return
;
if
(
!
match
)
return
;
var
shareId
=
match
[
1
];
var
shareId
=
match
[
1
];
var
query
=
new
baidu
.
frontia
.
storage
.
Query
();
var
query
=
new
baidu
.
frontia
.
storage
.
Query
();
...
@@ -308,11 +308,23 @@ $( function () {
...
@@ -308,11 +308,23 @@ $( function () {
}
);
}
);
isShareLink
=
true
;
isShareLink
=
true
;
}
}
function
loadPath
()
{
var
pattern
=
/path=
(
.+
?)([
&#
]
|$
)
/
;
var
match
=
pattern
.
exec
(
window
.
location
)
||
pattern
.
exec
(
document
.
referrer
);
if
(
!
match
)
return
;
thisMapFilename
=
decodeURIComponent
(
match
[
1
]
);
}
loadShare
();
loadShare
();
currentUser
=
baidu
.
frontia
.
getCurrentAccount
();
currentUser
=
baidu
.
frontia
.
getCurrentAccount
();
if
(
currentUser
)
{
if
(
currentUser
)
{
setCurrentUser
(
currentUser
);
setCurrentUser
(
currentUser
);
loadPath
();
if
(
thisMapFilename
)
{
loadPersonal
(
thisMapFilename
);
}
}
else
{
}
else
{
$login_btn
.
appendTo
(
$panel
);
$login_btn
.
appendTo
(
$panel
);
}
}
...
...
kity
@
ebccc80b
Subproject commit
a9630e638b29633f62cdc2df239bc702118b231a
Subproject commit
ebccc80ba41995fa718b1fb0b8f7d79938501ed1
src/adapter/contextmenu.js
View file @
2dda4048
...
@@ -62,18 +62,8 @@ KM.registerUI( 'contextmenu', function () {
...
@@ -62,18 +62,8 @@ KM.registerUI( 'contextmenu', function () {
$menu
.
kmui
().
hide
();
$menu
.
kmui
().
hide
();
});
});
me
.
on
(
'beforemousedown'
,
function
(
e
){
me
.
on
(
'beforemousedown'
,
function
(
e
){
var
isRightMB
;
if
(
e
.
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
){
e
.
stopPropagationImmediately
();
e
.
stopPropagationImmediately
();
}
}
})
})
}
);
}
);
...
...
src/core/event.js
View file @
2dda4048
...
@@ -41,5 +41,16 @@ var MinderEvent = kity.createClass( 'MindEvent', {
...
@@ -41,5 +41,16 @@ var MinderEvent = kity.createClass( 'MindEvent', {
},
},
preventDefault
:
function
(){
preventDefault
:
function
(){
this
.
originEvent
.
preventDefault
();
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 @
2dda4048
...
@@ -27,6 +27,7 @@ kity.extendClass( Minder, {
...
@@ -27,6 +27,7 @@ kity.extendClass( Minder, {
_firePharse
:
function
(
e
)
{
_firePharse
:
function
(
e
)
{
var
beforeEvent
,
preEvent
,
executeEvent
;
var
beforeEvent
,
preEvent
,
executeEvent
;
beforeEvent
=
new
MinderEvent
(
'before'
+
e
.
type
,
e
,
true
);
beforeEvent
=
new
MinderEvent
(
'before'
+
e
.
type
,
e
,
true
);
if
(
this
.
_fire
(
beforeEvent
)
)
{
if
(
this
.
_fire
(
beforeEvent
)
)
{
return
;
return
;
...
@@ -44,6 +45,7 @@ kity.extendClass( Minder, {
...
@@ -44,6 +45,7 @@ kity.extendClass( Minder, {
},
},
_interactChange
:
function
(
e
)
{
_interactChange
:
function
(
e
)
{
var
minder
=
this
;
var
minder
=
this
;
clearTimeout
(
this
.
_interactTimeout
);
clearTimeout
(
this
.
_interactTimeout
);
this
.
_interactTimeout
=
setTimeout
(
function
()
{
this
.
_interactTimeout
=
setTimeout
(
function
()
{
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
var
stoped
=
minder
.
_fire
(
new
MinderEvent
(
'beforeinteractchange'
)
);
...
@@ -59,10 +61,23 @@ kity.extendClass( Minder, {
...
@@ -59,10 +61,23 @@ kity.extendClass( Minder, {
callbacks
.
push
(
callback
);
callbacks
.
push
(
callback
);
},
},
_fire
:
function
(
e
)
{
_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
++
)
{
for
(
var
i
=
0
;
i
<
callbacks
.
length
;
i
++
)
{
callbacks
[
i
].
call
(
this
,
e
);
callbacks
[
i
].
call
(
this
,
e
);
if
(
e
.
shouldStopPropagationImmediately
()
)
{
if
(
e
.
shouldStopPropagationImmediately
()
)
{
...
@@ -72,17 +87,19 @@ kity.extendClass( Minder, {
...
@@ -72,17 +87,19 @@ kity.extendClass( Minder, {
return
e
.
shouldStopPropagation
();
return
e
.
shouldStopPropagation
();
},
},
on
:
function
(
name
,
callback
)
{
on
:
function
(
name
,
callback
)
{
var
types
=
name
.
split
(
' '
)
;
var
km
=
this
;
for
(
var
i
=
0
;
i
<
types
.
length
;
i
++
)
{
utils
.
each
(
name
.
split
(
/
\s
+/
),
function
(
i
,
n
)
{
this
.
_listen
(
types
[
i
]
.
toLowerCase
(),
callback
);
km
.
_listen
(
n
.
toLowerCase
(),
callback
);
}
}
);
return
this
;
return
this
;
},
},
off
:
function
(
name
,
callback
)
{
off
:
function
(
name
,
callback
)
{
var
types
=
name
.
split
(
' '
);
var
types
=
name
.
split
(
/
\s
+/
);
var
i
,
j
,
callbacks
,
removeIndex
;
var
i
,
j
,
callbacks
,
removeIndex
;
for
(
i
=
0
;
i
<
types
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
types
.
length
;
i
++
)
{
callbacks
=
this
.
_eventCallbacks
[
types
[
i
].
toLowerCase
()
];
callbacks
=
this
.
_eventCallbacks
[
types
[
i
].
toLowerCase
()
];
if
(
callbacks
)
{
if
(
callbacks
)
{
removeIndex
=
null
;
removeIndex
=
null
;
for
(
j
=
0
;
j
<
callbacks
.
length
;
j
++
)
{
for
(
j
=
0
;
j
<
callbacks
.
length
;
j
++
)
{
...
...
src/core/minder.js
View file @
2dda4048
...
@@ -5,6 +5,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -5,6 +5,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_initEvents
();
this
.
_initEvents
();
this
.
_initMinder
();
this
.
_initMinder
();
this
.
_initSelection
();
this
.
_initSelection
();
this
.
_initStatus
();
this
.
_initShortcutKey
();
this
.
_initShortcutKey
();
this
.
_initContextmenu
();
this
.
_initContextmenu
();
this
.
_initModules
();
this
.
_initModules
();
...
@@ -109,6 +110,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -109,6 +110,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
return
false
return
false
}
}
me
.
on
(
'keydown'
,
function
(
e
)
{
me
.
on
(
'keydown'
,
function
(
e
)
{
var
originEvent
=
e
.
originEvent
;
var
originEvent
=
e
.
originEvent
;
var
keyCode
=
originEvent
.
keyCode
||
originEvent
.
which
;
var
keyCode
=
originEvent
.
keyCode
||
originEvent
.
which
;
for
(
var
i
in
shortcutkeys
)
{
for
(
var
i
in
shortcutkeys
)
{
...
@@ -119,10 +121,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -119,10 +121,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
current
++
;
current
++
;
}
}
});
});
//todo 暂时通过receiver判断
if
(
me
.
isTextEditStatus
()){
return
;
}
if
(
current
==
keys
.
length
){
if
(
current
==
keys
.
length
){
if
(
me
.
queryCommandState
(
i
)
!=
-
1
)
if
(
me
.
queryCommandState
(
i
)
!=
-
1
)
me
.
execCommand
(
i
);
me
.
execCommand
(
i
);
...
@@ -147,6 +146,25 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -147,6 +146,25 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
},
},
getContextmenu
:
function
(){
getContextmenu
:
function
(){
return
this
.
contextmenus
;
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/core/node.js
View file @
2dda4048
...
@@ -180,7 +180,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -180,7 +180,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node
.
parent
.
removeChild
(
node
);
node
.
parent
.
removeChild
(
node
);
}
}
node
.
parent
=
this
;
node
.
parent
=
this
;
node
.
root
=
parent
.
root
;
node
.
root
=
node
.
parent
.
root
;
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
children
.
splice
(
index
,
0
,
node
);
},
},
...
...
src/module/editor.js
View file @
2dda4048
...
@@ -26,16 +26,9 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -26,16 +26,9 @@ KityMinder.registerModule( "TextEditModule", function () {
this
.
getPaper
().
addShape
(
sel
);
this
.
getPaper
().
addShape
(
sel
);
},
},
"events"
:
{
"events"
:
{
'beforemousedown'
:
function
(
e
){
'normal.beforemousedown textedit.beforemousedown'
:
function
(
e
){
var
isRightMB
;
if
(
e
.
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
){
e
.
stopPropagationImmediately
();
e
.
stopPropagationImmediately
();
return
;
return
;
}
}
...
@@ -48,6 +41,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -48,6 +41,7 @@ KityMinder.registerModule( "TextEditModule", function () {
node
=
selectionShape
.
getData
(
'relatedNode'
);
node
=
selectionShape
.
getData
(
'relatedNode'
);
e
.
stopPropagationImmediately
();
e
.
stopPropagationImmediately
();
}
}
km
.
setStatus
(
'normal'
)
}
}
if
(
node
){
if
(
node
){
var
textShape
=
node
.
getTextShape
();
var
textShape
=
node
.
getTextShape
();
...
@@ -56,6 +50,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -56,6 +50,7 @@ KityMinder.registerModule( "TextEditModule", function () {
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel
.
collapse
();
sel
.
collapse
();
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
km
.
setStatus
(
'textedit'
);
receiver
.
setTextEditStatus
(
true
)
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
.
setKityMinder
(
this
)
...
@@ -74,10 +69,11 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -74,10 +69,11 @@ KityMinder.registerModule( "TextEditModule", function () {
sel
.
setShow
();
sel
.
setShow
();
selectionByClick
=
false
;
selectionByClick
=
false
;
}
}
km
.
setStatus
(
'textedit'
)
}
}
}
}
},
},
'mouseup'
:
function
(
e
){
'
normal.mouseup textedit.
mouseup'
:
function
(
e
){
if
(
mouseDownStatus
){
if
(
mouseDownStatus
){
if
(
!
sel
.
collapsed
){
if
(
!
sel
.
collapsed
){
try
{
try
{
...
@@ -93,7 +89,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -93,7 +89,7 @@ KityMinder.registerModule( "TextEditModule", function () {
mouseDownStatus
=
false
;
mouseDownStatus
=
false
;
oneTime
=
0
;
oneTime
=
0
;
},
},
'beforemousemove'
:
function
(
e
){
'
textedit.
beforemousemove'
:
function
(
e
){
if
(
mouseDownStatus
){
if
(
mouseDownStatus
){
e
.
stopPropagationImmediately
();
e
.
stopPropagationImmediately
();
...
@@ -112,7 +108,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -112,7 +108,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
}
},
},
'dblclick'
:
function
(
e
){
'
normal.dblclick textedit.
dblclick'
:
function
(
e
){
var
text
=
e
.
kityEvent
.
targetShape
;
var
text
=
e
.
kityEvent
.
targetShape
;
if
(
text
.
getType
().
toLowerCase
()
==
'text'
)
{
if
(
text
.
getType
().
toLowerCase
()
==
'text'
)
{
...
@@ -121,8 +117,8 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -121,8 +117,8 @@ KityMinder.registerModule( "TextEditModule", function () {
sel
.
setEndOffset
(
text
.
getContent
().
length
);
sel
.
setEndOffset
(
text
.
getContent
().
length
);
sel
.
setShow
();
sel
.
setShow
();
receiver
.
setContainerTxt
(
text
.
getContent
()).
updateSelectionShow
(
1
)
receiver
.
setContainerTxt
(
text
.
getContent
()).
updateSelectionShow
(
1
)
.
updateRange
(
range
).
setTextEditStatus
(
true
)
.
updateRange
(
range
).
setTextEditStatus
(
true
)
;
km
.
setStatus
(
'textedit'
);
}
}
},
},
'restoreScene'
:
function
(){
'restoreScene'
:
function
(){
...
@@ -131,6 +127,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -131,6 +127,7 @@ KityMinder.registerModule( "TextEditModule", function () {
'stopTextEdit'
:
function
(){
'stopTextEdit'
:
function
(){
sel
.
setHide
();
sel
.
setHide
();
receiver
.
clear
().
setTextEditStatus
(
false
);
receiver
.
clear
().
setTextEditStatus
(
false
);
km
.
setStatus
(
'normal'
);
},
},
"resize"
:
function
(
e
)
{
"resize"
:
function
(
e
)
{
sel
.
setHide
();
sel
.
setHide
();
...
@@ -148,6 +145,7 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -148,6 +145,7 @@ KityMinder.registerModule( "TextEditModule", function () {
textShape
.
setStyle
(
'cursor'
,
'default'
);
textShape
.
setStyle
(
'cursor'
,
'default'
);
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
km
.
setStatus
(
'textedit'
);
receiver
.
setTextEditStatus
(
true
)
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
.
setKityMinder
(
this
)
...
@@ -185,8 +183,12 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -185,8 +183,12 @@ KityMinder.registerModule( "TextEditModule", function () {
}
}
receiver
.
clear
().
setTextEditStatus
(
false
);
receiver
.
clear
().
setTextEditStatus
(
false
);
if
(
this
.
getStatus
()
==
'textedit'
){
this
.
setStatus
(
'normal'
)
}
},
},
'selectionclear'
:
function
(){
'selectionclear'
:
function
(){
km
.
setStatus
(
'normal'
);
receiver
.
setTextEditStatus
(
false
).
clear
()
receiver
.
setTextEditStatus
(
false
).
clear
()
}
}
}
}
...
...
src/module/editor.receiver.js
View file @
2dda4048
...
@@ -3,6 +3,7 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -3,6 +3,7 @@ Minder.Receiver = kity.createClass('Receiver',{
clear
:
function
(){
clear
:
function
(){
this
.
container
.
innerHTML
=
''
;
this
.
container
.
innerHTML
=
''
;
this
.
selection
&&
this
.
selection
.
setHide
();
this
.
selection
&&
this
.
selection
.
setHide
();
this
.
range
&&
this
.
range
.
nativeSel
.
removeAllRanges
();
this
.
index
=
0
;
this
.
index
=
0
;
return
this
;
return
this
;
},
},
...
@@ -21,7 +22,7 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -21,7 +22,7 @@ Minder.Receiver = kity.createClass('Receiver',{
_div
.
className
=
'km_receiver'
;
_div
.
className
=
'km_receiver'
;
this
.
container
=
document
.
body
.
insertBefore
(
_div
,
document
.
body
.
firstChild
);
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);}'
);
//
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
.
timer
=
null
;
this
.
index
=
0
;
this
.
index
=
0
;
},
},
...
@@ -72,51 +73,65 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -72,51 +73,65 @@ Minder.Receiver = kity.createClass('Receiver',{
var
me
=
this
;
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
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'
:
case
'beforekeyup'
:
if
(
this
.
isTextEditStatus
()
){
switch
(
keyCode
){
switch
(
keyCode
){
case
keymap
.
Enter
:
case
keymap
.
Enter
:
case
keymap
.
Tab
:
case
keymap
.
Tab
:
if
(
this
.
keydownNode
===
this
.
minderNode
){
if
(
this
.
keydownNode
===
this
.
minderNode
){
this
.
rollbackStatus
();
this
.
setTextEditStatus
(
false
);
this
.
setTextEditStatus
(
false
);
this
.
clear
();
this
.
clear
();
}
}
e
.
preventDefault
();
e
.
preventDefault
();
return
;
return
;
case
keymap
.
Shift
:
case
keymap
.
Shift
:
case
keymap
.
Control
:
case
keymap
.
Control
:
case
keymap
.
Alt
:
case
keymap
.
Alt
:
case
keymap
.
Cmd
:
case
keymap
.
Cmd
:
return
;
return
;
}
}
var
text
=
this
.
container
.
textContent
.
replace
(
/
\u
200b/g
,
''
);
var
text
=
this
.
container
.
textContent
.
replace
(
/
\u
200b/g
,
''
);
if
(
this
.
textShape
.
getOpacity
()
==
0
){
if
(
this
.
textShape
.
getOpacity
()
==
0
){
this
.
textShape
.
setOpacity
(
1
);
this
.
textShape
.
setOpacity
(
1
);
}
}
this
.
textShape
.
setContent
(
text
);
this
.
textShape
.
setContent
(
text
);
this
.
setContainerStyle
();
this
.
setContainerStyle
();
this
.
minderNode
.
setText
(
text
);
this
.
minderNode
.
setText
(
text
);
if
(
text
.
length
==
0
){
if
(
text
.
length
==
0
){
this
.
textShape
.
setContent
(
'a'
);
this
.
textShape
.
setContent
(
'a'
);
this
.
textShape
.
setOpacity
(
0
);
this
.
textShape
.
setOpacity
(
0
);
}
}
this
.
km
.
updateLayout
(
this
.
minderNode
);
this
.
km
.
updateLayout
(
this
.
minderNode
);
this
.
setBaseOffset
();
this
.
setBaseOffset
();
this
.
updateTextData
();
this
.
updateTextData
();
this
.
updateIndex
();
this
.
updateIndex
();
this
.
updateSelection
();
this
.
updateSelection
();
this
.
timer
=
setTimeout
(
function
(){
this
.
timer
=
setTimeout
(
function
(){
me
.
selection
.
setShow
()
me
.
selection
.
setShow
()
},
500
);
},
500
);
return
true
;
return
true
;
}
}
}
},
},
updateIndex
:
function
(){
updateIndex
:
function
(){
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
...
...
src/module/hand.js
View file @
2dda4048
...
@@ -17,6 +17,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -17,6 +17,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
this
.
_enabled
=
value
;
this
.
_enabled
=
value
;
},
},
move
:
function
(
offset
)
{
this
.
_minder
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
},
_bind
:
function
()
{
_bind
:
function
()
{
var
dragger
=
this
,
var
dragger
=
this
,
...
@@ -24,7 +27,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -24,7 +27,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
lastPosition
=
null
,
lastPosition
=
null
,
currentPosition
=
null
;
currentPosition
=
null
;
this
.
_minder
.
on
(
'beforemousedown'
,
function
(
e
)
{
this
.
_minder
.
on
(
'
hand.
beforemousedown'
,
function
(
e
)
{
// 已经被用户打开拖放模式
// 已经被用户打开拖放模式
if
(
dragger
.
isEnabled
()
)
{
if
(
dragger
.
isEnabled
()
)
{
lastPosition
=
e
.
getPosition
();
lastPosition
=
e
.
getPosition
();
...
@@ -33,7 +36,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -33,7 +36,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
}
// 点击未选中的根节点临时开启
// 点击未选中的根节点临时开启
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
())
)
{
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
()
)
)
{
lastPosition
=
e
.
getPosition
();
lastPosition
=
e
.
getPosition
();
dragger
.
setEnabled
(
true
);
dragger
.
setEnabled
(
true
);
isRootDrag
=
true
;
isRootDrag
=
true
;
...
@@ -41,20 +44,19 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -41,20 +44,19 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
)
}
)
.
on
(
'beforemousemove'
,
function
(
e
)
{
.
on
(
'
hand.
beforemousemove'
,
function
(
e
)
{
if
(
lastPosition
)
{
if
(
lastPosition
)
{
currentPosition
=
e
.
getPosition
();
currentPosition
=
e
.
getPosition
();
// 当前偏移加上历史偏移
// 当前偏移加上历史偏移
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
dragger
.
move
(
offset
);
this
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
e
.
stopPropagation
();
e
.
stopPropagation
();
lastPosition
=
currentPosition
;
lastPosition
=
currentPosition
;
}
}
}
)
}
)
.
on
(
'mouseup'
,
function
(
e
)
{
.
on
(
'
hand.
mouseup'
,
function
(
e
)
{
lastPosition
=
null
;
lastPosition
=
null
;
// 临时拖动需要还原状态
// 临时拖动需要还原状态
...
@@ -67,10 +69,20 @@ var ViewDragger = kity.createClass( "ViewDragger", {
...
@@ -67,10 +69,20 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
);
}
);
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
var
km
=
this
;
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
minder
)
{
execute
:
function
(
minder
)
{
minder
.
_viewDragger
.
setEnabled
(
!
minder
.
_viewDragger
.
isEnabled
()
);
minder
.
_viewDragger
.
setEnabled
(
!
minder
.
_viewDragger
.
isEnabled
()
);
if
(
minder
.
_viewDragger
.
isEnabled
()){
minder
.
setStatus
(
'hand'
)
}
else
{
minder
.
rollbackStatus
()
}
},
},
queryState
:
function
(
minder
)
{
queryState
:
function
(
minder
)
{
return
minder
.
_viewDragger
.
isEnabled
()
?
1
:
0
;
return
minder
.
_viewDragger
.
isEnabled
()
?
1
:
0
;
...
@@ -90,6 +102,23 @@ KityMinder.registerModule( 'Hand', function () {
...
@@ -90,6 +102,23 @@ KityMinder.registerModule( 'Hand', function () {
this
.
execCommand
(
'hand'
);
this
.
execCommand
(
'hand'
);
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
mousewheel
:
function
(
e
)
{
var
dx
=
e
.
originEvent
.
wheelDeltaX
||
0
,
dy
=
e
.
originEvent
.
wheelDeltaY
||
e
.
originEvent
.
wheelDelta
;
this
.
_viewDragger
.
move
(
{
x
:
dx
/
2.5
,
y
:
dy
/
2.5
}
);
e
.
originEvent
.
preventDefault
();
},
dblclick
:
function
()
{
var
viewport
=
this
.
getPaper
().
getViewPort
();
var
offset
=
this
.
getRoot
().
getRenderContainer
(
this
.
getRenderContainer
()).
getTransform
().
getTranslate
();
var
dx
=
viewport
.
center
.
x
-
offset
.
x
,
dy
=
viewport
.
center
.
y
-
offset
.
y
;
//this.getRenderContainer().fxTranslate(dx, dy, 300);
}
}
}
}
};
};
...
...
src/module/keyboard.js
View file @
2dda4048
...
@@ -66,26 +66,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -66,26 +66,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
contentchange
:
function
()
{
contentchange
:
function
()
{
buildPositionNetwork
(
this
.
getRoot
()
);
buildPositionNetwork
(
this
.
getRoot
()
);
},
},
keydown
:
function
(
e
)
{
"normal.keydown"
:
function
(
e
)
{
var
keys
=
KityMinder
.
keymap
;
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
();
var
node
=
e
.
getTargetNode
();
this
.
receiver
.
keydownNode
=
node
;
this
.
receiver
.
keydownNode
=
node
;
switch
(
e
.
originEvent
.
keyCode
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
...
...
src/module/select.js
View file @
2dda4048
...
@@ -93,7 +93,7 @@ KityMinder.registerModule( "Select", function () {
...
@@ -93,7 +93,7 @@ KityMinder.registerModule( "Select", function () {
var
lastDownNode
=
null
;
var
lastDownNode
=
null
;
return
{
return
{
"events"
:
{
"events"
:
{
mousedown
:
function
(
e
)
{
"normal.mousedown textedit.mousedown"
:
function
(
e
)
{
var
downNode
=
e
.
getTargetNode
();
var
downNode
=
e
.
getTargetNode
();
// 没有点中节点:
// 没有点中节点:
...
@@ -101,6 +101,7 @@ KityMinder.registerModule( "Select", function () {
...
@@ -101,6 +101,7 @@ KityMinder.registerModule( "Select", function () {
if
(
!
downNode
)
{
if
(
!
downNode
)
{
this
.
removeAllSelectedNodes
();
this
.
removeAllSelectedNodes
();
marqueeActivator
.
selectStart
(
e
);
marqueeActivator
.
selectStart
(
e
);
this
.
setStatus
(
'normal'
)
}
}
// 点中了节点,并且按了 shift 键:
// 点中了节点,并且按了 shift 键:
...
@@ -122,8 +123,8 @@ KityMinder.registerModule( "Select", function () {
...
@@ -122,8 +123,8 @@ KityMinder.registerModule( "Select", function () {
lastDownNode
=
downNode
;
lastDownNode
=
downNode
;
}
}
},
},
mousemove
:
marqueeActivator
.
selectMove
,
"normal.mousemove textedit.mousemove"
:
marqueeActivator
.
selectMove
,
mouseup
:
function
(
e
)
{
"normal.mouseup textedit.mouseup"
:
function
(
e
)
{
var
upNode
=
e
.
getTargetNode
();
var
upNode
=
e
.
getTargetNode
();
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
...
...
src/ui/widget.js
View file @
2dda4048
...
@@ -142,7 +142,7 @@
...
@@ -142,7 +142,7 @@
return
obj
.
root
()[
_prefix
+
className
].
apply
(
obj
.
root
(),
arguments
)
return
obj
.
root
()[
_prefix
+
className
].
apply
(
obj
.
root
(),
arguments
)
}
else
{
}
else
{
$el
&&
obj
.
root
(
$el
);
$el
&&
obj
.
root
(
$el
);
obj
.
init
&&
obj
.
init
(
!
options
||
$
.
isPlainObject
(
options
)
?
$
.
extend2
(
options
||
{},
obj
.
defaultOpt
||
{},
true
)
:
options
);
obj
.
init
&&
obj
.
init
(
utils
.
clonePlainObject
(
!
options
||
$
.
isPlainObject
(
options
)
?
$
.
extend2
(
options
||
{},
obj
.
defaultOpt
||
{},
true
)
:
options
)
);
try
{
try
{
obj
.
root
().
find
(
'a'
).
click
(
function
(
evt
)
{
obj
.
root
().
find
(
'a'
).
click
(
function
(
evt
)
{
evt
.
preventDefault
()
evt
.
preventDefault
()
...
...
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