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
9003d6e6
Commit
9003d6e6
authored
Jan 06, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
Conflicts: src/module/keyboard.js
parents
4b1bae5e
3256b32c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
104 deletions
+100
-104
dev.html
demo/dev.html
+9
-68
minder.module.js
src/core/minder.module.js
+3
-1
connect.js
src/module/connect.js
+9
-4
keyboard.js
src/module/keyboard.js
+1
-1
layout.js
src/module/layout.js
+14
-3
render.js
src/module/render.js
+64
-27
No files found.
demo/dev.html
View file @
9003d6e6
...
@@ -11,86 +11,27 @@
...
@@ -11,86 +11,27 @@
<script>
<script>
minder
=
new
KM
.
createMinder
(
document
.
body
);
minder
=
new
KM
.
createMinder
(
document
.
body
);
minder
.
importData
({
data
:
{
x
:
50
,
y
:
50
,
text
:
'center'
,
},
children
:
[{
data
:
{
x
:
200
,
y
:
50
,
text
:
'child1'
}
},{
data
:
{
x
:
200
,
y
:
100
,
text
:
'child2'
},
children
:
[{
data
:
{
x
:
350
,
y
:
100
,
text
:
'leaf'
}
}]
}]
});
var
minderWidth
=
document
.
body
.
clientWidth
;
var
minderWidth
=
document
.
body
.
clientWidth
;
var
minderHeight
=
document
.
body
.
clientHeight
;
var
minderHeight
=
document
.
body
.
clientHeight
;
var
_
node
=
minder
.
getRoot
();
var
_
root
=
minder
.
getRoot
();
_
node
.
data
=
{
_
root
.
setData
(
"data"
,
{
centerX
:
minderWidth
/
2
,
x
:
minderWidth
/
2
,
centerY
:
minderHeight
/
2
,
y
:
minderHeight
/
2
,
style
:{
style
:{
radius
:
10
,
radius
:
10
,
fill
:
"orange"
,
fill
:
"orange"
,
stroke
:
"orange"
,
stroke
:
"orange"
,
color
:
"black"
,
color
:
"black"
,
padding
:[
10
,
10
,
10
,
10
],
padding
:[
10
,
10
,
10
,
10
],
fontSize
:
20
fontSize
:
20
,
align
:
"center"
},
},
text
:
"I am the root"
,
text
:
"I am the root"
,
};
});
minder
.
select
(
_node
);
// var _childnode = new MinderNode();
minder
.
select
(
_root
);
// _node.insertChild(_childnode);
minder
.
execCommand
(
"rendernode"
,
_root
);
// _childnode.data = {
// centerX:minderWidth/2+150,
// centerY:minderHeight/2+100,
// style:{
// radius:10,
// fill:"yellow",
// stroke:"orange",
// strokeWidth:2,
// color:"black",
// padding:[10,10,10,10],
// fontSize:12
// },
// text:"childnode1",
// };
// var _childnode2 = new MinderNode();
// _node.insertChild(_childnode2);
// _childnode2.data = {
// centerX:minderWidth/2+250,
// centerY:minderHeight/2+10,
// style:{
// radius:10,
// fill:"yellow",
// stroke:"orange",
// color:"black",
// padding:[10,10,10,10],
// fontSize:12
// },
// text:"childnode2",
// };
minder
.
execCommand
(
"rendernode"
,
_node
);
// minder.execCommand("rendernode",_childnode);
// minder.execCommand("rendernode",_childnode2);
</script>
</script>
</html>
</html>
\ No newline at end of file
src/core/minder.module.js
View file @
9003d6e6
...
@@ -26,7 +26,9 @@ kity.extendClass( Minder, {
...
@@ -26,7 +26,9 @@ kity.extendClass( Minder, {
//command加入命令池子
//command加入命令池子
dealCommands
=
moduleDeals
.
commands
;
dealCommands
=
moduleDeals
.
commands
;
Utils
.
extend
(
this
.
_commands
,
dealCommands
);
for
(
var
name
in
dealCommands
)
{
this
.
_commands
[
name
.
toLowerCase
()
]
=
dealCommands
[
name
];
}
//绑定事件
//绑定事件
dealEvents
=
moduleDeals
.
events
;
dealEvents
=
moduleDeals
.
events
;
...
...
src/module/connect.js
View file @
9003d6e6
...
@@ -145,15 +145,20 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () {
...
@@ -145,15 +145,20 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () {
}
else
{
}
else
{
var
parent
=
node
.
getParent
();
var
parent
=
node
.
getParent
();
var
_connect
=
new
ConnectBezier
(
parent
.
getRenderContainer
(),
node
.
getRenderContainer
()
);
var
_connect
=
new
ConnectBezier
(
parent
.
getRenderContainer
(),
node
.
getRenderContainer
()
);
_connect
.
stroke
(
new
kity
.
Pen
(
node
.
data
.
style
.
stroke
,
node
.
data
.
style
.
strokeWidth
)
);
var
nodeD
=
node
.
getData
(
"data"
);
node
.
connect
=
_connect
;
_connect
.
stroke
(
new
kity
.
Pen
(
nodeD
.
style
.
stroke
,
nodeD
.
style
.
strokeWidth
)
);
node
.
setData
(
"connect"
,
_connect
);
console
.
log
(
_connect
);
console
.
log
(
_connect
);
minder
.
getRenderContainer
().
addShape
(
_connect
);
minder
.
getRenderContainer
().
addShape
(
_connect
);
}
}
}
)();
}
)();
break
;
break
;
case
"erasenode"
:
case
"removenode"
:
break
;
(
function
()
{
var
node
=
command
.
commandArgs
[
0
];
node
.
getData
(
"connect"
).
remove
();
}
)();
default
:
default
:
break
;
break
;
};
};
...
...
src/module/keyboard.js
View file @
9003d6e6
...
@@ -86,7 +86,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -86,7 +86,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
isRootSelected
=
this
.
isNodeSelected
(
this
.
getRoot
()
);
isRootSelected
=
this
.
isNodeSelected
(
this
.
getRoot
()
);
console
.
log
(
e
.
originEvent
.
keyCode
);
console
.
log
(
e
.
originEvent
.
keyCode
);
e
.
originEvent
.
preventDefault
();
e
.
originEvent
.
preventDefault
();
switch
(
e
.
keyCode
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
case
13
:
case
13
:
// Enter
// Enter
...
...
src/module/layout.js
View file @
9003d6e6
KityMinder
.
registerModule
(
"LayoutModule"
,
function
()
{
KityMinder
.
registerModule
(
"LayoutModule"
,
function
()
{
var
CreateChildNodeCommand
=
kity
.
createClass
(
"CreateChildNodeCommand"
,
(
function
()
{
var
CreateChildNodeCommand
=
kity
.
createClass
(
"CreateChildNodeCommand"
,
(
function
()
{
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
km
,
parent
,
node
)
{
execute
:
function
(
km
,
parent
)
{
parent
.
insertChild
(
node
);
console
.
log
(
"parentX"
,
parent
.
getData
(
"data"
).
x
);
var
_node
=
new
MinderNode
();
var
_nodeD
=
{
text
:
"New Node"
,
x
:
parent
.
getData
(
"data"
).
x
+
200
,
y
:
Math
.
random
()
*
300
+
100
,
align
:
"left"
};
_node
.
setData
(
"data"
,
_nodeD
);
console
.
log
(
"node"
,
_node
);
parent
.
insertChild
(
_node
);
km
.
execCommand
(
'rendernode'
,
_node
);
return
_node
;
}
}
}
}
}
)()
);
}
)()
);
...
...
src/module/render.js
View file @
9003d6e6
KityMinder
.
registerModule
(
"RenderModule"
,
function
()
{
KityMinder
.
registerModule
(
"RenderModule"
,
function
()
{
var
RenderNodeCommand
=
kity
.
createClass
(
"RenderNodeCommand"
,
(
function
()
{
var
RenderNodeCommand
=
kity
.
createClass
(
"RenderNodeCommand"
,
(
function
()
{
var
node_default
=
{
var
MinderNodeShape
=
kity
.
createClass
(
"MinderNodeShape"
,
(
function
()
{
centerX
:
0
,
return
{
centerY
:
0
,
constructor
:
function
(
container
)
{
text
:
"Root"
,
this
.
rect
=
new
kity
.
Rect
();
style
:
{
this
.
text
=
new
kity
.
Text
();
fill
:
"#7ecef4"
,
this
.
shape
=
new
kity
.
Group
();
stroke
:
"white"
,
this
.
shape
.
addShapes
(
[
this
.
rect
,
this
.
text
]
);
strokeWidth
:
3
,
container
.
addShape
(
this
.
shape
,
"nodeShape"
);
padding
:
5
,
},
radius
:
5
highlight
:
function
()
{
this
.
rect
.
stroke
(
new
kity
.
Pen
(
"white"
,
3
)
);
},
unhighlight
:
function
()
{
this
.
rect
.
stroke
(
this
.
NormalInfo
);
}
}
}
};
}
)()
);
var
renderNode
=
function
(
km
,
node
)
{
var
renderNode
=
function
(
km
,
node
)
{
var
nodeD
=
Utils
.
extend
(
node_default
,
node
.
data
);
var
node_default
=
{
var
_style
=
nodeD
.
style
;
x
:
0
,
y
:
0
,
text
:
"Root"
,
style
:
{
radius
:
10
,
fill
:
"yellow"
,
stroke
:
"orange"
,
color
:
"black"
,
padding
:
[
5
,
5
,
5
,
5
],
fontSize
:
12
,
align
:
"left"
}
};
var
kR
=
node
.
getRenderContainer
();
var
kR
=
node
.
getRenderContainer
();
var
_node
=
node
.
shape
=
new
kity
.
Group
();
var
nodeShape
=
new
MinderNodeShape
(
kR
);
var
_txt
=
new
kity
.
Text
(
nodeD
.
text
||
"Node"
);
var
nd
=
JSON
.
parse
(
JSON
.
stringify
(
node_default
)
);
_txt
.
setSize
(
nodeD
.
fontSize
).
fill
(
nodeD
.
color
);
var
nodeD
=
Utils
.
extend
(
nd
,
node
.
getData
(
"data"
)
);
_node
.
addShape
(
_txt
);
node
.
setData
(
"data"
,
nodeD
);
kR
.
addShape
(
_node
);
var
_style
=
nodeD
.
style
;
var
txtWidth
=
_txt
.
getWidth
();
nodeShape
.
text
var
txtHeight
=
_txt
.
getHeight
();
.
setContent
(
nodeD
.
text
||
"Node"
)
.
setSize
(
nodeD
.
fontSize
)
.
fill
(
nodeD
.
color
);
var
txtWidth
=
nodeShape
.
text
.
getWidth
();
var
txtHeight
=
nodeShape
.
text
.
getHeight
();
var
_padding
=
_style
.
padding
;
var
_padding
=
_style
.
padding
;
nodeShape
.
text
.
setX
(
_padding
[
3
]
).
setY
(
_padding
[
0
]
+
txtHeight
);
var
_rectWidth
=
txtWidth
+
_padding
[
1
]
+
_padding
[
3
];
var
_rectWidth
=
txtWidth
+
_padding
[
1
]
+
_padding
[
3
];
var
_rectHeight
=
txtHeight
+
_padding
[
0
]
+
_padding
[
2
];
var
_rectHeight
=
txtHeight
+
_padding
[
0
]
+
_padding
[
2
];
console
.
log
(
_rectWidth
,
_rectHeight
);
var
_rect
=
new
kity
.
Rect
(
_rectWidth
,
_rectHeight
,
0
,
0
,
_style
.
radius
);
nodeShape
.
NormalInfo
=
new
kity
.
Pen
(
_style
.
stroke
,
_style
.
strokeWidth
);
_rect
.
stroke
(
new
kity
.
Pen
(
_style
.
stroke
,
_style
.
strokeWidth
)
).
fill
(
_style
.
fill
);
nodeShape
.
rect
.
setWidth
(
_rectWidth
).
setHeight
(
_rectHeight
).
stroke
(
nodeShape
.
NormalInfo
).
fill
(
_style
.
fill
).
setRadius
(
_style
.
radius
);
_node
.
addShape
(
_rect
).
bringTop
(
_txt
);
_node
.
translate
(
nodeD
.
centerX
-
_rectWidth
/
2
,
nodeD
.
centerY
-
_rectHeight
/
2
);
switch
(
nodeD
.
align
)
{
_txt
.
setX
(
_padding
[
3
]
).
setY
(
_padding
[
0
]
+
txtHeight
);
case
"center"
:
};
nodeShape
.
shape
.
translate
(
nodeD
.
x
-
_rectWidth
/
2
,
nodeD
.
y
-
_rectHeight
/
2
);
break
;
case
"right"
:
nodeShape
.
shape
.
translate
(
nodeD
.
x
-
_rectWidth
,
nodeD
.
y
-
_rectHeight
/
2
);
break
;
default
:
nodeShape
.
shape
.
translate
(
nodeD
.
x
,
nodeD
.
y
-
_rectHeight
/
2
);
break
;
}
if
(
km
.
isNodeSelected
(
node
)
)
{
nodeShape
.
highlight
();
}
}
return
{
return
{
base
:
Command
,
base
:
Command
,
...
...
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