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
d35bab8f
Commit
d35bab8f
authored
Feb 10, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
beee354a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
118 deletions
+0
-118
_example.js
src/module/_example.js
+0
-118
No files found.
src/module/_example.js
deleted
100644 → 0
View file @
beee354a
/**
* 模块初始化函数:模块名称大写,以 Module 作为后缀
*/
KityMinder
.
registerModule
(
"ExampleModule"
,
function
()
{
//console.log( "You can cheat: 上下左右ABAB" );
// TODO: 初始化模块静态变量
var
cheatCode
=
"38 40 37 39 65 66 65 66"
.
split
(
' '
);
// TODO: 进行模块命令定义
// HINT: 复杂的命令也可以在其它的文件中定义
var
ExampleCommand
=
kity
.
createClass
(
"ExampleCommand"
,
{
base
:
Command
,
/**
* 命令执行函数
* @required
* @param {KityMinder} km 命令执行时的 KityMinder 实例
*/
execute
:
function
(
km
)
{
// this.setContentChange(true) 可以告知 KM 命令的执行导致了内容的变化,KM会抛出 contentchange 事件
// this.setSelectionChange(true) 可以告知 KM 命令的执行导致了选区的变化,KM会抛出 selectionchange 事件
window
.
alert
(
'you cheat!'
);
},
/**
* 命令状态查询
* @optional
* @param {KityMinder} km 命令查询针对的 KityMinder 实例
* @return {int} 返回 0 表示命令在正常状态(Default)
* 返回 1 表示命令在生效的状态
* 返回 -1 表示命令当前不可用
*/
queryState
:
function
(
km
)
{
},
/**
* 命令当前值查询
* @param {KityMinder} km 命令查询针对的 KityMinder 实例
* @return {any} 返回命令自定义类型数据。
*/
queryValue
:
function
(
km
)
{
}
}
);
return
{
// TODO: 默认属性
"defaultOptions"
:
{
"test"
:
123
},
// TODO: 初始化完成后执行的函数
"init"
:
function
(
config
)
{
// console.log( "init", config );
},
// TODO: 需要注册的命令
"commands"
:
{
// 约定:命令名称全用小写
"cheat"
:
ExampleCommand
},
// TODO: 需要注册的事件
"events"
:
{
"click"
:
function
(
e
)
{
// 支持的鼠标事件:mousedown, mouseup, mousemove, click
},
"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'
);
}
},
"beforeExecCommand"
:
function
(
e
)
{
// e.cancel() 方法可以阻止 before 事件进入下个阶段
// e.cancelImmediately() 方法可以阻止当前回调后的回调执行,并且阻止事件进入下个阶段
console
.
log
(
e
.
type
+
' fired'
);
e
.
stopPropagation
();
},
"preExecCommand"
:
function
(
e
)
{
// 命令执行后的事件
console
.
log
(
e
.
type
+
' fired'
);
},
"contentchange"
:
function
(
e
)
{
// 内容改变后的事件
},
"selectionchange"
:
function
(
e
)
{
// 选区改变后的事件
}
},
// TODO: 定义模块的destroy方法
"destroy"
:
function
()
{
console
.
log
(
"destroy"
);
},
// TODO: 定义模块的reset方法
"reset"
:
function
()
{
console
.
log
(
"reset"
);
}
};
}
);
\ No newline at end of file
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