From 53ace4876e90d1e2301cae3b99b31610ae093cbc Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 22 Nov 2022 20:42:53 -0500 Subject: [PATCH] fx-compat: Fix feed Add To button And make accessible by keyboard --- .../zotero/elements/menuToolbarbutton.js | 21 +--- .../zotero/elements/splitMenuButton.js | 95 +++++++++++++++++++ .../zotero/xpcom/utilities_internal.js | 33 +++++++ chrome/content/zotero/zoteroPane.xhtml | 3 +- chrome/skin/default/zotero/itemPane.css | 2 +- chrome/skin/default/zotero/overlay.css | 9 ++ 6 files changed, 142 insertions(+), 21 deletions(-) create mode 100644 chrome/content/zotero/elements/splitMenuButton.js diff --git a/chrome/content/zotero/elements/menuToolbarbutton.js b/chrome/content/zotero/elements/menuToolbarbutton.js index a419257669..4f8b7b2307 100644 --- a/chrome/content/zotero/elements/menuToolbarbutton.js +++ b/chrome/content/zotero/elements/menuToolbarbutton.js @@ -33,26 +33,9 @@ constructor() { super(); this.addEventListener('mousedown', (event) => { - let popup = this.querySelector(':scope > menupopup'); - if (popup && this.getAttribute('nonnativepopup') != 'true') { + if (this.getAttribute('nonnativepopup') != 'true' + && Zotero.Utilities.Internal.showNativeElementPopup(this)) { event.preventDefault(); - - let rect = this.getBoundingClientRect(); - let dir = getComputedStyle(this).direction; - popup.openPopupAtScreen( - window.screenX + (dir == 'rtl' ? rect.right : rect.left), - window.screenY + rect.bottom, - true - ); - this.setAttribute('open', true); - - let handler = (event) => { - if (event.target == popup) { - this.setAttribute('open', false); - popup.removeEventListener('popuphiding', handler); - } - }; - popup.addEventListener('popuphiding', handler); } }); } diff --git a/chrome/content/zotero/elements/splitMenuButton.js b/chrome/content/zotero/elements/splitMenuButton.js new file mode 100644 index 0000000000..1159d9db3e --- /dev/null +++ b/chrome/content/zotero/elements/splitMenuButton.js @@ -0,0 +1,95 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2022 Corporation for Digital Scholarship + Vienna, Virginia, USA + https://www.zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +"use strict"; + +{ + /** + * Extends MozButton to provide a split menubutton with a clickable left side and a dropmarker that opens a menu. + */ + class SplitMenuButton extends customElements.get('button') { + constructor() { + super(); + + // Just in case, make sure this button does NOT appear as a standard diff --git a/chrome/skin/default/zotero/itemPane.css b/chrome/skin/default/zotero/itemPane.css index cd45fc4292..1478649753 100644 --- a/chrome/skin/default/zotero/itemPane.css +++ b/chrome/skin/default/zotero/itemPane.css @@ -100,6 +100,6 @@ } #zotero-feed-item-addTo-button .button-icon { - margin-right: 5px; + margin-inline-end: 5px; height: 16px; } diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index 22511b8487..daba3fd480 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -703,6 +703,15 @@ color: HighlightText; } +.split-menu-button, .split-menu-button [anonid="dropmarker-box"] { + /* Hide the dropmarker if the button overflows */ + overflow: hidden; +} + +.split-menu-button .split-menu-button-dropmarker { + margin-inline: 5px; +} + /* BEGIN 2X BLOCK -- DO NOT EDIT MANUALLY -- USE 2XIZE */ @media (min-resolution: 1.25dppx) {