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
2e9e68b6
Commit
2e9e68b6
authored
Feb 01, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added shicon
parent
c9d67aef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
12 deletions
+68
-12
layout.default.js
src/module/layout.default.js
+68
-12
No files found.
src/module/layout.default.js
View file @
2e9e68b6
...
...
@@ -3,21 +3,56 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
minderWidth
=
_target
.
clientWidth
;
var
minderHeight
=
_target
.
clientHeight
;
var
minder
=
this
;
var
s
hIcon
=
kity
.
createClass
(
"DefaultshIcon"
,
(
function
()
{
var
S
hIcon
=
kity
.
createClass
(
"DefaultshIcon"
,
(
function
()
{
return
{
constructor
:
function
(
node
)
{
this
.
_show
=
false
;
this
.
_node
=
node
;
var
nodeLayout
=
node
.
getData
(
"layout"
);
this
.
shape
=
new
kity
.
Group
();
this
.
_circle
=
new
kity
.
Circle
();
this
.
_plus
=
new
kity
.
Path
();
this
.
_dec
=
new
kity
.
Path
();
var
iconShape
=
this
.
shape
=
new
kity
.
Group
();
iconShape
.
class
=
"shicon"
;
iconShape
.
icon
=
this
;
var
circle
=
this
.
_circle
=
new
kity
.
Circle
().
fill
(
"white"
).
stroke
(
"gray"
).
setRadius
(
5
);
var
plus
=
this
.
_plus
=
new
kity
.
Path
();
plus
.
getDrawer
()
.
moveTo
(
-
3
,
0
)
.
lineTo
(
3
,
0
)
.
moveTo
(
0
,
-
3
)
.
lineTo
(
0
,
3
);
plus
.
stroke
(
"gray"
);
var
dec
=
this
.
_dec
=
new
kity
.
Path
();
dec
.
getDrawer
()
.
moveTo
(
-
3
,
0
)
.
lineTo
(
3
,
0
);
dec
.
stroke
(
"gray"
);
minder
.
getRenderContainer
().
addShape
(
iconShape
);
iconShape
.
addShapes
(
[
circle
,
plus
,
dec
]
);
node
.
setData
(
"shicon"
,
this
);
this
.
update
();
this
.
switchState
();
},
switch
:
function
(
show
)
{
switchState
:
function
()
{
if
(
!
this
.
_show
)
{
this
.
_plus
.
setOpacity
(
0
);
this
.
_dec
.
setOpacity
(
1
);
this
.
_show
=
true
;
}
else
{
this
.
_plus
.
setOpacity
(
1
);
this
.
_dec
.
setOpacity
(
0
);
this
.
_show
=
false
;
}
return
this
.
show
;
},
update
:
function
()
{
var
node
=
this
.
_node
;
var
Layout
=
node
.
getData
(
"layout"
);
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
-
5
;
}
else
{
nodeX
=
nodeShape
.
getRenderBox
().
closurePoints
[
0
].
x
+
5
;
}
this
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
nodeX
,
nodeY
)
);
},
remove
:
function
()
{
...
...
@@ -32,6 +67,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
container
=
node
.
getRenderContainer
();
var
txt
=
this
.
_txt
=
new
kity
.
Text
();
var
rect
=
this
.
_rect
=
new
kity
.
Rect
();
var
shicon
=
this
.
_shicon
=
new
ShIcon
(
node
);
container
.
addShapes
(
[
rect
,
txt
]
);
var
connect
=
this
.
_connect
=
new
kity
.
Group
();
var
bezier
=
connect
.
bezier
=
new
kity
.
Bezier
();
...
...
@@ -65,6 +101,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
_rectHeight
=
_txtHeight
+
Layout
.
padding
[
0
]
+
Layout
.
padding
[
2
];
rect
.
setWidth
(
_rectWidth
).
setHeight
(
_rectHeight
).
fill
(
node
.
getData
(
"highlight"
)
?
"chocolate"
:
Layout
.
fill
).
setRadius
(
Layout
.
radius
);
this
.
updateConnect
();
this
.
updateShIcon
();
},
updateConnect
:
function
()
{
var
rootX
=
minder
.
getRoot
().
getData
(
"layout"
).
x
;
...
...
@@ -90,6 +127,9 @@ KityMinder.registerModule( "LayoutDefault", function () {
connect
.
bezier
.
setPoints
(
[
sPos
,
endPos
]
).
stroke
(
"white"
);
connect
.
circle
.
setCenter
(
endPosV
.
x
+
(
Layout
.
appendside
===
"left"
?
3
:
-
3
),
endPosV
.
y
).
fill
(
"white"
).
stroke
(
"gray"
).
setRadius
(
2
);
},
updateShIcon
:
function
()
{
this
.
_shicon
.
update
();
},
clear
:
function
()
{
this
.
_node
.
getRenderContainer
().
clear
();
this
.
_connect
.
remove
();
...
...
@@ -104,6 +144,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
container
=
node
.
getRenderContainer
();
var
txt
=
this
.
_txt
=
new
kity
.
Text
();
var
underline
=
this
.
_underline
=
new
kity
.
Path
();
var
shicon
=
this
.
_shicon
=
new
ShIcon
(
node
);
var
highlightshape
=
this
.
_highlightshape
=
new
kity
.
Rect
();
container
.
addShapes
(
[
highlightshape
,
underline
,
txt
]
);
var
connect
=
this
.
_connect
=
new
kity
.
Path
();
...
...
@@ -143,6 +184,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
.
setHeight
(
_txtHeight
+
Layout
.
padding
[
0
]
+
Layout
.
padding
[
2
]
)
.
setOpacity
(
node
.
getData
(
"highlight"
)
?
1
:
0
);
this
.
updateConnect
();
this
.
updateShIcon
();
},
updateConnect
:
function
()
{
var
connect
=
this
.
_connect
;
...
...
@@ -176,6 +218,9 @@ KityMinder.registerModule( "LayoutDefault", function () {
connect
.
stroke
(
Layout
.
stroke
);
}
},
updateShIcon
:
function
()
{
this
.
_shicon
.
update
();
},
clear
:
function
()
{
this
.
_node
.
getRenderContainer
().
clear
();
this
.
_connect
.
remove
();
...
...
@@ -351,8 +396,9 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
}
if
(
Layout
.
shape
&&
Layout
.
shape
.
updateConnect
)
{
Layout
.
shape
.
updateConnect
();
if
(
Layout
.
shape
)
{
if
(
Layout
.
shape
.
updateConnect
)
Layout
.
shape
.
updateConnect
();
if
(
Layout
.
shape
.
updateShIcon
)
Layout
.
shape
.
updateShIcon
();
}
};
...
...
@@ -453,6 +499,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
box
=
set
[
i
].
getRenderContainer
().
getRenderBox
();
set
[
i
].
setPoint
(
box
.
x
,
box
.
y
);
}
//var shicon = new ShIcon( node );
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
siblingLayout
=
sibling
.
getData
(
"layout"
);
...
...
@@ -498,5 +545,14 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
};
this
.
addLayoutStyle
(
"default"
,
_style
);
return
{};
return
{
"events"
:
{
"click"
:
function
(
e
)
{
var
ico
=
e
.
kityEvent
.
targetShape
.
container
;
if
(
ico
.
class
===
"shicon"
)
{
var
state
=
ico
.
icon
.
switchState
();
}
}
}
};
}
);
\ 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