mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
Merge pull request #4519 from yurydelendik/pdfbugclean
Cleaning up the viewer and pdfbug; fixes bugs in Stepper
This commit is contained in:
commit
a06fca142e
2 changed files with 118 additions and 39 deletions
|
@ -546,9 +546,43 @@ var PDFView = {
|
|||
//#endif
|
||||
},
|
||||
|
||||
close: function pdfViewClose() {
|
||||
if (!this.pdfDocument) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pdfDocument.destroy();
|
||||
this.pdfDocument = null;
|
||||
|
||||
var errorWrapper = document.getElementById('errorWrapper');
|
||||
errorWrapper.setAttribute('hidden', 'true');
|
||||
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
while (thumbsView.hasChildNodes()) {
|
||||
thumbsView.removeChild(thumbsView.lastChild);
|
||||
}
|
||||
|
||||
if ('_loadingInterval' in thumbsView) {
|
||||
clearInterval(thumbsView._loadingInterval);
|
||||
}
|
||||
|
||||
var container = document.getElementById('viewer');
|
||||
while (container.hasChildNodes()) {
|
||||
container.removeChild(container.lastChild);
|
||||
}
|
||||
|
||||
if (typeof PDFBug !== 'undefined') {
|
||||
PDFBug.cleanup();
|
||||
}
|
||||
},
|
||||
|
||||
// TODO(mack): This function signature should really be pdfViewOpen(url, args)
|
||||
open: function pdfViewOpen(url, scale, password,
|
||||
pdfDataRangeTransport, args) {
|
||||
if (this.pdfDocument) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
var parameters = {password: password};
|
||||
if (typeof url === 'string') { // URL
|
||||
this.setTitleUsingUrl(url);
|
||||
|
@ -562,11 +596,6 @@ var PDFView = {
|
|||
}
|
||||
}
|
||||
|
||||
// Terminate worker of the previous document if any.
|
||||
if (this.pdfDocument) {
|
||||
this.pdfDocument.destroy();
|
||||
}
|
||||
this.pdfDocument = null;
|
||||
var self = this;
|
||||
self.loading = true;
|
||||
var passwordNeeded = function passwordNeeded(updatePassword, reason) {
|
||||
|
@ -858,31 +887,12 @@ var PDFView = {
|
|||
|
||||
this.pdfDocument = pdfDocument;
|
||||
|
||||
var errorWrapper = document.getElementById('errorWrapper');
|
||||
errorWrapper.setAttribute('hidden', 'true');
|
||||
|
||||
pdfDocument.getDownloadInfo().then(function() {
|
||||
PDFView.loadingBar.hide();
|
||||
var outerContainer = document.getElementById('outerContainer');
|
||||
outerContainer.classList.remove('loadingInProgress');
|
||||
});
|
||||
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
thumbsView.parentNode.scrollTop = 0;
|
||||
|
||||
while (thumbsView.hasChildNodes()) {
|
||||
thumbsView.removeChild(thumbsView.lastChild);
|
||||
}
|
||||
|
||||
if ('_loadingInterval' in thumbsView) {
|
||||
clearInterval(thumbsView._loadingInterval);
|
||||
}
|
||||
|
||||
var container = document.getElementById('viewer');
|
||||
while (container.hasChildNodes()) {
|
||||
container.removeChild(container.lastChild);
|
||||
}
|
||||
|
||||
var pagesCount = pdfDocument.numPages;
|
||||
|
||||
var id = pdfDocument.fingerprint;
|
||||
|
@ -907,6 +917,8 @@ var PDFView = {
|
|||
this.pagesPromise = pagesPromise;
|
||||
|
||||
var firstPagePromise = pdfDocument.getPage(1);
|
||||
var container = document.getElementById('viewer');
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
|
||||
// Fetch a single page so we can get a viewport that will be the default
|
||||
// viewport for all pages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue