1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- ( function( factory ) {
- if ( typeof define === "function" && define.amd ) {
-
- define( [
- "jquery",
- "./form",
- "./version"
- ], factory );
- } else {
-
- factory( jQuery );
- }
- }( function( $ ) {
- return $.ui.formResetMixin = {
- _formResetHandler: function() {
- var form = $( this );
-
- 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 ) {
-
- 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" );
- }
- }
- };
- } ) );
|