mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-14 03:22:48 +00:00
Added files
This commit is contained in:
43
mongoui/mongoui-master/node_modules/derby/lib/EventDispatcher.js
generated
vendored
Normal file
43
mongoui/mongoui-master/node_modules/derby/lib/EventDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
function empty() {}
|
||||
|
||||
module.exports = EventDispatcher;
|
||||
|
||||
function EventDispatcher(options) {
|
||||
if (options == null) options = {};
|
||||
this._onTrigger = options.onTrigger || empty;
|
||||
this._onBind = options.onBind || empty;
|
||||
this.clear();
|
||||
}
|
||||
|
||||
EventDispatcher.prototype = {
|
||||
clear: function() {
|
||||
this.names = {};
|
||||
}
|
||||
|
||||
, bind: function(name, listener, arg0) {
|
||||
this._onBind(name, listener, arg0);
|
||||
var names = this.names
|
||||
, obj = names[name] || {};
|
||||
obj[JSON.stringify(listener)] = listener;
|
||||
return names[name] = obj;
|
||||
}
|
||||
|
||||
, trigger: function(name, value, arg0, arg1, arg2, arg3, arg4, arg5) {
|
||||
var names = this.names
|
||||
, listeners = names[name]
|
||||
, onTrigger = this._onTrigger
|
||||
, count = 0
|
||||
, key, listener;
|
||||
for (key in listeners) {
|
||||
listener = listeners[key];
|
||||
count++;
|
||||
if (false !== onTrigger(name, listener, value, arg0, arg1, arg2, arg3, arg4, arg5)) {
|
||||
continue;
|
||||
}
|
||||
delete listeners[key];
|
||||
count--;
|
||||
}
|
||||
if (!count) delete names[name];
|
||||
return count;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user