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
7eae9ddd
Commit
7eae9ddd
authored
Jan 27, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new data
parent
b96701df
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
236 additions
and
352 deletions
+236
-352
dev.html
demo/dev.html
+2
-0
minder.js
src/core/minder.js
+1
-1
node.js
src/core/node.js
+49
-50
layout.default.js
src/module/layout.default.js
+183
-300
layout.js
src/module/layout.js
+1
-1
No files found.
demo/dev.html
View file @
7eae9ddd
...
@@ -24,5 +24,7 @@
...
@@ -24,5 +24,7 @@
var
val
=
e
.
target
.
value
;
var
val
=
e
.
target
.
value
;
minder
.
execCommand
(
"switchlayout"
,
val
);
minder
.
execCommand
(
"switchlayout"
,
val
);
},
false
);
},
false
);
// var b = new kity.Bezier([new kity.BezierPoint(0,0).setVertex(100,100),new kity.BezierPoint(100,0).setVertex(100,100)]);
// minder.getRenderContainer().addShape(b.stroke("white"));
</script>
</script>
</html>
</html>
\ No newline at end of file
src/core/minder.js
View file @
7eae9ddd
...
@@ -43,7 +43,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
...
@@ -43,7 +43,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_paper
.
getNode
().
setAttribute
(
'contenteditable'
,
true
);
this
.
_paper
.
getNode
().
setAttribute
(
'contenteditable'
,
true
);
this
.
_root
=
new
MinderNode
();
this
.
_root
=
new
MinderNode
();
this
.
_r
c
.
addShape
(
this
.
_root
.
getRenderContainer
()
);
this
.
_r
oot
.
setType
(
"root"
);
if
(
this
.
_options
.
renderTo
)
{
if
(
this
.
_options
.
renderTo
)
{
this
.
renderTo
(
this
.
_options
.
renderTo
);
this
.
renderTo
(
this
.
_options
.
renderTo
);
}
}
...
...
src/core/node.js
View file @
7eae9ddd
...
@@ -3,30 +3,38 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -3,30 +3,38 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this
.
parent
=
null
;
this
.
parent
=
null
;
this
.
children
=
[];
this
.
children
=
[];
this
.
data
=
{};
this
.
data
=
{};
if
(
utils
.
isString
(
options
)
)
{
this
.
_type
=
"main"
;
this
.
setData
(
'text'
,
options
)
if
(
Utils
.
isString
(
options
)
)
{
this
.
setData
(
'text'
,
options
);
}
else
{
}
else
{
this
.
setData
(
options
);
this
.
setData
(
options
);
}
}
this
.
rc
=
new
kity
.
Group
();
this
.
rc
=
new
kity
.
Group
();
this
.
rc
.
minderNode
=
this
;
this
.
rc
.
minderNode
=
this
;
},
},
setPoint
:
function
(
x
,
y
){
setPoint
:
function
(
x
,
y
)
{
this
.
setData
(
'point'
,{
this
.
setData
(
'point'
,
{
x
:
x
,
y
:
y
x
:
x
,
})
y
:
y
}
);
},
getPoint
:
function
()
{
return
this
.
getData
(
'point'
);
},
},
getPoint
:
function
(){
setType
:
function
(
type
)
{
return
this
.
getData
(
'point'
)
},
getType
:
function
(
type
)
{
},
},
setText
:
function
(
text
)
{
setText
:
function
(
text
)
{
this
.
setData
(
'text'
,
text
)
this
.
setData
(
'text'
,
text
)
;
},
},
getText
:
function
()
{
getText
:
function
()
{
return
this
.
getData
(
'text'
)
return
this
.
getData
(
'text'
)
;
},
},
isRoot
:
function
()
{
isRoot
:
function
()
{
return
this
.
getParent
()
==
null
?
true
:
false
;
return
this
.
getParent
()
==
=
null
?
true
:
false
;
},
},
getParent
:
function
()
{
getParent
:
function
()
{
return
this
.
parent
;
return
this
.
parent
;
...
@@ -89,16 +97,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -89,16 +97,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node
.
root
=
parent
.
root
;
node
.
root
=
parent
.
root
;
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
children
.
splice
(
index
,
0
,
node
);
// this.handelInsert( node );
},
},
//
// handelInsert: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node );
// }
// },
appendChild
:
function
(
node
)
{
appendChild
:
function
(
node
)
{
return
this
.
insertChild
(
node
);
return
this
.
insertChild
(
node
);
...
@@ -132,10 +131,10 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -132,10 +131,10 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
this
.
children
[
index
];
return
this
.
children
[
index
];
},
},
getFirstChild
:
function
()
{
getFirstChild
:
function
()
{
return
this
.
children
[
0
]
return
this
.
children
[
0
]
;
},
},
getLastChild
:
function
()
{
getLastChild
:
function
()
{
return
this
.
children
[
this
.
children
.
length
-
1
]
return
this
.
children
[
this
.
children
.
length
-
1
]
;
},
},
getData
:
function
(
name
)
{
getData
:
function
(
name
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
...
@@ -145,17 +144,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -145,17 +144,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
},
setData
:
function
(
name
,
value
)
{
setData
:
function
(
name
,
value
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
this
.
data
=
{}
this
.
data
=
{}
;
}
else
if
(
utils
.
isObject
(
name
))
{
}
else
if
(
utils
.
isObject
(
name
)
)
{
utils
.
extend
(
this
.
data
,
name
)
Utils
.
extend
(
this
.
data
,
name
);
}
else
{
}
else
{
if
(
value
===
undefined
)
{
if
(
value
===
undefined
)
{
this
.
data
[
name
]
=
null
;
this
.
data
[
name
]
=
null
;
delete
this
.
data
[
name
]
delete
this
.
data
[
name
];
}
else
{
}
else
{
this
.
data
[
name
]
=
value
;
this
.
data
[
name
]
=
value
;
}
}
}
}
},
},
...
@@ -163,7 +162,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -163,7 +162,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
this
.
rc
;
return
this
.
rc
;
},
},
getCommonAncestor
:
function
(
node
)
{
getCommonAncestor
:
function
(
node
)
{
return
utils
.
getNodeCommonAncestor
(
this
,
node
)
return
Utils
.
getNodeCommonAncestor
(
this
,
node
);
},
},
contains
:
function
(
node
)
{
contains
:
function
(
node
)
{
if
(
this
===
node
)
{
if
(
this
===
node
)
{
...
@@ -173,44 +172,44 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -173,44 +172,44 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
true
;
return
true
;
}
}
var
isContain
=
false
;
var
isContain
=
false
;
u
tils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
U
tils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
isContain
=
n
.
contains
(
node
);
isContain
=
n
.
contains
(
node
);
if
(
isContain
===
true
)
{
if
(
isContain
===
true
)
{
return
false
return
false
;
}
}
}
);
}
);
return
isContain
;
return
isContain
;
},
},
clone
:
function
()
{
clone
:
function
()
{
function
cloneNode
(
parent
,
isClonedNode
)
{
function
cloneNode
(
parent
,
isClonedNode
)
{
var
_tmp
=
new
KM
.
MinderNode
();
var
_tmp
=
new
KM
.
MinderNode
();
_tmp
.
data
=
utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
data
=
Utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
parent
=
parent
;
_tmp
.
parent
=
parent
;
if
(
parent
)
{
if
(
parent
)
{
parent
.
children
.
push
(
_tmp
);
parent
.
children
.
push
(
_tmp
);
}
}
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];)
{
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];
)
{
cloneNode
(
_tmp
,
ci
);
cloneNode
(
_tmp
,
ci
);
}
}
return
_tmp
;
return
_tmp
;
}
}
return
function
()
{
return
function
()
{
return
cloneNode
(
null
,
this
);
return
cloneNode
(
null
,
this
);
}
}
}(),
}(),
equals
:
function
(
node
)
{
equals
:
function
(
node
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
return
false
;
return
false
;
}
}
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
()
)
===
false
)
{
return
false
;
return
false
;
}
}
for
(
var
i
=
0
,
ci
;
ci
=
this
.
children
[
i
++
];)
{
for
(
var
i
=
0
,
ci
;
ci
=
this
.
children
[
i
++
];
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
return
false
;
return
false
;
}
}
}
}
...
...
src/module/layout.default.js
View file @
7eae9ddd
This diff is collapsed.
Click to expand it.
src/module/layout.js
View file @
7eae9ddd
...
@@ -64,7 +64,7 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -64,7 +64,7 @@ KityMinder.registerModule( "LayoutModule", function () {
}
);
}
);
var
switchLayout
=
function
(
km
,
style
)
{
var
switchLayout
=
function
(
km
,
style
)
{
var
_root
=
km
.
getRoot
();
var
_root
=
km
.
getRoot
();
km
.
getRenderContainer
().
clear
()
.
addShape
(
_root
.
getRenderContainer
().
clear
()
)
;
km
.
getRenderContainer
().
clear
();
_root
.
preTraverse
(
function
(
n
)
{
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
n
.
clearLayout
();
n
.
setPoint
();
n
.
setPoint
();
...
...
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