Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ability to pass a scale parameter in the (optional) args object parameter of PDFViewerApplication.open(file, args) #8820

Merged
merged 1 commit into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import {
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, MAX_SCALE,
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta,
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta, parseQueryString,
ProgressBar, RendererType
} from './ui_utils';
import {
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException,
Expand Down Expand Up @@ -649,7 +649,7 @@ let PDFViewerApplication = {
});
}

let parameters = Object.create(null), scale;
let parameters = Object.create(null);
if (typeof file === 'string') { // URL
this.setTitleUsingUrl(file);
parameters.url = file;
Expand All @@ -666,15 +666,16 @@ let PDFViewerApplication = {

if (args) {
for (let prop in args) {
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PDFJS_NEXT')) &&
!PDFJS.pdfjsNext && prop === 'scale') {
console.error('Call of open() with obsolete "scale" argument, ' +
'please use the "defaultZoomValue" preference instead.');
continue;
} else if (prop === 'length') {
this.pdfDocumentProperties.setFileSize(args[prop]);
}
parameters[prop] = args[prop];
}

if (args.scale) {
scale = args.scale;
}
if (args.length) {
this.pdfDocumentProperties.setFileSize(args.length);
}
}

let loadingTask = getDocument(parameters);
Expand All @@ -693,7 +694,7 @@ let PDFViewerApplication = {
loadingTask.onUnsupportedFeature = this.fallback.bind(this);

return loadingTask.promise.then((pdfDocument) => {
this.load(pdfDocument, scale);
this.load(pdfDocument);
}, (exception) => {
let message = exception && exception.message;
let loadingErrorMessage;
Expand Down Expand Up @@ -879,8 +880,7 @@ let PDFViewerApplication = {
}
},

load(pdfDocument, scale) {
scale = scale || UNKNOWN_SCALE;
load(pdfDocument) {
this.pdfDocument = pdfDocument;

pdfDocument.getDownloadInfo().then(() => {
Expand Down Expand Up @@ -977,7 +977,7 @@ let PDFViewerApplication = {
sidebarView,
};
}).then(({ hash, sidebarView, }) => {
this.setInitialView(hash, { sidebarView, scale, });
this.setInitialView(hash, { sidebarView, });
initialParams.hash = hash;

// Make all navigation keys work on document load,
Expand Down Expand Up @@ -1135,9 +1135,7 @@ let PDFViewerApplication = {
});
},

setInitialView(storedHash, options = {}) {
let { scale = 0, sidebarView = SidebarView.NONE, } = options;

setInitialView(storedHash, { sidebarView, } = {}) {
this.isInitialViewSet = true;
this.pdfSidebar.setInitialView(sidebarView);

Expand All @@ -1150,9 +1148,6 @@ let PDFViewerApplication = {
this.initialBookmark = null;
} else if (storedHash) {
this.pdfLinkService.setHash(storedHash);
} else if (scale) {
this.pdfViewer.currentScaleValue = scale;
this.page = 1;
}

// Ensure that the correct page number is displayed in the UI,
Expand Down
2 changes: 1 addition & 1 deletion web/pdf_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class PDFSidebar {
* @param {number} view - The sidebar view that should become visible,
* must be one of the values in {SidebarView}.
*/
setInitialView(view) {
setInitialView(view = SidebarView.NONE) {
if (this.isInitialViewSet) {
return;
}
Expand Down