home *** CD-ROM | disk | FTP | other *** search
- XB.UI.EventListener = function(element, type, listener, capture, context) {
- this.element = element;
- this.type = type;
- this.capture = capture;
- this.status = false;
-
- if (context)
- this.handler = function(e) {
- listener.call(context, e);
- }
- else
- this.handler = listener;
-
- this.enable();
- }
-
- XB.UI.EventListener.prototype = {
- enable: function() {
- this.assign(1);
- },
-
- disable: function() {
- this.assign(0);
- },
-
- assign: function(b) {
- if (b == this.status)
- return;
-
- this.status = b;
- this.element[b ? "addEventListener" : "removeEventListener"](this.type, this.handler, this.capture);
- }
- }