Add 'Zoom to Page Height' PDF reader option

Fixes #2255
This commit is contained in:
Martynas Bagdonas 2022-03-31 15:52:00 +07:00
parent 8e54f1649b
commit 3356557493
6 changed files with 30 additions and 0 deletions

View file

@ -157,6 +157,12 @@
label="&zotero.pdfReader.zoomPageWidth;"
oncommand="menuCmd('zoomPageWidth')"
/>
<menuitem
id="view-menuitem-zoom-page-height"
type="checkbox"
label="&zotero.pdfReader.zoomPageHeight;"
oncommand="menuCmd('zoomPageHeight')"
/>
</menupopup>
</menu>
<menu

View file

@ -407,6 +407,7 @@ const ZoteroStandalone = new function() {
this.updateMenuItemCheckmark('view-menuitem-hand-tool', reader.isHandToolActive());
this.updateMenuItemCheckmark('view-menuitem-zoom-auto', reader.isZoomAutoActive());
this.updateMenuItemCheckmark('view-menuitem-zoom-page-width', reader.isZoomPageWidthActive());
this.updateMenuItemCheckmark('view-menuitem-zoom-page-height', reader.isZoomPageHeightActive());
}
// Layout mode

View file

@ -329,6 +329,13 @@
label="&zotero.pdfReader.zoomPageWidth;"
oncommand="ZoteroStandalone.onReaderCmd('zoomPageWidth')"
/>
<menuitem
id="view-menuitem-zoom-page-height"
class="menu-type-reader"
type="checkbox"
label="&zotero.pdfReader.zoomPageHeight;"
oncommand="ZoteroStandalone.onReaderCmd('zoomPageHeight')"
/>
<menuseparator class="menu-type-reader"/>
<menu id="layout-menu" label="&layout.label;">

View file

@ -197,6 +197,10 @@ class ReaderInstance {
isZoomPageWidthActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentScaleValue === "page-width"');
}
isZoomPageHeightActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentScaleValue === "page-fit"');
}
allowNavigateFirstPage() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentPageNumber > 1');
@ -499,6 +503,15 @@ class ReaderInstance {
this._postMessage({ action: 'popupCmd', cmd: 'zoomPageWidth' });
});
popup.appendChild(menuitem);
// Zoom 'Page Height'
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', Zotero.getString('pdfReader.zoomPageHeight'));
menuitem.setAttribute('type', 'checkbox');
menuitem.setAttribute('checked', data.isZoomPageHeight);
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'zoomPageHeight' });
});
popup.appendChild(menuitem);
// Separator
popup.appendChild(this._window.document.createElement('menuseparator'));
// Next page
@ -1057,6 +1070,7 @@ class ReaderWindow extends ReaderInstance {
this._window.document.getElementById('view-menuitem-hand-tool').setAttribute('checked', this.isHandToolActive());
this._window.document.getElementById('view-menuitem-zoom-auto').setAttribute('checked', this.isZoomAutoActive());
this._window.document.getElementById('view-menuitem-zoom-page-width').setAttribute('checked', this.isZoomPageWidthActive());
this._window.document.getElementById('view-menuitem-zoom-page-height').setAttribute('checked', this.isZoomPageHeightActive());
}
_onGoMenuOpen() {

View file

@ -324,4 +324,5 @@
<!ENTITY zotero.pdfReader.zoomOut "Zoom Out">
<!ENTITY zotero.pdfReader.zoomAuto "Automatically Resize">
<!ENTITY zotero.pdfReader.zoomPageWidth "Zoom to Page Width">
<!ENTITY zotero.pdfReader.zoomPageHeight "Zoom to Page Height">
<!ENTITY zotero.pdfReader.transferFromPDF "Import Annotations…">

View file

@ -1369,6 +1369,7 @@ pdfReader.zoomIn = Zoom In
pdfReader.zoomOut = Zoom Out
pdfReader.zoomAuto = Automatically Resize
pdfReader.zoomPageWidth = Zoom to Page Width
pdfReader.zoomPageHeight = Zoom to Page Height
pdfReader.nextPage = Next Page
pdfReader.previousPage = Previous Page
pdfReader.page = Page