Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change button state before event process #1866

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions client/src/legacy/LeftAndMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ $.entwine('ss', function($) {
// default to first button if none given - simulates browser behaviour
if(!button) button = this.find('.btn-toolbar :submit:first');

if ($(button).is("button")) {
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
$(button).append(
$(
'<div class="btn__loading-icon">' +
'<span class="btn__circle btn__circle--1"></span>' +
'<span class="btn__circle btn__circle--2"></span>' +
'<span class="btn__circle btn__circle--3"></span>' +
"</div>"
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
)
);

$(button).css($(button).outerWidth() + "px");
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
}

// set button to "submitting" state
$(button).addClass('btn--loading loading');
$(button).prop('disabled', true);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

var beforeSubmitFormEventData = {
// array of promises that must resolve({success:true}) before the form is submitted
// result of each promise must be an object of
Expand Down Expand Up @@ -499,15 +517,12 @@ $.entwine('ss', function($) {
}
});
}
clearButton();
return false;
}

self.trigger('submitform', {form: form, button: button});

// set button to "submitting" state
$(button).addClass('btn--loading loading');
$(button).prop('disabled', true);

if($(button).is('button')) {
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

$(button).append($(
Expand Down Expand Up @@ -572,7 +587,10 @@ $.entwine('ss', function($) {
newContentEls.filter('form').trigger('aftersubmitform', {status: status, xhr: xhr, formData: formData});
}
}, ajaxOptions));
});
}).catch(function() {
// Handle errors from the promises
clearButton();
});;

return false;
},
Expand Down