|
|
@ -833,11 +833,9 @@ var PDFViewerApplication = { |
|
|
|
self.loadingBar.hide(); |
|
|
|
self.loadingBar.hide(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var pagesCount = pdfDocument.numPages; |
|
|
|
this._updateUIToolbar({ |
|
|
|
var toolbarConfig = this.appConfig.toolbar; |
|
|
|
resetNumPages: true, |
|
|
|
toolbarConfig.numPages.textContent = |
|
|
|
}); |
|
|
|
mozL10n.get('page_of', {pageCount: pagesCount}, 'of {{pageCount}}'); |
|
|
|
|
|
|
|
toolbarConfig.pageNumber.max = pagesCount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var store = this.store = new ViewHistory(id); |
|
|
|
var store = this.store = new ViewHistory(id); |
|
|
@ -1050,10 +1048,6 @@ var PDFViewerApplication = { |
|
|
|
|
|
|
|
|
|
|
|
this.isInitialViewSet = true; |
|
|
|
this.isInitialViewSet = true; |
|
|
|
|
|
|
|
|
|
|
|
// When opening a new file, when one is already loaded in the viewer,
|
|
|
|
|
|
|
|
// ensure that the 'pageNumber' element displays the correct value.
|
|
|
|
|
|
|
|
this.appConfig.toolbar.pageNumber.value = this.pdfViewer.currentPageNumber; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.pdfSidebar.setInitialView(this.preferenceSidebarViewOnLoad || |
|
|
|
this.pdfSidebar.setInitialView(this.preferenceSidebarViewOnLoad || |
|
|
|
(sidebarView | 0)); |
|
|
|
(sidebarView | 0)); |
|
|
|
|
|
|
|
|
|
|
@ -1224,6 +1218,67 @@ var PDFViewerApplication = { |
|
|
|
this.pdfPresentationMode.mouseScroll(delta); |
|
|
|
this.pdfPresentationMode.mouseScroll(delta); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @typedef UpdateUIToolbarParameters |
|
|
|
|
|
|
|
* @property {number} pageNumber |
|
|
|
|
|
|
|
* @property {string} scaleValue |
|
|
|
|
|
|
|
* @property {scale} scale |
|
|
|
|
|
|
|
* @property {boolean} resetNumPages |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param {Object} UpdateUIToolbarParameters |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_updateUIToolbar: function (params) { |
|
|
|
|
|
|
|
function selectScaleOption(value, scale) { |
|
|
|
|
|
|
|
var options = toolbarConfig.scaleSelect.options; |
|
|
|
|
|
|
|
var predefinedValueFound = false; |
|
|
|
|
|
|
|
for (var i = 0, ii = options.length; i < ii; i++) { |
|
|
|
|
|
|
|
var option = options[i]; |
|
|
|
|
|
|
|
if (option.value !== value) { |
|
|
|
|
|
|
|
option.selected = false; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
option.selected = true; |
|
|
|
|
|
|
|
predefinedValueFound = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!predefinedValueFound) { |
|
|
|
|
|
|
|
var customScale = Math.round(scale * 10000) / 100; |
|
|
|
|
|
|
|
toolbarConfig.customScaleOption.textContent = |
|
|
|
|
|
|
|
mozL10n.get('page_scale_percent', {scale: customScale}, '{{scale}}%'); |
|
|
|
|
|
|
|
toolbarConfig.customScaleOption.selected = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pageNumber = params.pageNumber || this.pdfViewer.currentPageNumber; |
|
|
|
|
|
|
|
var scaleValue = (params.scaleValue || params.scale || |
|
|
|
|
|
|
|
this.pdfViewer.currentScaleValue || DEFAULT_SCALE_VALUE).toString(); |
|
|
|
|
|
|
|
var scale = params.scale || this.pdfViewer.currentScale; |
|
|
|
|
|
|
|
var resetNumPages = params.resetNumPages || false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var toolbarConfig = this.appConfig.toolbar; |
|
|
|
|
|
|
|
var pagesCount = this.pagesCount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resetNumPages) { |
|
|
|
|
|
|
|
toolbarConfig.numPages.textContent = |
|
|
|
|
|
|
|
mozL10n.get('page_of', { pageCount: pagesCount }, 'of {{pageCount}}'); |
|
|
|
|
|
|
|
toolbarConfig.pageNumber.max = pagesCount; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
toolbarConfig.pageNumber.value = pageNumber; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbarConfig.previous.disabled = (pageNumber <= 1); |
|
|
|
|
|
|
|
toolbarConfig.next.disabled = (pageNumber >= pagesCount); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbarConfig.firstPage.disabled = (pageNumber <= 1); |
|
|
|
|
|
|
|
toolbarConfig.lastPage.disabled = (pageNumber >= pagesCount); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbarConfig.zoomOut.disabled = (scale === MIN_SCALE); |
|
|
|
|
|
|
|
toolbarConfig.zoomIn.disabled = (scale === MAX_SCALE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectScaleOption(scaleValue, scale); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
bindEvents: function pdfViewBindEvents() { |
|
|
|
bindEvents: function pdfViewBindEvents() { |
|
|
|
var eventBus = this.eventBus; |
|
|
|
var eventBus = this.eventBus; |
|
|
|
|
|
|
|
|
|
|
@ -1825,21 +1880,6 @@ function webViewerFileInputChange(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
function selectScaleOption(value) { |
|
|
|
|
|
|
|
var options = PDFViewerApplication.appConfig.toolbar.scaleSelect.options; |
|
|
|
|
|
|
|
var predefinedValueFound = false; |
|
|
|
|
|
|
|
for (var i = 0, ii = options.length; i < ii; i++) { |
|
|
|
|
|
|
|
var option = options[i]; |
|
|
|
|
|
|
|
if (option.value !== value) { |
|
|
|
|
|
|
|
option.selected = false; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
option.selected = true; |
|
|
|
|
|
|
|
predefinedValueFound = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return predefinedValueFound; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('localized', function localized(evt) { |
|
|
|
window.addEventListener('localized', function localized(evt) { |
|
|
|
PDFViewerApplication.eventBus.dispatch('localized'); |
|
|
|
PDFViewerApplication.eventBus.dispatch('localized'); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1925,20 +1965,11 @@ function webViewerFindFromUrlHash(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerScaleChanging(e) { |
|
|
|
function webViewerScaleChanging(e) { |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
PDFViewerApplication._updateUIToolbar({ |
|
|
|
appConfig.toolbar.zoomOut.disabled = (e.scale === MIN_SCALE); |
|
|
|
scaleValue: e.presetValue, |
|
|
|
appConfig.toolbar.zoomIn.disabled = (e.scale === MAX_SCALE); |
|
|
|
scale: e.scale, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Update the 'scaleSelect' DOM element.
|
|
|
|
|
|
|
|
var predefinedValueFound = selectScaleOption(e.presetValue || |
|
|
|
|
|
|
|
'' + e.scale); |
|
|
|
|
|
|
|
if (!predefinedValueFound) { |
|
|
|
|
|
|
|
var customScaleOption = appConfig.toolbar.customScaleOption; |
|
|
|
|
|
|
|
var customScale = Math.round(e.scale * 10000) / 100; |
|
|
|
|
|
|
|
customScaleOption.textContent = |
|
|
|
|
|
|
|
mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%'); |
|
|
|
|
|
|
|
customScaleOption.selected = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!PDFViewerApplication.initialized) { |
|
|
|
if (!PDFViewerApplication.initialized) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1947,20 +1978,14 @@ function webViewerScaleChanging(e) { |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageChanging(e) { |
|
|
|
function webViewerPageChanging(e) { |
|
|
|
var page = e.pageNumber; |
|
|
|
var page = e.pageNumber; |
|
|
|
if (e.previousPageNumber !== page) { |
|
|
|
|
|
|
|
PDFViewerApplication.appConfig.toolbar.pageNumber.value = page; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
|
PDFViewerApplication._updateUIToolbar({ |
|
|
|
|
|
|
|
pageNumber: page, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (e.previousPageNumber !== page && |
|
|
|
|
|
|
|
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
|
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page); |
|
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var numPages = PDFViewerApplication.pagesCount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PDFViewerApplication.appConfig.toolbar.previous.disabled = (page <= 1); |
|
|
|
|
|
|
|
PDFViewerApplication.appConfig.toolbar.next.disabled = (page >= numPages); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PDFViewerApplication.appConfig.toolbar.firstPage.disabled = (page <= 1); |
|
|
|
|
|
|
|
PDFViewerApplication.appConfig.toolbar.lastPage.disabled = (page >= numPages); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we need to update stats
|
|
|
|
// we need to update stats
|
|
|
|
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) { |
|
|
|
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) { |
|
|
|