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
7c7ac886
Commit
7c7ac886
authored
Jan 17, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added node delete
parent
fb4cc971
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
50 deletions
+36
-50
dev.html
demo/dev.html
+7
-6
layout.default.js
src/module/layout.default.js
+9
-19
layout.green.js
src/module/layout.green.js
+12
-18
layout.js
src/module/layout.js
+8
-7
No files found.
demo/dev.html
View file @
7c7ac886
...
...
@@ -17,11 +17,12 @@
<script>
minder
=
KM
.
createMinder
(
kityminder
);
// minder.execCommand("appendchildnode",new MinderNode('dsf'));
// minder.execCommand("appendsiblingnode",new MinderNode('sdf'));
// minder.execCommand("appendchildnode",new MinderNode('sdf'));
// minder.execCommand("appendsiblingnode",new MinderNode('df'));
// minder.execCommand("appendsiblingnode",new MinderNode('sdfsdf'));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
'dsf'
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
'sdf'
));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
'sdf'
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
'df'
));
var
del
=
new
MinderNode
(
'sdfsdf'
);
minder
.
execCommand
(
"appendsiblingnode"
,
del
);
minder
.
execCommand
(
"removenode"
,
del
);
</script>
</html>
\ No newline at end of file
src/module/layout.default.js
View file @
7c7ac886
...
...
@@ -378,24 +378,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateArrangement
(
_root
);
//如果是从其他style切过来的,需要重新布局
if
(
children
.
length
!==
0
)
{
_root
.
setData
(
"leftList"
,
[]
);
_root
.
setData
(
"rightList"
,
[]
);
var
leftList
=
_root
.
getData
(
"leftList"
);
var
rightList
=
_root
.
getData
(
"rightList"
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
if
(
i
%
2
===
0
)
{
rightList
.
push
(
children
[
i
]
);
children
[
i
].
setData
(
"appendside"
,
"right"
);
}
else
{
leftList
.
push
(
children
[
i
]
);
children
[
i
].
setData
(
"appendside"
,
"left"
);
}
children
[
i
].
getRenderContainer
().
clear
();
children
.
setData
(
"shape"
,
null
);
drawNode
(
children
[
i
]
);
updateArrangement
(
children
[
i
]
);
}
var
_buffer
=
_root
.
getChildren
();
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
var
parent
=
_buffer
[
0
].
getParent
();
this
.
appendChildNode
(
parent
,
_buffer
[
0
]
);
_buffer
.
shift
();
}
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
...
...
@@ -436,13 +424,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
},
removeNode
:
function
(
nodes
)
{
var
root
=
this
.
getRoot
();
var
minder
=
this
;
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
var
parent
=
nodes
[
i
].
getParent
();
if
(
parent
)
{
nodes
[
i
].
getRenderContainer
().
remove
();
updateConnect
(
minder
,
nodes
[
i
],
"remove"
);
parent
.
removeChild
(
nodes
[
i
]
);
}
}
this
.
setContentChanged
(
true
);
}
};
this
.
addLayoutStyle
(
"default"
,
_style
);
...
...
src/module/layout.green.js
View file @
7c7ac886
...
...
@@ -349,6 +349,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
},
initStyle
:
function
()
{
var
_root
=
this
.
getRoot
();
console
.
log
(
_root
);
var
minder
=
this
;
_root
.
setData
(
"style"
,
{
radius
:
10
,
...
...
@@ -366,7 +367,6 @@ KityMinder.registerModule( "LayoutGreen", function () {
_root
.
setData
(
"text"
,
"I am the root"
);
_root
.
setData
(
"appendside"
,
"right"
);
var
children
=
_root
.
getChildren
();
_root
.
setData
(
"leftList"
,
[]
);
_root
.
setData
(
"rightList"
,
[]
);
...
...
@@ -378,25 +378,16 @@ KityMinder.registerModule( "LayoutGreen", function () {
updateArrangement
(
_root
);
//如果是从其他style切过来的,需要重新布局
if
(
children
.
length
!==
0
)
{
_root
.
setData
(
"leftList"
,
[]
);
_root
.
setData
(
"rightList"
,
[]
);
var
leftList
=
_root
.
getData
(
"leftList"
);
var
rightList
=
_root
.
getData
(
"rightList"
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
if
(
i
%
2
===
0
)
{
rightList
.
push
(
children
[
i
]
);
children
[
i
].
setData
(
"appendside"
,
"right"
);
}
else
{
leftList
.
push
(
children
[
i
]
);
children
[
i
].
setData
(
"appendside"
,
"left"
);
}
drawNode
(
children
[
i
]
);
updateArrangement
(
children
[
i
]
);
}
var
_buffer
=
_root
.
getChildren
();
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
var
parent
=
_buffer
[
0
].
getParent
();
this
.
appendChildNode
(
parent
,
_buffer
[
0
]
);
_buffer
.
shift
();
}
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
var
minder
=
this
;
var
appendside
=
parent
.
getData
(
"appendside"
);
if
(
parent
===
root
)
{
var
leftList
=
parent
.
getData
(
"leftList"
);
...
...
@@ -417,7 +408,10 @@ KityMinder.registerModule( "LayoutGreen", function () {
}
else
{
node
.
setData
(
"align"
,
"left"
);
}
if
(
parent
.
getChildren
().
indexOf
(
node
)
===
-
1
)
parent
.
appendChild
(
node
,
index
);
if
(
parent
.
getChildren
().
indexOf
(
node
)
===
-
1
)
{
parent
.
appendChild
(
node
,
index
);
minder
.
handelNodeInsert
(
node
);
}
drawNode
(
node
);
updateArrangement
(
node
,
"append"
);
},
...
...
src/module/layout.js
View file @
7c7ac886
...
...
@@ -40,9 +40,9 @@ KityMinder.registerModule( "LayoutModule", function () {
execute
:
function
(
km
,
node
)
{
//km.select( node );
var
selectedNode
=
km
.
getSelectedNode
();
if
(
selectedNode
.
isRoot
())
{
if
(
selectedNode
.
isRoot
()
)
{
km
.
appendChildNode
(
selectedNode
,
node
);
}
else
{
}
else
{
km
.
appendSiblingNode
(
selectedNode
,
node
);
}
km
.
select
(
node
);
...
...
@@ -53,8 +53,9 @@ KityMinder.registerModule( "LayoutModule", function () {
var
RemoveNodeCommand
=
kity
.
createClass
(
"RemoveNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
nodes
)
{
km
.
removeNode
(
nodes
);
execute
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
km
.
removeNode
(
selectedNodes
);
}
};
}
)()
);
...
...
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