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
acb7dc6c
Commit
acb7dc6c
authored
Jan 09, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
b4f540a6
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
266 additions
and
298 deletions
+266
-298
minder.command.js
src/core/minder.command.js
+1
-1
connect.js
src/module/connect.js
+176
-176
editor.js
src/module/editor.js
+3
-1
editor.receiver.js
src/module/editor.receiver.js
+12
-1
layout.js
src/module/layout.js
+3
-34
render.js
src/module/render.js
+71
-85
No files found.
src/core/minder.command.js
View file @
acb7dc6c
...
@@ -84,7 +84,7 @@ kity.extendClass( Minder, {
...
@@ -84,7 +84,7 @@ kity.extendClass( Minder, {
result
=
command
.
execute
.
apply
(
command
,
[
me
].
concat
(
cmdArgs
)
);
result
=
command
.
execute
.
apply
(
command
,
[
me
].
concat
(
cmdArgs
)
);
this
.
_fire
(
new
MinderEvent
(
name
.
toLowerCase
()
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
}
}
...
...
src/module/connect.js
View file @
acb7dc6c
This diff is collapsed.
Click to expand it.
src/module/editor.js
View file @
acb7dc6c
...
@@ -25,11 +25,13 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -25,11 +25,13 @@ KityMinder.registerModule( "TextEditModule", function () {
receiver
.
setCursor
(
cursor
)
receiver
.
setCursor
(
cursor
)
.
setKityMinder
(
this
)
.
setMinderNode
(
e
.
getTargetNode
())
.
setTextShape
(
targetShape
)
.
setTextShape
(
targetShape
)
.
setCursorHeight
()
.
setCursorHeight
()
.
setCurrentIndex
(
position
)
.
setCurrentIndex
(
position
)
.
updateCursor
()
.
updateCursor
()
.
setRange
(
range
)
.
setRange
(
range
)
;
}
}
},
},
...
...
src/module/editor.receiver.js
View file @
acb7dc6c
...
@@ -52,12 +52,23 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -52,12 +52,23 @@ Minder.Receiver = kity.createClass('Receiver',{
paper
.
addShape
(
this
.
textShape
);
paper
.
addShape
(
this
.
textShape
);
return
this
;
return
this
;
},
},
setKityMinder
:
function
(
km
){
this
.
km
=
km
;
return
this
;
},
setMinderNode
:
function
(
node
){
this
.
minderNode
=
node
;
return
this
;
},
keyboardEvents
:
function
(
e
){
keyboardEvents
:
function
(
e
){
clearTimeout
(
this
.
timer
);
clearTimeout
(
this
.
timer
);
var
me
=
this
;
var
me
=
this
;
switch
(
e
.
type
){
switch
(
e
.
type
){
case
'keyup'
:
case
'keyup'
:
this
.
textShape
.
setContent
((
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
));
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
);
this
.
textShape
.
setContent
(
text
);
this
.
minderNode
.
setData
(
'text'
,
text
);
this
.
km
.
execCommand
(
'renderNode'
,
this
.
minderNode
);
this
.
updateTextData
();
this
.
updateTextData
();
this
.
updateCursor
();
this
.
updateCursor
();
this
.
timer
=
setTimeout
(
function
(){
this
.
timer
=
setTimeout
(
function
(){
...
...
src/module/layout.js
View file @
acb7dc6c
...
@@ -60,14 +60,12 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -60,14 +60,12 @@ KityMinder.registerModule( "LayoutModule", function () {
var
part2
=
(
children
[
j
+
1
]
?
(
children
[
j
+
1
].
getData
(
"branchheight"
)
-
10
)
/
2
:
0
);
var
part2
=
(
children
[
j
+
1
]
?
(
children
[
j
+
1
].
getData
(
"branchheight"
)
-
10
)
/
2
:
0
);
sY
+=
(
part1
+
part2
);
sY
+=
(
part1
+
part2
);
}
}
km
.
fire
(
"rendernode"
,
{
km
.
execCommand
(
"rendernode"
,
children
);
nodes
:
children
,
rerender
:
false
}
);
}
}
}
}
};
};
var
setX
=
function
(
node
)
{
var
setX
=
function
(
node
)
{
var
parent
=
node
.
getParent
();
var
parent
=
node
.
getParent
();
if
(
!
parent
)
return
false
;
if
(
!
parent
)
return
false
;
...
@@ -172,10 +170,7 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -172,10 +170,7 @@ KityMinder.registerModule( "LayoutModule", function () {
reAnalyze
(
km
,
layerArray
,
appendSide
);
reAnalyze
(
km
,
layerArray
,
appendSide
);
}
else
{
}
else
{
_node
.
setData
(
"y"
,
_node
.
getParent
().
getData
(
"y"
)
);
_node
.
setData
(
"y"
,
_node
.
getParent
().
getData
(
"y"
)
);
km
.
fire
(
"rendernode"
,
{
km
.
execCommand
(
"rendernode"
,
_node
);
nodes
:
_node
,
rerender
:
false
}
);
}
}
return
_node
;
return
_node
;
};
};
...
@@ -253,33 +248,7 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -253,33 +248,7 @@ KityMinder.registerModule( "LayoutModule", function () {
},
},
"events"
:
{
"events"
:
{
"contentupdate"
:
function
(
e
)
{
var
me
=
this
;
updateNode
(
me
,
e
.
node
);
},
"noderendercomplete"
:
function
(
e
)
{
if
(
!
e
.
rerender
)
return
false
;
var
parent
=
e
.
node
;
var
nodes
=
[];
parent
.
preTraverse
(
function
(
node
)
{
var
prt
=
node
.
getParent
();
if
(
!
prt
)
return
false
;
var
parentWidth
=
prt
.
getData
(
"width"
);
var
parentX
=
prt
.
getData
(
"x"
);
if
(
parent
.
getData
(
"align"
)
===
"center"
)
parentWidth
=
parentWidth
/
2
;
if
(
parent
.
getData
(
"appendside"
)
===
"left"
)
{
node
.
setData
(
"x"
,
parentX
-
parentWidth
-
50
);
}
else
{
node
.
setData
(
"x"
,
parentX
+
parentWidth
+
50
);
}
nodes
.
push
(
node
);
}
);
this
.
fire
(
"rendernode"
,
{
nodes
:
nodes
,
rerender
:
false
}
);
}
}
}
};
};
}
);
}
);
\ No newline at end of file
src/module/render.js
View file @
acb7dc6c
KityMinder
.
registerModule
(
"RenderModule"
,
function
()
{
KityMinder
.
registerModule
(
"RenderModule"
,
function
()
{
var
MinderNodeShape
=
kity
.
createClass
(
"MinderNodeShape"
,
(
function
()
{
var
RenderNodeCommand
=
kity
.
createClass
(
"RenderNodeCommand"
,
(
function
()
{
return
{
var
MinderNodeShape
=
kity
.
createClass
(
"MinderNodeShape"
,
(
function
()
{
constructor
:
function
(
container
)
{
return
{
this
.
rect
=
new
kity
.
Rect
();
constructor
:
function
(
container
)
{
this
.
text
=
new
kity
.
Text
();
this
.
rect
=
new
kity
.
Rect
();
this
.
shape
=
new
kity
.
Group
();
this
.
text
=
new
kity
.
Text
();
this
.
shape
.
addShapes
(
[
this
.
rect
,
this
.
text
]
);
this
.
shape
=
new
kity
.
Group
();
container
.
addShape
(
this
.
shape
,
"nodeShape"
);
this
.
shape
.
addShapes
(
[
this
.
rect
,
this
.
text
]
);
},
container
.
addShape
(
this
.
shape
,
"nodeShape"
);
highlight
:
function
()
{
},
this
.
rect
.
stroke
(
new
kity
.
Pen
(
"white"
,
3
)
);
highlight
:
function
()
{
},
this
.
rect
.
stroke
(
new
kity
.
Pen
(
"white"
,
3
)
);
unhighlight
:
function
()
{
},
this
.
rect
.
stroke
(
this
.
NormalInfo
);
unhighlight
:
function
()
{
}
this
.
rect
.
stroke
(
this
.
NormalInfo
);
};
}
}
)()
);
};
var
renderNode
=
function
(
km
,
node
)
{
}
)()
);
console
.
log
(
km
,
node
);
var
renderNode
=
function
(
km
,
node
)
{
var
styledefault
=
{
radius
:
10
,
fill
:
"yellow"
,
stroke
:
"orange"
,
color
:
"black"
,
padding
:
[
5
,
10
,
5
,
10
],
fontSize
:
20
,
};
var
kR
=
node
.
getRenderContainer
();
var
nodeShape
=
kR
.
nodeShape
=
kR
.
nodeShape
||
new
MinderNodeShape
(
kR
);
var
nd
=
JSON
.
parse
(
JSON
.
stringify
(
styledefault
)
);
var
nodeD
=
Utils
.
extend
(
nd
,
node
.
getData
(
"style"
)
);
node
.
setData
(
"style"
,
nodeD
);
var
_style
=
nodeD
;
nodeShape
.
text
.
setContent
(
node
.
getData
(
"text"
)
||
"Node"
)
.
setSize
(
nodeD
.
fontSize
)
.
fill
(
nodeD
.
color
);
var
txtWidth
=
nodeShape
.
text
.
getWidth
();
var
txtHeight
=
nodeShape
.
text
.
getHeight
();
var
_padding
=
_style
.
padding
;
var
_rectWidth
=
txtWidth
+
_padding
[
1
]
+
_padding
[
3
];
var
styledefault
=
{
var
_rectHeight
=
txtHeight
+
_padding
[
0
]
+
_padding
[
2
];
radius
:
10
,
node
.
setData
(
"width"
,
_rectWidth
);
fill
:
"yellow"
,
node
.
setData
(
"height"
,
_rectHeight
);
stroke
:
"orange"
,
nodeShape
.
text
color
:
"black"
,
.
setX
(
_padding
[
3
]
).
setY
(
_padding
[
0
]
+
txtHeight
);
padding
:
[
5
,
10
,
5
,
10
],
fontSize
:
20
,
};
var
kR
=
node
.
getRenderContainer
();
var
nodeShape
=
kR
.
nodeShape
=
kR
.
nodeShape
||
new
MinderNodeShape
(
kR
);
var
nd
=
JSON
.
parse
(
JSON
.
stringify
(
styledefault
)
);
var
nodeD
=
Utils
.
extend
(
nd
,
node
.
getData
(
"style"
)
);
node
.
setData
(
"style"
,
nodeD
);
var
_style
=
nodeD
;
nodeShape
.
text
.
setContent
(
node
.
getData
(
"text"
)
||
"Node"
)
.
setSize
(
nodeD
.
fontSize
)
.
fill
(
nodeD
.
color
);
var
txtWidth
=
nodeShape
.
text
.
getWidth
();
var
txtHeight
=
nodeShape
.
text
.
getHeight
();
var
_padding
=
_style
.
padding
;
nodeShape
.
NormalInfo
=
new
kity
.
Pen
(
_style
.
stroke
,
_style
.
strokeWidth
);
var
_rectWidth
=
txtWidth
+
_padding
[
1
]
+
_padding
[
3
];
nodeShape
.
rect
.
setWidth
(
_rectWidth
).
setHeight
(
_rectHeight
).
stroke
(
nodeShape
.
NormalInfo
).
fill
(
_style
.
fill
).
setRadius
(
_style
.
radius
);
var
_rectHeight
=
txtHeight
+
_padding
[
0
]
+
_padding
[
2
];
switch
(
node
.
getData
(
"align"
)
)
{
nodeShape
.
text
case
"center"
:
.
setX
(
_padding
[
3
]
).
setY
(
_padding
[
0
]
+
txtHeight
);
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
)
-
_rectWidth
/
2
,
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
break
;
case
"right"
:
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
)
-
_rectWidth
,
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
break
;
default
:
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
),
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
break
;
}
if
(
km
.
isNodeSelected
(
node
)
)
{
nodeShape
.
NormalInfo
=
new
kity
.
Pen
(
_style
.
stroke
,
_style
.
strokeWidth
);
nodeShape
.
highlight
();
nodeShape
.
rect
.
setWidth
(
_rectWidth
).
setHeight
(
_rectHeight
).
stroke
(
nodeShape
.
NormalInfo
).
fill
(
_style
.
fill
).
setRadius
(
_style
.
radius
);
}
switch
(
node
.
getData
(
"align"
)
)
{
};
case
"center"
:
var
renderNodes
=
function
(
km
,
node
)
{
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
)
-
_rectWidth
/
2
,
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
if
(
node
instanceof
Array
)
{
break
;
if
(
node
.
length
===
0
)
return
false
;
case
"right"
:
for
(
var
i
=
0
;
i
<
node
.
length
;
i
++
)
{
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
)
-
_rectWidth
,
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
renderNode
(
km
,
node
[
i
]
);
break
;
default
:
nodeShape
.
shape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
node
.
getData
(
"x"
),
node
.
getData
(
"y"
)
-
_rectHeight
/
2
)
);
break
;
}
}
return
false
;
}
else
{
if
(
km
.
isNodeSelected
(
node
)
)
{
renderNode
(
km
,
node
);
nodeShape
.
highlight
();
return
true
;
}
}
};
};
var
renderNodes
=
function
(
km
,
node
)
{
var
RenderNodeCommand
=
kity
.
createClass
(
"RenderNodeCommand"
,
(
function
()
{
if
(
node
instanceof
Array
)
{
if
(
node
.
length
===
0
)
return
false
;
for
(
var
i
=
0
;
i
<
node
.
length
;
i
++
)
{
renderNode
(
km
,
node
[
i
]
);
}
}
else
{
renderNode
(
km
,
node
);
}
};
return
{
return
{
base
:
Command
,
base
:
Command
,
execute
:
renderNodes
execute
:
renderNodes
...
@@ -100,16 +96,6 @@ KityMinder.registerModule( "RenderModule", function () {
...
@@ -100,16 +96,6 @@ KityMinder.registerModule( "RenderModule", function () {
},
},
"keydown keyup"
:
function
(
e
)
{
"keydown keyup"
:
function
(
e
)
{
},
"rendernode"
:
function
(
e
)
{
var
nodes
=
e
.
nodes
;
var
rerender
=
e
.
rerender
;
renderNodes
(
this
,
nodes
);
this
.
fire
(
"noderendercomplete"
,
{
node
:
nodes
,
rerender
:
rerender
}
);
}
}
}
}
};
};
...
...
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