Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 32 additions & 28 deletions gravity-forms/gw-prevent-duplicate-submissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,51 @@ function gw_disable_submit( $form ) {

<script type="text/javascript">

jQuery( document ).ready( function( $ ) {
document.addEventListener('DOMContentLoaded', function() {
if (typeof jQuery !== 'undefined') {
jQuery( document ).ready( function( $ ) {

var formId = '<?php echo $form['id']; ?>';
var formId = '<?php echo $form['id']; ?>';

$( '#gform_submit_button_' + formId ).on( 'click', function( event ) {
$( '#gform_submit_button_' + formId ).on( 'click', function( event ) {

if( hasPendingFileUploads( formId ) ) {
return;
}

var $submitCopy = $( this ).clone();

$submitCopy
.attr( 'id', '' )
.prop( 'disabled', true )
.attr( 'value', 'Processing...' )
.insertBefore( $( this ) );
if( hasPendingFileUploads( formId ) ) {
return;
}

$( this ).css( { visibility: 'hidden', position: 'absolute', transition: 'all 0s ease 0s' } );
var $submitCopy = $( this ).clone();

} );
$submitCopy
.attr( 'id', '' )
.prop( 'disabled', true )
.attr( 'value', 'Processing...' )
.insertBefore( $( this ) );

function hasPendingFileUploads() {
$( this ).css( { visibility: 'hidden', position: 'absolute', transition: 'all 0s ease 0s' } );

if( ! window[ 'gfMultiFileUploader' ] ) {
return false;
}
} );

var pendingUploads = false;
function hasPendingFileUploads() {

$.each( gfMultiFileUploader.uploaders, function( i, uploader ) {
if( uploader.total.queued > 0 ) {
pendingUploads = true;
if( ! window[ 'gfMultiFileUploader' ] ) {
return false;
}
} );

return pendingUploads;
}
var pendingUploads = false;

$.each( gfMultiFileUploader.uploaders, function( i, uploader ) {
if( uploader.total.queued > 0 ) {
pendingUploads = true;
return false;
}
} );

return pendingUploads;
}

} );
} );
}
});

</script>

Expand Down
Loading