| 1 |
"use strict"; |
| 2 |
module.exports = Event; |
| 3 |
|
| 4 |
Event.CAPTURING_PHASE = 1; |
| 5 |
Event.AT_TARGET = 2; |
| 6 |
Event.BUBBLING_PHASE = 3; |
| 7 |
|
| 8 |
function Event(type, dictionary) { |
| 9 |
|
| 10 |
this.type = ''; |
| 11 |
this.target = null; |
| 12 |
this.currentTarget = null; |
| 13 |
this.eventPhase = Event.AT_TARGET; |
| 14 |
this.bubbles = false; |
| 15 |
this.cancelable = false; |
| 16 |
this.isTrusted = false; |
| 17 |
this.defaultPrevented = false; |
| 18 |
this.timeStamp = Date.now(); |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
this._propagationStopped = false; |
| 23 |
this._immediatePropagationStopped = false; |
| 24 |
this._initialized = true; |
| 25 |
this._dispatching = false; |
| 26 |
|
| 27 |
|
| 28 |
if (type) this.type = type; |
| 29 |
if (dictionary) { |
| 30 |
for(var p in dictionary) { |
| 31 |
this[p] = dictionary[p]; |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
Event.prototype = Object.create(Object.prototype, { |
| 37 |
constructor: { value: Event }, |
| 38 |
stopPropagation: { value: function stopPropagation() { |
| 39 |
this._propagationStopped = true; |
| 40 |
}}, |
| 41 |
|
| 42 |
stopImmediatePropagation: { value: function stopImmediatePropagation() { |
| 43 |
this._propagationStopped = true; |
| 44 |
this._immediatePropagationStopped = true; |
| 45 |
}}, |
| 46 |
|
| 47 |
preventDefault: { value: function preventDefault() { |
| 48 |
if (this.cancelable) this.defaultPrevented = true; |
| 49 |
}}, |
| 50 |
|
| 51 |
initEvent: { value: function initEvent(type, bubbles, cancelable) { |
| 52 |
this._initialized = true; |
| 53 |
if (this._dispatching) return; |
| 54 |
|
| 55 |
this._propagationStopped = false; |
| 56 |
this._immediatePropagationStopped = false; |
| 57 |
this.defaultPrevented = false; |
| 58 |
this.isTrusted = false; |
| 59 |
|
| 60 |
this.target = null; |
| 61 |
this.type = type; |
| 62 |
this.bubbles = bubbles; |
| 63 |
this.cancelable = cancelable; |
| 64 |
}}, |
| 65 |
|
| 66 |
}); |