Add "Show in Library" option to PDF reader file menu #2032
This commit is contained in:
parent
09125277ac
commit
3c3c1ba88a
3 changed files with 33 additions and 29 deletions
|
@ -44,8 +44,10 @@
|
|||
<menubar>
|
||||
<menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
|
||||
<menupopup id="menu_FilePopup">
|
||||
<menuitem label="Export" oncommand="menuCmd('export')"/>
|
||||
<!-- TODO: Localize -->
|
||||
<menuitem label="Save As…" oncommand="menuCmd('export')"/>
|
||||
<menuitem label="Print" oncommand="menuCmd('print')"/>
|
||||
<menuitem label="&zotero.items.menu.showInLibrary;" oncommand="menuCmd('showInLibrary')"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close"
|
||||
accesskey="&closeCmd.accesskey;" command="cmd_close"/>
|
||||
|
|
|
@ -152,6 +152,7 @@
|
|||
label="Save As…"
|
||||
oncommand="ZoteroStandalone.onReaderCmd('export')"/>
|
||||
<menuitem label="Print" class="menu-type-reader" oncommand="ZoteroStandalone.onReaderCmd('print')"/>
|
||||
<menuitem label="&zotero.items.menu.showInLibrary;" class="menu-type-reader" oncommand="ZoteroStandalone.onReaderCmd('showInLibrary')"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_close" class="menu-type-library" label="&closeCmd.label;" key="key_close"
|
||||
accesskey="&closeCmd.accesskey;" command="cmd_close"/>
|
||||
|
|
|
@ -138,6 +138,34 @@ class ReaderInstance {
|
|||
await this._initPromise;
|
||||
this._postMessage({ action: 'setToolbarPlaceholderWidth', width });
|
||||
}
|
||||
|
||||
menuCmd(cmd) {
|
||||
if (cmd === 'export') {
|
||||
let zp = Zotero.getActiveZoteroPane();
|
||||
zp.exportPDF(this._itemID);
|
||||
return;
|
||||
}
|
||||
else if (cmd === 'showInLibrary') {
|
||||
let id = this._itemID;
|
||||
let item = Zotero.Items.get(this._itemID);
|
||||
if (item && item.parentItemID) {
|
||||
id = item.parentItemID;
|
||||
}
|
||||
let win = Zotero.getMainWindow();
|
||||
if (win) {
|
||||
win.ZoteroPane.selectItems([id]);
|
||||
win.Zotero_Tabs.select('zotero-pane');
|
||||
win.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let data = {
|
||||
action: 'menuCmd',
|
||||
cmd
|
||||
};
|
||||
this._postMessage(data);
|
||||
}
|
||||
|
||||
async _setState(state) {
|
||||
let item = Zotero.Items.get(this._itemID);
|
||||
|
@ -597,19 +625,6 @@ class ReaderTab extends ReaderInstance {
|
|||
}
|
||||
}
|
||||
|
||||
menuCmd(cmd) {
|
||||
if (cmd === 'export') {
|
||||
let zp = Zotero.getActiveZoteroPane();
|
||||
zp.exportPDF(this._itemID);
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
action: 'menuCmd',
|
||||
cmd
|
||||
};
|
||||
this._postMessage(data);
|
||||
}
|
||||
|
||||
_toggleNoteSidebar(isToggled) {
|
||||
let itemPane = this._window.document.getElementById('zotero-item-pane');
|
||||
if (itemPane.hidden) {
|
||||
|
@ -658,22 +673,8 @@ 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.menuCmd = (cmd) => {
|
||||
if (cmd === 'export') {
|
||||
let zp = Zotero.getActiveZoteroPane();
|
||||
zp.exportPDF(this._itemID);
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
action: 'menuCmd',
|
||||
cmd
|
||||
};
|
||||
this._postMessage(data);
|
||||
};
|
||||
|
||||
this._window.menuCmd = this.menuCmd.bind(this);
|
||||
this._iframe = this._window.document.getElementById('reader');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue