Add the various instance methods that can transition the object using
 the current event
760809
def add_actions
      # Checks whether the event can be fired on the current object
      machine.define_helper(:instance, "can_#{qualified_name}?") do |machine, object, *args|
        machine.event(name).can_fire?(object, *args)
      end

      # Gets the next transition that would be performed if the event were
      # fired now
      machine.define_helper(:instance, "#{qualified_name}_transition") do |machine, object, *args|
        machine.event(name).transition_for(object, *args)
      end

      # Fires the event
      machine.define_helper(:instance, qualified_name) do |machine, object, *args|
        machine.event(name).fire(object, *args)
      end

      # Fires the event, raising an exception if it fails
      machine.define_helper(:instance, "#{qualified_name}!") do |machine, object, *args|
        object.send(qualified_name, *args) || raise(StateMachines::InvalidTransition.new(object, machine, name))
      end
    end
1282504
def fire_events(object, *events)
      run_action = [true, false].include?(events.last) ? events.pop : true
      
      # Generate the transitions to run for each event
      transitions = events.collect do |event_name|
        # Find the actual event being run
        event = nil
        detect {|name, machine| event = machine.events[event_name, :qualified_name]}
        
        raise(InvalidEvent.new(object, event_name)) unless event
        
        # Get the transition that will be performed for the event
        unless transition = event.transition_for(object)
          event.on_failure(object)
        end
        
        transition
      end.compact
      
      # Run the events in parallel only if valid transitions were found for
      # all of them
      if events.length == transitions.length
        TransitionCollection.new(transitions, :actions => run_action).perform
      else
        false
      end
    end
618769
void createTransitionInstances(ProcessInstance processInstanceVO,
            List<Transition> transitions, Long fromActInstId)
           throws ProcessException,DataAccessException {
        TransitionInstance transInst;
        for (Transition transition : transitions) {
            try {
                if (tooManyMaxTransitionInstances(transition, processInstanceVO.getId())) {
                    // Look for a error transition at this time
                    // In case we find it, raise the error event
                    // Otherwise do not do anything
                    handleWorkTransitionError(processInstanceVO, transition.getId(), fromActInstId);
                } else {
                    transInst = createTransitionInstance(transition, processInstanceVO.getId());
                    String tag = logtag(processInstanceVO.getProcessId(),
                            processInstanceVO.getId(), transInst);
                    logger.info(tag, "Transition initiated from " + transition.getFromId() + " to " + transition.getToId());

                    InternalEvent jmsmsg;
                    int delay = 0;
                    jmsmsg = InternalEvent.createActivityStartMessage(
                            transition.getToId(), processInstanceVO.getId(),
                            transInst.getTransitionInstanceID(), processInstanceVO.getMasterRequestId(),
                            transition.getLabel());
                    delay = transition.getTransitionDelay();
                    String msgid = ScheduledEvent.INTERNAL_EVENT_PREFIX + processInstanceVO.getId()
                            + "start" + transition.getToId() + "by" + transInst.getTransitionInstanceID();
                    if (delay>0) this.sendDelayedInternalEvent(jmsmsg, delay, msgid, false);
                    else sendInternalEvent(jmsmsg);
                }
            } catch (SQLException ex) {
                throw new ProcessException(-1, ex.getMessage(), ex);
            } catch (MdwException ex) {
                throw new ProcessException(-1, ex.getMessage(), ex);
            }
        }
    }
655014
def transition(field, source='*', target=None, on_error=None, conditions=[], permission=None, custom={}):
    
    def inner_transition(func):
        wrapper_installed, fsm_meta = True, getattr(func, '_django_fsm', None)
        if not fsm_meta:
            wrapper_installed = False
            fsm_meta = FSMMeta(field=field, method=func)
            setattr(func, '_django_fsm', fsm_meta)

        if isinstance(source, (list, tuple, set)):
            for state in source:
                func._django_fsm.add_transition(func, state, target, on_error, conditions, permission, custom)
        else:
            func._django_fsm.add_transition(func, source, target, on_error, conditions, permission, custom)

        @wraps(func)
        def _change_state(instance, *args, **kwargs):
            return fsm_meta.field.change_state(instance, func, *args, **kwargs)

        if not wrapper_installed:
            return _change_state

        return func

    return inner_transition
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
            }
        }
    }
554939
function (method, options) {
    var self = this,
        should_bind_events = !S(this).data(this.attr_name(true));


    if (S(this.scope).is('[' + this.attr_name() +']')) {
      S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));

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

    } else {
      S('[' + this.attr_name() +']', this.scope).each(function () {
        var should_bind_events = !S(this).data(self.attr_name(true) + '-init');
        S(this).data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this))));

        if (should_bind_events) {
          self.events(this);
        }
      });
    }
    // # 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);
    }

  }
360704
function(object, events) {
        if (!object.__isInterfaceImplemented('events')) {
            object.__implementInterface('events', this.interface);
        }

        object.__initEvents();

        _.each(events, function(eventListeners, eventName) {
            _.each(eventListeners, function(listener, listenerName) {
                object.__addEventListener(eventName, listenerName, listener);
            });
        });
    }
677651
def add_transition(rel, href, options={})
      new_representor_hash = RepresentorHash.new(deep_dup(@representor_hash.to_h))
      options = symbolize_keys(options)
      options.delete(:method) if options[:method] == Transition::DEFAULT_METHOD
      link_values = options.merge({href: href, rel: rel})

      if options[DATA_KEY]
        link_values[Transition::DESCRIPTORS_KEY] = link_values.delete(DATA_KEY)
      end

      new_representor_hash.transitions.push(link_values)
      RepresentorBuilder.new(new_representor_hash)
    end
557258
function(options) {
        this._transitions = {}
        this._states = {}
        options = options || {}
        this._bindStates()
        this._bindTransitions()
        if (options.debugStateMachine === true)
          StateMachine.DebugView.register(this)
        this.bind('all', this._onMachineEvent, this)
        this.currentState = INIT_STATE
        this.startStateMachine = function() {
          throw new Error('startStateMachine has been called twice!')
        }
      }
1348516
private void bindEvents() {
		visibilityToggle.addClickHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				if (visibilityToggle.isEnabled()) {
					presenter.toggleLayerVisibility();
					visibilityToggle.setEnabled(true); // Works because JavaScript is single threaded...
				}
			}
		});
	}
177241
def _add_new_methods(cls):
        """"""
        for name, method in cls.context.new_methods.items():
            if hasattr(cls.context.new_class, name):
                raise ValueError(
                    "Name collision in state machine class - '{name}'."
                    .format(name)
                )

            setattr(cls.context.new_class, name, method)
579368
function(obj, propName)
{
	if (obj instanceof conbo.EventDispatcher)
	{
		var options = {property:propName, value:obj[propName]};
		
		obj.dispatchEvent(new conbo.ConboEvent('change:'+propName, options));
		obj.dispatchEvent(new conbo.ConboEvent('change', options));
	}
}
678537
function onClick(instance) {
    const self = instance;
    self.wrapperNodes.forEach((n) => {
      n.addEventListener(ANIMATIONEND, function thisFunction(e) {
        e.target.classList.remove('bubble');
        e.target.removeEventListener(ANIMATIONEND, thisFunction);
      });
      n.classList.add('bubble');
    });

    if (tooltip.getCurrentTarget() === self.wrapperNodes[0]) {
      return;
    }

    tooltip.createTooltip(self.wrapperNodes[0], self.result.text, false);

    setTimeout(() => {
      if (tooltip.getCurrentTarget()) {
        document.addEventListener('click', function thisFunction() {
          if (tooltip.getCurrentTarget() && tooltip.getCurrentTarget() === self.wrapperNodes[0]) {
            tooltip.removeTooltip();
          }
          document.removeEventListener('click', thisFunction);
        });
      }
    }, 0);
  }
608325
function AlphaTransition( element ) {

  const _baseTransition = new BaseTransition( element, CLASSES );

  /**
   * @returns {AlphaTransition} An instance.
   */
  function init() {
    _baseTransition.init();
    const _transitionCompleteBinded = _transitionComplete.bind( this );
    _baseTransition.addEventListener(
      BaseTransition.END_EVENT,
      _transitionCompleteBinded
    );
    return this;
  }

  /**
   * Handle the end of a transition.
   */
  function _transitionComplete() {
    this.trigger( BaseTransition.END_EVENT, { target: this } );
  }

  /**
   * Fade to 100% by applying a utility alpha class.
   * @returns {AlphaTransition} An instance.
   */
  function fadeIn() {
    _baseTransition.applyClass( CLASSES.ALPHA_100 );

    return this;
  }

  /**
   * Fade to nothing by applying a utility alpha class.
   * @returns {AlphaTransition} An instance.
   */
  function fadeOut() {
    _baseTransition.applyClass( CLASSES.ALPHA_0 );

    return this;
  }

  // Attach public events.
  this.addEventListener = Events.addEventListener;
  this.trigger = Events.trigger;
  this.removeEventListener = Events.removeEventListener;

  this.animateOff = _baseTransition.animateOff;
  this.animateOn = _baseTransition.animateOn;
  this.halt = _baseTransition.halt;
  this.isAnimated = _baseTransition.isAnimated;
  this.remove = _baseTransition.remove;
  this.setElement = _baseTransition.setElement;

  this.fadeIn = fadeIn;
  this.fadeOut = fadeOut;
  this.init = init;

  return this;
}
848820
function(type, handler)
	{
		var obj = this.__obj;
		
		if (obj)
		{
			switch (true)
			{
				// TODO Remove the last tiny piece of jQuery support?
				case conbo.$ && obj instanceof conbo.$:
				case window.$ && obj instanceof window.$:
				{
					obj.on(type, handler);
					break;
				}
				
				case obj instanceof conbo.EventDispatcher:
				{
					obj.addEventListener(type, handler);
					break;
				}
				
				default:
				{
					var types = type.split(' ');
					
					types.forEach(function(type)
					{
						obj.addEventListener(type, handler);
					});
				}
			}
		}
		
		return this;
	}
1002942
def define_event_transition(event_name, silent)
      machine.send(:define_singleton_method, event_name) do |*data, &block|
        method = silent ? :transition : :trigger
        machine.public_send(method, event_name, *data, &block)
      end
    end
684167
function initEvents() {
        var bind = _this.h.addEventListener;
        var eventTarget = params.eventTarget === 'wrapper' ? _this.wrapper : _this.container;
        //Touch Events
        if (! (_this.browser.ie10 || _this.browser.ie11)) {
            if (_this.support.touch) {
                bind(eventTarget, 'touchstart', onTouchStart);
                bind(eventTarget, 'touchmove', onTouchMove);
                bind(eventTarget, 'touchend', onTouchEnd);
            }
            if (params.simulateTouch) {
                bind(eventTarget, 'mousedown', onTouchStart);
                bind(document, 'mousemove', onTouchMove);
                bind(document, 'mouseup', onTouchEnd);
            }
        }
        else {
            bind(eventTarget, _this.touchEvents.touchStart, onTouchStart);
            bind(document, _this.touchEvents.touchMove, onTouchMove);
            bind(document, _this.touchEvents.touchEnd, onTouchEnd);
        }

        //Resize Event
        if (params.autoResize) {
            bind(window, 'resize', _this.resizeFix);
        }
        //Slide Events
        addSlideEvents();
        //Mousewheel
        _this._wheelEvent = false;
        if (params.mousewheelControl) {
            if (document.onmousewheel !== undefined) {
                _this._wheelEvent = 'mousewheel';
            }
            if (!_this._wheelEvent) {
                try {
                    new WheelEvent('wheel');
                    _this._wheelEvent = 'wheel';
                } catch (e) {}
            }
            if (!_this._wheelEvent) {
                _this._wheelEvent = 'DOMMouseScroll';
            }
            if (_this._wheelEvent) {
                bind(_this.container, _this._wheelEvent, handleMousewheel);
            }
        }

        //Keyboard
        function _loadImage(src) {
            var image = new Image();
            image.onload = function () {
                if (typeof _this === 'undefined' || _this === null) return;
                if (_this.imagesLoaded !== undefined) _this.imagesLoaded++;
                if (_this.imagesLoaded === _this.imagesToLoad.length) {
                    _this.reInit();
                    if (params.onImagesReady) _this.fireCallback(params.onImagesReady, _this);
                }
            };
            image.src = src;
        }

        if (params.keyboardControl) {
            bind(document, 'keydown', handleKeyboardKeys);
        }
        if (params.updateOnImagesReady) {
            _this.imagesToLoad = $$('img', _this.container);

            for (var i = 0; i < _this.imagesToLoad.length; i++) {
                _loadImage(_this.imagesToLoad[i].getAttribute('src'));
            }
        }
    }