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
af3b15e6
Commit
af3b15e6
authored
May 08, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added collapse
parent
70549100
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
13 deletions
+68
-13
expand.js
src/module/expand.js
+68
-13
No files found.
src/module/expand.js
View file @
af3b15e6
...
...
@@ -12,6 +12,26 @@ KityMinder.registerModule( "Expand", function () {
}
}
// var getCommonParents = function ( nodes ) {
// var _buffer = [];
// var resultSet = [];
// for ( var i = 0; i < nodes.length; i++ ) {
// _buffer.push( nodes[ i ] );
// }
// while ( _buffer.length !== 0 ) {
// var parent = _buffer[ 0 ].getParent();
// if ( parent.getType() === 'root' || _buffer.length === 1 ) {
// resultSet.push( _buffer[ 0 ] );
// } else {
// if ( _buffer.indexOf( parent ) === -1 ) {
// _buffer.push( parent );
// }
// }
// _buffer.shift();
// }
// return resultSet;
// }
// var setOptionValue = function ( root, layer, sub ) {
// var cur_layer = 1;
...
...
@@ -126,11 +146,29 @@ KityMinder.registerModule( "Expand", function () {
return
{
base
:
Command
,
execute
:
function
(
km
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
expand
();
}
);
km
.
initStyle
();
var
selectedNodes
=
km
.
getSelectedNodes
();
if
(
selectedNodes
.
length
===
0
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
expand
();
}
);
km
.
initStyle
();
}
else
{
var
selectedNode
=
km
.
getSelectedNode
();
var
children
=
selectedNode
.
getChildren
();
if
(
children
.
length
===
0
)
{
return
false
;
}
layerTravel
(
selectedNode
,
function
(
n
)
{
if
(
n
!==
selectedNode
)
n
.
expand
();
}
);
if
(
!
selectedNode
.
isExpanded
()
)
{
km
.
expandNode
(
selectedNode
);
}
else
{
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
if
(
children
[
i
].
getChildren
().
length
!==
0
)
km
.
expandNode
(
children
[
i
]
);
}
}
}
},
queryState
:
function
(
km
)
{
return
0
;
...
...
@@ -141,11 +179,25 @@ KityMinder.registerModule( "Expand", function () {
return
{
base
:
Command
,
execute
:
function
(
km
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
collapse
();
}
);
km
.
initStyle
();
var
selectedNodes
=
km
.
getSelectedNodes
();
if
(
selectedNodes
.
length
===
0
)
{
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
collapse
();
}
);
km
.
initStyle
();
}
else
{
var
selectedNode
=
km
.
getSelectedNode
();
var
children
=
selectedNode
.
getChildren
();
if
(
children
.
length
===
0
)
{
return
false
;
}
if
(
selectedNode
.
isExpanded
()
)
{
layerTravel
(
selectedNode
,
function
(
n
)
{
if
(
n
!==
selectedNode
)
n
.
collapse
();
}
);
km
.
expandNode
(
selectedNode
);
}
}
},
queryState
:
function
(
km
)
{
return
0
;
...
...
@@ -156,11 +208,14 @@ KityMinder.registerModule( "Expand", function () {
return
{
'events'
:
{
'beforeimport'
:
function
(
e
)
{
var
_root
=
this
.
getRoot
();
var
options
=
this
.
getOptions
();
var
defaultExpand
=
options
.
defaultExpand
;
//
var _root = this.getRoot();
//
var options = this.getOptions();
//
var defaultExpand = options.defaultExpand;
//setOptionValue( _root, defaultExpand.defaultLayer, defaultExpand.defaultSubShow );
}
},
'addShortcutKeys'
:
{
},
'commands'
:
{
'ExpandNode'
:
ExpandNodeCommand
,
...
...
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