Merge pull request #8820 from Snuffleupagus/viewer-open-rm-scale
Remove the ability to pass a `scale` parameter in the (optional) `args` object parameter of `PDFViewerApplication.open(file, args)`
This commit is contained in:
commit
26c4536964
35
web/app.js
35
web/app.js
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, MAX_SCALE,
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, MAX_SCALE,
|
||||||
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta,
|
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta, parseQueryString,
|
||||||
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE
|
ProgressBar, RendererType
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import {
|
import {
|
||||||
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException,
|
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException,
|
||||||
@ -649,7 +649,7 @@ let PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let parameters = Object.create(null), scale;
|
let parameters = Object.create(null);
|
||||||
if (typeof file === 'string') { // URL
|
if (typeof file === 'string') { // URL
|
||||||
this.setTitleUsingUrl(file);
|
this.setTitleUsingUrl(file);
|
||||||
parameters.url = file;
|
parameters.url = file;
|
||||||
@ -666,15 +666,16 @@ let PDFViewerApplication = {
|
|||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
for (let prop in 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];
|
parameters[prop] = args[prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.scale) {
|
|
||||||
scale = args.scale;
|
|
||||||
}
|
|
||||||
if (args.length) {
|
|
||||||
this.pdfDocumentProperties.setFileSize(args.length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadingTask = getDocument(parameters);
|
let loadingTask = getDocument(parameters);
|
||||||
@ -693,7 +694,7 @@ let PDFViewerApplication = {
|
|||||||
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
||||||
|
|
||||||
return loadingTask.promise.then((pdfDocument) => {
|
return loadingTask.promise.then((pdfDocument) => {
|
||||||
this.load(pdfDocument, scale);
|
this.load(pdfDocument);
|
||||||
}, (exception) => {
|
}, (exception) => {
|
||||||
let message = exception && exception.message;
|
let message = exception && exception.message;
|
||||||
let loadingErrorMessage;
|
let loadingErrorMessage;
|
||||||
@ -879,8 +880,7 @@ let PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
load(pdfDocument, scale) {
|
load(pdfDocument) {
|
||||||
scale = scale || UNKNOWN_SCALE;
|
|
||||||
this.pdfDocument = pdfDocument;
|
this.pdfDocument = pdfDocument;
|
||||||
|
|
||||||
pdfDocument.getDownloadInfo().then(() => {
|
pdfDocument.getDownloadInfo().then(() => {
|
||||||
@ -977,7 +977,7 @@ let PDFViewerApplication = {
|
|||||||
sidebarView,
|
sidebarView,
|
||||||
};
|
};
|
||||||
}).then(({ hash, sidebarView, }) => {
|
}).then(({ hash, sidebarView, }) => {
|
||||||
this.setInitialView(hash, { sidebarView, scale, });
|
this.setInitialView(hash, { sidebarView, });
|
||||||
initialParams.hash = hash;
|
initialParams.hash = hash;
|
||||||
|
|
||||||
// Make all navigation keys work on document load,
|
// Make all navigation keys work on document load,
|
||||||
@ -1135,9 +1135,7 @@ let PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setInitialView(storedHash, options = {}) {
|
setInitialView(storedHash, { sidebarView, } = {}) {
|
||||||
let { scale = 0, sidebarView = SidebarView.NONE, } = options;
|
|
||||||
|
|
||||||
this.isInitialViewSet = true;
|
this.isInitialViewSet = true;
|
||||||
this.pdfSidebar.setInitialView(sidebarView);
|
this.pdfSidebar.setInitialView(sidebarView);
|
||||||
|
|
||||||
@ -1150,9 +1148,6 @@ let PDFViewerApplication = {
|
|||||||
this.initialBookmark = null;
|
this.initialBookmark = null;
|
||||||
} else if (storedHash) {
|
} else if (storedHash) {
|
||||||
this.pdfLinkService.setHash(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,
|
// Ensure that the correct page number is displayed in the UI,
|
||||||
|
@ -126,7 +126,7 @@ class PDFSidebar {
|
|||||||
* @param {number} view - The sidebar view that should become visible,
|
* @param {number} view - The sidebar view that should become visible,
|
||||||
* must be one of the values in {SidebarView}.
|
* must be one of the values in {SidebarView}.
|
||||||
*/
|
*/
|
||||||
setInitialView(view) {
|
setInitialView(view = SidebarView.NONE) {
|
||||||
if (this.isInitialViewSet) {
|
if (this.isInitialViewSet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user