Merge pull request #4455 from aib/master

Fix download button waiting if document has started but not completed downloading
This commit is contained in:
Yury Delendik 2014-04-03 09:40:06 -05:00
commit 9c59437ac3

View File

@ -605,6 +605,8 @@ var PDFView = {
var self = this;
self.loading = true;
self.downloadComplete = false;
var passwordNeeded = function passwordNeeded(updatePassword, reason) {
PasswordPrompt.updatePassword = updatePassword;
PasswordPrompt.reason = reason;
@ -656,7 +658,7 @@ var PDFView = {
},
download: function pdfViewDownload() {
function noData() {
function downloadByUrl() {
downloadManager.downloadUrl(url, filename);
}
@ -670,7 +672,12 @@ var PDFView = {
};
if (!this.pdfDocument) { // the PDF is not ready yet
noData();
downloadByUrl();
return;
}
if (!this.downloadComplete) { // the PDF is still downloading
downloadByUrl();
return;
}
@ -679,8 +686,8 @@ var PDFView = {
var blob = PDFJS.createBlob(data, 'application/pdf');
downloadManager.download(blob, url, filename);
},
noData // Error occurred try downloading with just the url.
).then(null, noData);
downloadByUrl // Error occurred try downloading with just the url.
).then(null, downloadByUrl);
},
fallback: function pdfViewFallback(featureId) {
@ -897,6 +904,7 @@ var PDFView = {
DocumentProperties.resolveDataAvailable();
pdfDocument.getDownloadInfo().then(function() {
self.downloadComplete = true;
PDFView.loadingBar.hide();
var outerContainer = document.getElementById('outerContainer');
outerContainer.classList.remove('loadingInProgress');