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
536daed8
Commit
536daed8
authored
Feb 19, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
bfad6015
c658355d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
199 additions
and
23 deletions
+199
-23
dev.php
dist/dev.php
+1
-0
adapter.js
src/adapter/adapter.js
+16
-2
button.js
src/adapter/button.js
+1
-1
combobox.js
src/adapter/combobox.js
+2
-2
dialog.js
src/adapter/dialog.js
+1
-1
hand.js
src/adapter/hand.js
+113
-0
saveto.js
src/adapter/saveto.js
+1
-1
tooltips.js
src/adapter/tooltips.js
+24
-0
minder.js
src/core/minder.js
+8
-2
editor.js
src/module/editor.js
+3
-0
editor.receiver.js
src/module/editor.receiver.js
+13
-5
layout.bottom.js
src/module/layout.bottom.js
+5
-3
layout.default.js
src/module/layout.default.js
+3
-2
modal.js
src/ui/modal.js
+8
-4
No files found.
dist/dev.php
View file @
536daed8
...
...
@@ -61,6 +61,7 @@ $dependency = Array(
,
'src/adapter/saveto.js'
,
'src/adapter/view.js'
,
'src/adapter/dialog.js'
,
'src/adapter/tooltips.js'
,
'src/protocal/plain.js'
,
'src/protocal/json.js'
);
...
...
src/adapter/adapter.js
View file @
536daed8
utils
.
extend
(
KityMinder
,
function
()
{
var
_kityminderUI
=
{},
_kityminderToolbarUI
=
{},
_activeWidget
=
null
,
_widgetData
=
{},
_widgetCallBack
=
{};
...
...
@@ -9,6 +10,16 @@ utils.extend( KityMinder, function () {
_kityminderUI
[
name
]
=
fn
;
}
)
},
registerToolbarUI
:
function
(
uiname
,
fn
)
{
utils
.
each
(
uiname
.
split
(
/
\s
+/
),
function
(
i
,
name
)
{
_kityminderToolbarUI
[
name
]
=
fn
;
}
)
},
loadUI
:
function
(
km
){
utils
.
each
(
_kityminderUI
,
function
(
i
,
fn
)
{
fn
.
call
(
km
)
}
)
},
_createUI
:
function
(
id
)
{
var
$cont
=
$
(
'<div class="kmui-container"></div>'
),
$toolbar
=
$
.
kmuitoolbar
(),
...
...
@@ -17,6 +28,7 @@ utils.extend( KityMinder, function () {
$cont
.
append
(
$toolbar
).
append
(
$kmbody
).
append
(
$statusbar
);
$
(
utils
.
isString
(
id
)
?
'#'
+
id
:
id
).
append
(
$cont
);
return
{
'$container'
:
$cont
,
'$toolbar'
:
$toolbar
,
...
...
@@ -33,8 +45,8 @@ utils.extend( KityMinder, function () {
if
(
name
==
'|'
)
{
$
.
kmuiseparator
&&
btns
.
push
(
$
.
kmuiseparator
()
);
}
else
{
if
(
_kityminderUI
[
name
]
)
{
var
ui
=
_kityminderUI
[
name
].
call
(
km
,
name
);
if
(
_kityminder
Toolbar
UI
[
name
]
)
{
var
ui
=
_kityminder
Toolbar
UI
[
name
].
call
(
km
,
name
);
ui
&&
btns
.
push
(
ui
);
}
...
...
@@ -55,6 +67,8 @@ utils.extend( KityMinder, function () {
this
.
_createToolbar
(
containers
.
$toolbar
,
km
);
this
.
_createStatusbar
(
containers
.
$statusbar
,
km
);
km
.
$container
=
containers
.
$container
;
this
.
loadUI
(
km
);
return
km
.
fire
(
'interactchange'
);
},
registerWidget
:
function
(
name
,
pro
,
cb
)
{
...
...
src/adapter/button.js
View file @
536daed8
KM
.
registerUI
(
'bold italic redo undo'
,
KM
.
register
Toolbar
UI
(
'bold italic redo undo'
,
function
(
name
)
{
var
me
=
this
;
var
$btn
=
$
.
kmuibutton
(
{
...
...
src/adapter/combobox.js
View file @
536daed8
KM
.
registerUI
(
'layoutstyle fontfamily fontsize'
,
function
(
name
)
{
KM
.
register
Toolbar
UI
(
'layoutstyle fontfamily fontsize'
,
function
(
name
)
{
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
...
...
@@ -130,7 +130,7 @@ KM.registerUI( 'layoutstyle fontfamily fontsize', function ( name ) {
}
);
KM
.
registerUI
(
'forecolor'
,
function
(
name
)
{
KM
.
register
Toolbar
UI
(
'forecolor'
,
function
(
name
)
{
function
getCurrentColor
()
{
return
$colorLabel
.
css
(
'background-color'
);
}
...
...
src/adapter/dialog.js
View file @
536daed8
KM
.
registerUI
(
'markers'
,
function
(
name
)
{
KM
.
register
Toolbar
UI
(
'markers'
,
function
(
name
)
{
var
me
=
this
,
currentRange
,
$dialog
,
...
...
src/adapter/hand.js
0 → 100644
View file @
536daed8
function
zoom
(
paper
,
rate
)
{
var
viewbox
=
paper
.
getViewBox
();
var
zoomValue
=
paper
.
_zoom
||
1
;
var
w
=
viewbox
.
width
,
h
=
viewbox
.
height
,
x
=
viewbox
.
x
,
y
=
viewbox
.
y
;
var
ww
=
w
*
rate
,
hh
=
h
*
rate
,
xx
=
x
+
(
w
-
ww
)
/
2
,
yy
=
y
+
(
h
-
hh
)
/
2
;
var
animator
=
new
kity
.
Animator
(
{
beginValue
:
viewbox
,
finishValue
:
{
width
:
ww
,
height
:
hh
,
x
:
xx
,
y
:
yy
},
setter
:
function
(
target
,
value
)
{
target
.
setViewBox
(
value
.
x
,
value
.
y
,
value
.
width
,
value
.
height
);
}
}
);
animator
.
start
(
paper
,
100
,
'ease'
);
paper
.
_zoom
=
zoomValue
*=
rate
;
return
zoomValue
;
}
KM
.
registerToolbarUI
(
'hand zoom-in zoom-out'
,
function
(
name
)
{
var
me
=
this
;
var
$btn
=
$
.
kmuibutton
(
{
icon
:
name
,
click
:
{
'hand'
:
function
(
e
)
{
var
drag
=
me
.
_onDragMode
=
!
me
.
_onDragMode
;
me
.
_paper
.
setStyle
(
'cursor'
,
drag
?
'pointer'
:
'default'
);
me
.
_paper
.
setStyle
(
'cursor'
,
drag
?
'-webkit-grab'
:
'default'
);
$btn
.
kmui
().
active
(
drag
);
if
(
drag
)
{
me
.
_paper
.
drag
();
}
else
{
me
.
_paper
.
undrag
();
}
},
'zoom-in'
:
function
(
e
)
{
var
value
=
zoom
(
me
.
getPaper
(),
0.707
);
me
.
fire
(
'zoom'
,
{
zoom
:
value
}
);
},
'zoom-out'
:
function
(
e
)
{
var
value
=
zoom
(
me
.
getPaper
(),
1
/
0.707
);
me
.
fire
(
'zoom'
,
{
zoom
:
value
}
);
}
}[
name
],
title
:
this
.
getLang
(
'tooltips.'
)[
name
]
||
''
}
);
switch
(
name
)
{
case
'hand'
:
me
.
on
(
'beforemousemove'
,
function
(
e
)
{
if
(
this
.
_onDragMode
)
{
e
.
stopPropagation
();
}
}
);
me
.
on
(
'keyup'
,
function
(
e
)
{
if
(
e
.
keyCode
==
keymap
.
Space
&&
me
.
getSelectedNodes
().
length
==
0
)
{
$btn
.
click
();
e
.
preventDefault
();
}
});
kity
.
extendClass
(
kity
.
Paper
,
kity
.
Draggable
);
break
;
case
'zoom-in'
:
me
.
on
(
'zoom'
,
function
(
e
)
{
$btn
.
kmui
().
disabled
(
e
.
zoom
<=
0.5
);
}
);
break
;
case
'zoom-out'
:
me
.
on
(
'zoom'
,
function
(
e
)
{
$btn
.
kmui
().
disabled
(
e
.
zoom
>=
2
);
}
);
me
.
on
(
'mousewheel'
,
function
(
e
)
{
var
delta
=
e
.
originEvent
.
wheelDelta
;
if
(
Math
.
abs
(
delta
)
>
100
)
{
clearTimeout
(
me
.
_wheelZoomTimeout
);
}
else
{
return
;
}
me
.
_wheelZoomTimeout
=
setTimeout
(
function
()
{
var
value
;
var
lastValue
=
me
.
getPaper
().
_zoom
||
1
;
if
(
delta
<
0
&&
lastValue
>
0.5
)
{
value
=
zoom
(
me
.
getPaper
(),
0.707
);
me
.
fire
(
'zoom'
,
{
zoom
:
value
}
);
}
else
if
(
delta
>
0
&&
lastValue
<
2
)
{
value
=
zoom
(
me
.
getPaper
(),
1
/
0.707
);
me
.
fire
(
'zoom'
,
{
zoom
:
value
}
);
}
},
100
);
e
.
originEvent
.
preventDefault
();
}
);
}
return
$btn
;
}
);
\ No newline at end of file
src/adapter/saveto.js
View file @
536daed8
KM
.
registerUI
(
'saveto'
,
function
(
name
)
{
KM
.
register
Toolbar
UI
(
'saveto'
,
function
(
name
)
{
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
...
...
src/adapter/tooltips.js
0 → 100644
View file @
536daed8
KM
.
registerUI
(
'tooltips'
,
function
(
name
)
{
var
km
=
this
;
//添加tooltip;
if
(
$
.
kmuitooltip
){
$
(
"[data-original-title]"
,
km
.
$container
).
each
(
function
(
i
,
n
){
var
tooltips
=
km
.
getLang
(
'tooltips'
);
var
tooltip
=
$
(
n
).
data
(
'original-title'
);
utils
.
each
(
tooltips
,
function
(
v
,
k
){
if
(
k
==
tooltip
&&
km
.
getShortcutKey
(
v
)){
$
(
n
).
attr
(
'data-original-title'
,
tooltip
+
' ('
+
km
.
getShortcutKey
(
v
).
toUpperCase
()
+
')'
);
}
})
});
$
.
kmuitooltip
(
'attachTo'
,
$
(
"[data-original-title]"
,
km
.
$container
)).
css
(
'z-index'
,
km
.
getOptions
(
'zIndex'
)
+
1
);
}
km
.
$container
.
find
(
'a'
).
click
(
function
(
evt
){
evt
.
preventDefault
()
});
}
);
\ No newline at end of file
src/core/minder.js
View file @
536daed8
...
...
@@ -70,13 +70,19 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_bindshortcutKeys
();
},
addShortcutKeys
:
function
(
cmd
,
keys
)
{
var
obj
=
{};
var
obj
=
{}
,
km
=
this
;
if
(
keys
)
{
obj
[
cmd
]
=
keys
}
else
{
obj
=
cmd
;
}
utils
.
extend
(
this
.
_shortcutkeys
,
obj
)
utils
.
each
(
obj
,
function
(
k
,
v
){
km
.
_shortcutkeys
[
k
.
toLowerCase
()]
=
v
;
});
},
getShortcutKey
:
function
(
cmdName
){
return
this
.
_shortcutkeys
[
cmdName
]
},
_bindshortcutKeys
:
function
()
{
var
me
=
this
,
...
...
src/module/editor.js
View file @
536daed8
...
...
@@ -134,6 +134,9 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'selectionclear'
:
function
(){
receiver
.
setTextEditStatus
(
false
).
clear
()
}
}
};
...
...
src/module/editor.receiver.js
View file @
536daed8
...
...
@@ -2,7 +2,7 @@
Minder
.
Receiver
=
kity
.
createClass
(
'Receiver'
,{
clear
:
function
(){
this
.
container
.
innerHTML
=
''
;
this
.
selection
.
setHide
();
this
.
selection
&&
this
.
selection
.
setHide
();
this
.
index
=
0
;
return
this
;
},
...
...
@@ -127,16 +127,24 @@ Minder.Receiver = kity.createClass('Receiver',{
//更新模拟选区的范围
this
.
selection
.
setStartOffset
(
this
.
index
).
collapse
(
true
);
if
(
this
.
index
==
this
.
textData
.
length
){
if
(
this
.
index
==
0
){
this
.
selection
.
setPosition
(
this
.
getBaseOffset
())
}
else
{
this
.
selection
.
setPosition
({
x
:
this
.
textData
[
this
.
index
-
1
].
x
+
this
.
textData
[
this
.
index
-
1
].
width
,
y
:
this
.
textData
[
this
.
index
-
1
].
y
})
}
this
.
selection
.
setPosition
({
x
:
this
.
textData
[
this
.
index
-
1
].
x
+
this
.
textData
[
this
.
index
-
1
].
width
,
y
:
this
.
textData
[
this
.
index
-
1
].
y
})
}
else
{
this
.
selection
.
setPosition
(
this
.
textData
[
this
.
index
])
}
return
this
;
},
getBaseOffset
:
function
(){
return
this
.
textShape
.
getRenderBox
(
'top'
);
},
setBaseOffset
:
function
(){
this
.
offset
=
this
.
textShape
.
getRenderBox
(
'top'
);
return
this
;
...
...
src/module/layout.bottom.js
View file @
536daed8
...
...
@@ -224,7 +224,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
return
(
selfWidth
>
childWidth
?
selfWidth
:
childWidth
);
};
if
(
nodeType
===
"root"
)
{
Layout
.
x
=
getMinderSize
().
width
/
2
;
Layout
.
x
=
getMinderSize
().
width
/
2
-
node
.
getRenderContainer
().
getWidth
()
/
2
;
effectSet
.
push
(
node
);
}
else
{
if
(
action
===
"append"
||
action
===
"contract"
)
{
...
...
@@ -427,6 +427,8 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
},
appendChildNode
:
function
(
parent
,
node
,
sibling
)
{
minder
.
handelNodeInsert
(
node
);
node
.
clearLayout
();
//设置分支类型
if
(
parent
.
getType
()
===
"root"
)
{
node
.
setType
(
"main"
);
...
...
@@ -443,8 +445,8 @@ KityMinder.registerModule( "LayoutBottom", function () {
node
:
node
},
false
)
);
updateShapeByCont
(
node
);
var
set
1
=
updateLayoutVertical
(
node
,
parent
,
"append"
);
var
set
2
=
updateLayoutHorizon
(
node
);
var
set
2
=
updateLayoutHorizon
(
node
,
parent
,
"append"
);
var
set
1
=
updateLayoutVertical
(
node
);
var
set
=
uSet
(
set1
,
set2
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
...
...
src/module/layout.default.js
View file @
536daed8
...
...
@@ -53,9 +53,10 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
nodeShape
=
node
.
getRenderContainer
();
var
nodeX
,
nodeY
=
(
node
.
getType
()
===
"main"
?
Layout
.
y
:
(
Layout
.
y
+
nodeShape
.
getHeight
()
/
2
-
5
)
);
if
(
Layout
.
appendside
===
"left"
)
{
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
1
].
x
-
6
;
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
1
].
x
-
5
;
}
else
{
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
0
].
x
+
6
;
if
(
node
.
getType
()
===
"main"
)
nodeX
-=
3
;
}
this
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
nodeX
,
nodeY
)
);
},
...
...
@@ -340,7 +341,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
endPosV
=
endPos
.
getVertex
();
sPos
.
setVertex
(
rootX
,
rootY
);
connect
.
bezier
.
setPoints
(
[
sPos
,
endPos
]
).
stroke
(
nodeStyle
.
stroke
);
connect
.
circle
.
setCenter
(
endPosV
.
x
+
(
Layout
.
appendside
===
"left"
?
1
:
-
1.5
),
endPosV
.
y
).
fill
(
"white"
).
setRadius
(
4
);
connect
.
circle
.
setCenter
(
endPosV
.
x
+
(
Layout
.
appendside
===
"left"
?
-
0.5
:
-
1.5
),
endPosV
.
y
).
fill
(
"white"
).
setRadius
(
4
);
}
else
if
(
nodeType
===
"sub"
)
{
if
(
!
Layout
.
connect
)
{
connect
=
Layout
.
connect
=
new
kity
.
Path
();
...
...
src/ui/modal.js
View file @
536daed8
...
...
@@ -44,9 +44,11 @@ KM.ui.define( 'modal', {
$
(
this
).
toggleClass
(
'kmui-hover'
)
}
);
setTimeout
(
function
()
{
$
(
'.kmui-modal'
).
draggable
({
handle
:
'.kmui-modal-header'
});
},
100
);
setTimeout
(
function
()
{
$
(
'.kmui-modal'
).
draggable
(
{
handle
:
'.kmui-modal-header'
}
);
},
100
);
},
toggle
:
function
()
{
var
me
=
this
;
...
...
@@ -71,7 +73,9 @@ KM.ui.define( 'modal', {
.
trigger
(
'aftershow'
);
}
);
$
(
'.kmui-modal'
).
draggable
({
handle
:
'.kmui-modal-header'
});
$
(
'.kmui-modal'
).
draggable
(
{
handle
:
'.kmui-modal-header'
}
);
},
showTip
:
function
(
text
)
{
$
(
'.kmui-modal-tip'
,
this
.
root
()
).
html
(
text
).
fadeIn
();
...
...
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