mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 10:09:04 +00:00
feature(events) Util.slice -> [].slice, Util.check -> check, Util.type -> type
This commit is contained in:
parent
7eca5063d2
commit
c26032f088
1 changed files with 15 additions and 12 deletions
|
|
@ -10,11 +10,14 @@ var Util, DOM;
|
|||
function EventsProto() {
|
||||
var Events = this,
|
||||
|
||||
Type = Util.type,
|
||||
check = Util.check,
|
||||
|
||||
parseArgs = function(eventName, element, listener, callback) {
|
||||
var isFunc, isElement, error,
|
||||
EVENT_NAME = 0,
|
||||
ELEMENT = 1,
|
||||
type = Util.type(eventName);
|
||||
type = Type(eventName);
|
||||
|
||||
switch(type) {
|
||||
default:
|
||||
|
|
@ -37,7 +40,7 @@ var Util, DOM;
|
|||
break;
|
||||
|
||||
case 'string':
|
||||
isFunc = Util.type.function(element);
|
||||
isFunc = Type.function(element);
|
||||
|
||||
if (isFunc) {
|
||||
listener = element;
|
||||
|
|
@ -89,7 +92,7 @@ var Util, DOM;
|
|||
* @param listener
|
||||
*/
|
||||
this.add = function(type, element, listener) {
|
||||
Util.check(arguments, ['type']);
|
||||
check(arguments, ['type']);
|
||||
|
||||
parseArgs(type, element, listener, function(element, args) {
|
||||
element.addEventListener.apply(element, args);
|
||||
|
|
@ -129,7 +132,7 @@ var Util, DOM;
|
|||
* @param element {document by default}
|
||||
*/
|
||||
this.remove = function(type, element, listener) {
|
||||
Util.check(arguments, ['type']);
|
||||
check(arguments, ['type']);
|
||||
|
||||
parseArgs(type, element, listener, function(element, args) {
|
||||
element.removeEventListener.apply(element, args);
|
||||
|
|
@ -145,7 +148,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.addKey = function() {
|
||||
var name = 'keydown',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.add.apply(this, args);
|
||||
|
|
@ -158,7 +161,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.rmKey = function() {
|
||||
var name = 'keydown',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.remove.apply(this, args);
|
||||
|
|
@ -171,7 +174,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.addClick = function() {
|
||||
var name = 'click',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.add.apply(this, args);
|
||||
|
|
@ -184,7 +187,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.rmClick = function() {
|
||||
var name = 'click',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.remove.apply(this, args);
|
||||
|
|
@ -192,7 +195,7 @@ var Util, DOM;
|
|||
|
||||
this.addContextMenu = function() {
|
||||
var name = 'contextmenu',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.add.apply(this, args);
|
||||
|
|
@ -205,7 +208,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.addError = function() {
|
||||
var name = 'error',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.add.apply(this, args);
|
||||
|
|
@ -218,7 +221,7 @@ var Util, DOM;
|
|||
*/
|
||||
this.addLoad = function() {
|
||||
var name = 'load',
|
||||
argsArr = Util.slice(arguments),
|
||||
argsArr = [].slice.call(arguments),
|
||||
args = [name].concat(argsArr);
|
||||
|
||||
return this.add.apply(this, args);
|
||||
|
|
@ -278,7 +281,7 @@ var Util, DOM;
|
|||
* @param pEvent
|
||||
*/
|
||||
this.dispatch = function(event, element) {
|
||||
var isStr = Util.type.string(event);
|
||||
var isStr = Type.string(event);
|
||||
|
||||
if (isStr)
|
||||
event = Events.create(event);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue