home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil7320CA93A97D36234D783AE8B4A0EB0A < prev    next >
Text File  |  2010-07-12  |  771b  |  33 lines

  1. XB.UI.EventListener = function(element, type, listener, capture, context) {
  2.     this.element = element;
  3.     this.type = type;
  4.     this.capture = capture;
  5.     this.status = false;
  6.     
  7.     if (context)
  8.         this.handler = function(e) {
  9.             listener.call(context, e);
  10.         }
  11.     else
  12.         this.handler = listener;
  13.     
  14.     this.enable();
  15. }
  16.  
  17. XB.UI.EventListener.prototype = {
  18.     enable: function() {
  19.         this.assign(1);
  20.     },
  21.     
  22.     disable: function() {
  23.         this.assign(0);
  24.     },
  25.     
  26.     assign: function(b) {
  27.         if (b == this.status)
  28.             return;
  29.         
  30.         this.status = b;
  31.         this.element[b ? "addEventListener" : "removeEventListener"](this.type, this.handler, this.capture);
  32.     }
  33. }