Skip to content
Snippets Groups Projects
Commit ffaac323 authored by Sean McArthur's avatar Sean McArthur
Browse files

use jQuery.promise to trigger callbacks instead of setTimeout

this makes sure callbacks for animations truly are called only
after the animation has finished. before, it'd be possible to trigger slightly ahead because of setTimeout tomfoolery
parent 4b14bf66
No related branches found
No related tags found
No related merge requests found
......@@ -73,26 +73,19 @@ BrowserID.PageHelpers = (function() {
function replaceFormWithNotice(selector, onComplete) {
$("form").hide();
$(selector).fadeIn(ANIMATION_SPEED);
// If there is more than one .forminputs, the onComplete callback is called
// multiple times, we only want once.
onComplete && setTimeout(onComplete, ANIMATION_SPEED);
$(selector).fadeIn(ANIMATION_SPEED).promise().done(onComplete);
}
function replaceInputsWithNotice(selector, onComplete) {
$('.forminputs').hide();
$(selector).stop().hide().css({opacity:1}).fadeIn(ANIMATION_SPEED);
// If there is more than one .forminputs, the onComplete callback is called
// multiple times, we only want once.
onComplete && setTimeout(onComplete, ANIMATION_SPEED);
$(selector).stop().hide().css({opacity:1}).fadeIn(ANIMATION_SPEED)
.promise().done(onComplete);
}
function showInputs(onComplete) {
$('.notification').hide();
$('.forminputs').stop().hide().css({opacity:1}).fadeIn(ANIMATION_SPEED);
// If there is more than one .forminputs, the onComplete callback is called
// multiple times, we only want once.
onComplete && setTimeout(onComplete, ANIMATION_SPEED);
$('.forminputs').stop().hide().css({opacity:1}).fadeIn(ANIMATION_SPEED)
.promise().done(onComplete);
}
function emailSent(onComplete) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment