-
-
Save matijs/9429123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Show a progress element for any form submission via POST. | |
Prevent the form element from being submitted twice. | |
*/ | |
(function ( win, doc ) { | |
'use strict'; | |
if ( !win.addEventListener ) { | |
// doesn't cut the mustard. | |
return; | |
} | |
var submitting = false; | |
function checkForm( event ) { | |
if ( submitting ) { | |
event.preventDefault(); | |
} | |
else { | |
if ( event.target.method === 'post' ) { | |
submitting = true; | |
event.target.appendChild( doc.createElement('progress') ); | |
} | |
} | |
} | |
doc.documentElement.addEventListener( 'submit', checkForm, false ); | |
}( this, this.document )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment