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
37503c8d
Commit
37503c8d
authored
May 07, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added expand and collapse
parent
1b81fb1f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
41 deletions
+68
-41
kityminder.config.js
kityminder.config.js
+1
-1
minder.data.js
src/core/minder.data.js
+4
-4
expand.js
src/module/expand.js
+61
-29
layout.default.js
src/module/layout.default.js
+2
-2
layout.js
src/module/layout.js
+0
-5
No files found.
kityminder.config.js
View file @
37503c8d
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
//默认是全部展开,0表示全部展开
//默认是全部展开,0表示全部展开
,
,
defaultExpand
:
{
defaultExpand
:
{
defaultLayer
:
1
,
defaultLayer
:
2
,
defaultSubShow
:
5
defaultSubShow
:
5
}
}
};
};
...
...
src/core/minder.data.js
View file @
37503c8d
...
@@ -125,9 +125,9 @@ kity.extendClass( Minder, {
...
@@ -125,9 +125,9 @@ kity.extendClass( Minder, {
json
=
params
.
json
||
(
params
.
json
=
protocal
.
decode
(
local
)
);
json
=
params
.
json
||
(
params
.
json
=
protocal
.
decode
(
local
)
);
this
.
_fire
(
new
MinderEvent
(
'importData'
,
{
this
.
_fire
(
new
MinderEvent
(
'importData'
,
{
data
:
json
data
:
json
},
true
)
);
},
true
)
);
if
(
typeof
json
===
'object'
&&
'then'
in
json
)
{
if
(
typeof
json
===
'object'
&&
'then'
in
json
)
{
var
self
=
this
;
var
self
=
this
;
...
@@ -163,7 +163,7 @@ kity.extendClass( Minder, {
...
@@ -163,7 +163,7 @@ kity.extendClass( Minder, {
this
.
_root
.
setData
();
this
.
_root
.
setData
();
this
.
_root
.
setData
(
"currentstyle"
,
curLayout
);
this
.
_root
.
setData
(
"currentstyle"
,
curLayout
);
importNode
(
this
.
_root
,
json
,
this
);
importNode
(
this
.
_root
,
json
,
this
);
this
.
fire
(
'beforeimport'
);
this
.
_fire
(
new
MinderEvent
(
'import'
,
params
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
'import'
,
params
,
false
)
);
this
.
_firePharse
(
{
this
.
_firePharse
(
{
type
:
'contentchange'
type
:
'contentchange'
...
...
src/module/expand.js
View file @
37503c8d
...
@@ -3,7 +3,30 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -3,7 +3,30 @@ KityMinder.registerModule( "Expand", function () {
STATE_EXPAND
=
'expand'
,
STATE_EXPAND
=
'expand'
,
STATE_COLLAPSE
=
'collapse'
;
STATE_COLLAPSE
=
'collapse'
;
var
layerTravel
=
function
(
root
,
fn
)
{
var
_buffer
=
[
root
];
while
(
_buffer
.
length
!==
0
)
{
fn
(
_buffer
[
0
]
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
}
// var setOptionValue = function ( root, layer, sub ) {
// var cur_layer = 1;
// var _buffer = root.getChildren();
// while ( cur_layer < layer ) {
// var layer_len = _buffer.length;
// for ( var i = 0; i < layer_len; i++ ) {
// var c = _buffer[ i ].getChildren();
// if ( c.length < sub || ( !sub ) ) {
// _buffer[ i ].expand();
// _buffer = _buffer.concat( c );
// }
// }
// _buffer.splice( 0, layer_len );
// cur_layer++;
// }
// }
/**
/**
* 该函数返回一个策略,表示递归到节点指定的层数
* 该函数返回一个策略,表示递归到节点指定的层数
*
*
...
@@ -13,38 +36,38 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -13,38 +36,38 @@ KityMinder.registerModule( "Expand", function () {
* @param {int} deep_level 指定的层数
* @param {int} deep_level 指定的层数
* @param {Function} policy_after_level 超过的层数执行的策略
* @param {Function} policy_after_level 超过的层数执行的策略
*/
*/
function
generateDeepPolicy
(
deep_level
,
policy_after_level
)
{
function
generateDeepPolicy
(
deep_level
,
policy_after_level
)
{
return
function
(
node
,
state
,
policy
,
level
)
{
return
function
(
node
,
state
,
policy
,
level
)
{
var
children
,
child
,
i
;
var
children
,
child
,
i
;
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
node
.
setData
(
EXPAND_STATE_DATA
,
state
);
level
=
level
||
1
;
level
=
level
||
1
;
children
=
node
.
getChildren
();
children
=
node
.
getChildren
();
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
child
=
children
[
i
];
child
=
children
[
i
];
if
(
level
<=
deep_level
)
{
if
(
level
<=
deep_level
)
{
policy
(
child
,
state
,
policy
,
level
+
1
);
policy
(
child
,
state
,
policy
,
level
+
1
);
}
else
if
(
policy_after_level
)
{
}
else
if
(
policy_after_level
)
{
policy_after_level
(
child
,
state
,
policy
,
level
+
1
);
policy_after_level
(
child
,
state
,
policy
,
level
+
1
);
}
}
}
}
};
};
}
}
/**
/**
* 节点展开和收缩的策略常量
* 节点展开和收缩的策略常量
*
*
* 策略是一个处理函数,处理函数接受 3 个参数:
* 策略是一个处理函数,处理函数接受 3 个参数:
*
*
* @param {MinderNode} node 要处理的节点
* @param {MinderNode} node 要处理的节点
* @param {Enum} state 取值为 "expand" | "collapse",表示要对节点进行的操作是展开还是收缩
* @param {Enum} state 取值为 "expand" | "collapse",表示要对节点进行的操作是展开还是收缩
* @param {Function} policy 提供当前策略的函数,方便递归调用
* @param {Function} policy 提供当前策略的函数,方便递归调用
*/
*/
var
EXPAND_POLICY
=
MinderNode
.
EXPAND_POLICY
=
{
var
EXPAND_POLICY
=
MinderNode
.
EXPAND_POLICY
=
{
/**
/**
...
@@ -101,7 +124,10 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -101,7 +124,10 @@ KityMinder.registerModule( "Expand", function () {
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
)
{
execute
:
function
(
km
)
{
alert
(
'2'
);
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
expand
();
}
);
km
.
initStyle
();
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
0
;
return
0
;
...
@@ -112,7 +138,10 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -112,7 +138,10 @@ KityMinder.registerModule( "Expand", function () {
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
)
{
execute
:
function
(
km
)
{
alert
(
'1'
);
layerTravel
(
km
.
getRoot
(),
function
(
n
)
{
n
.
collapse
();
}
);
km
.
initStyle
();
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
return
0
;
return
0
;
...
@@ -121,8 +150,11 @@ KityMinder.registerModule( "Expand", function () {
...
@@ -121,8 +150,11 @@ KityMinder.registerModule( "Expand", function () {
}
)()
);
}
)()
);
return
{
return
{
'events'
:
{
'events'
:
{
'import'
:
function
(
e
)
{
'beforeimport'
:
function
(
e
)
{
//console.log( this.getRoot() );
var
_root
=
this
.
getRoot
();
var
options
=
this
.
getOptions
();
var
defaultExpand
=
options
.
defaultExpand
;
//setOptionValue( _root, defaultExpand.defaultLayer, defaultExpand.defaultSubShow );
}
}
},
},
'commands'
:
{
'commands'
:
{
...
...
src/module/layout.default.js
View file @
37503c8d
...
@@ -510,6 +510,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -510,6 +510,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
initStyle
:
function
()
{
initStyle
:
function
()
{
//渲染根节点
//渲染根节点
var
_root
=
minder
.
getRoot
();
var
_root
=
minder
.
getRoot
();
console
.
log
(
_root
);
var
historyPoint
=
_root
.
getPoint
();
var
historyPoint
=
_root
.
getPoint
();
if
(
historyPoint
)
historyPoint
=
JSON
.
parse
(
JSON
.
stringify
(
historyPoint
)
);
if
(
historyPoint
)
historyPoint
=
JSON
.
parse
(
JSON
.
stringify
(
historyPoint
)
);
minder
.
handelNodeInsert
(
_root
);
minder
.
handelNodeInsert
(
_root
);
...
@@ -545,7 +546,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -545,7 +546,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
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
]
);
if
(
mains
[
i
].
isExpanded
()
&&
mains
[
i
].
getChildren
().
length
>
0
)
{
if
(
mains
[
i
].
isExpanded
()
&&
(
mains
[
i
].
getChildren
().
length
>
0
)
)
{
minder
.
expandNode
(
mains
[
i
]
);
minder
.
expandNode
(
mains
[
i
]
);
}
}
}
}
...
@@ -568,7 +569,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -568,7 +569,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
while
(
_buffer
.
length
!==
0
)
{
while
(
_buffer
.
length
!==
0
)
{
var
c
=
_buffer
[
0
].
getChildren
();
var
c
=
_buffer
[
0
].
getChildren
();
if
(
_buffer
[
0
].
isExpanded
()
&&
c
.
length
!==
0
)
{
if
(
_buffer
[
0
].
isExpanded
()
&&
c
.
length
!==
0
)
{
//_buffer[ 0 ].getLayout().shicon.switchState( true );
for
(
var
x
=
0
;
x
<
c
.
length
;
x
++
)
{
for
(
var
x
=
0
;
x
<
c
.
length
;
x
++
)
{
minder
.
appendChildNode
(
_buffer
[
0
],
c
[
x
]
);
minder
.
appendChildNode
(
_buffer
[
0
],
c
[
x
]
);
}
}
...
...
src/module/layout.js
View file @
37503c8d
...
@@ -51,11 +51,6 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -51,11 +51,6 @@ KityMinder.registerModule( "LayoutModule", function () {
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
this
.
fire
(
'afterinitstyle'
);
this
.
fire
(
'afterinitstyle'
);
},
},
restoreStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
clearPaper
();
var
_root
=
this
.
getRoot
();
},
appendChildNode
:
function
(
parent
,
node
,
focus
,
index
)
{
appendChildNode
:
function
(
parent
,
node
,
focus
,
index
)
{
var
curStyle
=
this
.
getCurrentStyle
();
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
parent
,
node
,
focus
,
index
);
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
parent
,
node
,
focus
,
index
);
...
...
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