Open-source IoT Platform - Device management, data collection, processing and visualization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.0 KiB

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
once: function once(el, type, callback) {
var typeArray = type ? type.split(' ') : [];
var recursiveFunction = function recursiveFunction(event) {
event.target.removeEventListener(event.type, recursiveFunction);
return callback(event);
};
for (var i = typeArray.length - 1; i >= 0; i--) {
this.on(el, typeArray[i], recursiveFunction);
}
},
on: function on(el, type, callback) {
if (el.addEventListener) {
el.addEventListener(type, callback);
} else {
// IE8+ Support
el.attachEvent('on' + type, function () {
callback.call(el);
});
}
},
off: function off(el, type, callback) {
if (el.removeEventListener) {
el.removeEventListener(type, callback);
} else {
// IE8+ Support
el.detachEvent('on' + type, callback);
}
},
isKeyboard: function isKeyboard(event) {
return ['keydown', 'keypress', 'keyup'].indexOf(event.type) !== -1;
}
};