| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
( function( factory ) { |
| 16 |
"use strict"; |
| 17 |
|
| 18 |
if ( typeof define === "function" && define.amd ) { |
| 19 |
|
| 20 |
|
| 21 |
define( [ |
| 22 |
"jquery", |
| 23 |
"./version" |
| 24 |
], factory ); |
| 25 |
} else { |
| 26 |
|
| 27 |
|
| 28 |
factory( jQuery ); |
| 29 |
} |
| 30 |
} )( function( $ ) { |
| 31 |
"use strict"; |
| 32 |
|
| 33 |
return $.ui.formResetMixin = { |
| 34 |
_formResetHandler: function() { |
| 35 |
var form = $( this ); |
| 36 |
|
| 37 |
|
| 38 |
setTimeout( function() { |
| 39 |
var instances = form.data( "ui-form-reset-instances" ); |
| 40 |
$.each( instances, function() { |
| 41 |
this.refresh(); |
| 42 |
} ); |
| 43 |
} ); |
| 44 |
}, |
| 45 |
|
| 46 |
_bindFormResetHandler: function() { |
| 47 |
this.form = $( this.element.prop( "form" ) ); |
| 48 |
if ( !this.form.length ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
var instances = this.form.data( "ui-form-reset-instances" ) || []; |
| 53 |
if ( !instances.length ) { |
| 54 |
|
| 55 |
|
| 56 |
this.form.on( "reset.ui-form-reset", this._formResetHandler ); |
| 57 |
} |
| 58 |
instances.push( this ); |
| 59 |
this.form.data( "ui-form-reset-instances", instances ); |
| 60 |
}, |
| 61 |
|
| 62 |
_unbindFormResetHandler: function() { |
| 63 |
if ( !this.form.length ) { |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
var instances = this.form.data( "ui-form-reset-instances" ); |
| 68 |
instances.splice( $.inArray( this, instances ), 1 ); |
| 69 |
if ( instances.length ) { |
| 70 |
this.form.data( "ui-form-reset-instances", instances ); |
| 71 |
} else { |
| 72 |
this.form |
| 73 |
.removeData( "ui-form-reset-instances" ) |
| 74 |
.off( "reset.ui-form-reset" ); |
| 75 |
} |
| 76 |
} |
| 77 |
}; |
| 78 |
|
| 79 |
} ); |