From c9561f1041b8eb05cbc21ecff86025dfa64a49e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 16 Apr 2024 11:44:58 +0300 Subject: [PATCH] Prevent itemlist in classic cit and edit bibl dialogs from expanding Also - Cleanup the XUL of said dialogs - Refactor, spearate and clarify custom CSS injection into FX XUL elements --- chrome/content/zotero/customElements.js | 25 ++-- .../integration/addCitationDialog.xhtml | 111 +++++++++--------- .../integration/editBibliographyDialog.xhtml | 56 ++++----- chrome/skin/default/zotero/integration.css | 4 + scss/components/_selectItemsDialog.scss | 9 ++ scss/dialog-win.scss | 28 ----- scss/wizard-win.scss | 23 ---- scss/xulElementPatches/README.md | 4 + scss/xulElementPatches/dialog-win.scss | 28 +++++ scss/xulElementPatches/dialog.scss | 5 + scss/xulElementPatches/wizard-win.scss | 23 ++++ scss/{ => xulElementPatches}/wizard.scss | 0 12 files changed, 170 insertions(+), 146 deletions(-) delete mode 100644 scss/dialog-win.scss delete mode 100644 scss/wizard-win.scss create mode 100644 scss/xulElementPatches/README.md create mode 100644 scss/xulElementPatches/dialog-win.scss create mode 100644 scss/xulElementPatches/dialog.scss create mode 100644 scss/xulElementPatches/wizard-win.scss rename scss/{ => xulElementPatches}/wizard.scss (100%) diff --git a/chrome/content/zotero/customElements.js b/chrome/content/zotero/customElements.js index e93a729015..5880efc6e4 100644 --- a/chrome/content/zotero/customElements.js +++ b/chrome/content/zotero/customElements.js @@ -167,13 +167,20 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/librariesC // inject custom CSS into FF built-in custom elements (currently only ) const InjectCSSConfig = { - global: ["wizard"], + global: [ + "wizard", + { + element: "dialog", + patchedFunction: "connectedCallback" + } + ], win: [ "wizard", { element: "dialog", // The `attachShadow` are cleared in , we need to monkey-patch after `connectedCallback`. - patchee: "connectedCallback" + patchedFunction: "connectedCallback", + filename: "wizard-dialog" } ], mac: [], @@ -185,24 +192,24 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/librariesC if (key == "linux" && !Zotero.isLinux) continue; let prefix = ""; if (key == "global") { - prefix = "zotero/skin/"; + prefix = "zotero/skin/xulElementPatches/"; } else { - prefix = "zotero-platform/content/"; + prefix = "zotero-platform/content/xulElementPatches/"; } for (let config of configs) { - let element, patchee; + let element, patchedFunction; // By default, monkey-patch `attachShadow` if (typeof config === "string") { element = config; - patchee = "attachShadow"; + patchedFunction = "attachShadow"; } else { element = config.element; - patchee = config.patchee; + patchedFunction = config.patchedFunction; } - let oldFunc = customElements.get(element).prototype[patchee]; - customElements.get(element).prototype[patchee] = function () { + let oldFunc = customElements.get(element).prototype[patchedFunction]; + customElements.get(element).prototype[patchedFunction] = function () { let ret = oldFunc.apply(this, arguments); this.shadowRoot.append(MozXULElement.parseXULToFragment( `` diff --git a/chrome/content/zotero/integration/addCitationDialog.xhtml b/chrome/content/zotero/integration/addCitationDialog.xhtml index 8863f3e607..c70b71a380 100644 --- a/chrome/content/zotero/integration/addCitationDialog.xhtml +++ b/chrome/content/zotero/integration/addCitationDialog.xhtml @@ -34,6 +34,7 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +