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
3f9f070f
Commit
3f9f070f
authored
Feb 12, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
8e87eb5e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
19 deletions
+54
-19
node.js
src/core/node.js
+4
-1
layout.default.js
src/module/layout.default.js
+43
-17
layout.js
src/module/layout.js
+7
-1
No files found.
src/core/node.js
View file @
3f9f070f
...
...
@@ -227,7 +227,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
clone
:
function
()
{
function
cloneNode
(
parent
,
isClonedNode
)
{
var
_tmp
=
new
KM
.
MinderNode
(
isClonedNode
.
getText
()
);
var
_tmp
=
new
KM
.
MinderNode
(
isClonedNode
.
getText
()
);
_tmp
.
data
=
Utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
parent
=
parent
;
...
...
@@ -266,5 +266,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
isSelected
:
function
()
{
return
this
.
getData
(
'highlight'
)
===
true
;
},
clearChildren
:
function
()
{
this
.
children
=
[];
}
}
);
\ No newline at end of file
src/module/layout.default.js
View file @
3f9f070f
...
...
@@ -151,7 +151,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
_contWidth
=
contRc
.
getWidth
();
var
_contHeight
=
contRc
.
getHeight
();
Layout
.
underline
.
getDrawer
()
.
clear
()
.
moveTo
(
0
,
_contHeight
+
nodeStyle
.
padding
[
2
]
+
nodeStyle
.
padding
[
0
]
)
.
lineTo
(
_contWidth
+
nodeStyle
.
padding
[
1
]
+
nodeStyle
.
padding
[
3
],
_contHeight
+
nodeStyle
.
padding
[
2
]
+
nodeStyle
.
padding
[
0
]
);
Layout
.
underline
.
stroke
(
nodeStyle
.
stroke
);
...
...
@@ -291,6 +290,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
}
node
.
setPoint
(
Layout
.
x
,
Layout
.
y
);
};
var
updateConnectAndshIcon
=
function
(
node
)
{
var
nodeType
=
node
.
getType
();
...
...
@@ -417,7 +417,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
//设置root的align
_root
.
getData
(
"layout"
).
align
=
"center"
;
updateBg
(
_root
);
console
.
log
(
_root
.
getData
(
"layout"
),
_root
.
getRenderContainer
()
);
initLayout
(
_root
);
this
.
_fire
(
new
MinderEvent
(
"beforeRenderNode"
,
{
node
:
_root
...
...
@@ -429,11 +428,27 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutHorizon
(
_root
);
updateLayoutVertical
(
_root
);
translateNode
(
_root
);
console
.
log
(
_root
);
var
_buffer
=
[
_root
];
var
_cleanbuffer
=
[];
//打散结构
while
(
_buffer
.
length
!==
0
)
{
var
children
=
_buffer
[
0
].
getChildren
();
_buffer
=
_buffer
.
concat
(
children
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getData
(
"layout"
).
parent
=
_buffer
[
0
];
}
_buffer
[
0
].
clearChildren
();
if
(
_buffer
[
0
]
!==
_root
)
_cleanbuffer
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
}
//重组结构
for
(
var
j
=
0
;
j
<
_cleanbuffer
.
length
;
j
++
)
{
this
.
appendChildNode
(
_cleanbuffer
[
j
].
getData
(
"layout"
).
parent
,
_cleanbuffer
[
j
]
);
}
},
appendChildNode
:
function
(
parent
,
node
,
sibling
)
{
minder
.
handelNodeInsert
(
node
);
//设置align和appendside属性并在合适的位置插入节点
var
insert
=
(
parent
.
getChildren
().
indexOf
(
node
)
===
-
1
);
var
Layout
=
node
.
getData
(
"layout"
);
var
parentLayout
=
parent
.
getData
(
"layout"
);
if
(
sibling
)
{
...
...
@@ -451,6 +466,17 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
prtLayout
=
parent
.
getData
(
"layout"
);
Layout
.
appendside
=
prtLayout
.
appendside
;
Layout
.
align
=
prtLayout
.
align
;
parent
.
appendChild
(
node
);
}
else
{
var
nodeP
=
node
.
getPoint
();
if
(
nodeP
&&
nodeP
.
x
&&
nodeP
.
y
)
{
if
(
nodeP
.
x
>
parentLayout
.
x
)
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
}
else
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
}
}
else
{
if
(
parentLayout
.
rightList
.
length
>
1
&&
parentLayout
.
rightList
.
length
>
parentLayout
.
leftList
.
length
)
{
Layout
.
appendside
=
"left"
;
...
...
@@ -460,15 +486,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout
.
align
=
"left"
;
}
}
if
(
insert
)
{
if
(
parent
.
getType
()
===
"root"
)
{
var
sideList1
=
parentLayout
[
Layout
.
appendside
+
"List"
];
var
idx1
=
sideList1
.
length
;
parent
.
insertChild
(
node
,
idx1
);
sideList1
.
push
(
node
);
var
idx1
;
if
(
Layout
.
appendside
===
"right"
)
{
idx1
=
sideList1
.
length
;
}
else
{
parent
.
insertChild
(
node
)
;
idx1
=
parent
.
getChildren
().
length
;
}
parent
.
insertChild
(
node
,
idx1
);
}
}
//设置分支类型
...
...
src/module/layout.js
View file @
3f9f070f
...
...
@@ -25,7 +25,13 @@ KityMinder.registerModule( "LayoutModule", function () {
},
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
debugger
;
this
.
getRenderContainer
().
clear
();
debugger
;
var
_root
=
this
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
}
);
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
...
...
@@ -79,7 +85,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var
switchLayout
=
function
(
km
,
style
)
{
var
_root
=
km
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
//
n.clearLayout();
n
.
setPoint
();
n
.
getBgRc
().
clear
();
}
);
...
...
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