src/util/events.js
function (evtStr, handler) {
    if (!handler) {
      throw Error('Handler not specified');
    }
    if (!this.eventListeners) {
      this.eventListeners = {};
    }
    var events = evtStr.split(' '), len = events.length, n, event, parts, baseEvent, name;
    /*
     * loop through types and attach event listeners to each one. eg. 'click
     * mouseover.namespace mouseout' will create three event bindings
     */
    for (n = 0; n < len; n++) {
      event = events[n];
      parts = event.split('.');
      baseEvent = parts[0];
      name = parts[1] || '';
      // create events array if it doesn't exist
      if (!this.eventListeners[baseEvent]) {
        this.eventListeners[baseEvent] = [];
      }
      this.eventListeners[baseEvent].push({
        name: name,
        handler: handler
      });
    }
    return this;
  }
function (evtStr, handler) {
    if (!handler) {
      throw Error('Handler not specified');
    }
    if (!this.eventListeners) {
      this.eventListeners = {};
    }
    var events = evtStr.split(' '), len = events.length, n, event, parts, baseEvent, name;
    /*
     * loop through types and attach event listeners to each one. eg. 'click
     * mouseover.namespace mouseout' will create three event bindings
     */
    for (n = 0; n < len; n++) {
      event = events[n];
      parts = event.split('.');
      baseEvent = parts[0];
      name = parts[1] || '';
      // create events array if it doesn't exist
      if (!this.eventListeners[baseEvent]) {
        this.eventListeners[baseEvent] = [];
      }
      this.eventListeners[baseEvent].push({
        name: name,
        handler: handler
      });
    }
    return this;
  }
function ( evtStr , handler ) { if ( ! handler ) { throw Error ( 'Handler not specified' ) ; } if ( ! this . eventListeners ) { this . eventListeners = { } ; } var events = evtStr . split ( ' ' ) , len = events . length , n , event , parts , baseEvent , name ; /*
     * loop through types and attach event listeners to each one. eg. 'click
     * mouseover.namespace mouseout' will create three event bindings
     */ for ( n = 0 ; n < len ; n ++ ) { event = events [ n ] ; parts = event . split ( '.' ) ; baseEvent = parts [ 0 ] ; name = parts [ 1 ] || '' ; // create events array if it doesn't exist if ( ! this . eventListeners [ baseEvent ] ) { this . eventListeners [ baseEvent ] = [ ] ; } this . eventListeners [ baseEvent ] . push ( { name : name , handler : handler } ) ; } return this ; }
Pass in a string of events delimmited by a space to bind multiple events
at once such as 'mousedown mouseup mousemove'. Include a namespace to
bind an event by name such as 'click.foobar'.

@param {String}
evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo
touchstart.foo'
@param {Function}
handler The handler function is passed an event object
Pass in a string of events delimmited by a space to bind multiple events at once such as mousedown mouseup mousemove . Include a namespace to bind an event by name such as click . foobar .