Move the defaultUrl
parameter from the appConfig
and into AppOptions
instead
The `appConfig` contains (mostly) references to various DOM elements, used when initializing the viewer components. Hence `defaultUrl` seem like a slightly better fit for the new `AppOptions` abstraction, not to mention that it should thus be easier to set/modify it for custom deployments of the default viewer.
This commit is contained in:
parent
81c550903f
commit
57165afb08
@ -1568,12 +1568,12 @@ function webViewerInitialized() {
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
let queryString = document.location.search.substring(1);
|
||||
let params = parseQueryString(queryString);
|
||||
file = 'file' in params ? params.file : appConfig.defaultUrl;
|
||||
file = 'file' in params ? params.file : AppOptions.get('defaultUrl');
|
||||
validateFileURL(file);
|
||||
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
||||
file = window.location.href.split('#')[0];
|
||||
} else if (PDFJSDev.test('CHROME')) {
|
||||
file = appConfig.defaultUrl;
|
||||
file = AppOptions.get('defaultUrl');
|
||||
}
|
||||
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
|
@ -27,6 +27,11 @@ const OptionKind = {
|
||||
* compare with the format of `default_preferences.json`.
|
||||
*/
|
||||
const defaultOptions = {
|
||||
defaultUrl: {
|
||||
/** @type {string} */
|
||||
value: 'compressed.tracemonkey-pldi-09.pdf',
|
||||
kind: OptionKind.VIEWER,
|
||||
},
|
||||
defaultZoomValue: {
|
||||
/** @type {string} */
|
||||
value: '',
|
||||
|
@ -16,18 +16,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
let DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
|
||||
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
||||
var defaultUrl; // eslint-disable-line no-var
|
||||
|
||||
(function rewriteUrlClosure() {
|
||||
// Run this code outside DOMContentLoaded to make sure that the URL
|
||||
// is rewritten as soon as possible.
|
||||
let queryString = document.location.search.slice(1);
|
||||
let m = /(^|&)file=([^&]*)/.exec(queryString);
|
||||
DEFAULT_URL = m ? decodeURIComponent(m[2]) : '';
|
||||
defaultUrl = m ? decodeURIComponent(m[2]) : '';
|
||||
|
||||
// Example: chrome-extension://.../http://example.com/file.pdf
|
||||
let humanReadableUrl = '/' + DEFAULT_URL + location.hash;
|
||||
let humanReadableUrl = '/' + defaultUrl + location.hash;
|
||||
history.replaceState(history.state, '', humanReadableUrl);
|
||||
if (top === window) {
|
||||
chrome.runtime.sendMessage('showPageAction');
|
||||
@ -172,7 +172,6 @@ function getViewerConfiguration() {
|
||||
printContainer: document.getElementById('printContainer'),
|
||||
openFileInputName: 'fileInput',
|
||||
debuggerScriptPath: './debugger.js',
|
||||
defaultUrl: DEFAULT_URL,
|
||||
};
|
||||
}
|
||||
|
||||
@ -190,6 +189,10 @@ function webViewerLoad() {
|
||||
app.PDFViewerApplication.run(config);
|
||||
});
|
||||
} else {
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
||||
pdfjsWebAppOptions.AppOptions.set('defaultUrl', defaultUrl);
|
||||
}
|
||||
|
||||
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
|
||||
window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
|
||||
pdfjsWebApp.PDFViewerApplication.run(config);
|
||||
|
Loading…
x
Reference in New Issue
Block a user