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
fdeb0a30
Commit
fdeb0a30
authored
May 07, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
merge changes
parents
ce1fca81
7bbed859
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
102 deletions
+81
-102
minder.data.js
src/core/minder.data.js
+19
-16
expand.js
src/module/expand.js
+7
-1
layout.default.js
src/module/layout.default.js
+52
-81
layout.js
src/module/layout.js
+3
-4
No files found.
src/core/minder.data.js
View file @
fdeb0a30
...
...
@@ -41,7 +41,7 @@ function importNode( node, json, km ) {
for
(
var
field
in
data
)
{
node
.
setData
(
field
,
data
[
field
]
);
}
node
.
setData
(
'text'
,
data
.
text
||
km
.
getLang
(
DEFAULT_TEXT
[
node
.
getType
()
]
)
);
node
.
setData
(
'text'
,
data
.
text
||
km
.
getLang
(
DEFAULT_TEXT
[
node
.
getType
()
]
)
);
var
childrenTreeData
=
json
.
children
;
if
(
!
childrenTreeData
)
return
;
...
...
@@ -53,7 +53,6 @@ function importNode( node, json, km ) {
return
node
;
}
// 导入导出
kity
.
extendClass
(
Minder
,
{
exportData
:
function
(
protocalName
)
{
...
...
@@ -62,11 +61,11 @@ kity.extendClass( Minder, {
json
=
exportNode
(
this
.
getRoot
()
);
protocal
=
KityMinder
.
findProtocal
(
protocalName
);
if
(
this
.
_fire
(
new
MinderEvent
(
'beforeexport'
,
{
json
:
json
,
if
(
this
.
_fire
(
new
MinderEvent
(
'beforeexport'
,
{
json
:
json
,
protocalName
:
protocalName
,
protocal
:
protocal
},
true
)
)
===
true
)
return
;
},
true
)
)
===
true
)
return
;
if
(
protocal
)
{
return
protocal
.
encode
(
json
,
this
);
...
...
@@ -106,44 +105,48 @@ kity.extendClass( Minder, {
//*******************
function
ts
(
d
,
str
,
last
)
{
function
ts
(
d
,
str
,
last
)
{
var
h
=
d
.
getHours
(),
m
=
d
.
getMinutes
(),
s
=
d
.
getSeconds
(),
ms
=
d
.
getMilliseconds
();
if
(
last
)
{
console
.
log
(
'--- '
+
str
+
': '
+
(
d
-
last
)
+
' ---'
);
}
else
{
console
.
log
(
'--- '
+
str
+
' ---'
);
if
(
last
)
{
console
.
log
(
'--- '
+
str
+
': '
+
(
d
-
last
)
+
' ---'
);
}
else
{
console
.
log
(
'--- '
+
str
+
' ---'
);
}
return
d
;
}
var
t1
=
ts
(
new
Date
(),
'开始解析'
);
var
t1
=
ts
(
new
Date
(),
'开始解析'
);
//*******************
json
=
params
.
json
||
(
params
.
json
=
protocal
.
decode
(
local
)
);
this
.
_fire
(
new
MinderEvent
(
'importData'
,{
data
:
json
},
true
));
if
(
typeof
json
===
'object'
&&
'then'
in
json
)
{
var
self
=
this
;
json
.
then
(
local
,
function
(
data
)
{
//*******************
var
t2
=
ts
(
new
Date
(),
'解压解析耗时'
,
t1
);
var
t2
=
ts
(
new
Date
(),
'解压解析耗时'
,
t1
);
//*******************
self
.
_afterImportData
(
data
,
params
);
//*******************
ts
(
new
Date
(),
'渲染耗时'
,
t2
);
ts
(
new
Date
(),
'渲染耗时'
,
t2
);
//*******************
}
);
}
else
{
//*******************
var
t2
=
ts
(
new
Date
(),
'解压解析耗时'
,
t1
);
var
t2
=
ts
(
new
Date
(),
'解压解析耗时'
,
t1
);
//*******************
this
.
_afterImportData
(
json
,
params
);
//*******************
ts
(
new
Date
(),
'渲染耗时'
,
t2
);
ts
(
new
Date
(),
'渲染耗时'
,
t2
);
//*******************
}
return
this
;
...
...
src/module/expand.js
View file @
fdeb0a30
...
...
@@ -14,6 +14,7 @@ KityMinder.registerModule( "Expand", function () {
* @param {Function} policy_after_level 超过的层数执行的策略
*/
function
generateDeepPolicy
(
deep_level
,
policy_after_level
)
{
return
function
(
node
,
state
,
policy
,
level
)
{
var
children
,
child
,
i
;
...
...
@@ -93,10 +94,15 @@ KityMinder.registerModule( "Expand", function () {
* 判断节点当前的状态是否为展开
*/
isExpanded
:
function
()
{
return
!!
node
.
getData
(
EXPAND_STATE_DATA
)
;
return
this
.
getData
(
EXPAND_STATE_DATA
)
===
STATE_EXPAND
;
}
}
);
return
{
'events'
:
{
'importData'
:
function
(
e
)
{
var
data
=
e
.
data
;
}
},
'commands'
:
{}
};
}
);
\ No newline at end of file
src/module/layout.default.js
View file @
fdeb0a30
...
...
@@ -423,9 +423,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
if
(
nodeType
!==
"root"
&&
node
.
getChildren
().
length
!==
0
)
{
if
(
!
Layout
.
shicon
)
{
Layout
.
shicon
=
new
ShIcon
(
node
);
if
(
Layout
.
expand
)
{
Layout
.
shicon
.
switchState
();
}
}
Layout
.
shicon
.
update
();
}
...
...
@@ -508,7 +505,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
this
.
highlightNode
(
node
)
}
},
initStyle
:
function
(
expandall
)
{
initStyle
:
function
()
{
//渲染根节点
var
_root
=
minder
.
getRoot
();
var
historyPoint
=
_root
.
getPoint
();
if
(
historyPoint
)
historyPoint
=
JSON
.
parse
(
JSON
.
stringify
(
historyPoint
)
);
...
...
@@ -541,61 +539,71 @@ KityMinder.registerModule( "LayoutDefault", function () {
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
]
);
//console.log( mains[ i ].isExpanded() );
if
(
mains
[
i
].
isExpanded
()
&&
mains
[
i
].
getChildren
().
length
>
0
)
{
debugger
;
minder
.
expandNode
(
mains
[
i
]
);
}
}
_root
.
setPoint
(
_root
.
getLayout
().
x
,
_root
.
getLayout
().
y
);
},
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
;
}
cur_layer
++
;
var
clonelayer0
=
function
()
{
var
items
=
[];
for
(
var
i
=
0
;
i
<
mains
.
length
;
i
++
)
{
items
.
push
(
mains
[
i
]
);
var
_buffer
;
if
(
isExpand
)
{
node
.
expand
();
//遍历子树展开需要展开的节点
_buffer
=
[
node
];
debugger
;
while
(
_buffer
.
length
!==
0
)
{
var
c
=
_buffer
[
0
].
getChildren
();
if
(
_buffer
[
0
].
isExpanded
()
&&
c
.
length
!==
0
)
{
for
(
var
x
=
0
;
x
<
c
.
length
;
x
++
)
{
minder
.
appendChildNode
(
_buffer
[
0
],
c
[
x
]
);
}
_buffer
=
_buffer
.
concat
(
c
);
}
_buffer
.
shift
();
}
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
()
);
}
else
{
node
.
collapse
();
//遍历子树移除需要移除的节点
_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
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"contract"
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
}
_buffer
.
splice
(
0
,
layer_len
);
}
_root
.
setPoint
(
_root
.
getLayout
().
x
,
_root
.
getLayout
().
y
);
},
appendChildNode
:
function
(
parent
,
node
,
focus
,
sibling
)
{
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
parent
.
getLayout
().
expand
===
false
)
{
minder
.
expandNode
(
parent
);
}
minder
.
handelNodeInsert
(
node
);
var
Layout
=
node
.
getLayout
();
var
oldExpand
;
if
(
Layout
)
{
oldExpand
=
Layout
.
expand
;
}
node
.
clearLayout
();
node
.
getContRc
().
clear
();
Layout
=
node
.
getLayout
();
Layout
.
expand
=
oldExpand
||
false
;
if
(
parent
.
getType
()
!==
'root'
)
{
parent
.
getLayout
().
expand
=
true
;
}
Layout
.
added
=
true
;
var
parentLayout
=
parent
.
getLayout
();
var
children
=
parent
.
getChildren
();
...
...
@@ -744,43 +752,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
_buffer
.
shift
();
}
}
},
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
);
...
...
src/module/layout.js
View file @
fdeb0a30
...
...
@@ -38,7 +38,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
highlightNode
.
call
(
this
,
node
);
},
initStyle
:
function
(
expandall
)
{
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
_rc
.
remove
();
this
.
_rc
=
new
kity
.
Group
();
...
...
@@ -46,10 +46,9 @@ KityMinder.registerModule( "LayoutModule", function () {
var
_root
=
this
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
var
oldLayout
=
n
.
getLayout
();
n
.
clearLayout
();
}
);
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
,
expandall
);
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
this
.
fire
(
'afterinitstyle'
);
},
restoreStyle
:
function
()
{
...
...
@@ -127,7 +126,7 @@ KityMinder.registerModule( "LayoutModule", function () {
if
(
!
parent
)
{
return
null
;
}
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
parent
.
getLayout
().
expand
===
false
)
{
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
!
parent
.
isExpanded
()
)
{
km
.
expandNode
(
parent
);
}
...
...
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