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
afec1e6f
Commit
afec1e6f
authored
May 07, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added expand
parent
a5fe311c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
76 deletions
+146
-76
layout.default.js
src/module/layout.default.js
+146
-76
No files found.
src/module/layout.default.js
View file @
afec1e6f
...
@@ -508,7 +508,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -508,7 +508,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
this
.
highlightNode
(
node
)
this
.
highlightNode
(
node
)
}
}
},
},
initStyle
:
function
(
expandall
)
{
initStyle
:
function
()
{
//渲染根节点
var
_root
=
minder
.
getRoot
();
var
_root
=
minder
.
getRoot
();
var
historyPoint
=
_root
.
getPoint
();
var
historyPoint
=
_root
.
getPoint
();
if
(
historyPoint
)
historyPoint
=
JSON
.
parse
(
JSON
.
stringify
(
historyPoint
)
);
if
(
historyPoint
)
historyPoint
=
JSON
.
parse
(
JSON
.
stringify
(
historyPoint
)
);
...
@@ -541,61 +542,126 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -541,61 +542,126 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutVertical
(
_root
);
updateLayoutVertical
(
_root
);
translateNode
(
_root
);
translateNode
(
_root
);
if
(
historyPoint
)
_root
.
setPoint
(
historyPoint
.
x
,
historyPoint
.
y
);
if
(
historyPoint
)
_root
.
setPoint
(
historyPoint
.
x
,
historyPoint
.
y
);
var
expandoptions
=
minder
.
getOptions
(
'defaultExpand'
);
//渲染首层节点
var
cur_layer
=
0
;
var
expand_layer
=
expandoptions
.
defaultLayer
;
var
mains
=
_root
.
getChildren
();
var
mains
=
_root
.
getChildren
();
for
(
var
i
=
0
;
i
<
mains
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
mains
.
length
;
i
++
)
{
this
.
appendChildNode
(
_root
,
mains
[
i
]
);
this
.
appendChildNode
(
_root
,
mains
[
i
]
);
}
}
cur_layer
++
;
},
var
clonelayer0
=
function
()
{
expandNode
:
function
(
ico
)
{
var
items
=
[];
var
isExpand
,
node
;
for
(
var
i
=
0
;
i
<
mains
.
length
;
i
++
)
{
if
(
ico
instanceof
MinderNode
)
{
items
.
push
(
mains
[
i
]
);
node
=
ico
;
isExpand
=
node
.
getLayout
().
shicon
.
switchState
();
}
else
{
isExpand
=
ico
.
icon
.
switchState
();
node
=
ico
.
icon
.
_node
;
}
var
Layout
=
node
.
getLayout
();
Layout
.
expand
=
isExpand
;
var
_buffer
=
node
.
getChildren
();
if
(
isExpand
)
{
for
(
var
j
=
0
;
j
<
_buffer
.
length
;
j
++
)
{
minder
.
appendChildNode
(
node
,
_buffer
[
j
]
);
}
}
return
items
;
}
else
{
};
var
_buffer
=
node
.
getChildren
();
//创建一级节点的副本
while
(
_buffer
.
length
!==
0
)
{
var
_buffer
=
clonelayer0
();
var
Layout
=
_buffer
[
0
].
getLayout
();
next
=
[];
if
(
Layout
.
added
)
{
var
layer_nolimit
=
expandall
||
(
expand_layer
<
1
)
||
false
;
Layout
.
added
=
false
;
var
sub_nolimit
=
expandall
||
(
expandoptions
.
defaultSubShow
<
1
)
||
false
;
_buffer
[
0
].
getRenderContainer
().
remove
();
while
(
_buffer
.
length
!==
0
)
{
Layout
.
connect
.
remove
();
cur_layer
++
;
if
(
Layout
.
shicon
)
Layout
.
shicon
.
remove
();
var
layer_len
=
_buffer
.
length
;
for
(
var
j
=
0
;
j
<
layer_len
;
j
++
)
{
var
c
=
_buffer
[
j
].
getChildren
();
if
(
(
(
(
sub_nolimit
||
(
c
.
length
<=
expandoptions
.
defaultSubShow
)
)
&&
(
layer_nolimit
||
(
cur_layer
<=
expand_layer
)
)
)
||
_buffer
[
j
].
getLayout
().
expand
)
&&
c
.
length
!==
0
)
{
this
.
expandNode
(
_buffer
[
j
]
);
_buffer
=
_buffer
.
concat
(
_buffer
[
j
].
getChildren
()
);
}
}
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
}
_buffer
.
splice
(
0
,
layer_len
);
}
}
_root
.
setPoint
(
_root
.
getLayout
().
x
,
_root
.
getLayout
().
y
);
var
set
=
[];
if
(
!
isExpand
)
set
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"contract"
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
}
},
},
// initStyle: function ( expandall ) {
// var _root = minder.getRoot();
// var historyPoint = _root.getPoint();
// if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) );
// minder.handelNodeInsert( _root );
// //设置root的align
// _root.getLayout().align = "center";
// updateBg( _root );
// initLayout( _root );
// _root.getContRc().clear();
// this._firePharse( new MinderEvent( "RenderNodeLeft", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeCenter", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeRight", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeBottom", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNodeTop", {
// node: _root
// }, false ) );
// this._firePharse( new MinderEvent( "RenderNode", {
// node: _root
// }, false ) );
// updateShapeByCont( _root );
// updateLayoutHorizon( _root );
// updateLayoutVertical( _root );
// translateNode( _root );
// if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y );
// var expandoptions = minder.getOptions( 'defaultExpand' );
// var cur_layer = 0;
// var expand_layer = expandoptions.defaultLayer;
// var mains = _root.getChildren();
// for ( var i = 0; i < mains.length; i++ ) {
// this.appendChildNode( _root, mains[ i ] );
// }
// cur_layer++;
// var clonelayer0 = function () {
// var items = [];
// for ( var i = 0; i < mains.length; i++ ) {
// items.push( mains[ i ] );
// }
// return items;
// };
// //创建一级节点的副本
// var _buffer = clonelayer0();
// next = [];
// var layer_nolimit = expandall || ( expand_layer < 1 ) || false;
// var sub_nolimit = expandall || ( expandoptions.defaultSubShow < 1 ) || false;
// while ( _buffer.length !== 0 ) {
// cur_layer++;
// var layer_len = _buffer.length;
// for ( var j = 0; j < layer_len; j++ ) {
// var c = _buffer[ j ].getChildren();
// if (
// (
// ( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && ( layer_nolimit || ( cur_layer <= expand_layer ) ) ) ||
// _buffer[ j ].getLayout().expand
// ) && c.length !== 0 ) {
// this.expandNode( _buffer[ j ] );
// _buffer = _buffer.concat( _buffer[ j ].getChildren() );
// }
// }
// _buffer.splice( 0, layer_len );
// }
// _root.setPoint( _root.getLayout().x, _root.getLayout().y );
// },
appendChildNode
:
function
(
parent
,
node
,
focus
,
sibling
)
{
appendChildNode
:
function
(
parent
,
node
,
focus
,
sibling
)
{
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
parent
.
getLayout
().
expand
===
false
)
{
minder
.
expandNode
(
parent
);
}
minder
.
handelNodeInsert
(
node
);
minder
.
handelNodeInsert
(
node
);
var
Layout
=
node
.
getLayout
();
var
Layout
=
node
.
getLayout
();
var
oldExpand
;
if
(
Layout
)
{
oldExpand
=
Layout
.
expand
;
}
node
.
clearLayout
();
node
.
clearLayout
();
node
.
getContRc
().
clear
();
node
.
getContRc
().
clear
();
Layout
=
node
.
getLayout
();
Layout
=
node
.
getLayout
();
Layout
.
expand
=
oldExpand
||
false
;
if
(
parent
.
getType
()
!==
'root'
)
{
parent
.
getLayout
().
expand
=
true
;
}
Layout
.
added
=
true
;
Layout
.
added
=
true
;
var
parentLayout
=
parent
.
getLayout
();
var
parentLayout
=
parent
.
getLayout
();
var
children
=
parent
.
getChildren
();
var
children
=
parent
.
getChildren
();
...
@@ -746,42 +812,46 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -746,42 +812,46 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
}
},
},
expandNode
:
function
(
ico
)
{
expandNode
:
function
(
ico
)
{
var
isExpand
,
node
;
if
(
ico
instanceof
MinderNode
)
{
node
=
ico
;
isExpand
=
node
.
getLayout
().
shicon
.
switchState
();
}
else
{
isExpand
=
ico
.
icon
.
switchState
();
node
=
ico
.
icon
.
_node
;
}
var
Layout
=
node
.
getLayout
();
Layout
.
expand
=
isExpand
;
var
_buffer
=
node
.
getChildren
();
if
(
isExpand
)
{
for
(
var
j
=
0
;
j
<
_buffer
.
length
;
j
++
)
{
minder
.
appendChildNode
(
node
,
_buffer
[
j
]
);
}
}
else
{
var
_buffer
=
node
.
getChildren
();
while
(
_buffer
.
length
!==
0
)
{
var
Layout
=
_buffer
[
0
].
getLayout
();
if
(
Layout
.
added
)
{
Layout
.
added
=
false
;
_buffer
[
0
].
getRenderContainer
().
remove
();
Layout
.
connect
.
remove
();
if
(
Layout
.
shicon
)
Layout
.
shicon
.
remove
();
}
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
}
var
set
=
[];
if
(
!
isExpand
)
set
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"contract"
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
}
}
}
//,
// expandNode: function ( ico ) {
// var isExpand, node;
// if ( ico instanceof MinderNode ) {
// node = ico;
// isExpand = node.getLayout().shicon.switchState();
// } else {
// isExpand = ico.icon.switchState();
// node = ico.icon._node;
// }
// var Layout = node.getLayout();
// Layout.expand = isExpand;
// var _buffer = node.getChildren();
// if ( isExpand ) {
// for ( var j = 0; j < _buffer.length; j++ ) {
// minder.appendChildNode( node, _buffer[ j ] );
// }
// } else {
// var _buffer = node.getChildren();
// while ( _buffer.length !== 0 ) {
// var Layout = _buffer[ 0 ].getLayout();
// if ( Layout.added ) {
// Layout.added = false;
// _buffer[ 0 ].getRenderContainer().remove();
// Layout.connect.remove();
// if ( Layout.shicon ) Layout.shicon.remove();
// }
// _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
// _buffer.shift();
// }
// }
// var set = [];
// if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
// for ( var i = 0; i < set.length; i++ ) {
// translateNode( set[ i ] );
// updateConnectAndshIcon( set[ i ] );
// }
// }
};
};
this
.
addLayoutStyle
(
"default"
,
_style
);
this
.
addLayoutStyle
(
"default"
,
_style
);
return
{};
return
{};
...
...
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