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.
This commit is contained in:
Shubham Dhama 2018-04-17 01:03:48 +05:30 committed by Tim Abbott
parent c67897ba5b
commit 02c3223985
1 changed files with 11 additions and 9 deletions

View File

@ -50,10 +50,8 @@ exports.options = function (config) {
} }
var hide_upload_status = function () { var hide_upload_status = function () {
setTimeout(function () {
send_button.prop("disabled", false); send_button.prop("disabled", false);
send_status.removeClass("alert-info").hide(); send_status.removeClass("alert-info").hide();
}, 500);
$('div.progress.active').remove(); $('div.progress.active').remove();
}; };
@ -61,7 +59,9 @@ exports.options = function (config) {
send_button.attr("disabled", ""); send_button.attr("disabled", "");
send_status.addClass("alert-info").show(); send_status.addClass("alert-info").show();
send_status_close.one('click', function () { send_status_close.one('click', function () {
setTimeout(function () {
hide_upload_status(); hide_upload_status();
}, 500);
compose.abort_xhr(); compose.abort_xhr();
}); });
}; };
@ -140,10 +140,12 @@ exports.options = function (config) {
} }
compose_ui.autosize_textarea(); compose_ui.autosize_textarea();
setTimeout(function () {
$("#" + upload_bar + '-' + file.lastModified).parent().remove(); $("#" + upload_bar + '-' + file.lastModified).parent().remove();
if ($('div.progress.active').length === 0) { if ($('div.progress.active').length === 0) {
hide_upload_status(); hide_upload_status(file);
} }
}, 500);
// In order to upload the same file twice in a row, we need to clear out // 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, // the file input element, so that the next time we use the file dialog,