nhz.lib
Version:
NHZ Library
219 lines (209 loc) • 5.08 kB
JavaScript
/* mixin.Event */
var Event,
extend = require("extends__"),
hasProp = {}.hasOwnProperty;
module.exports = Event = (function(superClass) {
extend(Event, superClass);
Object.defineProperties(Event, {
CAPTURING_PHASE: {
configurable: false,
enumerable: true,
writable: false,
value: 1
},
BUBBLING_PHASE: {
configurable: false,
enumerable: true,
writable: false,
value: 3
},
DEFAULT_TYPE: {
configurable: false,
enumerable: true,
writable: false,
value: 'event'
}
});
function Event(type) {
var date, perf, timestamp;
if (type == null) {
type = Event.DEFAULT_TYPE;
}
date = Date.now();
perf = (typeof performance !== "undefined" && performance !== null ? performance.now() : void 0) || 0;
timestamp = 1000 * date + Math.floor(1000 * (perf - Math.floor(perf)));
Object.defineProperties(this, {
___is_event: {
configurable: false,
enumerable: false,
writable: false,
value: true
},
___type: {
configurable: false,
enumerable: false,
writable: true,
value: type
},
___timestamp: {
configurable: false,
enumerable: false,
writable: true,
value: timestamp
},
___source: {
configurable: false,
enumerable: false,
writable: true,
value: null
},
___target: {
configurable: false,
enumerable: false,
writable: true,
value: null
},
___phase: {
configurable: false,
enumerable: false,
writable: true,
value: null
},
___canceled: {
configurable: false,
enumerable: false,
writable: true,
value: false
},
___stopped: {
configurable: false,
enumerable: false,
writable: true,
value: false
},
___stopped_immediate: {
configurable: false,
enumerable: false,
writable: true,
value: false
},
___callback: {
configurable: false,
enumerable: false,
writable: true,
value: null
},
type: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___type;
};
})(this)
},
timestamp: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___timestamp;
};
})(this)
},
source: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___source;
};
})(this),
set: function(value) {
if ((!this.___source) && (value != null ? value.___is_event_source : void 0)) {
return this.___source = value;
}
}
},
target: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___target;
};
})(this),
set: function(value) {
if ((!this.___target) && (value != null ? value.___is_event_target : void 0)) {
return this.___target = value;
}
}
},
phase: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___phase;
};
})(this)
},
canceled: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___canceled;
};
})(this)
},
stopped: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___stopped;
};
})(this)
},
stoppedImmediate: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___stopped_immediate;
};
})(this)
},
callback: {
configurable: true,
enumerable: true,
get: (function(_this) {
return function() {
return _this.___callback;
};
})(this),
set: (function(_this) {
return function(value) {
if ((!_this.___callback) && typeof value === 'function') {
return _this.___callback = value;
}
};
})(this)
}
});
}
Event.prototype.cancel = function() {
this.___canceled = true;
return this;
};
Event.prototype.stop = function() {
this.___stopped = true;
return this;
};
Event.prototype.stopImmediate = function() {
this.___stopped_immediate = true;
return this;
};
return Event;
})(require('./base'));