/*-------------------------------------------------------------------------
Events:
-------------------------------------------------------------------------
427101
public function getExampleFormMarkup()
    {
        $label = Widget::Label($this->get('label'));
        $label->appendChild(Widget::Textarea('fields['.$this->get('element_name').']', (int)$this->get('size'), 50));

        return $label;
    }
1196585
static private function bindEventListenersEvents()
    {
    	if (self::$_eventListeners && !self::$_elInstances) {
    		foreach (self::$_eventListeners as $class => $listeners) {
    			if ($listeners) foreach ($listeners as $listener) {
    				
    				$listener = self::getListener($listener);
    				
    				$events = $listener->events();
    				
    				if ($events) foreach ($events as $name => $handler) {
    					Event::on($class, $name, is_string($handler) ? [$listener, $handler] : $handler);
    				}
    			}
    		}
    	}
    }
146897
function on (el, event, handler) {
  if (el.addEventListener) {
    el.addEventListener(event, handler)
  } else {
    el.attachEvent('on' + event, function () {
      handler.call(el)
    })
  }
}
823178
function(el, type, event) {
  if (!el) {
    // emit for ALL elements
    el = document.getElementsByTagName('*');
    var i = el.length;
    while (i--) if (el[i].nodeType === 1) {
      emit(el[i], type, event);
    }
    return;
  }

  event = event || {};
  event.target = event.target || el;
  event.type = event.type || type;

  // simulate bubbling
  while (el) {
    var data = DOM.getData(el, 'events')
      , handle = data && data[type];

    if (handle) {
      event.currentTarget = el;
      var ret = handle.call(el, event);
      if (ret === false || event.cancelBubble) break;
    }

    el = el.parentNode 
      || el.ownerDocument
      || el.defaultView 
      || el.parentWindow;
  }
}
911628
@Override
    public void onBrowserEvent(final Event event) {
        switch (DOM.eventGetType(event)) {
            case Event.ONDBLCLICK:
            case Event.ONFOCUS:
            case Event.ONCLICK:
                if (!isEnabled()) {
                    return;
                }
                break;
        }
        super.onBrowserEvent(event);
    }
735879
function EventListener(el, context) {
    this.context = context || null;

    this.el = el;

    this.events = {};

    this._onEvent = this._onEvent.bind(this);
}
304985
function onActivateEvent() {
         if (this.animatedTilesets === undefined) {
           this.animatedTilesets = [];
         }

         if (this.tilesets) {
           var tileset = this.tilesets.tilesets;

           for (var i = 0; i < tileset.length; i++) {
             if (tileset[i].isAnimated) {
               this.animatedTilesets.push(tileset[i]);
             }
           }
         }

         this.isAnimated = this.animatedTilesets.length > 0; // Force pre-render off when tileset animation is used

         if (this.isAnimated) {
           this.preRender = false;
         } // Resize the bounding rect


         this.getBounds().resize(this.width, this.height);
       }
234689
function() {
      var updateEventsIsArray = _.isArray(this.updateEvents);
      var updateEventsIsSingleValue = !updateEventsIsArray && (_.isObject(this.updateEvents) || _.isString(this.updateEvents));
      var updateEventsIsUndefined = _.isUndefined(this.updateEvents);
      var updateEventsIsValidType = updateEventsIsArray || updateEventsIsSingleValue || updateEventsIsUndefined;

      if (updateEventsIsSingleValue) {
        this.updateEvents = [this.updateEvents];
      }

      if (!updateEventsIsValidType) {
        throw new Error('Update events are not an array, string or object.  Please see parameters for examples of how to define updateEvents.  Configured UpdateEvents: ', this.updateEvents);
      }

      // Remove any random falsey values (mostly to get rid of undefined events).
      this.updateEvents = _.compact(this.updateEvents);
      _.each(this.updateEvents, this.__validUpdateEvent);
    }
23222
function fireWindowResizeEvent(event) {
        frameIsRequested = false;
        if (!componentInformation) {
            return;
        }
        var handlerResults = [];
        componentInformation.forEach(function (componentInformation, i) {
            // Skip if the component is not running anymore
            if (componentInformation.component._stopped) {
                return;
            }
            componentInformation.selectors.forEach(function (selector) {
                return selector.forEach(function (handler) {
                    return handlerResults.push(handler.call(componentInformation.component, event));
                });
            });
        });
        handlerResults.forEach(function (handlerResult) {
            if (typeof handlerResult === "function") {
                handlerResult();
            }
        });
    }
682623
function() {
        this.cal.beforeRenderNavEvent.fire();
        if (!this.__rendered) {
            this.createNav();
            this.createMask();
            this.applyListeners();
            this.__rendered = true;
        }
        this.cal.renderNavEvent.fire();
    }
79983
function (eventName, data) {
      if (document.createEvent) {
        var evt = document.createEvent('HTMLEvents');
        evt.initEvent(eventName, true, false);
        evt = this.extend(evt, data);
        return this.each(function (v) {
          return v.dispatchEvent(evt);
        });
      }
    }
1345696
function() {
        var html = this.root.getHtml(),
            el = this.getEl();
        el.innerHTML = html;
        if (!this._hasEvents) {
            Event.on(el, 'click', this._onClickEvent, this, true);
            Event.on(el, 'dblclick', this._onDblClickEvent, this, true);
            Event.on(el, 'mouseover', this._onMouseOverEvent, this, true);
            Event.on(el, 'mouseout', this._onMouseOutEvent, this, true);
            Event.on(el, 'keydown', this._onKeyDownEvent, this, true);
        }
        this._hasEvents = true;
    }
188556
function () {
        var self = this, settings = self.settings, elm, box, parent, name, parentEventsRoot;

        self.$el = $(self.getEl());
        self.state.set('rendered', true);

        // Bind on<event> settings
        for (name in settings) {
          if (name.indexOf("on") === 0) {
            self.on(name.substr(2), settings[name]);
          }
        }

        if (self._eventsRoot) {
          for (parent = self.parent(); !parentEventsRoot && parent; parent = parent.parent()) {
            parentEventsRoot = parent._eventsRoot;
          }

          if (parentEventsRoot) {
            for (name in parentEventsRoot._nativeEvents) {
              self._nativeEvents[name] = true;
            }
          }
        }

        bindPendingEvents(self);

        if (settings.style) {
          elm = self.getEl();
          if (elm) {
            elm.setAttribute('style', settings.style);
            elm.style.cssText = settings.style;
          }
        }

        if (self.settings.border) {
          box = self.borderBox;
          self.$el.css({
            'border-top-width': box.top,
            'border-right-width': box.right,
            'border-bottom-width': box.bottom,
            'border-left-width': box.left
          });
        }

        // Add instance to lookup
        var root = self.getRoot();
        if (!root.controlIdLookup) {
          root.controlIdLookup = {};
        }

        root.controlIdLookup[self._id] = self;

        for (var key in self._aria) {
          self.aria(key, self._aria[key]);
        }

        if (self.state.get('visible') === false) {
          self.getEl().style.display = 'none';
        }

        self.bindStates();

        self.state.on('change:visible', function (e) {
          var state = e.value, parentCtrl;

          if (self.state.get('rendered')) {
            self.getEl().style.display = state === false ? 'none' : '';

            // Need to force a reflow here on IE 8
            self.getEl().getBoundingClientRect();
          }

          // Parent container needs to reflow
          parentCtrl = self.parent();
          if (parentCtrl) {
            parentCtrl._lastRect = null;
          }

          self.fire(state ? 'show' : 'hide');

          ReflowQueue.add(self);
        });

        self.fire('postrender', {}, false);
      }
526440
function _onLoadEventFired(event, res) {
        // res = {timestamp}
        Inspector.DOM.getDocument(function onGetDocument(res) {
            exports.trigger("getDocument", res);
            // res = {root}
            _idToNode = {};
            _pendingRequests = 0;
            exports.root = new DOMNode(exports, res.root);
        });
    }
983567
@Override
    public void onPluginEvent(PluginEvent event) {
        ElementPlugin plugin = event.getPlugin();
        
        switch (event.getAction()) {
            case SUBSCRIBE:
                init();
                plugins.add(plugin);
                plugin.setDisabled(isDisabled());
                break;
            
            case UNSUBSCRIBE:
                plugins.remove(plugin);
                plugin.setDisabled(false);
                break;
        }
    }
125918
function(event, context, callback, selector) {
        var options = this.options;

        // Replace tokens
        if (event === '{mode}') {
            event = options.mode;
        }

        if (selector === '{selector}') {
            selector = this.nodes ? this.nodes.selector : '';
        }

        // Find and bind the function
        if ($.type(callback) === 'string') {
            callback = this[callback].bind(this);
        }

        this.__events.push([event, context, callback, selector]);
    }
887533
function() {
		/** All events from last tick */
		var pendingEvents = this._annotationChangedContext.events;
		var pendingLocations = this._annotationChangedContext.locations;
		var pendingModels = this._annotationChangedContext.textModels;
		/** All unique events from last tick */
		var handlingEvents = [];
		var handlingLocations = [];
		var handlingModels = [];
		// Cleanup
		this._annotationChangedContext.timeout = undefined;
		this._annotationChangedContext.events = [];
		this._annotationChangedContext.locations = [];
		// Remove duplicate events
		for (var i = 0; i < pendingEvents.length; i++) {
			var duplicate = false;
			for (var j = 0; j < i; j++) {
				if (pendingEvents[i].textModelChangedEvent === pendingEvents[j].textModelChangedEvent) {
					duplicate = true;
				}
				break;
			}
			if (!duplicate) {
				handlingEvents.push(pendingEvents[i]);
				handlingLocations.push(pendingLocations[i]);
				handlingModels.push(pendingModels[i]);
			}
		}

		// Handle
		for (i = 0; i < handlingEvents.length; i++) {
			var e = handlingEvents[i];
			for (j = 0; j < e.changed.length; j++) {
				var annotation = e.changed[j];
				var location = handlingLocations[i];
				var oldLine;
				var newLine = handlingModels[i].getLineAtOffset(annotation.start);
				if (annotation._oldStart > e.textModelChangedEvent.start) {
					oldLine = newLine - e.textModelChangedEvent.addedLineCount + e.textModelChangedEvent.removedLineCount;
				} else {
					oldLine = handlingModels[i].getLineAtOffset(annotation._oldStart);
				}
				var before = null;
				var after = null;
				if (annotation.type === AT.ANNOTATION_BOOKMARK) {
					before = new mBreakpoint.LineBookmark(location, oldLine, annotation.title);
					after = new mBreakpoint.LineBookmark(location, newLine, annotation.title);
				} else if (annotation.type === AT.ANNOTATION_BREAKPOINT) {
					before = new mBreakpoint.LineBreakpoint(location, oldLine, annotation.title, true);
					after = new mBreakpoint.LineBreakpoint(location, newLine, annotation.title, true);
				} else if (annotation.type === AT.ANNOTATION_CONDITIONAL_BREAKPOINT) {
					before = new mBreakpoint.LineConditionalBreakpoint(location, oldLine, annotation.title, annotation.title, true);
					after = new mBreakpoint.LineConditionalBreakpoint(location, newLine, annotation.title, annotation.title, true);
				}
				if (before && after) {
					this.debugService.updateBreakpoint(before, after, true);
				}
			}
		}
	}