text: // Generated by CoffeeScript 1.9.3
  
  /*
  Copyright (c) 2012-2013 [DeftJS Framework Contributors](http://deftjs.org)
  Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
   */
  
  /**
  * Event listener for events fired via the Deft.event.LiveEventBus.
  * @private
   */
  Ext.define('Deft.event.LiveEventListener', {
    alternateClassName: ['Deft.LiveEventListener'],
    requires: ['Ext.ComponentQuery'],
    constructor: function(config) {
      var component, components, i, len;
      Ext.apply(this, config);
      this.components = [];
      components = Ext.ComponentQuery.query(this.selector, this.container);
      for (i = 0, len = components.length; i < len; i++) {
        component = components[i];
        this.components.push(component);
        component.on(this.eventName, this.fn, this.scope, this.options);
      }
    },
    destroy: function() {
      var component, i, len, ref;
      ref = this.components;
      for (i = 0, len = ref.length; i < len; i++) {
        component = ref[i];
        component.un(this.eventName, this.fn, this.scope);
      }
      this.components = null;
    },
    register: function(component) {
      if (this.matches(component)) {
        this.components.push(component);
        component.on(this.eventName, this.fn, this.scope, this.options);
      }
    },
    unregister: function(component) {
      var index;
      index = Ext.Array.indexOf(this.components, component);
      if (index !== -1) {
        component.un(this.eventName, this.fn, this.scope);
        Ext.Array.erase(this.components, index, 1);
      }
    },
    matches: function(component) {
      if (this.selector === null && this.container === component) {
        return true;
      }
      if (this.container === null && Ext.Array.contains(Ext.ComponentQuery.query(this.selector), component)) {
        return true;
      }
      if (component.isDescendantOf(this.container) && Ext.Array.contains(this.container.query(this.selector), component)) {
        return true;
      }
      return false;
    }
  });
  