2016-04-07 19:03:49 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-13 20:11:17 +02:00
|
|
|
class EventTarget {
|
|
|
|
constructor() {
|
|
|
|
this.eventTarget = document.createDocumentFragment();
|
|
|
|
for (let method of [
|
|
|
|
'addEventListener',
|
|
|
|
'dispatchEvent',
|
|
|
|
'removeEventListener'
|
|
|
|
]) {
|
|
|
|
this[method] = this.eventTarget[method].bind(this.eventTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-17 20:25:44 +02:00
|
|
|
function proxyEvent(source, target, sourceEventType, targetEventType) {
|
2016-08-23 22:04:18 +02:00
|
|
|
if (!source.addEventListener) {
|
|
|
|
return;
|
|
|
|
}
|
2016-06-17 20:25:44 +02:00
|
|
|
if (!targetEventType) {
|
|
|
|
targetEventType = sourceEventType;
|
|
|
|
}
|
|
|
|
source.addEventListener(sourceEventType, e => {
|
|
|
|
target.dispatchEvent(new CustomEvent(targetEventType, {
|
|
|
|
detail: e.detail,
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-07 19:03:49 +02:00
|
|
|
module.exports = {
|
2016-05-11 21:29:57 +02:00
|
|
|
Success: 'success',
|
|
|
|
Error: 'error',
|
|
|
|
Info: 'info',
|
2016-04-07 19:03:49 +02:00
|
|
|
|
2016-06-17 20:25:44 +02:00
|
|
|
proxyEvent: proxyEvent,
|
2016-06-13 20:11:17 +02:00
|
|
|
EventTarget: EventTarget,
|
2016-04-07 19:03:49 +02:00
|
|
|
};
|