From 02c322398507a0ec475163175e3574ed3bee04de Mon Sep 17 00:00:00 2001 From: Shubham Dhama Date: Tue, 17 Apr 2018 01:03:48 +0530 Subject: [PATCH] upload: Improve logic for hiding progress bar for fast upload. With past logic, on fast upload progress bar don't appears because uploadFinished is called as soon as upload is finished so progress bar get disappeared. To make these hiding of progress bar smooth we set setTimeout for every hiding of progress bar as well as complete status element. --- static/js/upload.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/static/js/upload.js b/static/js/upload.js index 55f4aee01d..b2e57aeb85 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -50,10 +50,8 @@ exports.options = function (config) { } var hide_upload_status = function () { - setTimeout(function () { - send_button.prop("disabled", false); - send_status.removeClass("alert-info").hide(); - }, 500); + send_button.prop("disabled", false); + send_status.removeClass("alert-info").hide(); $('div.progress.active').remove(); }; @@ -61,7 +59,9 @@ exports.options = function (config) { send_button.attr("disabled", ""); send_status.addClass("alert-info").show(); send_status_close.one('click', function () { - hide_upload_status(); + setTimeout(function () { + hide_upload_status(); + }, 500); compose.abort_xhr(); }); }; @@ -140,10 +140,12 @@ exports.options = function (config) { } compose_ui.autosize_textarea(); - $("#" + upload_bar + '-' + file.lastModified).parent().remove(); - if ($('div.progress.active').length === 0) { - hide_upload_status(); - } + setTimeout(function () { + $("#" + upload_bar + '-' + file.lastModified).parent().remove(); + if ($('div.progress.active').length === 0) { + hide_upload_status(file); + } + }, 500); // In order to upload the same file twice in a row, we need to clear out // the file input element, so that the next time we use the file dialog,