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
4b1bae5e
Commit
4b1bae5e
authored
Jan 06, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
e37d42d1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
22 deletions
+145
-22
keyboard.html
keyboard.html
+96
-0
minder.command.js
src/core/minder.command.js
+42
-20
minder.js
src/core/minder.js
+1
-0
keyboard.js
src/module/keyboard.js
+6
-2
No files found.
keyboard.html
0 → 100644
View file @
4b1bae5e
<!DOCTYPE html>
<html>
<head>
<script
src=
"../kity/dist/kitygraph.all.js"
></script>
<script
src=
"../dist/dev.php"
></script>
</head>
<body
style=
"background:#262626; margin:0; padding:0"
>
</body>
<script>
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
minderHeight
=
document
.
body
.
clientHeight
;
var
_node
=
minder
.
getRoot
();
_node
.
data
=
{
centerX
:
minderWidth
/
2
,
centerY
:
minderHeight
/
2
,
style
:{
radius
:
10
,
fill
:
"orange"
,
stroke
:
"orange"
,
color
:
"black"
,
padding
:[
10
,
10
,
10
,
10
],
fontSize
:
20
},
text
:
"I am the root"
,
};
minder
.
select
(
_node
);
// var _childnode = new MinderNode();
// _node.insertChild(_childnode);
// _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>
</html>
\ No newline at end of file
src/core/minder.command.js
View file @
4b1bae5e
...
...
@@ -18,6 +18,43 @@ kity.extendClass( Minder, {
return
0
;
}
},
_initCommandStack
:
function
()
{
this
.
_commandStack
=
[];
},
_pushCommandStack
:
function
(
command
)
{
this
.
_commandStack
.
push
(
command
);
},
_popCommandStack
:
function
()
{
this
.
_commandStack
.
pop
();
},
getCommandStack
:
function
()
{
// 返回副本防止被修改
return
this
.
_commandStack
.
slice
(
0
);
},
getExecutingCommand
:
function
()
{
return
this
.
_commandStack
[
this
.
_commandStack
.
length
-
1
];
},
getTopExecutingCommand
:
function
()
{
return
this
.
_commandStack
[
0
];
},
isTopCommandExecuting
:
function
()
{
return
this
.
_commandStack
.
length
==
1
;
},
queryCommandState
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"State"
);
},
queryCommandValue
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"Value"
);
},
execCommand
:
function
(
name
)
{
var
TargetCommand
,
command
,
cmdArgs
,
eventParams
,
stoped
,
isTopCommand
,
result
;
var
me
=
this
;
...
...
@@ -29,6 +66,8 @@ kity.extendClass( Minder, {
command
=
new
TargetCommand
();
this
.
_pushCommandStack
(
command
);
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
console
.
log
(
cmdArgs
);
...
...
@@ -38,13 +77,6 @@ kity.extendClass( Minder, {
commandArgs
:
cmdArgs
};
if
(
!
this
.
_executingCommand
)
{
this
.
_executingCommand
=
command
;
isTopCommand
=
true
;
}
else
{
isTopCommand
=
false
;
}
stoped
=
this
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
true
)
);
if
(
!
stoped
)
{
...
...
@@ -54,7 +86,7 @@ kity.extendClass( Minder, {
this
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
// 顶级命令才触发事件
if
(
isTopCommand
)
{
if
(
this
.
isTopCommandExecuting
()
)
{
if
(
command
.
isContentChanged
()
)
{
this
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
}
...
...
@@ -65,19 +97,9 @@ kity.extendClass( Minder, {
}
}
// 顶级事件执行完毕才能清楚顶级事件的执行标记
if
(
isTopCommand
)
{
this
.
_executingCommand
=
null
;
}
return
result
||
null
;
},
queryCommandState
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"State"
);
},
this
.
_commandStack
.
pop
();
queryCommandValue
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"Value"
);
return
result
||
null
;
}
}
);
\ No newline at end of file
src/core/minder.js
View file @
4b1bae5e
...
...
@@ -16,6 +16,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_options
=
Utils
.
extend
(
window
.
KITYMINDER_CONFIG
||
{},
MinderDefaultOptions
,
options
);
this
.
_initEvents
();
this
.
_initMinder
();
this
.
_initCommandStack
();
this
.
_initModules
();
},
...
...
src/module/keyboard.js
View file @
4b1bae5e
...
...
@@ -49,9 +49,13 @@ KityMinder.registerModule( "KeyboardModule", function () {
var
KBCreateAndEditCommand
=
kity
.
createClass
(
{
base
:
Command
,
execute
:
function
(
km
,
type
,
referNode
)
{
var
node
=
km
.
execCommand
(
'create'
+
type
+
'node'
,
referNode
);
km
.
execCommand
(
'edit
t
ext'
,
node
);
var
node
=
this
.
createdNode
=
km
.
execCommand
(
'create'
+
type
+
'node'
,
referNode
);
km
.
execCommand
(
'edit
T
ext'
,
node
);
this
.
setContentChanged
(
true
);
},
revert
:
function
(
km
)
{
km
.
execCommand
(
'removeNode'
,
this
.
createdNode
);
}
}
);
...
...
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