Properly handle reader window closing
This commit is contained in:
parent
9d2d655039
commit
7fa05bc463
2 changed files with 10 additions and 14 deletions
|
@ -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 @@
|
|||
<commandset id="mainCommandSet">
|
||||
<!--FILE-->
|
||||
<command id="cmd_quitApplication" oncommand="goQuitApplication(event);"/>
|
||||
<command id="cmd_close" oncommand="window.close();"/>
|
||||
<command id="cmd_close" oncommand="reader.close()"/>
|
||||
|
||||
<!--EDIT-->
|
||||
<commandset id="editMenuCommands"/>
|
||||
|
@ -66,6 +67,7 @@
|
|||
command="minimizeWindow"
|
||||
key="&minimizeWindow.key;"
|
||||
modifiers="accel"/>
|
||||
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
|
||||
</keyset>
|
||||
|
||||
<keyset id="editMenuKeys">
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue