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
f3b162df
Commit
f3b162df
authored
Feb 20, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:kitygraph/kityminder into dev
parents
98e0d3cd
80d4ac10
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
368 additions
and
203 deletions
+368
-203
configure.js
configure.js
+1
-1
dev.php
dist/dev.php
+1
-0
zh-cn.js
lang/zh-cn/zh-cn.js
+7
-1
combobox.js
src/adapter/combobox.js
+12
-10
node.js
src/adapter/node.js
+68
-0
keymap.js
src/core/keymap.js
+10
-1
minder.js
src/core/minder.js
+35
-14
basestyle.js
src/module/basestyle.js
+2
-2
history.js
src/module/history.js
+2
-2
layout.bottom.js
src/module/layout.bottom.js
+102
-160
layout.default.js
src/module/layout.default.js
+0
-1
layout.js
src/module/layout.js
+30
-1
zoom.js
src/module/zoom.js
+1
-1
combobox.js
src/ui/combobox.js
+87
-9
comboboxmenu.css
themes/default/_css/comboboxmenu.css
+10
-0
No files found.
configure.js
View file @
f3b162df
...
...
@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL'
:
getKMBasePath
(),
//定义工具栏
toolbars
:
[
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers'
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers
| node
'
]
//设置主题
...
...
dist/dev.php
View file @
f3b162df
...
...
@@ -62,6 +62,7 @@ $dependency = Array(
,
'src/adapter/view.js'
,
'src/adapter/dialog.js'
,
'src/adapter/tooltips.js'
,
'src/adapter/node.js'
,
'src/protocal/plain.js'
,
'src/protocal/json.js'
);
...
...
lang/zh-cn/zh-cn.js
View file @
f3b162df
...
...
@@ -10,6 +10,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontfamily'
:
'字体'
,
'fontsize'
:
'字号'
,
'layoutstyle'
:
'主题'
,
'node'
:
'节点操作'
,
'saveto'
:
'导出'
,
'hand'
:
'允许拖拽'
,
'zoom-in'
:
'放大'
,
...
...
@@ -35,9 +36,14 @@ KityMinder.LANG[ 'zh-cn' ] = {
'quarterdone'
:
'完成1/4'
,
'halfdone'
:
'完成1/2'
,
'threequartersdone'
:
'完成3/4'
,
'done'
:
'已完成'
,
'done'
:
'已完成'
}
}
},
'node'
:{
'appendsiblingnode'
:
'插入兄弟节点'
,
'appendchildnode'
:
'插入孩子节点'
,
'removenode'
:
'删除节点'
}
};
\ No newline at end of file
src/adapter/combobox.js
View file @
f3b162df
KM
.
registerToolbarUI
(
'layoutstyle fontfamily fontsize'
,
function
(
name
)
{
KM
.
registerToolbarUI
(
'layoutstyle fontfamily fontsize
inserttopic
'
,
function
(
name
)
{
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
...
...
@@ -31,6 +31,8 @@ KM.registerToolbarUI( 'layoutstyle fontfamily fontsize', function ( name ) {
options
=
transForFontsize
(
options
);
break
;
case
'inserttopic'
:
optons
}
//实例化
...
...
src/adapter/node.js
0 → 100644
View file @
f3b162df
KM
.
registerToolbarUI
(
'node'
,
function
(
name
)
{
var
shortcutKeys
=
{
"appendsiblingnode"
:
"enter"
,
"appendchildnode"
:
"tab"
,
"removenode"
:
"del|backspace"
};
var
me
=
this
,
msg
=
me
.
getLang
(
'node'
),
label
=
me
.
getLang
(
'tooltips.'
+
name
),
options
=
{
label
:
label
,
title
:
label
,
comboboxName
:
name
,
items
:
me
.
getOptions
(
name
)
||
[],
itemStyles
:
[],
value
:
[],
autowidthitem
:
[]
},
$combox
=
null
;
if
(
options
.
items
.
length
==
0
)
{
return
null
;
}
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
transForInserttopic
(
options
)
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
comboboxWidget
=
$combox
.
kmui
();
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
me
.
execCommand
(
res
.
value
);
}).
on
(
"beforeshow"
,
function
()
{
if
(
$combox
.
parent
().
length
===
0
)
{
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
}
var
combox
=
$combox
.
kmui
();
combox
.
traverseItems
(
function
(
label
,
value
){
if
(
me
.
queryCommandState
(
value
)
==
-
1
){
combox
.
disableItemByLabel
(
label
)
}
else
{
combox
.
enableItemByLabel
(
label
)
}
})
});
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
function
transForInserttopic
(
options
)
{
var
tempItems
=
[];
utils
.
each
(
options
.
items
,
function
(
k
,
v
)
{
options
.
value
.
push
(
v
);
tempItems
.
push
(
(
msg
[
k
]
||
k
)
+
'('
+
shortcutKeys
[
v
].
toUpperCase
()
+
')'
);
options
.
autowidthitem
.
push
(
$
.
wordCountAdaptive
(
tempItems
[
tempItems
.
length
-
1
]
)
);
}
);
options
.
items
=
tempItems
;
return
options
;
}
});
src/core/keymap.js
View file @
f3b162df
...
...
@@ -28,5 +28,14 @@ var keymap = KityMinder.keymap = {
'NumLock'
:
144
,
'Cmd'
:
91
'Cmd'
:
91
,
'='
:
187
,
'-'
:
189
,
"b"
:
66
,
'i'
:
73
,
'z'
:
90
,
'y'
:
89
};
\ No newline at end of file
src/core/minder.js
View file @
f3b162df
...
...
@@ -87,25 +87,46 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
_bindshortcutKeys
:
function
()
{
var
me
=
this
,
shortcutkeys
=
this
.
_shortcutkeys
;
me
.
on
(
'keydown'
,
function
(
e
)
{
function
checkkey
(
key
,
keyCode
,
e
){
switch
(
key
){
case
'ctrl'
:
case
'cmd'
:
if
(
e
.
ctrlKey
||
e
.
metaKey
){
return
true
;
}
break
;
case
'alt'
:
if
(
e
.
altKey
){
return
true
}
break
;
case
'shift'
:
if
(
e
.
shiftKey
){
return
true
;
}
}
if
(
keyCode
==
keymap
[
key
]){
return
true
;
}
return
false
}
me
.
on
(
'keydown'
,
function
(
e
)
{
var
originEvent
=
e
.
originEvent
;
var
keyCode
=
originEvent
.
keyCode
||
originEvent
.
which
;
for
(
var
i
in
shortcutkeys
)
{
var
tmp
=
shortcutkeys
[
i
].
split
(
','
);
for
(
var
t
=
0
,
ti
;
ti
=
tmp
[
t
++
];
)
{
ti
=
ti
.
split
(
':'
);
var
key
=
ti
[
0
],
param
=
ti
[
1
];
if
(
/^
(
ctrl
)(\+
shift
)?\+(\d
+
)
$/
.
test
(
key
.
toLowerCase
()
)
||
/^
(\d
+
)
$/
.
test
(
key
)
)
{
if
(
(
(
RegExp
.
$1
==
'ctrl'
?
(
originEvent
.
ctrlKey
||
originEvent
.
metaKey
)
:
0
)
&&
(
RegExp
.
$2
!=
""
?
originEvent
[
RegExp
.
$2
.
slice
(
1
)
+
"Key"
]
:
1
)
&&
keyCode
==
RegExp
.
$3
)
||
keyCode
==
RegExp
.
$1
)
{
if
(
me
.
queryCommandState
(
i
,
param
)
!=
-
1
)
me
.
execCommand
(
i
,
param
);
e
.
preventDefault
();
}
var
keys
=
shortcutkeys
[
i
].
toLowerCase
().
split
(
'+'
);
var
current
=
0
;
utils
.
each
(
keys
,
function
(
i
,
k
){
if
(
checkkey
(
k
,
keyCode
,
originEvent
)){
current
++
;
}
});
if
(
current
==
keys
.
length
){
if
(
me
.
queryCommandState
(
i
)
!=
-
1
)
me
.
execCommand
(
i
);
originEvent
.
preventDefault
();
break
;
}
}
...
...
src/module/basestyle.js
View file @
f3b162df
...
...
@@ -69,8 +69,8 @@ KityMinder.registerModule( "basestylemodule", function () {
}
)
},
addShortcutKeys
:
{
"bold"
:
"ctrl+
66
"
,
//bold
"italic"
:
"ctrl+
73
"
//italic
"bold"
:
"ctrl+
b
"
,
//bold
"italic"
:
"ctrl+
i
"
//italic
},
"events"
:
{
"beforeRenderNode"
:
function
(
e
)
{
...
...
src/module/history.js
View file @
f3b162df
...
...
@@ -138,8 +138,8 @@ KityMinder.registerModule( "HistoryModule", function () {
}
)
},
addShortcutKeys
:
{
"Undo"
:
"ctrl+
90
"
,
//undo
"Redo"
:
"ctrl+
89
"
//redo
"Undo"
:
"ctrl+
z
"
,
//undo
"Redo"
:
"ctrl+
y
"
//redo
},
"events"
:
{
"saveScene"
:
function
(
e
)
{
...
...
src/module/layout.bottom.js
View file @
f3b162df
...
...
@@ -51,12 +51,8 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
node
=
this
.
_node
;
var
Layout
=
node
.
getLayout
();
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
;
}
else
{
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
0
].
x
+
6
;
}
var
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
1
].
x
+
10
;
var
nodeY
=
nodeShape
.
getRenderBox
().
closurePoints
[
0
].
y
;
this
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
nodeX
,
nodeY
)
);
},
remove
:
function
()
{
...
...
@@ -82,7 +78,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
fontSize
:
24
,
padding
:
[
15.5
,
25.5
,
15.5
,
25.5
],
margin
:
[
0
,
0
,
0
,
0
],
radius
:
3
0
,
radius
:
1
0
,
highlight
:
'rgb(254, 219, 0)'
},
"main"
:
{
...
...
@@ -91,15 +87,15 @@ KityMinder.registerModule( "LayoutBottom", function () {
color
:
"#333"
,
padding
:
[
6.5
,
20
,
6.5
,
20
],
fontSize
:
16
,
margin
:
[
0
,
10
,
30
,
5
0
],
radius
:
10
,
margin
:
[
20
,
10
,
10
,
1
0
],
radius
:
5
,
highlight
:
'rgb(254, 219, 0)'
},
"sub"
:
{
stroke
:
new
kity
.
Pen
(
"white"
,
2
).
setLineCap
(
"round"
).
setLineJoin
(
"round"
),
color
:
"white"
,
fontSize
:
12
,
margin
:
[
0
,
10
,
20
,
6
],
margin
:
[
1
0
,
10
,
20
,
6
],
padding
:
[
5
,
10
,
5.5
,
10
],
highlight
:
'rgb(254, 219, 0)'
}
...
...
@@ -134,6 +130,10 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
nodeStyle
=
nodeStyles
[
nodeType
];
var
txtShape
=
node
.
getTextShape
();
txtShape
.
fill
(
nodeStyle
.
color
).
setSize
(
nodeStyle
.
fontSize
).
setY
(
-
3
);
if
(
nodeType
===
"main"
)
{
var
subgroup
=
Layout
.
subgroup
=
new
kity
.
Group
();
minder
.
getRenderContainer
().
addShape
(
subgroup
);
}
};
//根据内容调整节点尺寸
var
updateShapeByCont
=
function
(
node
)
{
...
...
@@ -171,91 +171,79 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
contRc
.
setTransform
(
new
kity
.
Matrix
().
translate
(
nodeStyle
.
padding
[
3
],
nodeStyle
.
padding
[
0
]
+
node
.
getTextShape
().
getHeight
()
)
);
};
//计算节点在垂直方向的位置
var
updateLayoutVertical
=
function
(
node
)
{
var
updateLayoutAll
=
function
(
node
,
parent
,
action
)
{
var
effectSet
=
[];
var
nodeType
=
node
.
getType
();
var
parent
=
node
.
getParent
();
var
effectSet
=
[
node
];
var
Layout
=
node
.
getLayout
();
var
_buffer
=
[
node
];
while
(
_buffer
.
length
!==
0
)
{
var
prt
=
_buffer
[
0
].
getParent
();
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
if
(
!
prt
)
{
Layout
.
y
=
100
;
_buffer
.
shift
();
continue
;
}
var
parentLayout
=
prt
.
getLayout
();
var
parentHeight
=
prt
.
getRenderContainer
().
getHeight
();
var
parentStyle
=
nodeStyles
[
prt
.
getType
()
];
var
childLayout
=
_buffer
[
0
].
getLayout
();
var
childStyle
=
nodeStyles
[
_buffer
[
0
].
getType
()
];
childLayout
.
y
=
parentLayout
.
y
+
parentHeight
+
parentStyle
.
margin
[
2
]
+
childStyle
.
margin
[
2
];
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
}
return
effectSet
;
var
_root
=
minder
.
getRoot
();
var
countMainWidth
=
function
(
node
)
{
var
nLayout
=
node
.
getLayout
();
var
selfwidth
=
node
.
getRenderContainer
().
getWidth
()
+
nodeStyles
.
main
.
margin
[
1
]
+
nodeStyles
.
main
.
margin
[
3
];
var
childwidth
=
Layout
.
subgroup
.
getWidth
()
+
nodeStyles
.
sub
.
margin
[
3
];
var
branchwidth
=
nLayout
.
branchwidth
=
(
selfwidth
>
childwidth
?
selfwidth
:
childwidth
);
return
branchwidth
;
};
//计算节点在水平方向的位置
var
updateLayoutHorizon
=
function
(
node
,
parent
,
action
)
{
var
root
=
minder
.
getRoot
();
var
effectSet
=
[
node
];
if
(
action
===
"remove"
)
{
effectSet
=
[];
}
var
Layout
=
node
.
getLayout
();
var
nodeShape
=
node
.
getRenderContainer
();
var
nodeType
=
node
.
getType
();
var
nodeStyle
=
nodeStyles
[
nodeType
];
var
countBranchWidth
=
function
(
node
)
{
var
nodeStyle
=
nodeStyles
[
node
.
getType
()
];
var
selfWidth
=
node
.
getRenderContainer
().
getWidth
()
+
nodeStyle
.
margin
[
1
]
+
nodeStyle
.
margin
[
3
];
var
childWidth
=
(
function
()
{
var
sum
=
0
;
var
children
=
node
.
getChildren
();
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
childLayout
=
children
[
i
].
getLayout
();
if
(
children
[
i
].
getRenderContainer
().
getWidth
()
!==
0
)
sum
+=
childLayout
.
branchwidth
;
}
return
sum
;
}
)();
return
(
selfWidth
>
childWidth
?
selfWidth
:
childWidth
);
var
updateMain
=
function
(
node
)
{
};
if
(
nodeType
===
"root"
)
{
Layout
.
x
=
getMinderSize
().
width
/
2
-
node
.
getRenderContainer
().
getWidth
()
/
2
;
Layout
.
x
=
getMinderSize
().
width
/
2
;
Layout
.
y
=
100
;
Layout
.
align
=
"center"
;
effectSet
.
push
(
node
);
var
children
=
node
.
getChildren
();
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
childLayout
=
children
[
i
].
getLayout
();
childLayout
.
y
=
Layout
.
y
+
node
.
getRenderContainer
().
getHeight
()
+
nodeStyles
.
main
.
margin
[
0
];
}
effectSet
=
effectSet
.
concat
(
children
);
}
else
if
(
nodeType
===
"main"
)
{
Layout
.
align
=
"center"
;
var
mainnodes
=
_root
.
getChildren
();
var
rootLayout
=
_root
.
getLayout
();
var
rootbranchwidth
=
0
;
for
(
var
j
=
0
;
j
<
mainnodes
.
length
;
j
++
)
{
rootbranchwidth
+=
countMainWidth
(
mainnodes
[
j
]
);
}
var
sX
=
rootLayout
.
x
-
rootbranchwidth
/
2
;
for
(
var
k
=
0
;
k
<
mainnodes
.
length
;
k
++
)
{
var
mLayout
=
mainnodes
[
k
].
getLayout
();
var
mWidth
=
mainnodes
[
k
].
getRenderContainer
().
getWidth
();
mLayout
.
x
=
sX
+
nodeStyles
.
main
.
margin
[
3
]
+
mWidth
/
2
;
sX
+=
(
nodeStyles
.
main
.
margin
[
1
]
+
nodeStyles
.
main
.
margin
[
3
]
+
mWidth
);
}
if
(
action
===
"append"
)
{
Layout
.
y
=
rootLayout
.
y
+
_root
.
getRenderContainer
().
getHeight
()
+
nodeStyles
.
main
.
margin
[
0
];
}
effectSet
=
mainnodes
;
}
else
{
if
(
action
===
"append"
||
action
===
"contract"
)
{
Layout
.
branchwidth
=
node
.
getRenderContainer
().
getWidth
()
+
nodeStyle
.
margin
[
1
]
+
nodeStyle
.
margin
[
3
];
}
else
if
(
action
===
"change"
)
{
Layout
.
branchheight
=
countBranchWidth
(
node
);
}
Layout
.
align
=
"left"
;
var
parentLayout
=
parent
.
getLayout
();
var
parentShape
=
parent
.
getRenderContainer
();
var
prt
=
node
.
getParent
()
||
parent
;
//自底向上更新祖先元素的branchwidth值
while
(
prt
)
{
var
prtLayout
=
prt
.
getLayout
();
prtLayout
.
branchheight
=
countBranchWidth
(
prt
);
prt
=
prt
.
getParent
();
if
(
action
===
"append"
)
{
if
(
parent
.
getType
()
===
"main"
)
{
Layout
.
x
=
10
;
}
else
{
Layout
.
x
=
parentLayout
.
x
+
10
;
}
//自顶向下更新受影响一侧的y值
var
_buffer
=
[
root
];
while
(
_buffer
.
length
>
0
)
{
var
_buffer0Layout
=
_buffer
[
0
].
getLayout
();
var
children
=
_buffer
[
0
].
getChildren
();
_buffer
=
_buffer
.
concat
(
children
);
var
sX
=
_buffer0Layout
.
x
-
_buffer0Layout
.
branchwidth
/
2
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
childLayout
=
children
[
i
].
getLayout
();
childLayout
.
x
=
sX
;
sX
+=
childLayout
.
branchwidth
;
}
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
()
;
if
(
action
===
"append"
||
action
===
"change"
)
{
Layout
.
branchheight
=
node
.
getRenderContainer
().
getHeight
()
+
nodeStyles
.
sub
.
margin
[
0
]
+
nodeStyles
.
sub
.
margin
[
2
]
;
}
var
prt
=
parent
;
//自底向上更新branchheight
while
(
prt
.
getType
()
!==
"main"
)
{
var
c
=
prt
.
getChildren
();
var
prtLayout
=
prt
.
getLayout
();
var
branchHeight
=
prt
.
getRenderContainer
().
getHeight
()
+
nodeStyles
.
sub
.
margin
[
0
]
+
nodeStyles
.
sub
.
margin
[
2
];
for
(
var
i1
=
0
;
i1
<
c
.
length
;
i1
++
)
{
branchHeight
+=
c
[
i1
].
getLayout
().
branchheight
;
}
prtLayout
.
branchheight
=
branchHeight
;
prt
=
prt
.
getParent
();
}
//自顶向下更新y
var
idx
=
prt
.
getIndex
();
effectSet
=
[
node
];
}
return
effectSet
;
};
...
...
@@ -265,7 +253,20 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
align
=
Layout
.
align
;
var
_rectHeight
=
nodeShape
.
getHeight
();
var
_rectWidth
=
nodeShape
.
getWidth
();
switch
(
align
)
{
case
"right"
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
-
_rectWidth
,
Layout
.
y
)
);
break
;
case
"center"
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
-
_rectWidth
/
2
,
Layout
.
y
)
);
break
;
default
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
)
);
break
;
}
if
(
node
.
getType
()
===
"main"
)
{
Layout
.
subgroup
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
-
node
.
getRenderContainer
().
getWidth
()
/
2
+
10
,
Layout
.
y
+
node
.
getRenderContainer
().
getHeight
()
)
);
}
node
.
setPoint
(
Layout
.
x
,
Layout
.
y
);
};
var
updateConnectAndshIcon
=
function
(
node
)
{
...
...
@@ -274,70 +275,6 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
nodeStyle
=
nodeStyles
[
node
.
getType
()
];
var
connect
;
//更新连线
if
(
nodeType
===
"main"
)
{
if
(
!
Layout
.
connect
)
{
connect
=
Layout
.
connect
=
new
kity
.
Group
();
var
bezier
=
Layout
.
connect
.
bezier
=
new
kity
.
Bezier
();
var
circle
=
Layout
.
connect
.
circle
=
new
kity
.
Circle
();
connect
.
addShapes
(
[
bezier
,
circle
]
);
minder
.
getRenderContainer
().
addShape
(
connect
);
minder
.
getRoot
().
getRenderContainer
().
bringTop
();
}
var
parent
=
minder
.
getRoot
();
var
rootX
=
parent
.
getLayout
().
x
;
var
rootY
=
parent
.
getLayout
().
y
;
connect
=
Layout
.
connect
;
var
nodeShape
=
node
.
getRenderContainer
();
var
nodeClosurePoints
=
nodeShape
.
getRenderBox
().
closurePoints
;
var
sPos
;
var
endPos
;
if
(
Layout
.
appendside
===
"left"
)
{
sPos
=
new
kity
.
BezierPoint
(
rootX
-
30
,
nodeClosurePoints
[
2
].
y
+
nodeShape
.
getHeight
()
/
2
);
endPos
=
new
kity
.
BezierPoint
(
nodeClosurePoints
[
2
].
x
+
3
,
nodeClosurePoints
[
2
].
y
+
nodeShape
.
getHeight
()
/
2
);
}
else
{
sPos
=
new
kity
.
BezierPoint
(
rootX
+
30
,
nodeClosurePoints
[
3
].
y
+
nodeShape
.
getHeight
()
/
2
);
endPos
=
new
kity
.
BezierPoint
(
nodeClosurePoints
[
3
].
x
-
3
,
nodeClosurePoints
[
3
].
y
+
nodeShape
.
getHeight
()
/
2
);
}
var
sPosV
=
sPos
.
getVertex
();
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
);
}
else
if
(
nodeType
===
"sub"
)
{
if
(
!
Layout
.
connect
)
{
connect
=
Layout
.
connect
=
new
kity
.
Path
();
minder
.
getRenderContainer
().
addShape
(
connect
);
}
connect
=
Layout
.
connect
;
var
parentShape
=
node
.
getParent
().
getRenderContainer
();
var
parentBox
=
parentShape
.
getRenderBox
();
var
parentLayout
=
node
.
getParent
().
getLayout
();
var
parentStyle
=
nodeStyles
[
node
.
getParent
().
getType
()
];
var
Shape
=
node
.
getRenderContainer
();
var
sX
,
sY
=
parentLayout
.
y
;
var
nodeX
,
nodeY
=
Shape
.
getRenderBox
().
closurePoints
[
1
].
y
;
if
(
Layout
.
appendside
===
"left"
)
{
sX
=
parentBox
.
closurePoints
[
1
].
x
-
parentStyle
.
margin
[
1
];
nodeX
=
Shape
.
getRenderBox
().
closurePoints
[
0
].
x
;
connect
.
getDrawer
()
.
clear
()
.
moveTo
(
sX
,
sY
)
.
lineTo
(
sX
,
nodeY
>
sY
?
(
nodeY
-
nodeStyle
.
margin
[
3
]
)
:
(
nodeY
+
nodeStyle
.
margin
[
3
]
)
);
if
(
nodeY
>
sY
)
connect
.
getDrawer
().
carcTo
(
nodeStyle
.
margin
[
3
],
nodeX
,
nodeY
,
0
,
1
);
else
connect
.
getDrawer
().
carcTo
(
nodeStyle
.
margin
[
3
],
nodeX
,
nodeY
);
connect
.
stroke
(
nodeStyle
.
stroke
);
}
else
{
sX
=
parentBox
.
closurePoints
[
0
].
x
+
parentStyle
.
margin
[
1
];
nodeX
=
Shape
.
getRenderBox
().
closurePoints
[
1
].
x
+
1
;
connect
.
getDrawer
()
.
clear
()
.
moveTo
(
sX
,
sY
)
.
lineTo
(
sX
,
nodeY
>
sY
?
(
nodeY
-
nodeStyle
.
margin
[
3
]
)
:
(
nodeY
+
nodeStyle
.
margin
[
3
]
)
);
if
(
nodeY
>
sY
)
connect
.
getDrawer
().
carcTo
(
nodeStyle
.
margin
[
3
],
nodeX
,
nodeY
);
else
connect
.
getDrawer
().
carcTo
(
nodeStyle
.
margin
[
3
],
nodeX
,
nodeY
,
0
,
1
);
connect
.
stroke
(
nodeStyle
.
stroke
);
}
}
//更新收放icon
if
(
nodeType
!==
"root"
)
{
if
(
!
Layout
.
shicon
)
{
...
...
@@ -383,9 +320,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
},
false
)
);
updateShapeByCont
(
node
);
var
set1
=
updateLayoutHorizon
(
node
);
var
set2
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"change"
);
var
set
=
uSet
(
set1
,
set2
);
var
set
=
updateLayoutAll
(
node
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
...
...
@@ -405,8 +340,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
node
:
_root
},
false
)
);
updateShapeByCont
(
_root
);
updateLayoutHorizon
(
_root
);
updateLayoutVertical
(
_root
);
updateLayoutAll
(
_root
);
translateNode
(
_root
);
var
_buffer
=
[
_root
];
var
_cleanbuffer
=
[];
...
...
@@ -427,13 +361,22 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
},
appendChildNode
:
function
(
parent
,
node
,
sibling
)
{
minder
.
handelNodeInsert
(
node
);
node
.
clearLayout
();
var
parentLayout
=
parent
.
getLayout
();
//设置分支类型
if
(
parent
.
getType
()
===
"root"
)
{
node
.
setType
(
"main"
);
minder
.
handelNodeInsert
(
node
);
}
else
{
node
.
setType
(
"sub"
);
//将节点加入到main分支的subgroup中
parentLayout
.
subgroup
.
addShape
(
node
.
getRenderContainer
()
);
node
.
getLayout
().
subgroup
=
parentLayout
.
subgroup
;
}
if
(
sibling
)
{
parent
.
insertChild
(
node
,
sibling
.
getIndex
()
+
1
);
}
else
{
parent
.
appendChild
(
node
);
}
//计算位置等流程
updateBg
(
node
);
...
...
@@ -445,16 +388,15 @@ KityMinder.registerModule( "LayoutBottom", function () {
node
:
node
},
false
)
);
updateShapeByCont
(
node
);
var
set2
=
updateLayoutHorizon
(
node
,
parent
,
"append"
);
var
set1
=
updateLayoutVertical
(
node
);
var
set
=
uSet
(
set1
,
set2
);
var
set
=
updateLayoutAll
(
node
,
parent
,
"append"
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
}
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
parent
=
sibling
.
getParent
();
this
.
appendChildNode
(
parent
,
node
,
sibling
);
},
removeNode
:
function
(
nodes
)
{
...
...
src/module/layout.default.js
View file @
f3b162df
...
...
@@ -605,7 +605,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
parent
=
_buffer
[
0
].
getParent
();
Layout
.
parent
=
parent
;
_cleanbuffer
.
push
(
_buffer
[
0
]
);
//minder.appendChildNode( parent, _buffer[ 0 ] );
Layout
.
connect
=
null
;
Layout
.
shicon
=
null
;
}
else
{
...
...
src/module/layout.js
View file @
f3b162df
...
...
@@ -104,6 +104,14 @@ KityMinder.registerModule( "LayoutModule", function () {
km
.
appendChildNode
(
parent
,
node
);
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
}
)()
);
...
...
@@ -124,6 +132,14 @@ KityMinder.registerModule( "LayoutModule", function () {
}
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
||
selectedNode
===
km
.
getRoot
()
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
}
)()
);
...
...
@@ -148,6 +164,14 @@ KityMinder.registerModule( "LayoutModule", function () {
}
while
(
_buffer
.
length
>
1
);
km
.
removeNode
(
selectedNodes
);
km
.
select
(
_buffer
[
0
]
);
},
queryState
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
if
(
(
selectedNodes
.
length
===
1
&&
selectedNodes
[
0
]
===
km
.
getRoot
()
)
||
selectedNodes
.
length
===
0
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
}
)()
);
...
...
@@ -181,7 +205,12 @@ KityMinder.registerModule( "LayoutModule", function () {
}
},
"defaultOptions"
:
{
"defaultlayoutstyle"
:
"default"
"defaultlayoutstyle"
:
"default"
,
"node"
:
{
'appendsiblingnode'
:
'appendsiblingnode'
,
'appendchildnode'
:
'appendchildnode'
,
'removenode'
:
'removenode'
}
}
};
}
);
\ No newline at end of file
src/module/zoom.js
View file @
f3b162df
...
...
@@ -62,7 +62,7 @@ KityMinder.registerModule( 'Zoom', function () {
'zoom-out'
:
ZoomOutCommand
},
addShortcutKeys
:
{
"zoom-in"
:
"
+
"
,
//=
"zoom-in"
:
"
=
"
,
//=
"zoom-out"
:
"-"
//-
},
events
:
{
...
...
src/ui/combobox.js
View file @
f3b162df
...
...
@@ -21,7 +21,7 @@
"<%if(autoRecord) {%>"
+
"<%for( var i=0, len = recordStack.length; i<len; i++ ) {%>"
+
"<%var index = recordStack[i];%>"
+
"<li class=
\"
<%=itemClassName%><%if( selected == index ) {%> kmui-combobox-checked<%}%>
\"
data-item-index=
\"
<%=index%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
>"
+
"<li class=
\"
<%=itemClassName%><%if( selected == index ) {%> kmui-combobox-checked<%}%>
<%if( disabled[ index ] === true ) {%> kmui-combobox-item-disabled<%}%>
\"
data-item-index=
\"
<%=index%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
>"
+
"<span class=
\"
kmui-combobox-icon
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
></span>"
+
"<label class=
\"
<%=labelClassName%>
\"
style=
\"
<%=itemStyles[ index ]%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
><%=items[index]%></label>"
+
"</li>"
+
...
...
@@ -31,7 +31,7 @@
"<%}%>"
+
"<%}%>"
+
"<%for( var i=0, label; label = items[i]; i++ ) {%>"
+
"<li class=
\"
<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%>
\"
data-item-index=
\"
<%=i%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
>"
+
"<li class=
\"
<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%>
<%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>
\"
data-item-index=
\"
<%=i%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
>"
+
"<span class=
\"
kmui-combobox-icon
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
></span>"
+
"<label class=
\"
<%=labelClassName%>
\"
style=
\"
<%=itemStyles[ i ]%>
\"
unselectable=
\"
on
\"
onmousedown=
\"
return false
\"
><%=label%></label>"
+
"</li>"
+
...
...
@@ -46,6 +46,8 @@
value
:
[],
comboboxName
:
''
,
selected
:
''
,
//初始禁用状态
disabled
:
{},
//自动记录
autoRecord
:
true
,
//最多记录条数
...
...
@@ -87,6 +89,7 @@
initSelectItem
:
function
(){
var
me
=
this
,
options
=
me
.
data
(
"options"
),
labelClass
=
"."
+
labelClassName
;
me
.
root
().
delegate
(
'.'
+
itemClassName
,
'click'
,
function
(){
...
...
@@ -94,6 +97,10 @@
var
$li
=
$
(
this
),
index
=
$li
.
attr
(
'data-item-index'
);
if
(
options
.
disabled
[
index
]
)
{
return
false
;
}
me
.
trigger
(
'comboboxselect'
,
{
index
:
index
,
label
:
$li
.
find
(
labelClass
).
text
(),
...
...
@@ -126,11 +133,17 @@
*/
select
:
function
(
index
){
var
itemCount
=
this
.
data
(
'options'
).
itemCount
,
items
=
this
.
data
(
'options'
).
autowidthitem
;
var
options
=
this
.
data
(
'options'
),
itemCount
=
options
.
itemCount
,
items
=
options
.
autowidthitem
;
if
(
items
&&
!
items
.
length
)
{
items
=
this
.
data
(
'options'
).
items
;
items
=
options
.
items
;
}
// 禁用
if
(
options
.
disabled
[
index
]
)
{
return
null
;
}
if
(
itemCount
==
0
)
{
...
...
@@ -178,6 +191,65 @@
}
);
},
getItems
:
function
()
{
return
this
.
data
(
"options"
).
items
;
},
traverseItems
:
function
(
fn
){
var
values
=
this
.
data
(
'options'
).
value
;
var
labels
=
this
.
data
(
'options'
).
items
;
$
.
each
(
labels
,
function
(
i
,
label
){
fn
(
label
,
values
[
i
])
});
return
this
;
},
getItemMapping
:
function
()
{
return
this
.
data
(
"options"
).
itemMapping
;
},
disableItemByIndex
:
function
(
index
)
{
var
options
=
this
.
data
(
"options"
);
options
.
disabled
[
index
]
=
true
;
this
.
_repaint
();
},
disableItemByLabel
:
function
(
label
)
{
var
itemMapping
=
this
.
data
(
'options'
).
itemMapping
,
index
=
itemMapping
[
label
];
if
(
typeof
index
===
"number"
)
{
return
this
.
disableItemByIndex
(
index
);
}
return
false
;
},
enableItemByIndex
:
function
(
index
)
{
var
options
=
this
.
data
(
"options"
);
delete
options
.
disabled
[
index
];
this
.
_repaint
();
},
enableItemByLabel
:
function
(
label
)
{
var
itemMapping
=
this
.
data
(
'options'
).
itemMapping
,
index
=
itemMapping
[
label
];
if
(
typeof
index
===
"number"
)
{
return
this
.
enableItemByIndex
(
index
);
}
return
false
;
},
/**
* 转换记录栈
*/
...
...
@@ -256,8 +328,7 @@
_update
:
function
(
index
)
{
var
options
=
this
.
data
(
"options"
),
newStack
=
[],
newChilds
=
null
;
newStack
=
[];
$
.
each
(
options
.
recordStack
,
function
(
i
,
item
){
...
...
@@ -277,13 +348,20 @@
options
.
recordStack
=
newStack
;
options
.
selected
=
index
;
newChilds
=
$
(
$
.
parseTmpl
(
this
.
tpl
,
options
)
);
this
.
_repaint
();
newStack
=
null
;
},
_repaint
:
function
()
{
var
newChilds
=
$
(
$
.
parseTmpl
(
this
.
tpl
,
this
.
data
(
"options"
)
)
);
//重新渲染
this
.
root
().
html
(
newChilds
.
html
()
);
newChilds
=
null
;
newStack
=
null
;
}
};
...
...
themes/default/_css/comboboxmenu.css
View file @
f3b162df
...
...
@@ -19,6 +19,7 @@
.kmui-combobox-menu
.kmui-combobox-item
{
display
:
block
;
border
:
1px
solid
white
;
white-space
:
nowrap
;
}
.kmui-combobox-menu
.kmui-combobox-item-label
{
...
...
@@ -185,3 +186,12 @@
.kmui-combobox-paragraph
.kmui-combobox-item-6
.kmui-combobox-item-label
{
font-size
:
12px
;
}
.kmui-combobox-menu
.kmui-combobox-item-disabled
{
opacity
:
0.3
;
}
.kmui-combobox-menu
.kmui-combobox-item-disabled
:HOVER
{
border-color
:
#fff
;
background-color
:
#fff
;
}
\ No newline at end of file
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