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
65b73774
Commit
65b73774
authored
Dec 20, 2013
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Module Example
parent
8402f4c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
25 deletions
+28
-25
dev.html
demo/dev.html
+1
-19
dev.php
dist/dev.php
+10
-2
_example.js
src/module/_example.js
+17
-3
render.js
src/module/render.js
+0
-1
No files found.
demo/dev.html
View file @
65b73774
...
...
@@ -9,23 +9,8 @@
</body>
<script>
var
minder
=
new
km
.
KityMinder
();
minder
=
new
km
.
KityMinder
();
function
allEvent
()
{
var
events
=
'click mousedown mouseup keydown keyup keypress dblclick interactchange contentchange selectionchange import'
.
split
(
' '
);
var
pharseEvents
=
[];
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
pharseEvents
.
push
(
'before'
+
events
[
i
]);
pharseEvents
.
push
(
'pre'
+
events
[
i
]);
pharseEvents
.
push
(
events
[
i
]);
}
return
pharseEvents
.
join
(
' '
);
}
minder
.
on
(
allEvent
(),
function
(
e
)
{
//console.log(e.type, e);
});
minder
.
importData
({
data
:
{
x
:
50
,
...
...
@@ -53,9 +38,6 @@
}]
}]
});
console
.
log
(
minder
);
minder
.
update
();
m
=
minder
;
//console.log(minder.exportData());
</script>
</html>
\ No newline at end of file
dist/dev.php
View file @
65b73774
...
...
@@ -5,12 +5,20 @@ $dependency = Array(
'src/core/command.js'
,
'src/core/mindernode.js'
,
'src/core/minderevent.js'
,
'src/core/kityminder.js'
'src/core/kityminder.js'
,
'src/module/connect.js'
,
'src/module/history.js'
,
'src/module/icon.js'
,
'src/module/keyboard.js'
,
'src/module/layout.js'
,
'src/module/render.js'
,
'src/module/textedit.js'
,
'src/module/_example.js'
);
$content
=
""
;
header
(
'Content-Type: text/javascript'
);
header
(
'Content-Type: text/javascript
; charset=utf-8
'
);
foreach
(
$dependency
as
$index
=>
$dep
)
{
echo
file_get_contents
(
"../
$dep
"
)
.
"
\n\n
"
;
...
...
src/module/_example.js
View file @
65b73774
...
...
@@ -2,9 +2,10 @@
* 模块初始化函数:模块名称大写,以 Module 作为后缀
*/
KityMinder
.
registerModule
(
"ExampleModule"
,
function
()
{
console
.
log
(
"You can cheat: 上下左右ABAB"
);
// TODO: 初始化模块静态变量
var
moduleVar
=
"moduleValue"
;
var
cheatCode
=
"38 40 37 39 65 66 65 66"
.
split
(
' '
)
;
// TODO: 进行模块命令定义
// HINT: 复杂的命令也可以在其它的文件中定义
...
...
@@ -19,6 +20,7 @@ KityMinder.registerModule( "ExampleModule", function () {
execute
:
function
(
km
)
{
// this.setContentChange(true) 可以告知 KM 命令的执行导致了内容的变化,KM会抛出 contentchange 事件
// this.setSelectionChange(true) 可以告知 KM 命令的执行导致了选区的变化,KM会抛出 selectionchange 事件
window
.
alert
(
'you cheat!'
);
},
/**
...
...
@@ -49,7 +51,7 @@ KityMinder.registerModule( "ExampleModule", function () {
"commands"
:
{
// 约定:命令名称全用小写
"
example
"
:
ExampleCommand
"
cheat
"
:
ExampleCommand
},
// TODO: 需要注册的事件
...
...
@@ -59,17 +61,29 @@ KityMinder.registerModule( "ExampleModule", function () {
// 支持的鼠标事件:mousedown, mouseup, mousemove, click
},
"keydown
keyup
"
:
function
(
e
)
{
"keydown"
:
function
(
e
)
{
// 支持的键盘事件:keydown, keyup, keypress
if
(
!
this
.
_cheated
||
this
.
_cheated
[
0
]
!=
e
.
keyCode
)
{
this
.
_cheated
=
cheatCode
.
slice
(
0
);
}
if
(
this
.
_cheated
[
0
]
==
e
.
keyCode
)
{
this
.
_cheated
.
shift
();
}
console
.
log
(
this
.
_cheated
);
if
(
this
.
_cheated
.
length
===
0
)
{
this
.
execCommand
(
'cheat'
);
}
},
"beforecommand"
:
function
(
e
)
{
// e.cancel() 方法可以阻止 before 事件进入下个阶段
// e.cancelImmediately() 方法可以阻止当前回调后的回调执行,并且阻止事件进入下个阶段
console
.
log
(
e
.
type
+
' fired'
);
},
"command"
:
function
(
e
)
{
// 命令执行后的事件
console
.
log
(
e
.
type
+
' fired'
);
},
"contentchange"
:
function
(
e
)
{
...
...
src/module/render.js
View file @
65b73774
KityMinder
.
registerModule
(
"RenderModule"
,
function
()
{
console
.
log
(
"render loaded"
);
var
DrawShapeCommand
=
kity
.
createClass
(
"DrawShapeCommand"
,
{
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