diff --git a/chrome/content/zotero/reader.xhtml b/chrome/content/zotero/reader.xhtml index 6980dbd19c..084356b413 100644 --- a/chrome/content/zotero/reader.xhtml +++ b/chrome/content/zotero/reader.xhtml @@ -18,6 +18,7 @@ width="1300" height="800" persist="screenX screenY width height" + onclose="reader.close()" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" > @@ -43,7 +44,7 @@ - + @@ -66,6 +67,7 @@ command="minimizeWindow" key="&minimizeWindow.key;" modifiers="accel"/> + diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 169c5881dc..2eba69e87e 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -1014,6 +1014,7 @@ class ReaderWindow extends ReaderInstance { this._sidebarWidth = options.sidebarWidth; this._sidebarOpen = options.sidebarOpen; this._bottomPlaceholderHeight = 0; + this._onClose = options.onClose; let win = Services.wm.getMostRecentWindow('navigator:browser'); if (!win) return; @@ -1024,7 +1025,6 @@ class ReaderWindow extends ReaderInstance { this._window.addEventListener('DOMContentLoaded', (event) => { if (event.target === this._window.document) { - this._window.addEventListener('keypress', this._handleKeyPress); this._popupset = this._window.document.getElementById('zotero-reader-popupset'); this._window.onGoMenuOpen = this._onGoMenuOpen.bind(this); this._window.onViewMenuOpen = this._onViewMenuOpen.bind(this); @@ -1054,19 +1054,13 @@ class ReaderWindow extends ReaderInstance { close() { this._window.close(); + this._onClose(); } _setTitleValue(title) { this._window.document.title = title; } - _handleKeyPress = (event) => { - if ((Zotero.isMac && event.metaKey || event.ctrlKey) - && !event.shiftKey && !event.altKey && event.key === 'w') { - this._window.close(); - } - } - _onViewMenuOpen() { if (this._type === 'pdf') { this._window.document.getElementById('view-menuitem-vertical-scrolling').setAttribute('checked', this._internalReader.scrollMode === 0); @@ -1334,14 +1328,14 @@ class Reader { secondViewState, sidebarWidth: this._sidebarWidth, sidebarOpen: this._sidebarOpen, - bottomPlaceholderHeight: this._bottomPlaceholderHeight + bottomPlaceholderHeight: this._bottomPlaceholderHeight, + onClose: () => { + this._readers.splice(this._readers.indexOf(reader), 1); + Zotero.Session.debounceSave(); + } }); this._readers.push(reader); Zotero.Session.debounceSave(); - reader._window.addEventListener('close', () => { - this._readers.splice(this._readers.indexOf(reader), 1); - Zotero.Session.debounceSave(); - }); } else { reader = new ReaderTab({