From 49f9642c0d756293a26624c1a76469bba6d1a8a3 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Fri, 1 Jul 2022 15:27:14 +0300 Subject: [PATCH] Show parent item title for child notes in context pane Fixes #2681 --- chrome/content/zotero/contextPane.js | 23 +++++++++++++++------- chrome/skin/default/zotero/contextPane.css | 4 ++++ chrome/skin/default/zotero/itemPane.css | 4 ---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/contextPane.js b/chrome/content/zotero/contextPane.js index b355a6facb..bd79277df0 100644 --- a/chrome/content/zotero/contextPane.js +++ b/chrome/content/zotero/contextPane.js @@ -184,7 +184,7 @@ var ZoteroContextPane = new function () { setTimeout(() => { var contextNodes = Array.from(_notesPaneDeck.children); for (let contextNode of contextNodes) { - var nodes = Array.from(contextNode.children[2].children); + var nodes = Array.from(contextNode.querySelector('.zotero-context-pane-tab-notes-deck').children); for (let node of nodes) { var tabID = node.getAttribute('data-tab-id'); if (!document.getElementById(tabID)) { @@ -233,7 +233,7 @@ var ZoteroContextPane = new function () { notesContext.updateFromCache(); } - let tabNotesDeck = _notesPaneDeck.selectedPanel.children[2]; + let tabNotesDeck = _notesPaneDeck.selectedPanel.querySelector('.zotero-context-pane-tab-notes-deck'); let selectedIndex = Array.from(tabNotesDeck.children).findIndex(x => x.getAttribute('data-tab-id') == ids[0]); if (selectedIndex != -1) { tabNotesDeck.setAttribute('selectedIndex', selectedIndex); @@ -456,12 +456,16 @@ var ZoteroContextPane = new function () { editor.setAttribute('flex', 1); noteContainer.append(title, editor); + var tabNotesContainer = document.createElement('vbox'); + var title = document.createElement('vbox'); + title.className = 'zotero-context-pane-editor-parent-line'; let tabNotesDeck = document.createElement('deck'); tabNotesDeck.className = 'zotero-context-pane-tab-notes-deck'; tabNotesDeck.setAttribute('flex', 1); + tabNotesContainer.append(title, tabNotesDeck); let contextNode = document.createElement('deck'); - contextNode.append(list, noteContainer, tabNotesDeck); + contextNode.append(list, noteContainer, tabNotesContainer); _notesPaneDeck.append(contextNode); contextNode.className = 'context-node'; @@ -785,7 +789,8 @@ var ZoteroContextPane = new function () { } } - var tabNotesDeck = _notesPaneDeck.selectedPanel.children[2]; + var tabNotesDeck = _notesPaneDeck.selectedPanel.querySelector('.zotero-context-pane-tab-notes-deck'); + var parentTitleContainer; if (isChild) { var vbox = document.createElement('vbox'); vbox.setAttribute('data-tab-id', Zotero_Tabs.selectedID); @@ -811,17 +816,21 @@ var ZoteroContextPane = new function () { _notesPaneDeck.selectedPanel.setAttribute('selectedIndex', 2); tabNotesDeck.setAttribute('selectedIndex', tabNotesDeck.children.length - 1); + + parentTitleContainer = _notesPaneDeck.selectedPanel.children[2].querySelector('.zotero-context-pane-editor-parent-line'); } else { node.setAttribute('selectedIndex', 1); editor.mode = readOnly ? 'view' : 'edit'; editor.item = item; editor.parentItem = null; + + parentTitleContainer = node.querySelector('.zotero-context-pane-editor-parent-line'); } editor.focus(); - - node.querySelector('.zotero-context-pane-editor-parent-line').innerHTML = ''; + + parentTitleContainer.innerHTML = ''; var parentItem = item.parentItem; if (parentItem) { var container = document.createElementNS(HTML_NS, 'div'); @@ -832,7 +841,7 @@ var ZoteroContextPane = new function () { title.append(parentItem.getDisplayTitle()); title.className = 'parent-title'; container.append(img, title); - node.querySelector('.zotero-context-pane-editor-parent-line').append(container); + parentTitleContainer.append(container); } _updateAddToNote(); } diff --git a/chrome/skin/default/zotero/contextPane.css b/chrome/skin/default/zotero/contextPane.css index 623425265e..66c9054c84 100644 --- a/chrome/skin/default/zotero/contextPane.css +++ b/chrome/skin/default/zotero/contextPane.css @@ -68,6 +68,10 @@ background-color: #d2d8e2; } +.zotero-context-pane-editor-parent-line { + border-bottom: 1px solid #d9d9d9; +} + .zotero-context-pane-editor-parent-line > div { display: flex; align-items: center; diff --git a/chrome/skin/default/zotero/itemPane.css b/chrome/skin/default/zotero/itemPane.css index 1c757982a1..98d51f9b1e 100644 --- a/chrome/skin/default/zotero/itemPane.css +++ b/chrome/skin/default/zotero/itemPane.css @@ -49,10 +49,6 @@ margin-left: 5px; } -.zotero-context-pane-pinned-note { - border-top: 1px solid #d9d9d9; -} - /*.zotero-editpane-tabs {*/ /* background: #ececec;*/ /*}*/