diff --git a/chrome/content/zotero/reader.xul b/chrome/content/zotero/reader.xul index 0dba461772..a12c2e4f21 100644 --- a/chrome/content/zotero/reader.xul +++ b/chrome/content/zotero/reader.xul @@ -39,6 +39,11 @@ oncommand="document.getElementById('zotero-tb-search').select()"/> + + + + + @@ -65,7 +70,7 @@ - + - - + + - - + - - + + + - - - - - - - + + + + + + + + + + + + - - - - - + + @@ -216,28 +218,11 @@ hidden="true"/> - + - - - - - - - - - - - + + + + + + + + + + 1'); + } + + allowNavigateLastPage() { + return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentPageNumber < PDFViewerApplication.pdfViewer.pagesCount'); + } + + allowNavigateBack() { + try { + let { uid } = this._iframeWindow.history.state; + if (uid == 0) { + return false; + } + } + catch (e) { + } + return true; + } + + allowNavigateForward() { + try { + let { uid } = this._iframeWindow.history.state; + let length = this._iframeWindow.history.length; + if (uid == length - 1) { + return false; + } + } + catch (e) { + } + return true; + } + menuCmd(cmd) { if (cmd === 'export') { let zp = Zotero.getActiveZoteroPane(); @@ -169,6 +208,7 @@ class ReaderInstance { } async _setState(state) { + this.state = state; let item = Zotero.Items.get(this._itemID); if (item) { item.setAttachmentLastPageIndex(state.pageIndex); @@ -322,7 +362,7 @@ class ReaderInstance { // Add to note menuitem = this._window.document.createElement('menuitem'); menuitem.setAttribute('label', Zotero.getString('pdfReader.addToNote')); - let hasActiveEditor = this._window.ZoteroContextPane.getActiveEditor(); + let hasActiveEditor = this._window.ZoteroContextPane && this._window.ZoteroContextPane.getActiveEditor(); menuitem.setAttribute('disabled', !hasActiveEditor); menuitem.addEventListener('command', () => { let data = { @@ -643,7 +683,7 @@ class ReaderTab extends ReaderInstance { } _addToNote(annotations) { - let noteEditor = this._window.ZoteroContextPane.getActiveEditor(); + let noteEditor = this._window.ZoteroContextPane && this._window.ZoteroContextPane.getActiveEditor(); if (!noteEditor) { return; } @@ -661,7 +701,7 @@ class ReaderWindow extends ReaderInstance { super(); this._sidebarWidth = sidebarWidth; this._sidebarOpen = sidebarOpen; - this._bottomPlaceholderHeight = bottomPlaceholderHeight; + this._bottomPlaceholderHeight = 0; this.init(); } @@ -678,6 +718,8 @@ class ReaderWindow extends ReaderInstance { this._window.addEventListener('keypress', this._handleKeyPress); this._popupset = this._window.document.getElementById('zotero-reader-popupset'); this._window.menuCmd = this.menuCmd.bind(this); + this._window.onGoMenuOpen = this._onGoMenuOpen.bind(this); + this._window.onViewMenuOpen = this._onViewMenuOpen.bind(this); this._iframe = this._window.document.getElementById('reader'); } @@ -702,6 +744,44 @@ class ReaderWindow extends ReaderInstance { this._window.close(); } } + + _onViewMenuOpen() { + this._window.document.getElementById('view-menuitem-vertical-scrolling').setAttribute('checked', this.state.scrollMode == 0); + this._window.document.getElementById('view-menuitem-horizontal-scrolling').setAttribute('checked', this.state.scrollMode == 1); + this._window.document.getElementById('view-menuitem-wrapped-scrolling').setAttribute('checked', this.state.scrollMode == 2); + this._window.document.getElementById('view-menuitem-no-spreads').setAttribute('checked', this.state.spreadMode == 0); + this._window.document.getElementById('view-menuitem-odd-spreads').setAttribute('checked', this.state.spreadMode == 1); + this._window.document.getElementById('view-menuitem-even-spreads').setAttribute('checked', this.state.spreadMode == 2); + this._window.document.getElementById('view-menuitem-hand-tool').setAttribute('checked', this.isHandToolActive()); + } + + _onGoMenuOpen() { + let keyBack = this._window.document.getElementById('key_back'); + let keyForward = this._window.document.getElementById('key_forward'); + + if (Zotero.isMac) { + keyBack.setAttribute('key', '['); + keyBack.setAttribute('modifiers', 'meta'); + keyForward.setAttribute('key', ']'); + keyForward.setAttribute('modifiers', 'meta'); + } + else { + keyBack.setAttribute('keycode', 'VK_LEFT'); + keyBack.setAttribute('modifiers', 'alt'); + keyForward.setAttribute('keycode', 'VK_RIGHT'); + keyForward.setAttribute('modifiers', 'alt'); + } + + let menuItemBack = this._window.document.getElementById('go-menuitem-back'); + let menuItemForward = this._window.document.getElementById('go-menuitem-forward'); + menuItemBack.setAttribute('key', 'key_back'); + menuItemForward.setAttribute('key', 'key_forward'); + + this._window.document.getElementById('go-menuitem-first-page').setAttribute('disabled', !this.allowNavigateFirstPage()); + this._window.document.getElementById('go-menuitem-last-page').setAttribute('disabled', !this.allowNavigateLastPage()); + this._window.document.getElementById('go-menuitem-back').setAttribute('disabled', !this.allowNavigateBack()); + this._window.document.getElementById('go-menuitem-forward').setAttribute('disabled', !this.allowNavigateForward()); + } } diff --git a/chrome/locale/en-US/zotero/standalone.dtd b/chrome/locale/en-US/zotero/standalone.dtd index d7dfc8a79a..c493639259 100644 --- a/chrome/locale/en-US/zotero/standalone.dtd +++ b/chrome/locale/en-US/zotero/standalone.dtd @@ -44,6 +44,9 @@ + + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index aaf7668c7e..f77cde670b 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -336,11 +336,12 @@ - - + + + + - diff --git a/pdf-reader b/pdf-reader index 521570fba3..dc81445206 160000 --- a/pdf-reader +++ b/pdf-reader @@ -1 +1 @@ -Subproject commit 521570fba3302b35ce9984469c579c21c1eace86 +Subproject commit dc81445206934f78c98a6d27e09fcd631d559988