standard header in about page (#676)
[openemr.git] / public / assets / jquery-ui-1-12-1 / ui / form-reset-mixin.js
blob74be1d5b9a783fe3fda25629c9c941b4f2d57c18
1 /*!
2  * jQuery UI Form Reset Mixin 1.12.1
3  * http://jqueryui.com
4  *
5  * Copyright jQuery Foundation and other contributors
6  * Released under the MIT license.
7  * http://jquery.org/license
8  */
10 //>>label: Form Reset Mixin
11 //>>group: Core
12 //>>description: Refresh input widgets when their form is reset
13 //>>docs: http://api.jqueryui.com/form-reset-mixin/
15 ( function( factory ) {
16         if ( typeof define === "function" && define.amd ) {
18                 // AMD. Register as an anonymous module.
19                 define( [
20                         "jquery",
21                         "./form",
22                         "./version"
23                 ], factory );
24         } else {
26                 // Browser globals
27                 factory( jQuery );
28         }
29 }( function( $ ) {
31 return $.ui.formResetMixin = {
32         _formResetHandler: function() {
33                 var form = $( this );
35                 // Wait for the form reset to actually happen before refreshing
36                 setTimeout( function() {
37                         var instances = form.data( "ui-form-reset-instances" );
38                         $.each( instances, function() {
39                                 this.refresh();
40                         } );
41                 } );
42         },
44         _bindFormResetHandler: function() {
45                 this.form = this.element.form();
46                 if ( !this.form.length ) {
47                         return;
48                 }
50                 var instances = this.form.data( "ui-form-reset-instances" ) || [];
51                 if ( !instances.length ) {
53                         // We don't use _on() here because we use a single event handler per form
54                         this.form.on( "reset.ui-form-reset", this._formResetHandler );
55                 }
56                 instances.push( this );
57                 this.form.data( "ui-form-reset-instances", instances );
58         },
60         _unbindFormResetHandler: function() {
61                 if ( !this.form.length ) {
62                         return;
63                 }
65                 var instances = this.form.data( "ui-form-reset-instances" );
66                 instances.splice( $.inArray( this, instances ), 1 );
67                 if ( instances.length ) {
68                         this.form.data( "ui-form-reset-instances", instances );
69                 } else {
70                         this.form
71                                 .removeData( "ui-form-reset-instances" )
72                                 .off( "reset.ui-form-reset" );
73                 }
74         }
77 } ) );