|
|
@ -138,7 +138,7 @@ var PDFViewerApplication = { |
|
|
|
baseUrl: '', |
|
|
|
baseUrl: '', |
|
|
|
externalServices: DefaultExternalServices, |
|
|
|
externalServices: DefaultExternalServices, |
|
|
|
_boundEvents: {}, |
|
|
|
_boundEvents: {}, |
|
|
|
initialize: function pdfViewInitialize(appConfig) { |
|
|
|
initialize: function initialize(appConfig) { |
|
|
|
var _this = this; |
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
|
|
this.preferences = this.externalServices.createPreferences(); |
|
|
|
this.preferences = this.externalServices.createPreferences(); |
|
|
@ -334,11 +334,10 @@ var PDFViewerApplication = { |
|
|
|
resolve(undefined); |
|
|
|
resolve(undefined); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
run: function run(config) { |
|
|
|
run: function pdfViewRun(config) { |
|
|
|
|
|
|
|
this.initialize(config).then(webViewerInitialized); |
|
|
|
this.initialize(config).then(webViewerInitialized); |
|
|
|
}, |
|
|
|
}, |
|
|
|
zoomIn: function pdfViewZoomIn(ticks) { |
|
|
|
zoomIn: function zoomIn(ticks) { |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
do { |
|
|
|
do { |
|
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
@ -347,7 +346,7 @@ var PDFViewerApplication = { |
|
|
|
} while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE); |
|
|
|
} while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE); |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
}, |
|
|
|
}, |
|
|
|
zoomOut: function pdfViewZoomOut(ticks) { |
|
|
|
zoomOut: function zoomOut(ticks) { |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
var newScale = this.pdfViewer.currentScale; |
|
|
|
do { |
|
|
|
do { |
|
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); |
|
|
@ -356,6 +355,7 @@ var PDFViewerApplication = { |
|
|
|
} while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE); |
|
|
|
} while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE); |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
this.pdfViewer.currentScaleValue = newScale; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get pagesCount() { |
|
|
|
get pagesCount() { |
|
|
|
return this.pdfDocument ? this.pdfDocument.numPages : 0; |
|
|
|
return this.pdfDocument ? this.pdfDocument.numPages : 0; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -375,7 +375,7 @@ var PDFViewerApplication = { |
|
|
|
return PDFPrintServiceFactory.instance.supportsPrinting; |
|
|
|
return PDFPrintServiceFactory.instance.supportsPrinting; |
|
|
|
}, |
|
|
|
}, |
|
|
|
get supportsFullscreen() { |
|
|
|
get supportsFullscreen() { |
|
|
|
var support; |
|
|
|
var support = void 0; |
|
|
|
var doc = document.documentElement; |
|
|
|
var doc = document.documentElement; |
|
|
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) { |
|
|
|
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) { |
|
|
@ -402,29 +402,29 @@ var PDFViewerApplication = { |
|
|
|
get supportedMouseWheelZoomModifierKeys() { |
|
|
|
get supportedMouseWheelZoomModifierKeys() { |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
}, |
|
|
|
}, |
|
|
|
initPassiveLoading: function pdfViewInitPassiveLoading() { |
|
|
|
initPassiveLoading: function initPassiveLoading() { |
|
|
|
throw new Error('Not implemented: initPassiveLoading'); |
|
|
|
throw new Error('Not implemented: initPassiveLoading'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { |
|
|
|
setTitleUsingUrl: function setTitleUsingUrl(url) { |
|
|
|
this.url = url; |
|
|
|
this.url = url; |
|
|
|
this.baseUrl = url.split('#')[0]; |
|
|
|
this.baseUrl = url.split('#')[0]; |
|
|
|
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, ''); |
|
|
|
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, ''); |
|
|
|
if (!title) { |
|
|
|
if (!title) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
title = decodeURIComponent((0, _pdf.getFilenameFromUrl)(url)) || url; |
|
|
|
title = decodeURIComponent((0, _pdf.getFilenameFromUrl)(url)) || url; |
|
|
|
} catch (e) { |
|
|
|
} catch (ex) { |
|
|
|
title = url; |
|
|
|
title = url; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.setTitle(title); |
|
|
|
this.setTitle(title); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setTitle: function pdfViewSetTitle(title) { |
|
|
|
setTitle: function setTitle(title) { |
|
|
|
if (this.isViewerEmbedded) { |
|
|
|
if (this.isViewerEmbedded) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
document.title = title; |
|
|
|
document.title = title; |
|
|
|
}, |
|
|
|
}, |
|
|
|
close: function pdfViewClose() { |
|
|
|
close: function close() { |
|
|
|
var errorWrapper = this.appConfig.errorWrapper.container; |
|
|
|
var errorWrapper = this.appConfig.errorWrapper.container; |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
errorWrapper.setAttribute('hidden', 'true'); |
|
|
|
if (!this.pdfLoadingTask) { |
|
|
|
if (!this.pdfLoadingTask) { |
|
|
@ -521,8 +521,9 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
download: function download() { |
|
|
|
|
|
|
|
var _this4 = this; |
|
|
|
|
|
|
|
|
|
|
|
download: function pdfViewDownload() { |
|
|
|
|
|
|
|
function downloadByUrl() { |
|
|
|
function downloadByUrl() { |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
|
} |
|
|
|
} |
|
|
@ -530,23 +531,19 @@ var PDFViewerApplication = { |
|
|
|
var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url); |
|
|
|
var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url); |
|
|
|
var downloadManager = this.downloadManager; |
|
|
|
var downloadManager = this.downloadManager; |
|
|
|
downloadManager.onerror = function (err) { |
|
|
|
downloadManager.onerror = function (err) { |
|
|
|
PDFViewerApplication.error('PDF failed to download.'); |
|
|
|
_this4.error('PDF failed to download: ' + err); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (!this.pdfDocument) { |
|
|
|
if (!this.pdfDocument || !this.downloadComplete) { |
|
|
|
downloadByUrl(); |
|
|
|
downloadByUrl(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this.downloadComplete) { |
|
|
|
this.pdfDocument.getData().then(function (data) { |
|
|
|
downloadByUrl(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.pdfDocument.getData().then(function getDataSuccess(data) { |
|
|
|
|
|
|
|
var blob = (0, _pdf.createBlob)(data, 'application/pdf'); |
|
|
|
var blob = (0, _pdf.createBlob)(data, 'application/pdf'); |
|
|
|
downloadManager.download(blob, url, filename); |
|
|
|
downloadManager.download(blob, url, filename); |
|
|
|
}, downloadByUrl).then(null, downloadByUrl); |
|
|
|
}).catch(downloadByUrl); |
|
|
|
}, |
|
|
|
}, |
|
|
|
fallback: function pdfViewFallback(featureId) {}, |
|
|
|
fallback: function fallback(featureId) {}, |
|
|
|
error: function pdfViewError(message, moreInfo) { |
|
|
|
error: function error(message, moreInfo) { |
|
|
|
var moreInfoText = [this.l10n.get('error_version_info', { |
|
|
|
var moreInfoText = [this.l10n.get('error_version_info', { |
|
|
|
version: _pdf.version || '?', |
|
|
|
version: _pdf.version || '?', |
|
|
|
build: _pdf.build || '?' |
|
|
|
build: _pdf.build || '?' |
|
|
@ -596,8 +593,8 @@ var PDFViewerApplication = { |
|
|
|
errorMoreInfo.value = parts.join('\n'); |
|
|
|
errorMoreInfo.value = parts.join('\n'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
progress: function pdfViewProgress(level) { |
|
|
|
progress: function progress(level) { |
|
|
|
var _this4 = this; |
|
|
|
var _this5 = this; |
|
|
|
|
|
|
|
|
|
|
|
var percent = Math.round(level * 100); |
|
|
|
var percent = Math.round(level * 100); |
|
|
|
if (percent > this.loadingBar.percent || isNaN(percent)) { |
|
|
|
if (percent > this.loadingBar.percent || isNaN(percent)) { |
|
|
@ -609,22 +606,22 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
this.loadingBar.show(); |
|
|
|
this.loadingBar.show(); |
|
|
|
this.disableAutoFetchLoadingBarTimeout = setTimeout(function () { |
|
|
|
this.disableAutoFetchLoadingBarTimeout = setTimeout(function () { |
|
|
|
_this4.loadingBar.hide(); |
|
|
|
_this5.loadingBar.hide(); |
|
|
|
_this4.disableAutoFetchLoadingBarTimeout = null; |
|
|
|
_this5.disableAutoFetchLoadingBarTimeout = null; |
|
|
|
}, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT); |
|
|
|
}, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
load: function load(pdfDocument, scale) { |
|
|
|
load: function load(pdfDocument, scale) { |
|
|
|
var _this5 = this; |
|
|
|
var _this6 = this; |
|
|
|
|
|
|
|
|
|
|
|
scale = scale || _ui_utils.UNKNOWN_SCALE; |
|
|
|
scale = scale || _ui_utils.UNKNOWN_SCALE; |
|
|
|
this.pdfDocument = pdfDocument; |
|
|
|
this.pdfDocument = pdfDocument; |
|
|
|
pdfDocument.getDownloadInfo().then(function () { |
|
|
|
pdfDocument.getDownloadInfo().then(function () { |
|
|
|
_this5.downloadComplete = true; |
|
|
|
_this6.downloadComplete = true; |
|
|
|
_this5.loadingBar.hide(); |
|
|
|
_this6.loadingBar.hide(); |
|
|
|
firstPagePromise.then(function () { |
|
|
|
firstPagePromise.then(function () { |
|
|
|
_this5.eventBus.dispatch('documentload', { source: _this5 }); |
|
|
|
_this6.eventBus.dispatch('documentload', { source: _this6 }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false); |
|
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false); |
|
|
@ -643,27 +640,27 @@ var PDFViewerApplication = { |
|
|
|
var pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
var pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
pdfThumbnailViewer.setDocument(pdfDocument); |
|
|
|
pdfThumbnailViewer.setDocument(pdfDocument); |
|
|
|
firstPagePromise.then(function (pdfPage) { |
|
|
|
firstPagePromise.then(function (pdfPage) { |
|
|
|
_this5.loadingBar.setWidth(_this5.appConfig.viewerContainer); |
|
|
|
_this6.loadingBar.setWidth(_this6.appConfig.viewerContainer); |
|
|
|
if (!_pdf.PDFJS.disableHistory && !_this5.isViewerEmbedded) { |
|
|
|
if (!_pdf.PDFJS.disableHistory && !_this6.isViewerEmbedded) { |
|
|
|
if (!_this5.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
if (!_this6.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
_this5.pdfHistory.clearHistoryState(); |
|
|
|
_this6.pdfHistory.clearHistoryState(); |
|
|
|
} |
|
|
|
} |
|
|
|
_this5.pdfHistory.initialize(_this5.documentFingerprint); |
|
|
|
_this6.pdfHistory.initialize(_this6.documentFingerprint); |
|
|
|
if (_this5.pdfHistory.initialDestination) { |
|
|
|
if (_this6.pdfHistory.initialDestination) { |
|
|
|
_this5.initialDestination = _this5.pdfHistory.initialDestination; |
|
|
|
_this6.initialDestination = _this6.pdfHistory.initialDestination; |
|
|
|
} else if (_this5.pdfHistory.initialBookmark) { |
|
|
|
} else if (_this6.pdfHistory.initialBookmark) { |
|
|
|
_this5.initialBookmark = _this5.pdfHistory.initialBookmark; |
|
|
|
_this6.initialBookmark = _this6.pdfHistory.initialBookmark; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var initialParams = { |
|
|
|
var initialParams = { |
|
|
|
destination: _this5.initialDestination, |
|
|
|
destination: _this6.initialDestination, |
|
|
|
bookmark: _this5.initialBookmark, |
|
|
|
bookmark: _this6.initialBookmark, |
|
|
|
hash: null |
|
|
|
hash: null |
|
|
|
}; |
|
|
|
}; |
|
|
|
var storedHash = _this5.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this5.viewerPrefs['defaultZoomValue'] : null; |
|
|
|
var storedHash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null; |
|
|
|
var sidebarView = _this5.viewerPrefs['sidebarViewOnLoad']; |
|
|
|
var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad']; |
|
|
|
new Promise(function (resolve, reject) { |
|
|
|
new Promise(function (resolve, reject) { |
|
|
|
if (!_this5.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
if (!_this6.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -679,42 +676,40 @@ var PDFViewerApplication = { |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
storedHash = 'page=' + values.page + '&zoom=' + (_this5.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop; |
|
|
|
storedHash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop; |
|
|
|
sidebarView = _this5.viewerPrefs['sidebarViewOnLoad'] || values.sidebarView | 0; |
|
|
|
sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'] || values.sidebarView | 0; |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
}).catch(function () { |
|
|
|
}).catch(resolve); |
|
|
|
resolve(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}).then(function () { |
|
|
|
}).then(function () { |
|
|
|
_this5.setInitialView(storedHash, { |
|
|
|
_this6.setInitialView(storedHash, { |
|
|
|
sidebarView: sidebarView, |
|
|
|
sidebarView: sidebarView, |
|
|
|
scale: scale |
|
|
|
scale: scale |
|
|
|
}); |
|
|
|
}); |
|
|
|
initialParams.hash = storedHash; |
|
|
|
initialParams.hash = storedHash; |
|
|
|
if (!_this5.isViewerEmbedded) { |
|
|
|
if (!_this6.isViewerEmbedded) { |
|
|
|
_this5.pdfViewer.focus(); |
|
|
|
pdfViewer.focus(); |
|
|
|
} |
|
|
|
} |
|
|
|
return pagesPromise; |
|
|
|
return pagesPromise; |
|
|
|
}).then(function () { |
|
|
|
}).then(function () { |
|
|
|
if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) { |
|
|
|
if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (_this5.hasEqualPageSizes) { |
|
|
|
if (_this6.hasEqualPageSizes) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
_this5.initialDestination = initialParams.destination; |
|
|
|
_this6.initialDestination = initialParams.destination; |
|
|
|
_this5.initialBookmark = initialParams.bookmark; |
|
|
|
_this6.initialBookmark = initialParams.bookmark; |
|
|
|
_this5.pdfViewer.currentScaleValue = _this5.pdfViewer.currentScaleValue; |
|
|
|
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; |
|
|
|
_this5.setInitialView(initialParams.hash); |
|
|
|
_this6.setInitialView(initialParams.hash); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getPageLabels().then(function (labels) { |
|
|
|
pdfDocument.getPageLabels().then(function (labels) { |
|
|
|
if (!labels || _this5.viewerPrefs['disablePageLabels']) { |
|
|
|
if (!labels || _this6.viewerPrefs['disablePageLabels']) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var i = 0, |
|
|
|
var i = 0, |
|
|
|
numLabels = labels.length; |
|
|
|
numLabels = labels.length; |
|
|
|
if (numLabels !== _this5.pagesCount) { |
|
|
|
if (numLabels !== _this6.pagesCount) { |
|
|
|
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); |
|
|
|
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -726,17 +721,17 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
pdfViewer.setPageLabels(labels); |
|
|
|
pdfViewer.setPageLabels(labels); |
|
|
|
pdfThumbnailViewer.setPageLabels(labels); |
|
|
|
pdfThumbnailViewer.setPageLabels(labels); |
|
|
|
_this5.toolbar.setPagesCount(pdfDocument.numPages, true); |
|
|
|
_this6.toolbar.setPagesCount(pdfDocument.numPages, true); |
|
|
|
_this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
_this6.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pagesPromise.then(function () { |
|
|
|
pagesPromise.then(function () { |
|
|
|
if (!_this5.supportsPrinting) { |
|
|
|
if (!_this6.supportsPrinting) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
pdfDocument.getJavaScript().then(function (javaScript) { |
|
|
|
pdfDocument.getJavaScript().then(function (javaScript) { |
|
|
|
if (javaScript.length) { |
|
|
|
if (javaScript.length) { |
|
|
|
console.warn('Warning: JavaScript is not supported'); |
|
|
|
console.warn('Warning: JavaScript is not supported'); |
|
|
|
_this5.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript); |
|
|
|
_this6.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript); |
|
|
|
} |
|
|
|
} |
|
|
|
var regex = /\bprint\s*\(/; |
|
|
|
var regex = /\bprint\s*\(/; |
|
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) { |
|
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) { |
|
|
@ -752,18 +747,18 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { |
|
|
|
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { |
|
|
|
pdfDocument.getOutline().then(function (outline) { |
|
|
|
pdfDocument.getOutline().then(function (outline) { |
|
|
|
_this5.pdfOutlineViewer.render({ outline: outline }); |
|
|
|
_this6.pdfOutlineViewer.render({ outline: outline }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getAttachments().then(function (attachments) { |
|
|
|
pdfDocument.getAttachments().then(function (attachments) { |
|
|
|
_this5.pdfAttachmentViewer.render({ attachments: attachments }); |
|
|
|
_this6.pdfAttachmentViewer.render({ attachments: attachments }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getMetadata().then(function (_ref2) { |
|
|
|
pdfDocument.getMetadata().then(function (_ref2) { |
|
|
|
var info = _ref2.info, |
|
|
|
var info = _ref2.info, |
|
|
|
metadata = _ref2.metadata; |
|
|
|
metadata = _ref2.metadata; |
|
|
|
|
|
|
|
|
|
|
|
_this5.documentInfo = info; |
|
|
|
_this6.documentInfo = info; |
|
|
|
_this5.metadata = metadata; |
|
|
|
_this6.metadata = metadata; |
|
|
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdf.version || '-') + (!_pdf.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); |
|
|
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdf.version || '-') + (!_pdf.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); |
|
|
|
var pdfTitle = void 0; |
|
|
|
var pdfTitle = void 0; |
|
|
|
if (metadata && metadata.has('dc:title')) { |
|
|
|
if (metadata && metadata.has('dc:title')) { |
|
|
@ -776,11 +771,11 @@ var PDFViewerApplication = { |
|
|
|
pdfTitle = info['Title']; |
|
|
|
pdfTitle = info['Title']; |
|
|
|
} |
|
|
|
} |
|
|
|
if (pdfTitle) { |
|
|
|
if (pdfTitle) { |
|
|
|
_this5.setTitle(pdfTitle + ' - ' + document.title); |
|
|
|
_this6.setTitle(pdfTitle + ' - ' + document.title); |
|
|
|
} |
|
|
|
} |
|
|
|
if (info.IsAcroFormPresent) { |
|
|
|
if (info.IsAcroFormPresent) { |
|
|
|
console.warn('Warning: AcroForm/XFA is not supported'); |
|
|
|
console.warn('Warning: AcroForm/XFA is not supported'); |
|
|
|
_this5.fallback(_pdf.UNSUPPORTED_FEATURES.forms); |
|
|
|
_this6.fallback(_pdf.UNSUPPORTED_FEATURES.forms); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -812,8 +807,7 @@ var PDFViewerApplication = { |
|
|
|
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
|
|
|
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
cleanup: function cleanup() { |
|
|
|
cleanup: function pdfViewCleanup() { |
|
|
|
|
|
|
|
if (!this.pdfDocument) { |
|
|
|
if (!this.pdfDocument) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -823,20 +817,20 @@ var PDFViewerApplication = { |
|
|
|
this.pdfDocument.cleanup(); |
|
|
|
this.pdfDocument.cleanup(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
forceRendering: function pdfViewForceRendering() { |
|
|
|
forceRendering: function forceRendering() { |
|
|
|
this.pdfRenderingQueue.printing = this.printing; |
|
|
|
this.pdfRenderingQueue.printing = this.printing; |
|
|
|
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible; |
|
|
|
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible; |
|
|
|
this.pdfRenderingQueue.renderHighestPriority(); |
|
|
|
this.pdfRenderingQueue.renderHighestPriority(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
beforePrint: function pdfViewSetupBeforePrint() { |
|
|
|
beforePrint: function beforePrint() { |
|
|
|
var _this6 = this; |
|
|
|
var _this7 = this; |
|
|
|
|
|
|
|
|
|
|
|
if (this.printService) { |
|
|
|
if (this.printService) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this.supportsPrinting) { |
|
|
|
if (!this.supportsPrinting) { |
|
|
|
this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) { |
|
|
|
this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) { |
|
|
|
_this6.error(printMessage); |
|
|
|
_this7.error(printMessage); |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -853,6 +847,7 @@ var PDFViewerApplication = { |
|
|
|
this.forceRendering(); |
|
|
|
this.forceRendering(); |
|
|
|
printService.layout(); |
|
|
|
printService.layout(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get hasEqualPageSizes() { |
|
|
|
get hasEqualPageSizes() { |
|
|
|
var firstPage = this.pdfViewer.getPageView(0); |
|
|
|
var firstPage = this.pdfViewer.getPageView(0); |
|
|
|
for (var i = 1, ii = this.pagesCount; i < ii; ++i) { |
|
|
|
for (var i = 1, ii = this.pagesCount; i < ii; ++i) { |
|
|
@ -884,21 +879,22 @@ var PDFViewerApplication = { |
|
|
|
this.forceRendering(); |
|
|
|
this.forceRendering(); |
|
|
|
pdfViewer.currentPageNumber = pageNumber; |
|
|
|
pdfViewer.currentPageNumber = pageNumber; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
requestPresentationMode: function requestPresentationMode() { |
|
|
|
requestPresentationMode: function pdfViewRequestPresentationMode() { |
|
|
|
|
|
|
|
if (!this.pdfPresentationMode) { |
|
|
|
if (!this.pdfPresentationMode) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.pdfPresentationMode.request(); |
|
|
|
this.pdfPresentationMode.request(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
bindEvents: function bindEvents() { |
|
|
|
bindEvents: function bindEvents() { |
|
|
|
var eventBus = this.eventBus; |
|
|
|
var eventBus = this.eventBus, |
|
|
|
this._boundEvents.beforePrint = this.beforePrint.bind(this); |
|
|
|
_boundEvents = this._boundEvents; |
|
|
|
this._boundEvents.afterPrint = this.afterPrint.bind(this); |
|
|
|
|
|
|
|
|
|
|
|
_boundEvents.beforePrint = this.beforePrint.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); |
|
|
@ -928,41 +924,45 @@ var PDFViewerApplication = { |
|
|
|
eventBus.on('fileinputchange', webViewerFileInputChange); |
|
|
|
eventBus.on('fileinputchange', webViewerFileInputChange); |
|
|
|
}, |
|
|
|
}, |
|
|
|
bindWindowEvents: function bindWindowEvents() { |
|
|
|
bindWindowEvents: function bindWindowEvents() { |
|
|
|
var eventBus = this.eventBus; |
|
|
|
var eventBus = this.eventBus, |
|
|
|
this._boundEvents.windowResize = function () { |
|
|
|
_boundEvents = this._boundEvents; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_boundEvents.windowResize = function () { |
|
|
|
eventBus.dispatch('resize'); |
|
|
|
eventBus.dispatch('resize'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowHashChange = function () { |
|
|
|
_boundEvents.windowHashChange = function () { |
|
|
|
eventBus.dispatch('hashchange', { hash: document.location.hash.substring(1) }); |
|
|
|
eventBus.dispatch('hashchange', { hash: document.location.hash.substring(1) }); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowBeforePrint = function () { |
|
|
|
_boundEvents.windowBeforePrint = function () { |
|
|
|
eventBus.dispatch('beforeprint'); |
|
|
|
eventBus.dispatch('beforeprint'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
this._boundEvents.windowAfterPrint = function () { |
|
|
|
_boundEvents.windowAfterPrint = function () { |
|
|
|
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); |
|
|
|
this._boundEvents.windowChange = function (evt) { |
|
|
|
_boundEvents.windowChange = function (evt) { |
|
|
|
var files = evt.target.files; |
|
|
|
var files = evt.target.files; |
|
|
|
if (!files || files.length === 0) { |
|
|
|
if (!files || files.length === 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
eventBus.dispatch('fileinputchange', { fileInput: evt.target }); |
|
|
|
eventBus.dispatch('fileinputchange', { fileInput: evt.target }); |
|
|
|
}; |
|
|
|
}; |
|
|
|
window.addEventListener('change', this._boundEvents.windowChange); |
|
|
|
window.addEventListener('change', _boundEvents.windowChange); |
|
|
|
}, |
|
|
|
}, |
|
|
|
unbindEvents: function unbindEvents() { |
|
|
|
unbindEvents: function unbindEvents() { |
|
|
|
var eventBus = this.eventBus; |
|
|
|
var eventBus = this.eventBus, |
|
|
|
|
|
|
|
_boundEvents = this._boundEvents; |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
@ -990,26 +990,28 @@ var PDFViewerApplication = { |
|
|
|
eventBus.off('find', webViewerFind); |
|
|
|
eventBus.off('find', webViewerFind); |
|
|
|
eventBus.off('findfromurlhash', webViewerFindFromUrlHash); |
|
|
|
eventBus.off('findfromurlhash', webViewerFindFromUrlHash); |
|
|
|
eventBus.off('fileinputchange', webViewerFileInputChange); |
|
|
|
eventBus.off('fileinputchange', webViewerFileInputChange); |
|
|
|
this._boundEvents.beforePrint = null; |
|
|
|
_boundEvents.beforePrint = null; |
|
|
|
this._boundEvents.afterPrint = null; |
|
|
|
_boundEvents.afterPrint = null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
unbindWindowEvents: function unbindWindowEvents() { |
|
|
|
unbindWindowEvents: function unbindWindowEvents() { |
|
|
|
|
|
|
|
var _boundEvents = this._boundEvents; |
|
|
|
|
|
|
|
|
|
|
|
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', this._boundEvents.windowResize); |
|
|
|
window.removeEventListener('resize', _boundEvents.windowResize); |
|
|
|
window.removeEventListener('hashchange', this._boundEvents.windowHashChange); |
|
|
|
window.removeEventListener('hashchange', _boundEvents.windowHashChange); |
|
|
|
window.removeEventListener('beforeprint', this._boundEvents.windowBeforePrint); |
|
|
|
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint); |
|
|
|
window.removeEventListener('afterprint', this._boundEvents.windowAfterPrint); |
|
|
|
window.removeEventListener('afterprint', _boundEvents.windowAfterPrint); |
|
|
|
window.removeEventListener('change', this._boundEvents.windowChange); |
|
|
|
window.removeEventListener('change', _boundEvents.windowChange); |
|
|
|
this._boundEvents.windowChange = null; |
|
|
|
_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; |
|
|
|
var validateFileURL = void 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
validateFileURL = function validateFileURL(file) { |
|
|
|
validateFileURL = function validateFileURL(file) { |
|
|
@ -1022,12 +1024,12 @@ var validateFileURL; |
|
|
|
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; |
|
|
|
var message = ex && ex.message; |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) { |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) { |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, { message: message }); |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, { message: message }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
throw e; |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
@ -1052,7 +1054,7 @@ function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerInitialized() { |
|
|
|
function webViewerInitialized() { |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
var file; |
|
|
|
var file = void 0; |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var params = (0, _ui_utils.parseQueryString)(queryString); |
|
|
|
var params = (0, _ui_utils.parseQueryString)(queryString); |
|
|
|
file = 'file' in params ? params.file : appConfig.defaultUrl; |
|
|
|
file = 'file' in params ? params.file : appConfig.defaultUrl; |
|
|
@ -1134,8 +1136,8 @@ function webViewerInitialized() { |
|
|
|
if (PDFViewerApplication.supportsIntegratedFind) { |
|
|
|
if (PDFViewerApplication.supportsIntegratedFind) { |
|
|
|
appConfig.toolbar.viewFind.classList.add('hidden'); |
|
|
|
appConfig.toolbar.viewFind.classList.add('hidden'); |
|
|
|
} |
|
|
|
} |
|
|
|
appConfig.sidebar.mainContainer.addEventListener('transitionend', function (e) { |
|
|
|
appConfig.sidebar.mainContainer.addEventListener('transitionend', function (evt) { |
|
|
|
if (e.target === this) { |
|
|
|
if (evt.target === this) { |
|
|
|
PDFViewerApplication.eventBus.dispatch('resize'); |
|
|
|
PDFViewerApplication.eventBus.dispatch('resize'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
@ -1150,7 +1152,7 @@ function webViewerInitialized() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
var webViewerOpenFileViaURL; |
|
|
|
var webViewerOpenFileViaURL = void 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
@ -1163,9 +1165,9 @@ var webViewerOpenFileViaURL; |
|
|
|
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, 'An error occurred while loading the PDF.').then(function (msg) { |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) { |
|
|
|
PDFViewerApplication.error(msg, e); |
|
|
|
PDFViewerApplication.error(msg, ex); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1175,8 +1177,8 @@ var webViewerOpenFileViaURL; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerPageRendered(e) { |
|
|
|
function webViewerPageRendered(evt) { |
|
|
|
var pageNumber = e.pageNumber; |
|
|
|
var pageNumber = evt.pageNumber; |
|
|
|
var pageIndex = pageNumber - 1; |
|
|
|
var pageIndex = pageNumber - 1; |
|
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex); |
|
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex); |
|
|
|
if (pageNumber === PDFViewerApplication.page) { |
|
|
|
if (pageNumber === PDFViewerApplication.page) { |
|
|
@ -1198,10 +1200,10 @@ function webViewerPageRendered(e) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerTextLayerRendered(e) {} |
|
|
|
function webViewerTextLayerRendered(evt) {} |
|
|
|
function webViewerPageMode(e) { |
|
|
|
function webViewerPageMode(evt) { |
|
|
|
var mode = e.mode, |
|
|
|
var mode = evt.mode, |
|
|
|
view; |
|
|
|
view = void 0; |
|
|
|
switch (mode) { |
|
|
|
switch (mode) { |
|
|
|
case 'thumbs': |
|
|
|
case 'thumbs': |
|
|
|
view = _pdf_sidebar.SidebarView.THUMBS; |
|
|
|
view = _pdf_sidebar.SidebarView.THUMBS; |
|
|
@ -1222,8 +1224,8 @@ function webViewerPageMode(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
PDFViewerApplication.pdfSidebar.switchView(view, true); |
|
|
|
PDFViewerApplication.pdfSidebar.switchView(view, true); |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerNamedAction(e) { |
|
|
|
function webViewerNamedAction(evt) { |
|
|
|
var action = e.action; |
|
|
|
var action = evt.action; |
|
|
|
switch (action) { |
|
|
|
switch (action) { |
|
|
|
case 'GoToPage': |
|
|
|
case 'GoToPage': |
|
|
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
|
|
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
|
|
@ -1235,9 +1237,10 @@ function webViewerNamedAction(e) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerPresentationModeChanged(e) { |
|
|
|
function webViewerPresentationModeChanged(evt) { |
|
|
|
var active = e.active; |
|
|
|
var active = evt.active, |
|
|
|
var switchInProgress = e.switchInProgress; |
|
|
|
switchInProgress = evt.switchInProgress; |
|
|
|
|
|
|
|
|
|
|
|
PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL; |
|
|
|
PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL; |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerSidebarViewChanged(evt) { |
|
|
|
function webViewerSidebarViewChanged(evt) { |
|
|
@ -1276,9 +1279,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; |
|
|
|
var hash = evt.hash; |
|
|
|
if (!hash) { |
|
|
|
if (!hash) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1289,18 +1292,17 @@ function webViewerHashchange(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var webViewerFileInputChange; |
|
|
|
var webViewerFileInputChange = void 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
webViewerFileInputChange = function webViewerFileInputChange(e) { |
|
|
|
webViewerFileInputChange = function webViewerFileInputChange(evt) { |
|
|
|
var file = e.fileInput.files[0]; |
|
|
|
var file = evt.fileInput.files[0]; |
|
|
|
if (!_pdf.PDFJS.disableCreateObjectURL && typeof URL !== 'undefined' && URL.createObjectURL) { |
|
|
|
if (!_pdf.PDFJS.disableCreateObjectURL && URL.createObjectURL) { |
|
|
|
PDFViewerApplication.open(URL.createObjectURL(file)); |
|
|
|
PDFViewerApplication.open(URL.createObjectURL(file)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
var fileReader = new FileReader(); |
|
|
|
var fileReader = new FileReader(); |
|
|
|
fileReader.onload = function webViewerChangeFileReaderOnload(evt) { |
|
|
|
fileReader.onload = function webViewerChangeFileReaderOnload(evt) { |
|
|
|
var buffer = evt.target.result; |
|
|
|
var buffer = evt.target.result; |
|
|
|
var uint8Array = new Uint8Array(buffer); |
|
|
|
PDFViewerApplication.open(new Uint8Array(buffer)); |
|
|
|
PDFViewerApplication.open(uint8Array); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
fileReader.readAsArrayBuffer(file); |
|
|
|
fileReader.readAsArrayBuffer(file); |
|
|
|
} |
|
|
|
} |
|
|
@ -1347,15 +1349,15 @@ function webViewerZoomIn() { |
|
|
|
function webViewerZoomOut() { |
|
|
|
function webViewerZoomOut() { |
|
|
|
PDFViewerApplication.zoomOut(); |
|
|
|
PDFViewerApplication.zoomOut(); |
|
|
|
} |
|
|
|
} |
|
|
|
function webViewerPageNumberChanged(e) { |
|
|
|
function webViewerPageNumberChanged(evt) { |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
pdfViewer.currentPageLabel = e.value; |
|
|
|
pdfViewer.currentPageLabel = evt.value; |
|
|
|
if (e.value !== pdfViewer.currentPageNumber.toString() && e.value !== pdfViewer.currentPageLabel) { |
|
|
|
if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) { |
|
|
|
PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
PDFViewerApplication.toolbar.setPageNumber(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); |
|
|
@ -1366,31 +1368,31 @@ function webViewerRotateCcw() { |
|
|
|
function webViewerDocumentProperties() { |
|
|
|
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; |
|
|
|
var 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) { |
|
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page); |
|
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page); |
|
|
@ -1403,7 +1405,7 @@ function webViewerPageChanging(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var zoomDisabled = false, |
|
|
|
var zoomDisabled = false, |
|
|
|
zoomDisabledTimeout; |
|
|
|
zoomDisabledTimeout = void 0; |
|
|
|
function webViewerWheel(evt) { |
|
|
|
function webViewerWheel(evt) { |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
var pdfViewer = PDFViewerApplication.pdfViewer; |
|
|
|
if (pdfViewer.isInPresentationMode) { |
|
|
|
if (pdfViewer.isInPresentationMode) { |
|
|
|