|
|
|
@ -15,9 +15,9 @@
@@ -15,9 +15,9 @@
|
|
|
|
|
/* globals PDFBug, Stats */ |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, MAX_SCALE, |
|
|
|
|
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta, parseQueryString, |
|
|
|
|
ProgressBar, RendererType |
|
|
|
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, isValidRotation, |
|
|
|
|
MAX_SCALE, MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta, |
|
|
|
|
parseQueryString, ProgressBar, RendererType |
|
|
|
|
} from './ui_utils'; |
|
|
|
|
import { |
|
|
|
|
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException, |
|
|
|
@ -935,6 +935,8 @@ let PDFViewerApplication = {
@@ -935,6 +935,8 @@ let PDFViewerApplication = {
|
|
|
|
|
|
|
|
|
|
if (this.pdfHistory.initialBookmark) { |
|
|
|
|
this.initialBookmark = this.pdfHistory.initialBookmark; |
|
|
|
|
|
|
|
|
|
this.initialRotation = this.pdfHistory.initialRotation; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -948,6 +950,7 @@ let PDFViewerApplication = {
@@ -948,6 +950,7 @@ let PDFViewerApplication = {
|
|
|
|
|
zoom: DEFAULT_SCALE_VALUE, |
|
|
|
|
scrollLeft: '0', |
|
|
|
|
scrollTop: '0', |
|
|
|
|
rotation: null, |
|
|
|
|
sidebarView: SidebarView.NONE, |
|
|
|
|
}).catch(() => { /* Unable to read from storage; ignoring errors. */ }); |
|
|
|
|
|
|
|
|
@ -956,12 +959,14 @@ let PDFViewerApplication = {
@@ -956,12 +959,14 @@ let PDFViewerApplication = {
|
|
|
|
|
// Initialize the default values, from user preferences.
|
|
|
|
|
let hash = this.viewerPrefs['defaultZoomValue'] ? |
|
|
|
|
('zoom=' + this.viewerPrefs['defaultZoomValue']) : null; |
|
|
|
|
let rotation = null; |
|
|
|
|
let sidebarView = this.viewerPrefs['sidebarViewOnLoad']; |
|
|
|
|
|
|
|
|
|
if (values.exists && this.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
|
hash = 'page=' + values.page + |
|
|
|
|
'&zoom=' + (this.viewerPrefs['defaultZoomValue'] || values.zoom) + |
|
|
|
|
',' + values.scrollLeft + ',' + values.scrollTop; |
|
|
|
|
rotation = parseInt(values.rotation, 10); |
|
|
|
|
sidebarView = sidebarView || (values.sidebarView | 0); |
|
|
|
|
} |
|
|
|
|
if (pageMode && !this.viewerPrefs['disablePageMode']) { |
|
|
|
@ -970,13 +975,14 @@ let PDFViewerApplication = {
@@ -970,13 +975,14 @@ let PDFViewerApplication = {
|
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
hash, |
|
|
|
|
rotation, |
|
|
|
|
sidebarView, |
|
|
|
|
}; |
|
|
|
|
}).then(({ hash, sidebarView, }) => { |
|
|
|
|
}).then(({ hash, rotation, sidebarView, }) => { |
|
|
|
|
initialParams.bookmark = this.initialBookmark; |
|
|
|
|
initialParams.hash = hash; |
|
|
|
|
|
|
|
|
|
this.setInitialView(hash, { sidebarView, }); |
|
|
|
|
this.setInitialView(hash, { rotation, sidebarView, }); |
|
|
|
|
|
|
|
|
|
// Make all navigation keys work on document load,
|
|
|
|
|
// unless the viewer is embedded in a web page.
|
|
|
|
@ -1131,14 +1137,24 @@ let PDFViewerApplication = {
@@ -1131,14 +1137,24 @@ let PDFViewerApplication = {
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setInitialView(storedHash, { sidebarView, } = {}) { |
|
|
|
|
setInitialView(storedHash, { rotation, sidebarView, } = {}) { |
|
|
|
|
let setRotation = (angle) => { |
|
|
|
|
if (isValidRotation(angle)) { |
|
|
|
|
this.pdfViewer.pagesRotation = angle; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.isInitialViewSet = true; |
|
|
|
|
this.pdfSidebar.setInitialView(sidebarView); |
|
|
|
|
|
|
|
|
|
if (this.initialBookmark) { |
|
|
|
|
setRotation(this.initialRotation); |
|
|
|
|
delete this.initialRotation; |
|
|
|
|
|
|
|
|
|
this.pdfLinkService.setHash(this.initialBookmark); |
|
|
|
|
this.initialBookmark = null; |
|
|
|
|
} else if (storedHash) { |
|
|
|
|
setRotation(rotation); |
|
|
|
|
|
|
|
|
|
this.pdfLinkService.setHash(storedHash); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1232,16 +1248,10 @@ let PDFViewerApplication = {
@@ -1232,16 +1248,10 @@ let PDFViewerApplication = {
|
|
|
|
|
if (!this.pdfDocument) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let { pdfViewer, pdfThumbnailViewer, } = this; |
|
|
|
|
let pageNumber = pdfViewer.currentPageNumber; |
|
|
|
|
let newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360; |
|
|
|
|
|
|
|
|
|
pdfViewer.pagesRotation = newRotation; |
|
|
|
|
pdfThumbnailViewer.pagesRotation = newRotation; |
|
|
|
|
|
|
|
|
|
this.forceRendering(); |
|
|
|
|
// Ensure that the active page doesn't change during rotation.
|
|
|
|
|
pdfViewer.currentPageNumber = pageNumber; |
|
|
|
|
let newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360; |
|
|
|
|
this.pdfViewer.pagesRotation = newRotation; |
|
|
|
|
// Note that the thumbnail viewer is updated, and rendering is triggered,
|
|
|
|
|
// in the 'rotationchanging' event handler.
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
requestPresentationMode() { |
|
|
|
@ -1266,6 +1276,7 @@ let PDFViewerApplication = {
@@ -1266,6 +1276,7 @@ let PDFViewerApplication = {
|
|
|
|
|
eventBus.on('updateviewarea', webViewerUpdateViewarea); |
|
|
|
|
eventBus.on('pagechanging', webViewerPageChanging); |
|
|
|
|
eventBus.on('scalechanging', webViewerScaleChanging); |
|
|
|
|
eventBus.on('rotationchanging', webViewerRotationChanging); |
|
|
|
|
eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged); |
|
|
|
|
eventBus.on('pagemode', webViewerPageMode); |
|
|
|
|
eventBus.on('namedaction', webViewerNamedAction); |
|
|
|
@ -1343,6 +1354,7 @@ let PDFViewerApplication = {
@@ -1343,6 +1354,7 @@ let PDFViewerApplication = {
|
|
|
|
|
eventBus.off('updateviewarea', webViewerUpdateViewarea); |
|
|
|
|
eventBus.off('pagechanging', webViewerPageChanging); |
|
|
|
|
eventBus.off('scalechanging', webViewerScaleChanging); |
|
|
|
|
eventBus.off('rotationchanging', webViewerRotationChanging); |
|
|
|
|
eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged); |
|
|
|
|
eventBus.off('pagemode', webViewerPageMode); |
|
|
|
|
eventBus.off('namedaction', webViewerNamedAction); |
|
|
|
@ -1769,6 +1781,7 @@ function webViewerUpdateViewarea(evt) {
@@ -1769,6 +1781,7 @@ function webViewerUpdateViewarea(evt) {
|
|
|
|
|
'zoom': location.scale, |
|
|
|
|
'scrollLeft': location.left, |
|
|
|
|
'scrollTop': location.top, |
|
|
|
|
'rotation': location.rotation, |
|
|
|
|
}).catch(function() { /* unable to write to storage */ }); |
|
|
|
|
} |
|
|
|
|
let href = |
|
|
|
@ -1926,6 +1939,14 @@ function webViewerScaleChanging(evt) {
@@ -1926,6 +1939,14 @@ function webViewerScaleChanging(evt) {
|
|
|
|
|
PDFViewerApplication.pdfViewer.update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function webViewerRotationChanging(evt) { |
|
|
|
|
PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation; |
|
|
|
|
|
|
|
|
|
PDFViewerApplication.forceRendering(); |
|
|
|
|
// Ensure that the active page doesn't change during rotation.
|
|
|
|
|
PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function webViewerPageChanging(evt) { |
|
|
|
|
let page = evt.pageNumber; |
|
|
|
|
|
|
|
|
|