|
|
@ -44,8 +44,8 @@ import { SecondaryToolbar } from './secondary_toolbar'; |
|
|
|
import { Toolbar } from './toolbar'; |
|
|
|
import { Toolbar } from './toolbar'; |
|
|
|
import { ViewHistory } from './view_history'; |
|
|
|
import { ViewHistory } from './view_history'; |
|
|
|
|
|
|
|
|
|
|
|
var DEFAULT_SCALE_DELTA = 1.1; |
|
|
|
const DEFAULT_SCALE_DELTA = 1.1; |
|
|
|
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; |
|
|
|
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; |
|
|
|
|
|
|
|
|
|
|
|
function configure(PDFJS) { |
|
|
|
function configure(PDFJS) { |
|
|
|
PDFJS.imageResourcesPath = './images/'; |
|
|
|
PDFJS.imageResourcesPath = './images/'; |
|
|
@ -64,7 +64,7 @@ function configure(PDFJS) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var DefaultExternalServices = { |
|
|
|
const DefaultExternalServices = { |
|
|
|
updateFindControlState(data) {}, |
|
|
|
updateFindControlState(data) {}, |
|
|
|
initPassiveLoading(callbacks) {}, |
|
|
|
initPassiveLoading(callbacks) {}, |
|
|
|
fallback(data, callback) {}, |
|
|
|
fallback(data, callback) {}, |
|
|
@ -87,7 +87,7 @@ var DefaultExternalServices = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var PDFViewerApplication = { |
|
|
|
let PDFViewerApplication = { |
|
|
|
initialBookmark: document.location.hash.substring(1), |
|
|
|
initialBookmark: document.location.hash.substring(1), |
|
|
|
initialDestination: null, |
|
|
|
initialDestination: null, |
|
|
|
initialized: false, |
|
|
|
initialized: false, |
|
|
@ -153,8 +153,8 @@ var PDFViewerApplication = { |
|
|
|
externalServices: DefaultExternalServices, |
|
|
|
externalServices: DefaultExternalServices, |
|
|
|
_boundEvents: {}, |
|
|
|
_boundEvents: {}, |
|
|
|
|
|
|
|
|
|
|
|
// called once when the document is loaded
|
|
|
|
// Called once when the document is loaded.
|
|
|
|
initialize: function pdfViewInitialize(appConfig) { |
|
|
|
initialize(appConfig) { |
|
|
|
this.preferences = this.externalServices.createPreferences(); |
|
|
|
this.preferences = this.externalServices.createPreferences(); |
|
|
|
|
|
|
|
|
|
|
|
configure(PDFJS); |
|
|
|
configure(PDFJS); |
|
|
@ -171,7 +171,7 @@ var PDFViewerApplication = { |
|
|
|
this.bindWindowEvents(); |
|
|
|
this.bindWindowEvents(); |
|
|
|
|
|
|
|
|
|
|
|
// We can start UI localization now.
|
|
|
|
// We can start UI localization now.
|
|
|
|
var appContainer = appConfig.appContainer || document.documentElement; |
|
|
|
let appContainer = appConfig.appContainer || document.documentElement; |
|
|
|
this.l10n.translate(appContainer).then(() => { |
|
|
|
this.l10n.translate(appContainer).then(() => { |
|
|
|
// Dispatch the 'localized' event on the `eventBus` once the viewer
|
|
|
|
// Dispatch the 'localized' event on the `eventBus` once the viewer
|
|
|
|
// has been fully initialized and translated.
|
|
|
|
// has been fully initialized and translated.
|
|
|
@ -192,7 +192,7 @@ var PDFViewerApplication = { |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
_readPreferences() { |
|
|
|
_readPreferences() { |
|
|
|
var { preferences, viewerPrefs, } = this; |
|
|
|
let { preferences, viewerPrefs, } = this; |
|
|
|
|
|
|
|
|
|
|
|
return Promise.all([ |
|
|
|
return Promise.all([ |
|
|
|
preferences.get('enableWebGL').then(function resolved(value) { |
|
|
|
preferences.get('enableWebGL').then(function resolved(value) { |
|
|
@ -422,12 +422,12 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
run: function pdfViewRun(config) { |
|
|
|
run(config) { |
|
|
|
this.initialize(config).then(webViewerInitialized); |
|
|
|
this.initialize(config).then(webViewerInitialized); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
zoomIn: function pdfViewZoomIn(ticks) { |
|
|
|
zoomIn(ticks) { |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
let newScale = this.pdfViewer.currentScale; |
|
|
|
do { |
|
|
|
do { |
|
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = Math.ceil(newScale * 10) / 10; |
|
|
|
newScale = Math.ceil(newScale * 10) / 10; |
|
|
@ -436,8 +436,8 @@ var PDFViewerApplication = { |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
zoomOut: function pdfViewZoomOut(ticks) { |
|
|
|
zoomOut(ticks) { |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
let newScale = this.pdfViewer.currentScale; |
|
|
|
do { |
|
|
|
do { |
|
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = Math.floor(newScale * 10) / 10; |
|
|
|
newScale = Math.floor(newScale * 10) / 10; |
|
|
@ -471,12 +471,12 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get supportsFullscreen() { |
|
|
|
get supportsFullscreen() { |
|
|
|
var support; |
|
|
|
let support; |
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) { |
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) { |
|
|
|
support = document.fullscreenEnabled === true || |
|
|
|
support = document.fullscreenEnabled === true || |
|
|
|
document.mozFullScreenEnabled === true; |
|
|
|
document.mozFullScreenEnabled === true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
var doc = document.documentElement; |
|
|
|
let doc = document.documentElement; |
|
|
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || |
|
|
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || |
|
|
|
doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
|
|
|
|
|
|
|
@ -507,8 +507,7 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get loadingBar() { |
|
|
|
get loadingBar() { |
|
|
|
var bar = new ProgressBar('#loadingBar'); |
|
|
|
let bar = new ProgressBar('#loadingBar'); |
|
|
|
|
|
|
|
|
|
|
|
return shadow(this, 'loadingBar', bar); |
|
|
|
return shadow(this, 'loadingBar', bar); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -516,9 +515,11 @@ var PDFViewerApplication = { |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
initPassiveLoading: function pdfViewInitPassiveLoading() { |
|
|
|
initPassiveLoading() { |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) { |
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) { |
|
|
|
|
|
|
|
throw new Error('Not implemented: initPassiveLoading'); |
|
|
|
|
|
|
|
} |
|
|
|
this.externalServices.initPassiveLoading({ |
|
|
|
this.externalServices.initPassiveLoading({ |
|
|
|
onOpenWithTransport(url, length, transport) { |
|
|
|
onOpenWithTransport(url, length, transport) { |
|
|
|
PDFViewerApplication.open(url, { range: transport, }); |
|
|
|
PDFViewerApplication.open(url, { range: transport, }); |
|
|
@ -531,7 +532,7 @@ var PDFViewerApplication = { |
|
|
|
PDFViewerApplication.open(data); |
|
|
|
PDFViewerApplication.open(data); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onOpenWithURL(url, length, originalURL) { |
|
|
|
onOpenWithURL(url, length, originalURL) { |
|
|
|
var file = url, args = null; |
|
|
|
let file = url, args = null; |
|
|
|
if (length !== undefined) { |
|
|
|
if (length !== undefined) { |
|
|
|
args = { length, }; |
|
|
|
args = { length, }; |
|
|
|
} |
|
|
|
} |
|
|
@ -550,19 +551,16 @@ var PDFViewerApplication = { |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error('Not implemented: initPassiveLoading'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { |
|
|
|
setTitleUsingUrl(url) { |
|
|
|
this.url = url; |
|
|
|
this.url = url; |
|
|
|
this.baseUrl = url.split('#')[0]; |
|
|
|
this.baseUrl = url.split('#')[0]; |
|
|
|
var title = getPDFFileNameFromURL(url, ''); |
|
|
|
let title = getPDFFileNameFromURL(url, ''); |
|
|
|
if (!title) { |
|
|
|
if (!title) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
title = decodeURIComponent(getFilenameFromUrl(url)) || url; |
|
|
|
title = decodeURIComponent(getFilenameFromUrl(url)) || url; |
|
|
|
} catch (e) { |
|
|
|
} catch (ex) { |
|
|
|
// decodeURIComponent may throw URIError,
|
|
|
|
// decodeURIComponent may throw URIError,
|
|
|
|
// fall back to using the unprocessed url in that case
|
|
|
|
// fall back to using the unprocessed url in that case
|
|
|
|
title = url; |
|
|
|
title = url; |
|
|
@ -571,7 +569,7 @@ var PDFViewerApplication = { |
|
|
|
this.setTitle(title); |
|
|
|
this.setTitle(title); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setTitle: function pdfViewSetTitle(title) { |
|
|
|
setTitle(title) { |
|
|
|
if (this.isViewerEmbedded) { |
|
|
|
if (this.isViewerEmbedded) { |
|
|
|
// Embedded PDF viewers should not be changing their parent page's title.
|
|
|
|
// Embedded PDF viewers should not be changing their parent page's title.
|
|
|
|
return; |
|
|
|
return; |
|
|
@ -584,15 +582,15 @@ var PDFViewerApplication = { |
|
|
|
* @returns {Promise} - Returns the promise, which is resolved when all |
|
|
|
* @returns {Promise} - Returns the promise, which is resolved when all |
|
|
|
* destruction is completed. |
|
|
|
* destruction is completed. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
close: function pdfViewClose() { |
|
|
|
close() { |
|
|
|
var errorWrapper = this.appConfig.errorWrapper.container; |
|
|
|
let errorWrapper = this.appConfig.errorWrapper.container; |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
|
|
|
|
|
|
|
|
if (!this.pdfLoadingTask) { |
|
|
|
if (!this.pdfLoadingTask) { |
|
|
|
return Promise.resolve(); |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var promise = this.pdfLoadingTask.destroy(); |
|
|
|
let promise = this.pdfLoadingTask.destroy(); |
|
|
|
this.pdfLoadingTask = null; |
|
|
|
this.pdfLoadingTask = null; |
|
|
|
|
|
|
|
|
|
|
|
if (this.pdfDocument) { |
|
|
|
if (this.pdfDocument) { |
|
|
@ -718,42 +716,36 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
download: function pdfViewDownload() { |
|
|
|
download() { |
|
|
|
function downloadByUrl() { |
|
|
|
function downloadByUrl() { |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var url = this.baseUrl; |
|
|
|
let url = this.baseUrl; |
|
|
|
// Use this.url instead of this.baseUrl to perform filename detection based
|
|
|
|
// Use this.url instead of this.baseUrl to perform filename detection based
|
|
|
|
// on the reference fragment as ultimate fallback if needed.
|
|
|
|
// on the reference fragment as ultimate fallback if needed.
|
|
|
|
var filename = getPDFFileNameFromURL(this.url); |
|
|
|
let filename = getPDFFileNameFromURL(this.url); |
|
|
|
var downloadManager = this.downloadManager; |
|
|
|
let downloadManager = this.downloadManager; |
|
|
|
downloadManager.onerror = function (err) { |
|
|
|
downloadManager.onerror = (err) => { |
|
|
|
// This error won't really be helpful because it's likely the
|
|
|
|
// This error won't really be helpful because it's likely the
|
|
|
|
// fallback won't work either (or is already open).
|
|
|
|
// fallback won't work either (or is already open).
|
|
|
|
PDFViewerApplication.error('PDF failed to download.'); |
|
|
|
this.error(`PDF failed to download: ${err}`); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (!this.pdfDocument) { // the PDF is not ready yet
|
|
|
|
// When the PDF document isn't ready, or the PDF file is still downloading,
|
|
|
|
|
|
|
|
// simply download using the URL.
|
|
|
|
|
|
|
|
if (!this.pdfDocument || !this.downloadComplete) { |
|
|
|
downloadByUrl(); |
|
|
|
downloadByUrl(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!this.downloadComplete) { // the PDF is still downloading
|
|
|
|
this.pdfDocument.getData().then(function(data) { |
|
|
|
downloadByUrl(); |
|
|
|
let blob = createBlob(data, 'application/pdf'); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.pdfDocument.getData().then( |
|
|
|
|
|
|
|
function getDataSuccess(data) { |
|
|
|
|
|
|
|
var blob = createBlob(data, 'application/pdf'); |
|
|
|
|
|
|
|
downloadManager.download(blob, url, filename); |
|
|
|
downloadManager.download(blob, url, filename); |
|
|
|
}, |
|
|
|
}).catch(downloadByUrl); // Error occurred, try downloading with the URL.
|
|
|
|
downloadByUrl // Error occurred try downloading with just the url.
|
|
|
|
|
|
|
|
).then(null, downloadByUrl); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fallback: function pdfViewFallback(featureId) { |
|
|
|
fallback(featureId) { |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
// Only trigger the fallback once so we don't spam the user with messages
|
|
|
|
// Only trigger the fallback once so we don't spam the user with messages
|
|
|
@ -781,7 +773,7 @@ var PDFViewerApplication = { |
|
|
|
* that is more technical. Should have a 'message' |
|
|
|
* that is more technical. Should have a 'message' |
|
|
|
* and optionally a 'stack' property. |
|
|
|
* and optionally a 'stack' property. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
error: function pdfViewError(message, moreInfo) { |
|
|
|
error(message, moreInfo) { |
|
|
|
let moreInfoText = [this.l10n.get('error_version_info', |
|
|
|
let moreInfoText = [this.l10n.get('error_version_info', |
|
|
|
{ version: version || '?', build: build || '?', }, |
|
|
|
{ version: version || '?', build: build || '?', }, |
|
|
|
'PDF.js v{{version}} (build: {{build}})')]; |
|
|
|
'PDF.js v{{version}} (build: {{build}})')]; |
|
|
@ -809,21 +801,21 @@ var PDFViewerApplication = { |
|
|
|
|
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
var errorWrapperConfig = this.appConfig.errorWrapper; |
|
|
|
let errorWrapperConfig = this.appConfig.errorWrapper; |
|
|
|
var errorWrapper = errorWrapperConfig.container; |
|
|
|
let errorWrapper = errorWrapperConfig.container; |
|
|
|
errorWrapper.removeAttribute('hidden'); |
|
|
|
errorWrapper.removeAttribute('hidden'); |
|
|
|
|
|
|
|
|
|
|
|
var errorMessage = errorWrapperConfig.errorMessage; |
|
|
|
let errorMessage = errorWrapperConfig.errorMessage; |
|
|
|
errorMessage.textContent = message; |
|
|
|
errorMessage.textContent = message; |
|
|
|
|
|
|
|
|
|
|
|
var closeButton = errorWrapperConfig.closeButton; |
|
|
|
let closeButton = errorWrapperConfig.closeButton; |
|
|
|
closeButton.onclick = function() { |
|
|
|
closeButton.onclick = function() { |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var errorMoreInfo = errorWrapperConfig.errorMoreInfo; |
|
|
|
let errorMoreInfo = errorWrapperConfig.errorMoreInfo; |
|
|
|
var moreInfoButton = errorWrapperConfig.moreInfoButton; |
|
|
|
let moreInfoButton = errorWrapperConfig.moreInfoButton; |
|
|
|
var lessInfoButton = errorWrapperConfig.lessInfoButton; |
|
|
|
let lessInfoButton = errorWrapperConfig.lessInfoButton; |
|
|
|
moreInfoButton.onclick = function() { |
|
|
|
moreInfoButton.onclick = function() { |
|
|
|
errorMoreInfo.removeAttribute('hidden'); |
|
|
|
errorMoreInfo.removeAttribute('hidden'); |
|
|
|
moreInfoButton.setAttribute('hidden', 'true'); |
|
|
|
moreInfoButton.setAttribute('hidden', 'true'); |
|
|
@ -849,8 +841,8 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
progress: function pdfViewProgress(level) { |
|
|
|
progress(level) { |
|
|
|
var percent = Math.round(level * 100); |
|
|
|
let percent = Math.round(level * 100); |
|
|
|
// When we transition from full request to range requests, it's possible
|
|
|
|
// When we transition from full request to range requests, it's possible
|
|
|
|
// that we discard some of the loaded data. This can cause the loading
|
|
|
|
// that we discard some of the loaded data. This can cause the loading
|
|
|
|
// bar to move backwards. So prevent this by only updating the bar if it
|
|
|
|
// bar to move backwards. So prevent this by only updating the bar if it
|
|
|
@ -967,9 +959,7 @@ var PDFViewerApplication = { |
|
|
|
sidebarView = this.viewerPrefs['sidebarViewOnLoad'] || |
|
|
|
sidebarView = this.viewerPrefs['sidebarViewOnLoad'] || |
|
|
|
(values.sidebarView | 0); |
|
|
|
(values.sidebarView | 0); |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
}).catch(function() { |
|
|
|
}).catch(resolve); |
|
|
|
resolve(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
|
this.setInitialView(storedHash, { sidebarView, scale, }); |
|
|
|
this.setInitialView(storedHash, { sidebarView, scale, }); |
|
|
|
initialParams.hash = storedHash; |
|
|
|
initialParams.hash = storedHash; |
|
|
@ -977,7 +967,7 @@ var PDFViewerApplication = { |
|
|
|
// Make all navigation keys work on document load,
|
|
|
|
// Make all navigation keys work on document load,
|
|
|
|
// unless the viewer is embedded in a web page.
|
|
|
|
// unless the viewer is embedded in a web page.
|
|
|
|
if (!this.isViewerEmbedded) { |
|
|
|
if (!this.isViewerEmbedded) { |
|
|
|
this.pdfViewer.focus(); |
|
|
|
pdfViewer.focus(); |
|
|
|
} |
|
|
|
} |
|
|
|
return pagesPromise; |
|
|
|
return pagesPromise; |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
@ -993,7 +983,7 @@ var PDFViewerApplication = { |
|
|
|
this.initialDestination = initialParams.destination; |
|
|
|
this.initialDestination = initialParams.destination; |
|
|
|
this.initialBookmark = initialParams.bookmark; |
|
|
|
this.initialBookmark = initialParams.bookmark; |
|
|
|
|
|
|
|
|
|
|
|
this.pdfViewer.currentScaleValue = this.pdfViewer.currentScaleValue; |
|
|
|
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; |
|
|
|
this.setInitialView(initialParams.hash); |
|
|
|
this.setInitialView(initialParams.hash); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1124,7 +1114,7 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setInitialView(storedHash, options = {}) { |
|
|
|
setInitialView(storedHash, options = {}) { |
|
|
|
var { scale = 0, sidebarView = SidebarView.NONE, } = options; |
|
|
|
let { scale = 0, sidebarView = SidebarView.NONE, } = options; |
|
|
|
|
|
|
|
|
|
|
|
this.isInitialViewSet = true; |
|
|
|
this.isInitialViewSet = true; |
|
|
|
this.pdfSidebar.setInitialView(sidebarView); |
|
|
|
this.pdfSidebar.setInitialView(sidebarView); |
|
|
@ -1156,7 +1146,7 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
cleanup: function pdfViewCleanup() { |
|
|
|
cleanup() { |
|
|
|
if (!this.pdfDocument) { |
|
|
|
if (!this.pdfDocument) { |
|
|
|
return; // run cleanup when document is loaded
|
|
|
|
return; // run cleanup when document is loaded
|
|
|
|
} |
|
|
|
} |
|
|
@ -1169,14 +1159,14 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
forceRendering: function pdfViewForceRendering() { |
|
|
|
forceRendering() { |
|
|
|
this.pdfRenderingQueue.printing = this.printing; |
|
|
|
this.pdfRenderingQueue.printing = this.printing; |
|
|
|
this.pdfRenderingQueue.isThumbnailViewEnabled = |
|
|
|
this.pdfRenderingQueue.isThumbnailViewEnabled = |
|
|
|
this.pdfSidebar.isThumbnailViewVisible; |
|
|
|
this.pdfSidebar.isThumbnailViewVisible; |
|
|
|
this.pdfRenderingQueue.renderHighestPriority(); |
|
|
|
this.pdfRenderingQueue.renderHighestPriority(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
beforePrint: function pdfViewSetupBeforePrint() { |
|
|
|
beforePrint() { |
|
|
|
if (this.printService) { |
|
|
|
if (this.printService) { |
|
|
|
// There is no way to suppress beforePrint/afterPrint events,
|
|
|
|
// There is no way to suppress beforePrint/afterPrint events,
|
|
|
|
// but PDFPrintService may generate double events -- this will ignore
|
|
|
|
// but PDFPrintService may generate double events -- this will ignore
|
|
|
@ -1204,9 +1194,9 @@ var PDFViewerApplication = { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var pagesOverview = this.pdfViewer.getPagesOverview(); |
|
|
|
let pagesOverview = this.pdfViewer.getPagesOverview(); |
|
|
|
var printContainer = this.appConfig.printContainer; |
|
|
|
let printContainer = this.appConfig.printContainer; |
|
|
|
var printService = PDFPrintServiceFactory.instance.createPrintService( |
|
|
|
let printService = PDFPrintServiceFactory.instance.createPrintService( |
|
|
|
this.pdfDocument, pagesOverview, printContainer, this.l10n); |
|
|
|
this.pdfDocument, pagesOverview, printContainer, this.l10n); |
|
|
|
this.printService = printService; |
|
|
|
this.printService = printService; |
|
|
|
this.forceRendering(); |
|
|
|
this.forceRendering(); |
|
|
@ -1223,9 +1213,9 @@ var PDFViewerApplication = { |
|
|
|
|
|
|
|
|
|
|
|
// Whether all pages of the PDF have the same width and height.
|
|
|
|
// Whether all pages of the PDF have the same width and height.
|
|
|
|
get hasEqualPageSizes() { |
|
|
|
get hasEqualPageSizes() { |
|
|
|
var firstPage = this.pdfViewer.getPageView(0); |
|
|
|
let firstPage = this.pdfViewer.getPageView(0); |
|
|
|
for (var i = 1, ii = this.pagesCount; i < ii; ++i) { |
|
|
|
for (let i = 1, ii = this.pagesCount; i < ii; ++i) { |
|
|
|
var pageView = this.pdfViewer.getPageView(i); |
|
|
|
let pageView = this.pdfViewer.getPageView(i); |
|
|
|
if (pageView.width !== firstPage.width || |
|
|
|
if (pageView.width !== firstPage.width || |
|
|
|
pageView.height !== firstPage.height) { |
|
|
|
pageView.height !== firstPage.height) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1258,7 +1248,7 @@ var PDFViewerApplication = { |
|
|
|
pdfViewer.currentPageNumber = pageNumber; |
|
|
|
pdfViewer.currentPageNumber = pageNumber; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
requestPresentationMode: function pdfViewRequestPresentationMode() { |
|
|
|
requestPresentationMode() { |
|
|
|
if (!this.pdfPresentationMode) { |
|
|
|
if (!this.pdfPresentationMode) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1266,15 +1256,15 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
bindEvents() { |
|
|
|
bindEvents() { |
|
|
|
let eventBus = this.eventBus; |
|
|
|
let { eventBus, _boundEvents, } = this; |
|
|
|
|
|
|
|
|
|
|
|
this._boundEvents.beforePrint = this.beforePrint.bind(this); |
|
|
|
_boundEvents.beforePrint = this.beforePrint.bind(this); |
|
|
|
this._boundEvents.afterPrint = this.afterPrint.bind(this); |
|
|
|
_boundEvents.afterPrint = this.afterPrint.bind(this); |
|
|
|
|
|
|
|
|
|
|
|
eventBus.on('resize', webViewerResize); |
|
|
|
eventBus.on('resize', webViewerResize); |
|
|
|
eventBus.on('hashchange', webViewerHashchange); |
|
|
|
eventBus.on('hashchange', webViewerHashchange); |
|
|
|
eventBus.on('beforeprint', this._boundEvents.beforePrint); |
|
|
|
eventBus.on('beforeprint', _boundEvents.beforePrint); |
|
|
|
eventBus.on('afterprint', this._boundEvents.afterPrint); |
|
|
|
eventBus.on('afterprint', _boundEvents.afterPrint); |
|
|
|
eventBus.on('pagerendered', webViewerPageRendered); |
|
|
|
eventBus.on('pagerendered', webViewerPageRendered); |
|
|
|
eventBus.on('textlayerrendered', webViewerTextLayerRendered); |
|
|
|
eventBus.on('textlayerrendered', webViewerTextLayerRendered); |
|
|
|
eventBus.on('updateviewarea', webViewerUpdateViewarea); |
|
|
|
eventBus.on('updateviewarea', webViewerUpdateViewarea); |
|
|
@ -1307,32 +1297,32 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
bindWindowEvents() { |
|
|
|
bindWindowEvents() { |
|
|
|
let eventBus = this.eventBus; |
|
|
|
let { eventBus, _boundEvents, } = this; |
|
|
|
|
|
|
|
|
|
|
|
this._boundEvents.windowResize = () => { |
|
|
|
_boundEvents.windowResize = () => { |
|
|
|
eventBus.dispatch('resize'); |
|
|
|
eventBus.dispatch('resize'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowHashChange = () => { |
|
|
|
_boundEvents.windowHashChange = () => { |
|
|
|
eventBus.dispatch('hashchange', { |
|
|
|
eventBus.dispatch('hashchange', { |
|
|
|
hash: document.location.hash.substring(1), |
|
|
|
hash: document.location.hash.substring(1), |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowBeforePrint = () => { |
|
|
|
_boundEvents.windowBeforePrint = () => { |
|
|
|
eventBus.dispatch('beforeprint'); |
|
|
|
eventBus.dispatch('beforeprint'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowAfterPrint = () => { |
|
|
|
_boundEvents.windowAfterPrint = () => { |
|
|
|
eventBus.dispatch('afterprint'); |
|
|
|
eventBus.dispatch('afterprint'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('wheel', webViewerWheel); |
|
|
|
window.addEventListener('wheel', webViewerWheel); |
|
|
|
window.addEventListener('click', webViewerClick); |
|
|
|
window.addEventListener('click', webViewerClick); |
|
|
|
window.addEventListener('keydown', webViewerKeyDown); |
|
|
|
window.addEventListener('keydown', webViewerKeyDown); |
|
|
|
window.addEventListener('resize', this._boundEvents.windowResize); |
|
|
|
window.addEventListener('resize', _boundEvents.windowResize); |
|
|
|
window.addEventListener('hashchange', this._boundEvents.windowHashChange); |
|
|
|
window.addEventListener('hashchange', _boundEvents.windowHashChange); |
|
|
|
window.addEventListener('beforeprint', this._boundEvents.windowBeforePrint); |
|
|
|
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint); |
|
|
|
window.addEventListener('afterprint', this._boundEvents.windowAfterPrint); |
|
|
|
window.addEventListener('afterprint', _boundEvents.windowAfterPrint); |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
this._boundEvents.windowChange = (evt) => { |
|
|
|
_boundEvents.windowChange = (evt) => { |
|
|
|
let files = evt.target.files; |
|
|
|
let files = evt.target.files; |
|
|
|
if (!files || files.length === 0) { |
|
|
|
if (!files || files.length === 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1341,17 +1331,17 @@ var PDFViewerApplication = { |
|
|
|
fileInput: evt.target, |
|
|
|
fileInput: evt.target, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
window.addEventListener('change', this._boundEvents.windowChange); |
|
|
|
window.addEventListener('change', _boundEvents.windowChange); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
unbindEvents() { |
|
|
|
unbindEvents() { |
|
|
|
let eventBus = this.eventBus; |
|
|
|
let { eventBus, _boundEvents, } = this; |
|
|
|
|
|
|
|
|
|
|
|
eventBus.off('resize', webViewerResize); |
|
|
|
eventBus.off('resize', webViewerResize); |
|
|
|
eventBus.off('hashchange', webViewerHashchange); |
|
|
|
eventBus.off('hashchange', webViewerHashchange); |
|
|
|
eventBus.off('beforeprint', this._boundEvents.beforePrint); |
|
|
|
eventBus.off('beforeprint', _boundEvents.beforePrint); |
|
|
|
eventBus.off('afterprint', this._boundEvents.afterPrint); |
|
|
|
eventBus.off('afterprint', _boundEvents.afterPrint); |
|
|
|
eventBus.off('pagerendered', webViewerPageRendered); |
|
|
|
eventBus.off('pagerendered', webViewerPageRendered); |
|
|
|
eventBus.off('textlayerrendered', webViewerTextLayerRendered); |
|
|
|
eventBus.off('textlayerrendered', webViewerTextLayerRendered); |
|
|
|
eventBus.off('updateviewarea', webViewerUpdateViewarea); |
|
|
|
eventBus.off('updateviewarea', webViewerUpdateViewarea); |
|
|
@ -1382,69 +1372,66 @@ var PDFViewerApplication = { |
|
|
|
eventBus.off('fileinputchange', webViewerFileInputChange); |
|
|
|
eventBus.off('fileinputchange', webViewerFileInputChange); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._boundEvents.beforePrint = null; |
|
|
|
_boundEvents.beforePrint = null; |
|
|
|
this._boundEvents.afterPrint = null; |
|
|
|
_boundEvents.afterPrint = null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
unbindWindowEvents() { |
|
|
|
unbindWindowEvents() { |
|
|
|
|
|
|
|
let { _boundEvents, } = this; |
|
|
|
|
|
|
|
|
|
|
|
window.removeEventListener('wheel', webViewerWheel); |
|
|
|
window.removeEventListener('wheel', webViewerWheel); |
|
|
|
window.removeEventListener('click', webViewerClick); |
|
|
|
window.removeEventListener('click', webViewerClick); |
|
|
|
window.removeEventListener('keydown', webViewerKeyDown); |
|
|
|
window.removeEventListener('keydown', webViewerKeyDown); |
|
|
|
window.removeEventListener('resize', |
|
|
|
window.removeEventListener('resize', _boundEvents.windowResize); |
|
|
|
this._boundEvents.windowResize); |
|
|
|
window.removeEventListener('hashchange', _boundEvents.windowHashChange); |
|
|
|
window.removeEventListener('hashchange', |
|
|
|
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint); |
|
|
|
this._boundEvents.windowHashChange); |
|
|
|
window.removeEventListener('afterprint', _boundEvents.windowAfterPrint); |
|
|
|
window.removeEventListener('beforeprint', |
|
|
|
|
|
|
|
this._boundEvents.windowBeforePrint); |
|
|
|
|
|
|
|
window.removeEventListener('afterprint', |
|
|
|
|
|
|
|
this._boundEvents.windowAfterPrint); |
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
window.removeEventListener('change', |
|
|
|
window.removeEventListener('change', _boundEvents.windowChange); |
|
|
|
this._boundEvents.windowChange); |
|
|
|
_boundEvents.windowChange = null; |
|
|
|
this._boundEvents.windowChange = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._boundEvents.windowResize = null; |
|
|
|
_boundEvents.windowResize = null; |
|
|
|
this._boundEvents.windowHashChange = null; |
|
|
|
_boundEvents.windowHashChange = null; |
|
|
|
this._boundEvents.windowBeforePrint = null; |
|
|
|
_boundEvents.windowBeforePrint = null; |
|
|
|
this._boundEvents.windowAfterPrint = null; |
|
|
|
_boundEvents.windowAfterPrint = null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var validateFileURL; |
|
|
|
let validateFileURL; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', |
|
|
|
const HOSTED_VIEWER_ORIGINS = ['null', |
|
|
|
'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
validateFileURL = function validateFileURL(file) { |
|
|
|
validateFileURL = function validateFileURL(file) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
var viewerOrigin = new URL(window.location.href).origin || 'null'; |
|
|
|
let viewerOrigin = new URL(window.location.href).origin || 'null'; |
|
|
|
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) { |
|
|
|
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) { |
|
|
|
// Hosted or local viewer, allow for any file locations
|
|
|
|
// Hosted or local viewer, allow for any file locations
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var fileOrigin = new URL(file, window.location.href).origin; |
|
|
|
let fileOrigin = new URL(file, window.location.href).origin; |
|
|
|
// Removing of the following line will not guarantee that the viewer will
|
|
|
|
// Removing of the following line will not guarantee that the viewer will
|
|
|
|
// start accepting URLs from foreign origin -- CORS headers on the remote
|
|
|
|
// start accepting URLs from foreign origin -- CORS headers on the remote
|
|
|
|
// server must be properly configured.
|
|
|
|
// server must be properly configured.
|
|
|
|
if (fileOrigin !== viewerOrigin) { |
|
|
|
if (fileOrigin !== viewerOrigin) { |
|
|
|
throw new Error('file origin does not match viewer\'s'); |
|
|
|
throw new Error('file origin does not match viewer\'s'); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (ex) { |
|
|
|
var message = e && e.message; |
|
|
|
let message = ex && ex.message; |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while loading the PDF.'). |
|
|
|
'An error occurred while loading the PDF.'). |
|
|
|
then((loadingErrorMessage) => { |
|
|
|
then((loadingErrorMessage) => { |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, { message, }); |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, { message, }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
throw e; |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
let appConfig = PDFViewerApplication.appConfig; |
|
|
|
var script = document.createElement('script'); |
|
|
|
let script = document.createElement('script'); |
|
|
|
script.src = appConfig.debuggerScriptPath; |
|
|
|
script.src = appConfig.debuggerScriptPath; |
|
|
|
script.onload = function () { |
|
|
|
script.onload = function () { |
|
|
|
PDFBug.enable(enabledTabs); |
|
|
|
PDFBug.enable(enabledTabs); |
|
|
@ -1463,11 +1450,11 @@ function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerInitialized() { |
|
|
|
function webViewerInitialized() { |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
let appConfig = PDFViewerApplication.appConfig; |
|
|
|
var file; |
|
|
|
let file; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
let queryString = document.location.search.substring(1); |
|
|
|
var params = parseQueryString(queryString); |
|
|
|
let params = parseQueryString(queryString); |
|
|
|
file = 'file' in params ? params.file : appConfig.defaultUrl; |
|
|
|
file = 'file' in params ? params.file : appConfig.defaultUrl; |
|
|
|
validateFileURL(file); |
|
|
|
validateFileURL(file); |
|
|
|
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
@ -1476,9 +1463,9 @@ function webViewerInitialized() { |
|
|
|
file = appConfig.defaultUrl; |
|
|
|
file = appConfig.defaultUrl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var waitForBeforeOpening = []; |
|
|
|
let waitForBeforeOpening = []; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
var fileInput = document.createElement('input'); |
|
|
|
let fileInput = document.createElement('input'); |
|
|
|
fileInput.id = appConfig.openFileInputName; |
|
|
|
fileInput.id = appConfig.openFileInputName; |
|
|
|
fileInput.className = 'fileInput'; |
|
|
|
fileInput.className = 'fileInput'; |
|
|
|
fileInput.setAttribute('type', 'file'); |
|
|
|
fileInput.setAttribute('type', 'file'); |
|
|
@ -1500,8 +1487,8 @@ function webViewerInitialized() { |
|
|
|
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) || |
|
|
|
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) || |
|
|
|
PDFViewerApplication.viewerPrefs['pdfBugEnabled']) { |
|
|
|
PDFViewerApplication.viewerPrefs['pdfBugEnabled']) { |
|
|
|
// Special debugging flags in the hash section of the URL.
|
|
|
|
// Special debugging flags in the hash section of the URL.
|
|
|
|
var hash = document.location.hash.substring(1); |
|
|
|
let hash = document.location.hash.substring(1); |
|
|
|
var hashParams = parseQueryString(hash); |
|
|
|
let hashParams = parseQueryString(hash); |
|
|
|
|
|
|
|
|
|
|
|
if ('disableworker' in hashParams) { |
|
|
|
if ('disableworker' in hashParams) { |
|
|
|
PDFJS.disableWorker = (hashParams['disableworker'] === 'true'); |
|
|
|
PDFJS.disableWorker = (hashParams['disableworker'] === 'true'); |
|
|
@ -1548,15 +1535,15 @@ function webViewerInitialized() { |
|
|
|
case 'visible': |
|
|
|
case 'visible': |
|
|
|
case 'shadow': |
|
|
|
case 'shadow': |
|
|
|
case 'hover': |
|
|
|
case 'hover': |
|
|
|
var viewer = appConfig.viewerContainer; |
|
|
|
let viewer = appConfig.viewerContainer; |
|
|
|
viewer.classList.add('textLayer-' + hashParams['textlayer']); |
|
|
|
viewer.classList.add('textLayer-' + hashParams['textlayer']); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ('pdfbug' in hashParams) { |
|
|
|
if ('pdfbug' in hashParams) { |
|
|
|
PDFJS.pdfBug = true; |
|
|
|
PDFJS.pdfBug = true; |
|
|
|
var pdfBug = hashParams['pdfbug']; |
|
|
|
let pdfBug = hashParams['pdfbug']; |
|
|
|
var enabled = pdfBug.split(','); |
|
|
|
let enabled = pdfBug.split(','); |
|
|
|
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled)); |
|
|
|
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1587,8 +1574,8 @@ function webViewerInitialized() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appConfig.sidebar.mainContainer.addEventListener('transitionend', |
|
|
|
appConfig.sidebar.mainContainer.addEventListener('transitionend', |
|
|
|
function(e) { |
|
|
|
function(evt) { |
|
|
|
if (e.target === /* mainContainer */ this) { |
|
|
|
if (evt.target === /* mainContainer */ this) { |
|
|
|
PDFViewerApplication.eventBus.dispatch('resize'); |
|
|
|
PDFViewerApplication.eventBus.dispatch('resize'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
@ -1607,7 +1594,7 @@ function webViewerInitialized() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var webViewerOpenFileViaURL; |
|
|
|
let webViewerOpenFileViaURL; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
@ -1615,7 +1602,7 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
|
|
|
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
|
|
|
// very quickly, so there is no need to set up progress event listeners.
|
|
|
|
// very quickly, so there is no need to set up progress event listeners.
|
|
|
|
PDFViewerApplication.setTitleUsingUrl(file); |
|
|
|
PDFViewerApplication.setTitleUsingUrl(file); |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
let xhr = new XMLHttpRequest(); |
|
|
|
xhr.onload = function() { |
|
|
|
xhr.onload = function() { |
|
|
|
PDFViewerApplication.open(new Uint8Array(xhr.response)); |
|
|
|
PDFViewerApplication.open(new Uint8Array(xhr.response)); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -1623,10 +1610,10 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
xhr.open('GET', file); |
|
|
|
xhr.open('GET', file); |
|
|
|
xhr.responseType = 'arraybuffer'; |
|
|
|
xhr.responseType = 'arraybuffer'; |
|
|
|
xhr.send(); |
|
|
|
xhr.send(); |
|
|
|
} catch (e) { |
|
|
|
} catch (ex) { |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while loading the PDF.').then((msg) => { |
|
|
|
'An error occurred while loading the PDF.').then((msg) => { |
|
|
|
PDFViewerApplication.error(msg, e); |
|
|
|
PDFViewerApplication.error(msg, ex); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1649,10 +1636,10 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageRendered(e) { |
|
|
|
function webViewerPageRendered(evt) { |
|
|
|
var pageNumber = e.pageNumber; |
|
|
|
let pageNumber = evt.pageNumber; |
|
|
|
var pageIndex = pageNumber - 1; |
|
|
|
let pageIndex = pageNumber - 1; |
|
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex); |
|
|
|
let pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex); |
|
|
|
|
|
|
|
|
|
|
|
// If the page is still visible when it has finished rendering,
|
|
|
|
// If the page is still visible when it has finished rendering,
|
|
|
|
// ensure that the page number input loading indicator is hidden.
|
|
|
|
// ensure that the page number input loading indicator is hidden.
|
|
|
@ -1668,7 +1655,7 @@ function webViewerPageRendered(e) { |
|
|
|
|
|
|
|
|
|
|
|
// Use the rendered page to set the corresponding thumbnail image.
|
|
|
|
// Use the rendered page to set the corresponding thumbnail image.
|
|
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
|
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer. |
|
|
|
let thumbnailView = PDFViewerApplication.pdfThumbnailViewer. |
|
|
|
getThumbnail(pageIndex); |
|
|
|
getThumbnail(pageIndex); |
|
|
|
thumbnailView.setImage(pageView); |
|
|
|
thumbnailView.setImage(pageView); |
|
|
|
} |
|
|
|
} |
|
|
@ -1699,10 +1686,10 @@ function webViewerPageRendered(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerTextLayerRendered(e) { |
|
|
|
function webViewerTextLayerRendered(evt) { |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
evt.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
PDFViewerApplication.l10n.get('document_colors_not_allowed', null, |
|
|
|
PDFViewerApplication.l10n.get('document_colors_not_allowed', null, |
|
|
|
'PDF documents are not allowed to use their own colors: ' + |
|
|
|
'PDF documents are not allowed to use their own colors: ' + |
|
|
|
'\'Allow pages to choose their own colors\' ' + |
|
|
|
'\'Allow pages to choose their own colors\' ' + |
|
|
@ -1714,9 +1701,9 @@ function webViewerTextLayerRendered(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageMode(e) { |
|
|
|
function webViewerPageMode(evt) { |
|
|
|
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
|
|
|
|
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
|
|
|
|
var mode = e.mode, view; |
|
|
|
let mode = evt.mode, view; |
|
|
|
switch (mode) { |
|
|
|
switch (mode) { |
|
|
|
case 'thumbs': |
|
|
|
case 'thumbs': |
|
|
|
view = SidebarView.THUMBS; |
|
|
|
view = SidebarView.THUMBS; |
|
|
@ -1738,10 +1725,10 @@ function webViewerPageMode(e) { |
|
|
|
PDFViewerApplication.pdfSidebar.switchView(view, /* forceOpen = */ true); |
|
|
|
PDFViewerApplication.pdfSidebar.switchView(view, /* forceOpen = */ true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerNamedAction(e) { |
|
|
|
function webViewerNamedAction(evt) { |
|
|
|
// Processing couple of named actions that might be useful.
|
|
|
|
// Processing couple of named actions that might be useful.
|
|
|
|
// See also PDFLinkService.executeNamedAction
|
|
|
|
// See also PDFLinkService.executeNamedAction
|
|
|
|
var action = e.action; |
|
|
|
let action = evt.action; |
|
|
|
switch (action) { |
|
|
|
switch (action) { |
|
|
|
case 'GoToPage': |
|
|
|
case 'GoToPage': |
|
|
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
|
|
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
|
|
@ -1755,9 +1742,8 @@ function webViewerNamedAction(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPresentationModeChanged(e) { |
|
|
|
function webViewerPresentationModeChanged(evt) { |
|
|
|
var active = e.active; |
|
|
|
let { active, switchInProgress, } = evt; |
|
|
|
var switchInProgress = e.switchInProgress; |
|
|
|
|
|
|
|
PDFViewerApplication.pdfViewer.presentationModeState = |
|
|
|
PDFViewerApplication.pdfViewer.presentationModeState = |
|
|
|
switchInProgress ? PresentationModeState.CHANGING : |
|
|
|
switchInProgress ? PresentationModeState.CHANGING : |
|
|
|
active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL; |
|
|
|
active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL; |
|
|
@ -1767,7 +1753,7 @@ function webViewerSidebarViewChanged(evt) { |
|
|
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = |
|
|
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = |
|
|
|
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible; |
|
|
|
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible; |
|
|
|
|
|
|
|
|
|
|
|
var store = PDFViewerApplication.store; |
|
|
|
let store = PDFViewerApplication.store; |
|
|
|
if (store && PDFViewerApplication.isInitialViewSet) { |
|
|
|
if (store && PDFViewerApplication.isInitialViewSet) { |
|
|
|
// Only update the storage when the document has been loaded *and* rendered.
|
|
|
|
// Only update the storage when the document has been loaded *and* rendered.
|
|
|
|
store.set('sidebarView', evt.view).catch(function() { }); |
|
|
|
store.set('sidebarView', evt.view).catch(function() { }); |
|
|
@ -1775,7 +1761,7 @@ function webViewerSidebarViewChanged(evt) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerUpdateViewarea(evt) { |
|
|
|
function webViewerUpdateViewarea(evt) { |
|
|
|
var location = evt.location, store = PDFViewerApplication.store; |
|
|
|
let location = evt.location, store = PDFViewerApplication.store; |
|
|
|
|
|
|
|
|
|
|
|
if (store && PDFViewerApplication.isInitialViewSet) { |
|
|
|
if (store && PDFViewerApplication.isInitialViewSet) { |
|
|
|
store.setMultiple({ |
|
|
|
store.setMultiple({ |
|
|
@ -1786,7 +1772,7 @@ function webViewerUpdateViewarea(evt) { |
|
|
|
'scrollTop': location.top, |
|
|
|
'scrollTop': location.top, |
|
|
|
}).catch(function() { /* unable to write to storage */ }); |
|
|
|
}).catch(function() { /* unable to write to storage */ }); |
|
|
|
} |
|
|
|
} |
|
|
|
var href = |
|
|
|
let href = |
|
|
|
PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams); |
|
|
|
PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams); |
|
|
|
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href; |
|
|
|
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href; |
|
|
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = |
|
|
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = |
|
|
@ -1797,14 +1783,14 @@ function webViewerUpdateViewarea(evt) { |
|
|
|
location.pageNumber); |
|
|
|
location.pageNumber); |
|
|
|
|
|
|
|
|
|
|
|
// Show/hide the loading indicator in the page number input element.
|
|
|
|
// Show/hide the loading indicator in the page number input element.
|
|
|
|
var currentPage = |
|
|
|
let currentPage = |
|
|
|
PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1); |
|
|
|
PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1); |
|
|
|
var loading = currentPage.renderingState !== RenderingStates.FINISHED; |
|
|
|
let loading = currentPage.renderingState !== RenderingStates.FINISHED; |
|
|
|
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading); |
|
|
|
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerResize() { |
|
|
|
function webViewerResize() { |
|
|
|
var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue; |
|
|
|
let currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue; |
|
|
|
if (currentScaleValue === 'auto' || |
|
|
|
if (currentScaleValue === 'auto' || |
|
|
|
currentScaleValue === 'page-fit' || |
|
|
|
currentScaleValue === 'page-fit' || |
|
|
|
currentScaleValue === 'page-width') { |
|
|
|
currentScaleValue === 'page-width') { |
|
|
@ -1819,9 +1805,9 @@ function webViewerResize() { |
|
|
|
PDFViewerApplication.pdfViewer.update(); |
|
|
|
PDFViewerApplication.pdfViewer.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerHashchange(e) { |
|
|
|
function webViewerHashchange(evt) { |
|
|
|
if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) { |
|
|
|
if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) { |
|
|
|
var hash = e.hash; |
|
|
|
let hash = evt.hash; |
|
|
|
if (!hash) { |
|
|
|
if (!hash) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1833,21 +1819,19 @@ function webViewerHashchange(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var webViewerFileInputChange; |
|
|
|
let webViewerFileInputChange; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
webViewerFileInputChange = function webViewerFileInputChange(e) { |
|
|
|
webViewerFileInputChange = function webViewerFileInputChange(evt) { |
|
|
|
var file = e.fileInput.files[0]; |
|
|
|
let file = evt.fileInput.files[0]; |
|
|
|
|
|
|
|
|
|
|
|
if (!PDFJS.disableCreateObjectURL && |
|
|
|
if (!PDFJS.disableCreateObjectURL && URL.createObjectURL) { |
|
|
|
typeof URL !== 'undefined' && URL.createObjectURL) { |
|
|
|
|
|
|
|
PDFViewerApplication.open(URL.createObjectURL(file)); |
|
|
|
PDFViewerApplication.open(URL.createObjectURL(file)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Read the local file into a Uint8Array.
|
|
|
|
// Read the local file into a Uint8Array.
|
|
|
|
var fileReader = new FileReader(); |
|
|
|
let fileReader = new FileReader(); |
|
|
|
fileReader.onload = function webViewerChangeFileReaderOnload(evt) { |
|
|
|
fileReader.onload = function webViewerChangeFileReaderOnload(evt) { |
|
|
|
var buffer = evt.target.result; |
|
|
|
let buffer = evt.target.result; |
|
|
|
var uint8Array = new Uint8Array(buffer); |
|
|
|
PDFViewerApplication.open(new Uint8Array(buffer)); |
|
|
|
PDFViewerApplication.open(uint8Array); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
fileReader.readAsArrayBuffer(file); |
|
|
|
fileReader.readAsArrayBuffer(file); |
|
|
|
} |
|
|
|
} |
|
|
@ -1855,7 +1839,7 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
PDFViewerApplication.setTitleUsingUrl(file.name); |
|
|
|
PDFViewerApplication.setTitleUsingUrl(file.name); |
|
|
|
|
|
|
|
|
|
|
|
// URL does not reflect proper document location - hiding some icons.
|
|
|
|
// URL does not reflect proper document location - hiding some icons.
|
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
let appConfig = PDFViewerApplication.appConfig; |
|
|
|
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true'); |
|
|
|
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', |
|
|
|
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', |
|
|
|
'true'); |
|
|
|
'true'); |
|
|
@ -1868,7 +1852,7 @@ function webViewerPresentationMode() { |
|
|
|
PDFViewerApplication.requestPresentationMode(); |
|
|
|
PDFViewerApplication.requestPresentationMode(); |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerOpenFile() { |
|
|
|
function webViewerOpenFile() { |
|
|
|
var openFileInputName = PDFViewerApplication.appConfig.openFileInputName; |
|
|
|
let openFileInputName = PDFViewerApplication.appConfig.openFileInputName; |
|
|
|
document.getElementById(openFileInputName).click(); |
|
|
|
document.getElementById(openFileInputName).click(); |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerPrint() { |
|
|
|
function webViewerPrint() { |
|
|
@ -1899,20 +1883,20 @@ function webViewerZoomIn() { |
|
|
|
function webViewerZoomOut() { |
|
|
|
function webViewerZoomOut() { |
|
|
|
PDFViewerApplication.zoomOut(); |
|
|
|
PDFViewerApplication.zoomOut(); |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerPageNumberChanged(e) { |
|
|
|
function webViewerPageNumberChanged(evt) { |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
let pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
pdfViewer.currentPageLabel = e.value; |
|
|
|
pdfViewer.currentPageLabel = evt.value; |
|
|
|
|
|
|
|
|
|
|
|
// Ensure that the page number input displays the correct value, even if the
|
|
|
|
// Ensure that the page number input displays the correct value, even if the
|
|
|
|
// value entered by the user was invalid (e.g. a floating point number).
|
|
|
|
// value entered by the user was invalid (e.g. a floating point number).
|
|
|
|
if (e.value !== pdfViewer.currentPageNumber.toString() && |
|
|
|
if (evt.value !== pdfViewer.currentPageNumber.toString() && |
|
|
|
e.value !== pdfViewer.currentPageLabel) { |
|
|
|
evt.value !== pdfViewer.currentPageLabel) { |
|
|
|
PDFViewerApplication.toolbar.setPageNumber( |
|
|
|
PDFViewerApplication.toolbar.setPageNumber( |
|
|
|
pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerScaleChanged(e) { |
|
|
|
function webViewerScaleChanged(evt) { |
|
|
|
PDFViewerApplication.pdfViewer.currentScaleValue = e.value; |
|
|
|
PDFViewerApplication.pdfViewer.currentScaleValue = evt.value; |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerRotateCw() { |
|
|
|
function webViewerRotateCw() { |
|
|
|
PDFViewerApplication.rotatePages(90); |
|
|
|
PDFViewerApplication.rotatePages(90); |
|
|
@ -1924,36 +1908,36 @@ function webViewerDocumentProperties() { |
|
|
|
PDFViewerApplication.pdfDocumentProperties.open(); |
|
|
|
PDFViewerApplication.pdfDocumentProperties.open(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerFind(e) { |
|
|
|
function webViewerFind(evt) { |
|
|
|
PDFViewerApplication.findController.executeCommand('find' + e.type, { |
|
|
|
PDFViewerApplication.findController.executeCommand('find' + evt.type, { |
|
|
|
query: e.query, |
|
|
|
query: evt.query, |
|
|
|
phraseSearch: e.phraseSearch, |
|
|
|
phraseSearch: evt.phraseSearch, |
|
|
|
caseSensitive: e.caseSensitive, |
|
|
|
caseSensitive: evt.caseSensitive, |
|
|
|
highlightAll: e.highlightAll, |
|
|
|
highlightAll: evt.highlightAll, |
|
|
|
findPrevious: e.findPrevious, |
|
|
|
findPrevious: evt.findPrevious, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerFindFromUrlHash(e) { |
|
|
|
function webViewerFindFromUrlHash(evt) { |
|
|
|
PDFViewerApplication.findController.executeCommand('find', { |
|
|
|
PDFViewerApplication.findController.executeCommand('find', { |
|
|
|
query: e.query, |
|
|
|
query: evt.query, |
|
|
|
phraseSearch: e.phraseSearch, |
|
|
|
phraseSearch: evt.phraseSearch, |
|
|
|
caseSensitive: false, |
|
|
|
caseSensitive: false, |
|
|
|
highlightAll: true, |
|
|
|
highlightAll: true, |
|
|
|
findPrevious: false, |
|
|
|
findPrevious: false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerScaleChanging(e) { |
|
|
|
function webViewerScaleChanging(evt) { |
|
|
|
PDFViewerApplication.toolbar.setPageScale(e.presetValue, e.scale); |
|
|
|
PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale); |
|
|
|
|
|
|
|
|
|
|
|
PDFViewerApplication.pdfViewer.update(); |
|
|
|
PDFViewerApplication.pdfViewer.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageChanging(e) { |
|
|
|
function webViewerPageChanging(evt) { |
|
|
|
var page = e.pageNumber; |
|
|
|
let page = evt.pageNumber; |
|
|
|
|
|
|
|
|
|
|
|
PDFViewerApplication.toolbar.setPageNumber(page, e.pageLabel || null); |
|
|
|
PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null); |
|
|
|
PDFViewerApplication.secondaryToolbar.setPageNumber(page); |
|
|
|
PDFViewerApplication.secondaryToolbar.setPageNumber(page); |
|
|
|
|
|
|
|
|
|
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
@ -1962,22 +1946,22 @@ function webViewerPageChanging(e) { |
|
|
|
|
|
|
|
|
|
|
|
// we need to update stats
|
|
|
|
// we need to update stats
|
|
|
|
if (PDFJS.pdfBug && Stats.enabled) { |
|
|
|
if (PDFJS.pdfBug && Stats.enabled) { |
|
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1); |
|
|
|
let pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1); |
|
|
|
if (pageView.stats) { |
|
|
|
if (pageView.stats) { |
|
|
|
Stats.add(page, pageView.stats); |
|
|
|
Stats.add(page, pageView.stats); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var zoomDisabled = false, zoomDisabledTimeout; |
|
|
|
let zoomDisabled = false, zoomDisabledTimeout; |
|
|
|
function webViewerWheel(evt) { |
|
|
|
function webViewerWheel(evt) { |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
let pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
if (pdfViewer.isInPresentationMode) { |
|
|
|
if (pdfViewer.isInPresentationMode) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (evt.ctrlKey || evt.metaKey) { |
|
|
|
if (evt.ctrlKey || evt.metaKey) { |
|
|
|
var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys; |
|
|
|
let support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys; |
|
|
|
if ((evt.ctrlKey && !support.ctrlKey) || |
|
|
|
if ((evt.ctrlKey && !support.ctrlKey) || |
|
|
|
(evt.metaKey && !support.metaKey)) { |
|
|
|
(evt.metaKey && !support.metaKey)) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1989,27 +1973,27 @@ function webViewerWheel(evt) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var previousScale = pdfViewer.currentScale; |
|
|
|
let previousScale = pdfViewer.currentScale; |
|
|
|
|
|
|
|
|
|
|
|
var delta = normalizeWheelEventDelta(evt); |
|
|
|
let delta = normalizeWheelEventDelta(evt); |
|
|
|
|
|
|
|
|
|
|
|
var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0; |
|
|
|
const MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0; |
|
|
|
var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE; |
|
|
|
let ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE; |
|
|
|
if (ticks < 0) { |
|
|
|
if (ticks < 0) { |
|
|
|
PDFViewerApplication.zoomOut(-ticks); |
|
|
|
PDFViewerApplication.zoomOut(-ticks); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
PDFViewerApplication.zoomIn(ticks); |
|
|
|
PDFViewerApplication.zoomIn(ticks); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var currentScale = pdfViewer.currentScale; |
|
|
|
let currentScale = pdfViewer.currentScale; |
|
|
|
if (previousScale !== currentScale) { |
|
|
|
if (previousScale !== currentScale) { |
|
|
|
// After scaling the page via zoomIn/zoomOut, the position of the upper-
|
|
|
|
// After scaling the page via zoomIn/zoomOut, the position of the upper-
|
|
|
|
// left corner is restored. When the mouse wheel is used, the position
|
|
|
|
// left corner is restored. When the mouse wheel is used, the position
|
|
|
|
// under the cursor should be restored instead.
|
|
|
|
// under the cursor should be restored instead.
|
|
|
|
var scaleCorrectionFactor = currentScale / previousScale - 1; |
|
|
|
let scaleCorrectionFactor = currentScale / previousScale - 1; |
|
|
|
var rect = pdfViewer.container.getBoundingClientRect(); |
|
|
|
let rect = pdfViewer.container.getBoundingClientRect(); |
|
|
|
var dx = evt.clientX - rect.left; |
|
|
|
let dx = evt.clientX - rect.left; |
|
|
|
var dy = evt.clientY - rect.top; |
|
|
|
let dy = evt.clientY - rect.top; |
|
|
|
pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor; |
|
|
|
pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor; |
|
|
|
pdfViewer.container.scrollTop += dy * scaleCorrectionFactor; |
|
|
|
pdfViewer.container.scrollTop += dy * scaleCorrectionFactor; |
|
|
|
} |
|
|
|
} |
|
|
@ -2026,7 +2010,7 @@ function webViewerClick(evt) { |
|
|
|
if (!PDFViewerApplication.secondaryToolbar.isOpen) { |
|
|
|
if (!PDFViewerApplication.secondaryToolbar.isOpen) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
let appConfig = PDFViewerApplication.appConfig; |
|
|
|
if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || |
|
|
|
if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || |
|
|
|
(appConfig.toolbar.container.contains(evt.target) && |
|
|
|
(appConfig.toolbar.container.contains(evt.target) && |
|
|
|
evt.target !== appConfig.secondaryToolbar.toggleButton)) { |
|
|
|
evt.target !== appConfig.secondaryToolbar.toggleButton)) { |
|
|
@ -2039,14 +2023,14 @@ function webViewerKeyDown(evt) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var handled = false, ensureViewerFocused = false; |
|
|
|
let handled = false, ensureViewerFocused = false; |
|
|
|
var cmd = (evt.ctrlKey ? 1 : 0) | |
|
|
|
let cmd = (evt.ctrlKey ? 1 : 0) | |
|
|
|
(evt.altKey ? 2 : 0) | |
|
|
|
(evt.altKey ? 2 : 0) | |
|
|
|
(evt.shiftKey ? 4 : 0) | |
|
|
|
(evt.shiftKey ? 4 : 0) | |
|
|
|
(evt.metaKey ? 8 : 0); |
|
|
|
(evt.metaKey ? 8 : 0); |
|
|
|
|
|
|
|
|
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
let pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode; |
|
|
|
let isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode; |
|
|
|
|
|
|
|
|
|
|
|
// First, handle the key bindings that are independent whether an input
|
|
|
|
// First, handle the key bindings that are independent whether an input
|
|
|
|
// control is selected or not.
|
|
|
|
// control is selected or not.
|
|
|
@ -2061,7 +2045,7 @@ function webViewerKeyDown(evt) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 71: // g
|
|
|
|
case 71: // g
|
|
|
|
if (!PDFViewerApplication.supportsIntegratedFind) { |
|
|
|
if (!PDFViewerApplication.supportsIntegratedFind) { |
|
|
|
var findState = PDFViewerApplication.findController.state; |
|
|
|
let findState = PDFViewerApplication.findController.state; |
|
|
|
if (findState) { |
|
|
|
if (findState) { |
|
|
|
PDFViewerApplication.findController.executeCommand('findagain', { |
|
|
|
PDFViewerApplication.findController.executeCommand('findagain', { |
|
|
|
query: findState.query, |
|
|
|
query: findState.query, |
|
|
@ -2159,8 +2143,8 @@ function webViewerKeyDown(evt) { |
|
|
|
|
|
|
|
|
|
|
|
// Some shortcuts should not get handled if a control/input element
|
|
|
|
// Some shortcuts should not get handled if a control/input element
|
|
|
|
// is selected.
|
|
|
|
// is selected.
|
|
|
|
var curElement = document.activeElement || document.querySelector(':focus'); |
|
|
|
let curElement = document.activeElement || document.querySelector(':focus'); |
|
|
|
var curElementTagName = curElement && curElement.tagName.toUpperCase(); |
|
|
|
let curElementTagName = curElement && curElement.tagName.toUpperCase(); |
|
|
|
if (curElementTagName === 'INPUT' || |
|
|
|
if (curElementTagName === 'INPUT' || |
|
|
|
curElementTagName === 'TEXTAREA' || |
|
|
|
curElementTagName === 'TEXTAREA' || |
|
|
|
curElementTagName === 'SELECT') { |
|
|
|
curElementTagName === 'SELECT') { |
|
|
@ -2315,7 +2299,7 @@ function webViewerKeyDown(evt) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Abstract factory for the print service. */ |
|
|
|
/* Abstract factory for the print service. */ |
|
|
|
var PDFPrintServiceFactory = { |
|
|
|
let PDFPrintServiceFactory = { |
|
|
|
instance: { |
|
|
|
instance: { |
|
|
|
supportsPrinting: false, |
|
|
|
supportsPrinting: false, |
|
|
|
createPrintService() { |
|
|
|
createPrintService() { |
|
|
|