From 3701b841166c24e4cfdb61da02d39f3b8f9b7762 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Fri, 25 Sep 2020 19:44:48 +0300 Subject: [PATCH] Proof of concept note view in tab mode --- chrome/content/zotero/tabs.js | 3 + chrome/content/zotero/xpcom/reader.js | 16 + chrome/content/zotero/zoteroPane.js | 23 + chrome/content/zotero/zoteroPane.xul | 720 +++++++++++++------------- 4 files changed, 407 insertions(+), 355 deletions(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index a426f3a27a..cf4f40c771 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -197,6 +197,9 @@ var Zotero_Tabs = new function () { this._selectedID = id; this.deck.selectedIndex = Array.from(this.deck.children).findIndex(x => x.id == id); this._update(); + if (this.onTabSelect) { + this.onTabSelect(tab.type); + } }; /** diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index c4f8e37df5..9967469f66 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -481,6 +481,22 @@ class ReaderTab extends ReaderInstance { } } + _toggleNoteSidebar(isToggled) { + let itemPane = this._window.document.getElementById('zotero-item-pane'); + var noteEditor = this._window.document.getElementById('zotero-note-editor'); + let item = noteEditor.item; + let zp = Zotero.getActiveZoteroPane(); + if (itemPane.hidden) { + if (item) { + zp.selectItem(item.id); + itemPane.hidden = false; + } + } + else { + itemPane.hidden = true; + } + } + _setTitleValue(title) { this._window.Zotero_Tabs.rename(this.tabID, title); } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b7af1d897c..97f51c9231 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -131,6 +131,29 @@ var ZoteroPane = new function() // continue loading pane _loadPane(); + + Zotero_Tabs.onTabSelect = (type) => { + let toolbar = document.getElementById('zotero-pane-horizontal-space'); + let extendedToolbar = document.getElementById('zotero-reader-toolbar-extension'); + let itemPane = document.getElementById('zotero-item-pane'); + if (type == 'library') { + toolbar.hidden = false; + extendedToolbar.hidden = true; + itemPane.hidden = false; + } + else { + toolbar.hidden = true; + extendedToolbar.hidden = false; + let items = ZoteroPane_Local.itemsView.getSelectedItems(); + + if (items.length == 1 && items[0].isNote()) { + itemPane.hidden = false; + } + else { + itemPane.hidden = true; + } + } + } }; /** diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index e6c9d11007..d2bb5da07f 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -74,13 +74,8 @@ - - - + + @@ -194,10 +189,10 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +