Bind a function to the submit event of each matched element.

@param jsScope
Scope to use
@return the jQuery code
499491
public static ChainableStatement submit(JsScope jsScope)
	{
		return new DefaultChainableStatement(FormEvent.SUBMIT.getEventLabel(), jsScope.render());
	}
1130593
function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
  return function(propertyName, func) {
    const scope = this;
    const event = _event || propertyName;
    const target = !_target ? this.el : document.querySelector(_target);
    if (!target) {
      console.warn("Couldn't subscribe "+this.name+"."+propertyName+" to "+event+" on "+_target
        +" because querySelector returned undefined.");
      return;
    }
    const listenIn = _listenIn || "init";
    const removeIn = _removeIn || "remove";

    const listenFunc = this[listenIn];
    const removeFunc = this[removeIn];
    const boundFunc = func.bind(this);
    
    this[listenIn] = function() {
      if (listenFunc !== undefined) {
        listenFunc.apply(scope, arguments);
      }
      target.addEventListener(event, boundFunc);
    }

    this[removeIn] = function() {
      if (removeFunc !== undefined) {
        removeFunc.apply(scope, arguments);
      }
      target.removeEventListener(event, boundFunc);
    }

    return func;
  }
}
605715
function jsTreeCtrl() {
        /*jshint validthis:true */
        var nodeSerialId = 1;
        var vm = this;

        vm.nodesFingerprint = function (e) {
            if (!e.__uiNodeId) {
                e.__uiNodeId = nodeSerialId++;
            }
            return '' + e.__uiNodeId + (e.id || '') + (e.text || '') + (e.type || '');
        };

        vm.changeWatcher = function (arraySource, tokenFn) {
            var self;
            var getTokens = function () {
                var result = [], token, el;
                if (arraySource) {
                    var array = angular.isFunction(arraySource) ? arraySource() : arraySource;
                    for (var i = 0, n = array.length; i < n; i++) {
                        el = array[i];
                        token = tokenFn(el);
                        map[token] = el;
                        result.push(token);
                    }
                }
                return result;
            };
            // returns elements in that are in a but not in b
            // subtractAsSets([4, 5, 6], [4, 5, 7]) => [6]
            var subtractAsSets = function (a, b) {
                var result = [], inB = {}, i, n;
                for (i = 0, n = b.length; i < n; i++) {
                    inB[b[i]] = true;
                }
                for (i = 0, n = a.length; i < n; i++) {
                    if (!inB[a[i]]) {
                        result.push(a[i]);
                    }
                }
                return result;
            };

            // Map objects to tokens and vice-versa
            var map = {};

            var applyChanges = function (newTokens, oldTokens) {
                var i, n, el, token;
                var replacedTokens = {};
                var removedTokens = subtractAsSets(oldTokens, newTokens);
                for (i = 0, n = removedTokens.length; i < n; i++) {
                    var removedToken = removedTokens[i];
                    el = map[removedToken];
                    delete map[removedToken];
                    var newToken = tokenFn(el);
                    // if the element wasn't removed but simply got a new token, its old token will be different from the current one
                    if (newToken === removedToken) {
                        self.onRemoved(el);
                    } else {
                        replacedTokens[newToken] = removedToken;
                        self.onChanged(el);
                    }
                }

                var addedTokens = subtractAsSets(newTokens, oldTokens);
                for (i = 0, n = addedTokens.length; i < n; i++) {
                    token = addedTokens[i];
                    el = map[token];
                    if (!replacedTokens[token]) {
                        self.onAdded(el);
                    }
                }

            };
            self = {
                subscribe: function (scope, onChanged) {
                    scope.$watch(getTokens, function (newTokens, oldTokens) {
                        if (!onChanged || onChanged(newTokens, oldTokens) !== false) {
                            applyChanges(newTokens, oldTokens);
                        }
                    }, true);
                },
                onAdded: angular.noop,
                onChanged: angular.noop,
                onRemoved: angular.noop
            };
            return self;
        };
    }
137046
public void generateBootsFacesAJAXAndJavaScriptForJQuery(FacesContext context, UIComponent component,
			ResponseWriter rw, String jQueryExpressionOfTargetElement, Map<String, String> additionalEventHandlers,
			boolean attachOnReady) throws IOException {
		if (jQueryExpressionOfTargetElement.contains(":")) {
			if (!jQueryExpressionOfTargetElement.contains("\\\\:")) { // avoid escaping twice
				jQueryExpressionOfTargetElement = jQueryExpressionOfTargetElement.replace(":", "\\\\:");
			}
		}
		IAJAXComponent ajaxComponent = (IAJAXComponent) component;
		Set<String> events = ajaxComponent.getJQueryEvents().keySet();
		for (String event : events) {
			StringBuilder code = new StringBuilder();
			String additionalEventHandler = null;
			if (null != additionalEventHandlers)
				additionalEventHandler = additionalEventHandlers.get(event);

			String parameterList = null;
			if (null != ajaxComponent.getJQueryEventParameterListsForAjax()) {
				if (null != ajaxComponent.getJQueryEventParameterListsForAjax().get(event))
					parameterList = ajaxComponent.getJQueryEventParameterListsForAjax().get(event);
			}
			generateAJAXCallForASingleEvent(context, (ClientBehaviorHolder) component, rw, null, event,
					additionalEventHandler, true, event, code, parameterList);
			if (code.length() > 0) {
				rw.startElement("script", component);
				parameterList = "event";
				if (null != ajaxComponent.getJQueryEventParameterLists()) {
					if (null != ajaxComponent.getJQueryEventParameterLists().get(event))
						parameterList = ajaxComponent.getJQueryEventParameterLists().get(event);
				}
				String js = "$('" + jQueryExpressionOfTargetElement + "').on('"
						+ ajaxComponent.getJQueryEvents().get(event) + "', function(" + parameterList + "){"
						+ code.toString() + "});";
				if (attachOnReady)
					js = "$(function() { " + js + " })";
				rw.writeText(js, null);
				rw.endElement("script");
			}
		}
	}
1112806
function JQLite(element) {
  if (element instanceof JQLite) {
    return element;
  }
  if (!(this instanceof JQLite)) {
    if (isString(element) && element.charAt(0) != '<') {
      throw Error('selectors not implemented');
    }
    return new JQLite(element);
  }

  if (isString(element)) {
    var div = document.createElement('div');
    // Read about the NoScope elements here:
    // http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
    div.innerHTML = '<div>&#160;</div>' + element; // IE insanity to make NoScope elements work!
    div.removeChild(div.firstChild); // remove the superfluous div
    JQLiteAddNodes(this, div.childNodes);
    this.remove(); // detach the elements from the temporary DOM div.
  } else {
    JQLiteAddNodes(this, element);
  }
}
837418
function( options ) {
		/// <summary>
		/// Validates the selected form. This method sets up event handlers for submit, focus,
		/// keyup, blur and click to trigger validation of the entire form or individual
		/// elements. Each one can be disabled, see the onxxx options (onsubmit, onfocusout,
		/// onkeyup, onclick). focusInvalid focuses elements when submitting a invalid form.
		/// </summary>
		/// <param name="options" type="Object">
		/// A set of key/value pairs that configure the validate. All options are optional.
		/// </param>

		// if nothing is selected, return nothing; can't chain anyway
		if (!this.length) {
			options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
			return;
		}

		// check if a validator for this form was already created
		var validator = $.data(this[0], 'validator');
		if ( validator ) {
			return validator;
		}
		
		validator = new $.validator( options, this[0] );
		$.data(this[0], 'validator', validator); 
		
		if ( validator.settings.onsubmit ) {
		
			// allow suppresing validation by adding a cancel class to the submit button
			this.find("input, button").filter(".cancel").click(function() {
				validator.cancelSubmit = true;
			});
			
			// when a submitHandler is used, capture the submitting button
			if (validator.settings.submitHandler) {
				this.find("input, button").filter(":submit").click(function() {
					validator.submitButton = this;
				});
			}
		
			// validate the form on submit
			this.submit( function( event ) {
				if ( validator.settings.debug )
					// prevent form submit to be able to see console output
					event.preventDefault();
					
				function handle() {
					if ( validator.settings.submitHandler ) {
						if (validator.submitButton) {
							// insert a hidden input as a replacement for the missing submit button
							var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
						}
						validator.settings.submitHandler.call( validator, validator.currentForm );
						if (validator.submitButton) {
							// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
							hidden.remove();
						}
						return false;
					}
					return true;
				}
					
				// prevent submit for invalid forms or custom submit handlers
				if ( validator.cancelSubmit ) {
					validator.cancelSubmit = false;
					return handle();
				}
				if ( validator.form() ) {
					if ( validator.pendingRequest ) {
						validator.formSubmitted = true;
						return false;
					}
					return handle();
				} else {
					validator.focusInvalid();
					return false;
				}
			});
		}
		
		return validator;
	}
239480
function bindEnter(dom, visitId, at){
	var selector = "> form .workarea-commandbox [mc-name=enter]";
	dom.on("click", selector, function(event){
		event.preventDefault();
		event.stopPropagation();
		dom.find(selector).prop("disabled", true);
		var names = dom.find("> form input[name=item]:checked").map(function(){
			return $(this).val();
		}).get();
		var newShinryouIds, newConductIds;
		var newShinryouList = [], newConductList = [];
		task.run([
			function(done){
				service.enterShinryouByNames(visitId, names, function(err, result){
					if( err ){
						done(err);
						return;
					}
					newShinryouIds = result.shinryou_ids;
					newConductIds = result.conduct_ids;
					done();
				})
			},
			function(done){
				conti.forEach(newShinryouIds, function(newShinryouId, done){
					service.getFullShinryou(newShinryouId, at, function(err, result){
						if( err ){
							done(err);
							return;
						}
						newShinryouList.push(result);
						done();
					})
				}, done);
			},
			function(done){
				conti.forEach(newConductIds, function(newConductId, done){
					service.getFullConduct(newConductId, at, function(err, result){
						if( err ){
							done(err);
							return;
						}
						newConductList.push(result);
						done();
					})
				}, done);
			}
		], function(err){
			if( err ){
				alert(err);
				return;
			}
			dom.trigger("entered", [newShinryouList, newConductList]);
		})
	})
}
556179
function bindEvent(element, type, handler, context) {
    /**
     * Event handler
     * @param {Event} e - event object
     */
    function eventHandler(e) {
        handler.call(context || element, e || window.event);
    }

    /**
     * Event handler for normalize mouseenter event
     * @param {MouseEvent} e - event object
     */
    function mouseEnterHandler(e) {
        e = e || window.event;

        if (checkMouse(element, e)) {
            eventHandler(e);
        }
    }

    if ('addEventListener' in element) {
        if (type === 'mouseenter' || type === 'mouseleave') {
            type = (type === 'mouseenter') ? 'mouseover' : 'mouseout';
            element.addEventListener(type, mouseEnterHandler);
            memorizeHandler(element, type, handler, mouseEnterHandler);
        } else {
            element.addEventListener(type, eventHandler);
            memorizeHandler(element, type, handler, eventHandler);
        }
    } else if ('attachEvent' in element) {
        element.attachEvent(`on${type}`, eventHandler);
        memorizeHandler(element, type, handler, eventHandler);
    }
}
523921
function (selector, hash, uuid) {
    this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
    this.actionQueue.push(this.webdriverClient.submit.bind(this.webdriverClient));
    this.actionQueue.push(this._submitCb.bind(this, selector, hash, uuid));
    return this;
  }
1193072
function () {
			this.writeDebug('_formEventHandler');
			var _this = this;
			// ASP.net or regular submission?
			if (this.settings.noForm === true) {
				$(document).on('click.'+pluginName, '.' + this.settings.formContainer + ' button', function (e) {
					_this.processForm(e);
				});
				$(document).on('keydown.'+pluginName, function (e) {
					if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
						_this.processForm(e);
					}
				});
			}
			else {
				$(document).on('submit.'+pluginName, '#' + this.settings.formID, function (e) {
					_this.processForm(e);
				});
			}

			// Reset button trigger
			if ($('.bh-sl-reset').length && $('#' + this.settings.mapID).length) {
				$(document).on('click.' + pluginName, '.bh-sl-reset', function () {
					_this.mapReload();
				});
			}
		}
755315
public Binding toBinding(BindingElement element) {
		final TypeReference typeReference = typeRef(element.getBind());
		final String annotatedWith = element.getAnnotatedWith();
		final String annotatedWithName = element.getAnnotatedWithName();
		if (!Strings.isEmpty(annotatedWith)) {
			final TypeReference annotationType = typeRef(annotatedWith);
			if (element.isInstance()) {
				return bindAnnotatedWithToInstance(typeReference, annotationType, element.getTo(),
						element.getFunctionName());
			}
			final TypeReference typeReference2 = typeRef(element.getTo());
			return bindAnnotatedWith(typeReference, annotationType, typeReference2,
						element.getFunctionName());
		}
		if (!Strings.isEmpty(annotatedWithName)) {
			if (element.isInstance()) {
				return bindAnnotatedWithNameToInstance(typeReference, annotatedWithName,
						element.getTo(),
						element.getFunctionName());
			}
			final TypeReference typeReference2 = typeRef(element.getTo());
			return bindAnnotatedWithName(typeReference, annotatedWithName, typeReference2,
						element.getFunctionName());
		}
		if (element.isInstance()) {
			return bindToInstance(typeReference,
					element.getFunctionName(),
					element.getTo(),
					element.isSingleton(),
					element.isEager());
		}
		final TypeReference typeReference2 = typeRef(element.getTo());
		return bindToType(
					typeReference,
					element.getFunctionName(),
					typeReference2,
					element.isSingleton(),
					element.isEager(),
					element.isProvider());
	}
152032
function(element) {
      var parent = $mdUtil.getClosest(element, 'form');
      var form = parent ? angular.element(parent).controller('form') : null;

      return form ? form.$submitted : false;
    }
1192495
public int doEndTag()
            throws JspException
    {
        String idScript = null;

        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

        // Acquire the label value we will be generating
        if (_value == null)
            _value = Bundle.getString("Tags_ButtonText", null);
        _state.value = _value;

        // Generate an HTML element
        _state.disabled = isDisabled();

        // Add parameters for popup window support.
        if (_popupSupport != null) {
            _popupSupport.addParams(this, request);
        }

        // targetScope implies an extra parameter.  If there's no action on this button, get the action from the
        // nearest form, so we can construct an action url with our extra parameter.
        if (_targetScope != null && _action == null) {
            Form parentForm = getNearestForm();
            if (parentForm != null) {
                _action = parentForm.getAction();
            }
        }

        if (_action == null && _params != null && _popupSupport == null) {
            Form parentForm = getNearestForm();
            if (parentForm != null) {
                _action = parentForm.getAction();
            }
        }

        if (_action != null) {
            boolean isAction = PageFlowTagUtils.isAction(request, _action);
            if (isAction) {

                // If the action we're submitting to is checking for double-submits, save a token in the session.
                // This will be written out as a param (below), and will be checked in PageFlowRequestProcessor.
                String token = PageFlowTagUtils.getToken(request, _action);
                if (token != null) {
                    if (_params == null) {
                        _params = new HashMap();
                    }
                    _params.put(Constants.TOKEN_KEY, token);
                }

                // Add the scope ID parameter if there's one on the tag, or if there's one in the request.
                if (_targetScope != null) {
                    if (_params == null) {
                        _params = new HashMap();
                    }
                    _params.put(ScopedServletUtils.SCOPE_ID_PARAM, _targetScope);
                }

                String overrideAction = ACTION_OVERRIDE + _action;
                overrideAction = HtmlUtils.addParams(overrideAction, _params, response.getCharacterEncoding());
                String buttonOutput = URLRewriterService.getNamePrefix(pageContext.getServletContext(),
                        pageContext.getRequest(), overrideAction) + overrideAction;
                if (buttonOutput.indexOf(";") > -1) {
                    buttonOutput = buttonOutput.substring(0, buttonOutput.indexOf(";"));
                }
                _state.name = buttonOutput;

                // don't write the id attribute
                Form parentForm = getNearestForm();
                idScript = renderNameAndId(request, _state, parentForm);
            }
            else {
                // set the error because the action is invalid
                registerTagError(Bundle.getString("Tags_BadAction", _action), null);
            }
        }
        else {
            Form parentForm = getNearestForm();
            idScript = renderNameAndId(request, _state, parentForm);
        }

        boolean buttonDisableAndSubmit = false;
        boolean buttonDisable = false;
        
        // if the user overrides the onclick we will ignore this
        if (getOnClick() == null) {
            if (_disableSecondClick) {
                Form parentForm = getNearestForm();
                String href = getActionUrl(request, response);
                String entry;
                if (parentForm != null && href != null && (_state.type == null || _state.type == INPUT_SUBMIT)) {
                    entry = ScriptRequestState.getString("buttonDisableAndSubmitFormAction",
                            new Object[]{parentForm.getRealFormId(), href});
                    buttonDisableAndSubmit = true;
                }
                else {
                    entry = ScriptRequestState.getString("buttonDisableAction", null);
                    buttonDisable = true;
                }
                _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, entry);
                if (parentForm != null)
                    parentForm.insureRealId();
            }
            else if (_popupSupport != null) {
                String href = getActionUrl(request, response);

                if (href != null) {
                    href = response.encodeURL(href);
                    setOnClick(_popupSupport.getOnClick(request,href));
                }
            }
        }
        
        // report any errors that may have been generated.
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase br = null;
        if (_renderAsButton) {
            br = TagRenderingBase.Factory.getRendering(TagRenderingBase.BUTTON_TAG, request);
            br.doStartTag(writer, _state);
            // add the body content
            if (_text != null)
                write(_text);
            else if (_value != null)
                write(_value);
        }
        else {
            br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_SUBMIT_TAG, request);
            br.doStartTag(writer, _state);
        }
        br.doEndTag(writer);

        //Emit javascript if this button needs to sumbit the form or open a popup window
        if (idScript != null || _popupSupport != null || buttonDisable || buttonDisableAndSubmit) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            InternalStringBuilder script = new InternalStringBuilder(32);
            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);
            IScriptReporter sr = getScriptReporter();

            if (buttonDisableAndSubmit)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE_AND_SUBMIT, true, false, null);
            if (buttonDisable)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE, true, false, null);
            if (_popupSupport != null)
                _popupSupport.writeScript(request, srs, getScriptReporter(), scriptWriter);
            if (idScript != null)
                scriptWriter.append(idScript);
            write(script.toString());
        }
        
        // Evaluate the remainder of this page
        localRelease();
        return EVAL_PAGE;
    }
729356
function (s) {
/*Line 40 - 'AtomUIComponent.js' */                var scope = this._localScope || this.get_scope();
/*Line 41 - 'AtomUIComponent.js' */                for (var k in s) {
/*Line 42 - 'AtomUIComponent.js' */                    if (/^(application|owner|app|parent)$/gi.test(k))
/*Line 43 - 'AtomUIComponent.js' */                        throw new Error("Invalid name for the scope property");
/*Line 44 - 'AtomUIComponent.js' */                    // if value is already set...
/*Line 45 - 'AtomUIComponent.js' */                    var v = s[k];
/*Line 46 - 'AtomUIComponent.js' */                    if (scope == window.appScope && !window.atomApplication._ready) {
/*Line 47 - 'AtomUIComponent.js' */                        if ((k.indexOf('_') != 0)
/*Line 48 - 'AtomUIComponent.js' */                            && (v !== undefined && v !== null)
/*Line 49 - 'AtomUIComponent.js' */                            && (/string|number|boolean/i.test(typeof (v)))){
/*Line 50 - 'AtomUIComponent.js' */                                atomApplication._defaultScope[k] = v;
/*Line 51 - 'AtomUIComponent.js' */                            }
/*Line 52 - 'AtomUIComponent.js' */                    }
/*Line 53 - 'AtomUIComponent.js' */                    if (scope[k] !== undefined)
/*Line 54 - 'AtomUIComponent.js' */                        continue;
/*Line 55 - 'AtomUIComponent.js' */                    scope[k] = v;
/*Line 56 - 'AtomUIComponent.js' */                }
/*Line 57 - 'AtomUIComponent.js' */            }
1307805
function CodeHintList(editor, insertHintOnTab, maxResults) {

        /**
         * The list of hints to display
         *
         * @type {Array.<string|jQueryObject>}
         */
        this.hints = [];

        /**
         * The selected position in the list; otherwise -1.
         *
         * @type {number}
         */
        this.selectedIndex = -1;

        /**
         * The maximum number of hints to display. Can be overriden via maxCodeHints pref
         *
         * @type {number}
         */
        this.maxResults = ValidationUtils.isIntegerInRange(maxResults, 1, 1000) ? maxResults : 50;

        /**
         * Is the list currently open?
         *
         * @type {boolean}
         */
        this.opened = false;

        /**
         * The editor context
         *
         * @type {Editor}
         */
        this.editor = editor;

        /**
         * Whether the currently selected hint should be inserted on a tab key event
         *
         * @type {boolean}
         */
        this.insertHintOnTab = insertHintOnTab;

        /**
         * Pending text insertion
         *
         * @type {string}
         */
        this.pendingText = "";

        /**
         * The hint selection callback function
         *
         * @type {Function}
         */
        this.handleSelect = null;

        /**
         * The hint list closure callback function
         *
         * @type {Function}
         */
        this.handleClose = null;

        /**
         * The hint list menu object
         *
         * @type {jQuery.Object}
         */
        this.$hintMenu =
            $("<li class='dropdown codehint-menu'></li>")
                .append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
                        .hide())
                .append("<ul class='dropdown-menu'></ul>");

        this._keydownHook = this._keydownHook.bind(this);
    }
1097051
public static ChainableStatement load(JsScope jsScope)
	{
		return new DefaultChainableStatement(StateEvent.LOAD.getEventLabel(), jsScope.render());
	}
415120
Object executeScript(String jsScript) {
    String jsScriptWithFunction = "(function (){" + jsScript + "})();";
    try {
      return jsScriptEngine.eval(jsScriptWithFunction);
    } catch (ScriptException e) {
      throw new org.molgenis.script.core.ScriptException(e);
    }
  }