return the right callback to invoke an event stringifying the callback and invoking it to simulate a proper DOM behavior
354983
function updateEvent(value) {
  switch (typeof value) {
    case 'function': return 'return (' + escape(
      JS_SHORTCUT.test(value) && !JS_FUNCTION.test(value) ?
        ('function ' + value) :
        value
    ) + ').call(this, event)';
    case 'object': return '';
    default: return escape(value || '');
  }
}
893795
function delegate(callback, el) {
        var currentElement = el;

        do {
            if (!isClickTarget(currentElement)) continue;
            callback(currentElement);
            return;
        } while(currentElement.nodeName.toUpperCase() !== 'BODY' && (currentElement = currentElement.parentNode));
    }
1125263
function iterateEvents(target, entity, bindings, functionCallback, stringCallback){
    if (!entity || !bindings) { return; }

    // allow the bindings to be a function
    if (_.isFunction(bindings)){
      bindings = bindings.call(target);
    }

    // iterate the bindings and bind them
    _.each(bindings, function(methods, evt){

      // allow for a function as the handler, 
      // or a list of event names as a string
      if (_.isFunction(methods)){
        functionCallback(target, entity, evt, methods);
      } else {
        stringCallback(target, entity, evt, methods);
      }

    });
  }
595757
function dispatchCustomEvent(node, type) {
	const event = document.createEvent('CustomEvent');

	event.initCustomEvent(type, true, true, undefined);

	node.dispatchEvent(event);
}
208777
def callback(event, buffer = nil, start = nil, the_end = nil)
      return if !start.nil? && start == the_end
      if @callbacks.has_key? event
        @callbacks[event].call(buffer, start, the_end)
      end
    end
1187520
function stringify(obj, callback) {
	process.nextTick(function () {
		var str = stringifySync(obj);
		callback(str);
	});
}
1211379
function (eventName) {
        var event = { type: eventName, target: this },
            handlerList = this._eventHandlers && this._eventHandlers[eventName],
            i;

        if (!handlerList) {
            return;
        }

        // Use a clone of the list in case handlers call on()/off() while we're still in the loop
        handlerList = handlerList.slice();

        // Pass 'event' object followed by any additional args trigger() was given
        var applyArgs = Array.prototype.slice.call(arguments, 1);
        applyArgs.unshift(event);

        for (i = 0; i < handlerList.length; i++) {
            try {
                // Call one handler
                handlerList[i].handler.apply(null, applyArgs);
            } catch (err) {
                console.error("Exception in '" + eventName + "' listener on", this, String(err), err.stack);
                console.assert();  // causes dev tools to pause, just like an uncaught exception
            }
        }
    }
848627
def _invoke(self, arguments, autoescape):
        """"""
        rv = self._func(*arguments)
        if autoescape:
            rv = Markup(rv)
        return rv
1201006
function (/*HTMLElement*/ obj, /*String*/ type, /*Function*/ fn, /*Object*/ context) {
		var id = TL.Util.stamp(fn),
			key = '_tl_' + type + id;

		if (obj[key]) {
			return;
		}

		var handler = function (e) {
			return fn.call(context || obj, e || TL.DomEvent._getEvent());
		};

		if (TL.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
			this.addDoubleTapListener(obj, handler, id);
		} else if ('addEventListener' in obj) {
			if (type === 'mousewheel') {
				obj.addEventListener('DOMMouseScroll', handler, false);
				obj.addEventListener(type, handler, false);
			} else if ((type === 'mouseenter') || (type === 'mouseleave')) {
				var originalHandler = handler,
					newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout');
				handler = function (e) {
					if (!TL.DomEvent._checkMouse(obj, e)) {
						return;
					}
					return originalHandler(e);
				};
				obj.addEventListener(newType, handler, false);
			} else {
				obj.addEventListener(type, handler, false);
			}
		} else if ('attachEvent' in obj) {
			obj.attachEvent("on" + type, handler);
		}

		obj[key] = handler;
	}
845743
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)):
    
    if not isinstance(buttons, (tuple, list)):
        buttons = (buttons,)
    if not isinstance(types, (tuple, list)):
        types = (types,)

    def handler(event):
        if isinstance(event, ButtonEvent):
            if event.event_type in types and event.button in buttons:
                callback(*args)
    _listener.add_handler(handler)
    return handler
643114
function handleEvent(dom, handler, e) {
  var ptag = this.__.parent,
    item = this.__.item;

  if (!item)
    { while (ptag && !item) {
      item = ptag.__.item;
      ptag = ptag.__.parent;
    } }

  // override the event properties
  /* istanbul ignore next */
  if (isWritable(e, 'currentTarget')) { e.currentTarget = dom; }
  /* istanbul ignore next */
  if (isWritable(e, 'target')) { e.target = e.srcElement; }
  /* istanbul ignore next */
  if (isWritable(e, 'which')) { e.which = e.charCode || e.keyCode; }

  e.item = item;

  handler.call(this, e);

  // avoid auto updates
  if (!settings$1.autoUpdate) { return }

  if (!e.preventUpdate) {
    var p = getImmediateCustomParentTag(this);
    // fixes #2083
    if (p.isMounted) { p.update(); }
  }
}
122469
function createCallback(element,callback) {

    var fn = function(originalEvent) {

      !originalEvent && ( originalEvent = window.event );

      // create a normalized event object
      var event = {
        // keep a ref to the original event object
        originalEvent: originalEvent,
        target: originalEvent.target || originalEvent.srcElement,
        type: "wheel",
        deltaMode: originalEvent.type == "MozMousePixelScroll" ? 0 : 1,
        deltaX: 0,
        delatZ: 0,
        preventDefault: function() {
          originalEvent.preventDefault ?
            originalEvent.preventDefault() :
            originalEvent.returnValue = false;
        }
      };

      // calculate deltaY (and deltaX) according to the event
      if ( support == "mousewheel" ) {
        event.deltaY = - 1/40 * originalEvent.wheelDelta;
        // Webkit also support wheelDeltaX
        originalEvent.wheelDeltaX && ( event.deltaX = - 1/40 * originalEvent.wheelDeltaX );
      } else {
        event.deltaY = originalEvent.detail;
      }

      // it's time to fire the callback
      return callback( event );

    };

    fns.push({
      element: element,
      fn: fn,
    });

    return fn;
  }
1359138
def _on_click(self, event):
        
        if callable(self.__callback):
            self.__callback(self.selection)
200347
function(type) {
        var self = this,
            event,
            context,
            func,
            selector,
            win = $(window),
            doc = $(document);

        $.each(this.__events, function(i, value) {
            event = value[0];
            context = value[1];
            func = value[2];
            selector = value[3];

            // Determine the correct context
            if (self[context]) {
                context = self[context];

            } else if (context === 'window') {
                context = win;

            } else if (context === 'document') {
                context = doc;
            }

            // Ready events
            if (event === 'ready') {
                doc.ready(func);

            // Delegated events
            } else if (selector) {
                $(context)[type](event, selector, func);

            // Regular events
            } else {
                $(context)[type](event, func);
            }
        });
    }
1192172
function (method, options) {
    var self = this,
        bind = function(){
          var $this = S(this),
              should_bind_events = !$this.data(self.attr_name(true) + '-init');
          $this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this)));

          if (should_bind_events) {
            self.events(this);
          }
        };

    if (S(this.scope).is('[' + this.attr_name() +']')) {
      bind.call(this.scope);
    } else {
      S('[' + this.attr_name() +']', this.scope).each(bind);
    }
    // # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating.
    if (typeof method === 'string') {
      return this[method].call(this, options);
    }

  }
175782
function onListeners($this, eventsInput, callback, context, type)
  {
    if ( !isFunction( callback ) )
    {
      return noop;
    }

    var callbackContext = context || $this;
    var events = toArray( eventsInput, ' ' );
    var listeners = $this.$$on;

    if ( !listeners )
    {
      Class.prop( $this, '$$on', listeners = {} );
    }

    var nodes = [];

    for (var i = 0; i < events.length; i++)
    {
      var eventName = events[ i ];
      var eventListeners = listeners[ eventName ];

      if ( !eventListeners )
      {
        eventListeners = listeners[ eventName ] = new EventNode();
      }

      nodes.push( new EventNode( eventListeners, callback, callbackContext, type, triggerId ) );
    }

    return function ignore()
    {
      for (var i = 0; i < nodes.length; i++)
      {
        nodes[ i ].remove();
      }

      nodes.length = 0;
    };
  }
374257
function (event) {
            var own = this;
            var returnValue = true;
            // grab the event object (IE uses a global event object)
            event = event || own._fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
            // get a reference to the hash table of event handlers
            var handlers = this.events[event.type];
            // execute each event handler
            for (var i in handlers) {
                var _handleEvent = handlers[i];
                if (_handleEvent(event) === false) {
                    returnValue = false;
                }
            }
            return returnValue;
        }