From 347caaff4ca5756c3ed277f18b0ea6ee7b9a5169 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Sat, 8 Jun 2024 22:58:05 +0800 Subject: [PATCH] Rename itemBox > infoBox Following the discussion in #4114 --- chrome/content/zotero-platform/win/overlay.css | 8 -------- chrome/content/zotero/customElements.js | 3 ++- .../content/zotero/elements/duplicatesMergePane.js | 10 +++++----- chrome/content/zotero/elements/itemBox.js | 8 ++++---- chrome/content/zotero/elements/itemDetails.js | 2 +- chrome/content/zotero/elements/mergeGroup.js | 2 +- chrome/content/zotero/xpcom/schema.js | 2 +- chrome/content/zotero/zoteroPane.js | 6 +++--- scss/_zotero.scss | 2 +- scss/elements/_duplicatesMergePane.scss | 6 +++--- scss/elements/{_itemBox.scss => _infoBox.scss} | 4 ++-- .../elements/{_itemBox.scss => _infoBox.scss} | 2 +- scss/win/elements/{_itemBox.scss => _infoBox.scss} | 2 +- scss/zotero-unix.scss | 2 +- scss/zotero-win.scss | 2 +- test/tests/itemPaneTest.js | 14 +++++++------- 16 files changed, 34 insertions(+), 41 deletions(-) rename scss/elements/{_itemBox.scss => _infoBox.scss} (99%) rename scss/linux/elements/{_itemBox.scss => _infoBox.scss} (88%) rename scss/win/elements/{_itemBox.scss => _infoBox.scss} (98%) diff --git a/chrome/content/zotero-platform/win/overlay.css b/chrome/content/zotero-platform/win/overlay.css index 6ac37edd03..5171f664f4 100644 --- a/chrome/content/zotero-platform/win/overlay.css +++ b/chrome/content/zotero-platform/win/overlay.css @@ -17,14 +17,6 @@ tree { padding-left: 0.05em; } -.zotero-editpane-item-box > scrollbox, .zotero-view-item > tabpanel > vbox, -#zotero-editpane-tags > scrollbox, .zotero-editpane-related { - padding-top: 5px; -} - -#zotero-editpane-tags > scrollbox { - padding-left: 5px; -} /* Default scrollbar displays up/down arrows even diff --git a/chrome/content/zotero/customElements.js b/chrome/content/zotero/customElements.js index d64bc9d7e6..07160e81f8 100644 --- a/chrome/content/zotero/customElements.js +++ b/chrome/content/zotero/customElements.js @@ -40,7 +40,8 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/itemTreeMe ['context-pane', 'chrome://zotero/content/elements/contextPane.js'], ['duplicates-merge-pane', 'chrome://zotero/content/elements/duplicatesMergePane.js'], ['guidance-panel', 'chrome://zotero/content/elements/guidancePanel.js'], - ['item-box', 'chrome://zotero/content/elements/itemBox.js'], + // TODO: rename itemBox.js to infoBox.js later to avoid conflict + ['info-box', 'chrome://zotero/content/elements/itemBox.js'], ['item-details', 'chrome://zotero/content/elements/itemDetails.js'], ['item-pane', 'chrome://zotero/content/elements/itemPane.js'], ['item-message-pane', 'chrome://zotero/content/elements/itemMessagePane.js'], diff --git a/chrome/content/zotero/elements/duplicatesMergePane.js b/chrome/content/zotero/elements/duplicatesMergePane.js index 8895b818e4..d2187bfef1 100644 --- a/chrome/content/zotero/elements/duplicatesMergePane.js +++ b/chrome/content/zotero/elements/duplicatesMergePane.js @@ -41,8 +41,8 @@ &zotero.duplicatesMerge.fieldSelect; - - + + `, ['chrome://zotero/locale/zotero.dtd']); @@ -110,7 +110,7 @@ let button = document.getElementById('zotero-duplicates-merge-button'); let versionSelect = document.getElementById('zotero-duplicates-merge-version-select'); - let itembox = document.getElementById('zotero-duplicates-merge-item-box'); + let itembox = document.getElementById('zotero-duplicates-merge-info-box'); let fieldSelect = document.getElementById('zotero-duplicates-merge-field-select'); let alternatives = oldestItem.multiDiff(otherItems, this._ignoreFields); @@ -148,7 +148,7 @@ } setMaster(pos) { - let itembox = document.getElementById('zotero-duplicates-merge-item-box'); + let itembox = document.getElementById('zotero-duplicates-merge-info-box'); itembox.mode = 'fieldmerge'; this._otherItems = this._items.concat(); @@ -173,7 +173,7 @@ } async merge() { - let itembox = document.getElementById('zotero-duplicates-merge-item-box'); + let itembox = document.getElementById('zotero-duplicates-merge-info-box'); Zotero.CollectionTreeCache.clear(); // Update master item with any field alternatives from the item box let json = this._masterItem.toJSON(); diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index ddc2f5979e..9eeaf0ff18 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -36,7 +36,7 @@ false ); - class ItemBox extends ItemPaneSectionElementBase { + class InfoBox extends ItemPaneSectionElementBase { constructor() { super(); @@ -69,7 +69,7 @@ return MozXULElement.parseXULToFragment(` -
+
@@ -1650,7 +1650,7 @@ addAutocompleteToElement(elem) { var fieldName = elem.getAttribute('fieldname'); - var [field, creatorIndex, creatorField] = fieldName.split('-'); + var [field, _creatorIndex, _creatorField] = fieldName.split('-'); if (elem.getAttribute("readonly") || !(field == 'creator' || Zotero.ItemFields.isAutocompleteField(fieldName))) { return; } @@ -2525,5 +2525,5 @@ return this.querySelector(`#${id}`); } } - customElements.define("item-box", ItemBox); + customElements.define("info-box", InfoBox); } diff --git a/chrome/content/zotero/elements/itemDetails.js b/chrome/content/zotero/elements/itemDetails.js index def19a1dc0..75a136dca2 100644 --- a/chrome/content/zotero/elements/itemDetails.js +++ b/chrome/content/zotero/elements/itemDetails.js @@ -50,7 +50,7 @@ - + diff --git a/chrome/content/zotero/elements/mergeGroup.js b/chrome/content/zotero/elements/mergeGroup.js index 7e1e7c07cf..39ec53d3ab 100644 --- a/chrome/content/zotero/elements/mergeGroup.js +++ b/chrome/content/zotero/elements/mergeGroup.js @@ -370,7 +370,7 @@ import ReactDOM from "react-dom"; var elementName; switch (this.type) { case 'item': - elementName = 'item-box'; + elementName = 'info-box'; break; case 'attachment': diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 4d2c786b50..f7065ea50f 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -852,7 +852,7 @@ Zotero.Schema = new function(){ var enumerator = Services.wm.getEnumerator("navigator:browser"); while (enumerator.hasMoreElements()) { let win = enumerator.getNext(); - //win.document.getElementById('zotero-editpane-item-box').buildItemTypeMenu(); + //win.document.getElementById('zotero-editpane-info-box').buildItemTypeMenu(); } }); } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 850944d4eb..711b041232 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1326,7 +1326,7 @@ var ZoteroPane = new function() var mru = Zotero.Prefs.get('newItemTypeMRU'); var type = mru ? mru.split(',')[0] : 'book'; await ZoteroPane.newItem(Zotero.ItemTypes.getID(type)); - let itemBox = document.getElementById('zotero-editpane-item-box'); + let itemBox = document.getElementById('zotero-editpane-info-box'); // Ensure itemBox is opened itemBox.open = true; var menu = itemBox.itemTypeMenu; @@ -1468,7 +1468,7 @@ var ZoteroPane = new function() if (manual) { // Update most-recently-used list for New Item menu this.addItemTypeToNewItemTypeMRU(Zotero.ItemTypes.getName(typeID)); - let itemBox = ZoteroPane.itemPane.querySelector("item-box"); + let itemBox = ZoteroPane.itemPane.querySelector("info-box"); // Make sure the item box is opened itemBox.open = true; // Focus the title field @@ -2159,7 +2159,7 @@ var ZoteroPane = new function() await original.saveTx({ skipDateModifiedUpdate: true }); await duplicate.saveTx(); - ZoteroPane.itemPane.querySelector("item-box").getTitleField().focus(); + ZoteroPane.itemPane.querySelector("info-box").getTitleField().focus(); return duplicate; }; diff --git a/scss/_zotero.scss b/scss/_zotero.scss index 27735bc1d9..fbae7be4f4 100644 --- a/scss/_zotero.scss +++ b/scss/_zotero.scss @@ -75,7 +75,7 @@ @import "elements/attachmentPreviewBox"; @import "elements/colorPicker"; @import "elements/guidancePanel"; -@import "elements/itemBox"; +@import "elements/infoBox"; @import "elements/noteEditor"; @import "elements/notesBox"; @import "elements/publicationsLicenseInfo"; diff --git a/scss/elements/_duplicatesMergePane.scss b/scss/elements/_duplicatesMergePane.scss index b3af6cded1..c18c078b34 100644 --- a/scss/elements/_duplicatesMergePane.scss +++ b/scss/elements/_duplicatesMergePane.scss @@ -1,5 +1,5 @@ duplicates-merge-pane { - &, #zotero-duplicates-merge-version-select, #zotero-duplicates-merge-item-box-container { + &, #zotero-duplicates-merge-version-select, #zotero-duplicates-merge-info-box-container { display: flex; flex-direction: column; gap: 8px; @@ -20,12 +20,12 @@ duplicates-merge-pane { } } - #zotero-duplicates-merge-item-box-container { + #zotero-duplicates-merge-info-box-container { flex: 1; padding-inline: 8px; overflow-y: scroll; - #zotero-duplicates-merge-item-box { + #zotero-duplicates-merge-info-box { border-top: var(--material-border-quinary); } diff --git a/scss/elements/_itemBox.scss b/scss/elements/_infoBox.scss similarity index 99% rename from scss/elements/_itemBox.scss rename to scss/elements/_infoBox.scss index 8c2456172d..d4ece26c94 100644 --- a/scss/elements/_itemBox.scss +++ b/scss/elements/_infoBox.scss @@ -1,4 +1,4 @@ -item-box { +info-box { display: flex; min-width: 0; @@ -8,7 +8,7 @@ item-box { display: none; } - #item-box { + #info-box { width: 100%; } diff --git a/scss/linux/elements/_itemBox.scss b/scss/linux/elements/_infoBox.scss similarity index 88% rename from scss/linux/elements/_itemBox.scss rename to scss/linux/elements/_infoBox.scss index 898af8a121..4c84b2046f 100644 --- a/scss/linux/elements/_itemBox.scss +++ b/scss/linux/elements/_infoBox.scss @@ -1,4 +1,4 @@ -item-box { +info-box { #item-type-menu { padding: 1px; diff --git a/scss/win/elements/_itemBox.scss b/scss/win/elements/_infoBox.scss similarity index 98% rename from scss/win/elements/_itemBox.scss rename to scss/win/elements/_infoBox.scss index 894cca0790..a0a3aaa8cf 100644 --- a/scss/win/elements/_itemBox.scss +++ b/scss/win/elements/_infoBox.scss @@ -1,4 +1,4 @@ -item-box { +info-box { @media (-moz-platform: windows-win10) { .meta-data > input, .meta-data > textarea, .creator-name-box > input { diff --git a/scss/zotero-unix.scss b/scss/zotero-unix.scss index c0ff465095..b5b345957c 100644 --- a/scss/zotero-unix.scss +++ b/scss/zotero-unix.scss @@ -14,4 +14,4 @@ // Elements -@import "linux/elements/itemBox"; +@import "linux/elements/infoBox"; diff --git a/scss/zotero-win.scss b/scss/zotero-win.scss index 234953f486..43b62ff20e 100644 --- a/scss/zotero-win.scss +++ b/scss/zotero-win.scss @@ -12,7 +12,7 @@ // Elements -@import "win/elements/itemBox"; +@import "win/elements/infoBox"; // Components diff --git a/test/tests/itemPaneTest.js b/test/tests/itemPaneTest.js index 133ef9b4ca..ae78772775 100644 --- a/test/tests/itemPaneTest.js +++ b/test/tests/itemPaneTest.js @@ -236,7 +236,7 @@ describe("Item pane", function () { var item = new Zotero.Item('book'); var id = yield item.saveTx(); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); var label = itemBox.querySelectorAll('[fieldname="series"]')[1]; assert.equal(label.value, ''); @@ -261,7 +261,7 @@ describe("Item pane", function () { ]); await item.saveTx(); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); var lastName = itemBox.querySelector('#itembox-field-value-creator-0-lastName'); var parent = lastName.closest(".creator-type-value"); assert.property(parent, 'oncontextmenu'); @@ -293,7 +293,7 @@ describe("Item pane", function () { ]); await item.saveTx(); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); var label = itemBox.querySelector('#itembox-field-value-creator-0-lastName'); var firstlast = label.closest('.creator-type-value'); firstlast.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, button: 2 })); @@ -320,7 +320,7 @@ describe("Item pane", function () { ]); await item.saveTx(); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); // Move One to the last spot itemBox.moveCreator(0, null, 3); await waitForItemEvent('modify'); @@ -364,7 +364,7 @@ describe("Item pane", function () { ]); var id = yield item.saveTx(); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); var label = itemBox.querySelector('[fieldname="place"]'); label.click(); var textbox = itemBox.querySelector('[fieldname="place"]'); @@ -387,7 +387,7 @@ describe("Item pane", function () { it("should accept 'now' for Accessed", async function () { var item = await createDataObject('item'); - var itemBox = doc.getElementById('zotero-editpane-item-box'); + var itemBox = doc.getElementById('zotero-editpane-info-box'); var textbox = itemBox.querySelector('[fieldname="accessDate"]'); textbox.value = 'now'; // Blur events don't necessarily trigger if window doesn't have focus @@ -413,7 +413,7 @@ describe("Item pane", function () { ]); await item.saveTx(); - let itemBox = doc.getElementById('zotero-editpane-item-box'); + let itemBox = doc.getElementById('zotero-editpane-info-box'); itemBox.querySelector('[fieldname="creator-0-lastName"]').click(); itemBox.hideEditor(itemBox.querySelector('input[fieldname="creator-0-lastName"]'));