Sha256: f0e8869ebdfbe7cf1067b8eed772dc6a44c261c2c0cd3789cad58156dd3e4f75

Contents?: true

Size: 1.75 KB

Versions: 13

Compression:

Stored size: 1.75 KB

Contents

/*!
 * jQuery UI Form Reset Mixin 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Form Reset Mixin
//>>group: Core
//>>description: Refresh input widgets when their form is reset
//>>docs: http://api.jqueryui.com/form-reset-mixin/

( function( factory ) {
	if ( typeof define === "function" && define.amd ) {

		// AMD. Register as an anonymous module.
		define( [
			"jquery",
			"./form",
			"./version"
		], factory );
	} else {

		// Browser globals
		factory( jQuery );
	}
}( function( $ ) {

return $.ui.formResetMixin = {
	_formResetHandler: function() {
		var form = $( this );

		// Wait for the form reset to actually happen before refreshing
		setTimeout( function() {
			var instances = form.data( "ui-form-reset-instances" );
			$.each( instances, function() {
				this.refresh();
			} );
		} );
	},

	_bindFormResetHandler: function() {
		this.form = this.element.form();
		if ( !this.form.length ) {
			return;
		}

		var instances = this.form.data( "ui-form-reset-instances" ) || [];
		if ( !instances.length ) {

			// We don't use _on() here because we use a single event handler per form
			this.form.on( "reset.ui-form-reset", this._formResetHandler );
		}
		instances.push( this );
		this.form.data( "ui-form-reset-instances", instances );
	},

	_unbindFormResetHandler: function() {
		if ( !this.form.length ) {
			return;
		}

		var instances = this.form.data( "ui-form-reset-instances" );
		instances.splice( $.inArray( this, instances ), 1 );
		if ( instances.length ) {
			this.form.data( "ui-form-reset-instances", instances );
		} else {
			this.form
				.removeData( "ui-form-reset-instances" )
				.off( "reset.ui-form-reset" );
		}
	}
};

} ) );

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
ext_yarn-0.6.0 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.5.0 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.4.0 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.3.1 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.3.0 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.2.0 vendor/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.1.2 node_modules/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.1.1 node_modules/jquery-ui/ui/form-reset-mixin.js
ext_yarn-0.1.0 node_modules/jquery-ui/ui/form-reset-mixin.js
ext_sprockets-0.1.6 node_modules/jquery-ui/ui/form-reset-mixin.js
ext_sprockets-0.1.5 node_modules/jquery-ui/ui/form-reset-mixin.js
ext_sprockets-0.1.1 node_modules/jquery-ui/ui/form-reset-mixin.js
date_picker-0.0.9 test/dummy/vendor/assets/components/jquery-ui/ui/form-reset-mixin.js