Browse Source

EventWindow is no longer restricted to window object events only.

dev-tmpl
Bryan Miller 6 years ago
parent
commit
38bf95034b
1 changed files with 7 additions and 8 deletions
  1. +7
    -8
      app/js/ui/EventWindow.js

+ 7
- 8
app/js/ui/EventWindow.js View File

window[eventName] = (function(event){ window[eventName] = (function(event){
this.emit(eventName, event); this.emit(eventName, event);
}).bind(this); }).bind(this);
}
super.listen(eventName, callback, owner, once);
return this;
}
} }
throw new ValueError("Window object has no event named '" + eventName +"'.");
super.listen(eventName, callback, owner, once);
return this;
} }


unlisten(eventName, callback, owner=null){
unlisten(eventName, callback, owner=null){
super.unlisten(eventName, callback, owner);
if (window.hasOwnProperty(eventName)){ if (window.hasOwnProperty(eventName)){
super.unlisten(eventName, callback, owner);
if (super.event_listener_count(eventName) == 0){ if (super.event_listener_count(eventName) == 0){
window[eventName] = undefined; window[eventName] = undefined;
} }
return this; return this;
} }


unlisten_event(eventName){
unlisten_event(eventName){
super.unlisten_event(eventName);
if (window.hasOwnProperty(eventName)){ if (window.hasOwnProperty(eventName)){
super.unlisten_event(eventName);
window[eventName] = undefined; window[eventName] = undefined;
} }
return this; return this;

Loading…
Cancel
Save