Skip to content

Commit

Permalink
Fix #729: Implement progressUploadThreshold to show processing when…
Browse files Browse the repository at this point in the history
… waiting for server response
  • Loading branch information
kartik-v committed Aug 2, 2016
1 parent 86d03e4 commit 921e568
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions js/fileinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@
self.uploadCount = 0;
self.uploadStatus = {};
self.uploadLog = [];
self._setProgress(100);
self._setProgress(101);
}, 100);
};
fnBefore = function (jqXHR) {
Expand Down Expand Up @@ -1809,6 +1809,7 @@
$btnUpload.removeAttr('disabled');
$btnDelete.removeAttr('disabled');
$thumb.removeClass('file-uploading');
self._setProgress(101, $('#' + previewId).find('.file-thumb-progress'));
}
if (!allFiles) {
self.unlock(false);
Expand Down Expand Up @@ -1916,7 +1917,7 @@
}
};
fnComplete = function () {
self._setProgress(100);
self._setProgress(101);
self.unlock();
self._initSuccessThumbs();
self._clearFileInput();
Expand Down Expand Up @@ -1976,7 +1977,7 @@
}
};
fnComplete = function () {
self._setProgress(100);
self._setProgress(101);
self.unlock();
self._clearFileInput();
self._raise('filebatchuploadcomplete', [self.filestack, self._getExtraData()]);
Expand Down Expand Up @@ -2337,16 +2338,17 @@
},
_setProgressCancelled: function () {
var self = this;
self._setProgress(100, self.$progress, self.msgCancelled);
self._setProgress(101, self.$progress, self.msgCancelled);
},
_setProgress: function (p, $el, error) {
var self = this, pct = Math.min(p, 100), template = pct < 100 ? self.progressTemplate :
(error ? self.progressErrorTemplate : self.progressCompleteTemplate),
pctLimit = self.progressUploadThreshold;
$el = $el || self.$progress;
if (!isEmpty(template)) {
if (pctLimit && pct > pctLimit) {
$el.html(template.replace('{percent}%', self.msgUploadThreshold).replace(/\{percent}/g, pctLimit));
if (pctLimit && pct > pctLimit && p <= 100) {
var out = template.replace('{percent}', pctLimit).replace('{percent}', pctLimit).replace('{percent}%', self.msgUploadThreshold);
$el.html(out);
} else {
$el.html(template.replace(/\{percent}/g, pct));
}
Expand Down Expand Up @@ -2813,7 +2815,7 @@
data.abortData = self.ajaxAborted.data || {};
data.abortMessage = self.ajaxAborted.message;
self.cancel();
self._setProgress(100, self.$progress, self.msgCancelled);
self._setProgress(101, self.$progress, self.msgCancelled);
self._showUploadError(self.ajaxAborted.message, data, 'filecustomerror');
return true;
}
Expand Down
Loading

0 comments on commit 921e568

Please sign in to comment.