src/basis/dom/event.js
function addHandler(node, eventType, handler, thisObject){
    node = getNode(node);

    if (!node)
      throw 'basis.event.addHandler: can\'t attach event listener to undefined';

    if (typeof handler != 'function')
      throw 'basis.event.addHandler: handler is not a function';

    var handlers = node === global ? globalEvents : node[EVENT_HOLDER];

    if (!handlers)
      handlers = node[EVENT_HOLDER] = {};

    var eventTypeHandlers = handlers[eventType];
    var handlerObject = {
      handler: handler,
      thisObject: thisObject
    };

    if (!eventTypeHandlers)
    {
      eventTypeHandlers = handlers[eventType] = [handlerObject];
      eventTypeHandlers.fireEvent = function(event){ // closure
        // simulate capture phase for old browsers
        event = wrap(event);
        if (noCaptureScheme && event && globalHandlers[eventType])
        {
          if (typeof event.returnValue == 'undefined')
          {
            observeGlobalEvents(event);
            if (event.cancelBubble === true)
              return;
            if (typeof event.returnValue == 'undefined')
              event.returnValue = true;
          }
        }

        startFrame(event);

        // call eventType handlers
        for (var i = 0, wrappedEvent = new Event(event), item; item = eventTypeHandlers[i++];)
          item.handler.call(item.thisObject, wrappedEvent);

        finishFrame(event);
      };

      if (W3CSUPPORT)
        // W3C DOM event model
        node.addEventListener(eventType, eventTypeHandlers.fireEvent, false);
      else
        // old IE event model
        node.attachEvent('on' + eventType, eventTypeHandlers.fireEvent);
    }
    else
    {
      // check for duplicates, exit if found
      for (var i = 0, item; item = eventTypeHandlers[i]; i++)
        if (item.handler === handler && item.thisObject === thisObject)
          return;

      // add only unique handlers
      eventTypeHandlers.push(handlerObject);
    }
  }
function addHandler(node, eventType, handler, thisObject){
    node = getNode(node);

    if (!node)
      throw 'basis.event.addHandler: can\'t attach event listener to undefined';

    if (typeof handler != 'function')
      throw 'basis.event.addHandler: handler is not a function';

    var handlers = node === global ? globalEvents : node[EVENT_HOLDER];

    if (!handlers)
      handlers = node[EVENT_HOLDER] = {};

    var eventTypeHandlers = handlers[eventType];
    var handlerObject = {
      handler: handler,
      thisObject: thisObject
    };

    if (!eventTypeHandlers)
    {
      eventTypeHandlers = handlers[eventType] = [handlerObject];
      eventTypeHandlers.fireEvent = function(event){ // closure
        // simulate capture phase for old browsers
        event = wrap(event);
        if (noCaptureScheme && event && globalHandlers[eventType])
        {
          if (typeof event.returnValue == 'undefined')
          {
            observeGlobalEvents(event);
            if (event.cancelBubble === true)
              return;
            if (typeof event.returnValue == 'undefined')
              event.returnValue = true;
          }
        }

        startFrame(event);

        // call eventType handlers
        for (var i = 0, wrappedEvent = new Event(event), item; item = eventTypeHandlers[i++];)
          item.handler.call(item.thisObject, wrappedEvent);

        finishFrame(event);
      };

      if (W3CSUPPORT)
        // W3C DOM event model
        node.addEventListener(eventType, eventTypeHandlers.fireEvent, false);
      else
        // old IE event model
        node.attachEvent('on' + eventType, eventTypeHandlers.fireEvent);
    }
    else
    {
      // check for duplicates, exit if found
      for (var i = 0, item; item = eventTypeHandlers[i]; i++)
        if (item.handler === handler && item.thisObject === thisObject)
          return;

      // add only unique handlers
      eventTypeHandlers.push(handlerObject);
    }
  }
function addHandler ( node , eventType , handler , thisObject ) { node = getNode ( node ) ; if ( ! node ) throw 'basis.event.addHandler: can\'t attach event listener to undefined' ; if ( typeof handler != 'function' ) throw 'basis.event.addHandler: handler is not a function' ; var handlers = node === global ? globalEvents : node [ EVENT_HOLDER ] ; if ( ! handlers ) handlers = node [ EVENT_HOLDER ] = { } ; var eventTypeHandlers = handlers [ eventType ] ; var handlerObject = { handler : handler , thisObject : thisObject } ; if ( ! eventTypeHandlers ) { eventTypeHandlers = handlers [ eventType ] = [ handlerObject ] ; eventTypeHandlers . fireEvent = function ( event ) { // closure // simulate capture phase for old browsers event = wrap ( event ) ; if ( noCaptureScheme && event && globalHandlers [ eventType ] ) { if ( typeof event . returnValue == 'undefined' ) { observeGlobalEvents ( event ) ; if ( event . cancelBubble === true ) return ; if ( typeof event . returnValue == 'undefined' ) event . returnValue = true ; } } startFrame ( event ) ; // call eventType handlers for ( var i = 0 , wrappedEvent = new Event ( event ) , item ; item = eventTypeHandlers [ i ++ ] ; ) item . handler . call ( item . thisObject , wrappedEvent ) ; finishFrame ( event ) ; } ; if ( W3CSUPPORT ) // W3C DOM event model node . addEventListener ( eventType , eventTypeHandlers . fireEvent , false ) ; else // old IE event model node . attachEvent ( 'on' + eventType , eventTypeHandlers . fireEvent ) ; } else { // check for duplicates, exit if found for ( var i = 0 , item ; item = eventTypeHandlers [ i ] ; i ++ ) if ( item . handler === handler && item . thisObject === thisObject ) return ; // add only unique handlers eventTypeHandlers . push ( handlerObject ) ; } }
common event handlers  
Adds handler for node for eventType events.
@param {Node|Window|string} node
@param {string} eventType
@param {function(event)} handler
@param {object=} thisObject Context for handler
common event handlers Adds handler for node for eventType events .