fx-compat: Fix <tab> keyboard nav, move CE imports to single file (#2756)

Having a single customElements.js file that we import everywhere we need it
helps with organization, and it gives us a single place to put things like the
<tab> fix.

We could switch to using setElementCreationCallback() like Firefox if the number
of imports gets out of hand, but the overhead right now should be small.
This commit is contained in:
Abe Jellinek 2023-04-12 23:09:40 -04:00 committed by GitHub
parent 33ef7b1641
commit 01b9a3c268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 39 deletions

View file

@ -68,7 +68,7 @@
}
// Custom elements
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<commandset id="mainCommandSet">

View file

@ -26,7 +26,7 @@
<script>
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/zoteroSearch.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<script src="include.js"/>

View file

@ -0,0 +1,61 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2022 Corporation for Digital Scholarship
Vienna, Virginia, USA
http://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 <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
'use strict';
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/base.js", this);
// Load our custom elements
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/attachmentBox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/guidancePanel.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/itemBox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/menulistItemTypes.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/noteEditor.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/notesBox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/quickSearchTextbox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/relatedBox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/shadowAutocompleteInput.js', this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/splitMenuButton.js", this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/tagsBox.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/textLink.js', this);
Services.scriptloader.loadSubScript('chrome://zotero/content/elements/zoteroSearch.js', this);
// Fix missing property bug that breaks arrow key navigation between <tab>s
{
let MozTabPrototype = customElements.get('tab').prototype;
if (!MozTabPrototype.hasOwnProperty('container')) {
Object.defineProperty(MozTabPrototype, 'container', {
get: function () {
if (this.parentElement && this.parentElement.localName == 'tabs') {
return this.parentElement;
}
else {
return null;
}
}
});
}
}

View file

@ -26,8 +26,6 @@
"use strict";
{
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/base.js", this);
class GuidancePanel extends XULElementBase {
content = MozXULElement.parseXULToFragment(`
<panel type="arrow" align="top">

View file

@ -26,11 +26,6 @@
"use strict";
{
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/shadowAutocompleteInput.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/guidancePanel.js", this);
class ItemBox extends XULElement {
constructor() {
super();

View file

@ -26,13 +26,16 @@
"use strict";
{
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
class SearchElementBase extends XULElementBase {
get stylesheets() {
return [
'chrome://global/skin/global.css',
'chrome://zotero-platform/content/zoteroSearch.css'
];
}
}
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/base.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/shadowAutocompleteInput.js", this);
class ZoteroSearch extends XULElementBase {
class ZoteroSearch extends SearchElementBase {
content = MozXULElement.parseXULToFragment(`
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="search-box" flex="1" onkeypress="this.closest('zoterosearch').handleKeyPress(event)">

View file

@ -14,7 +14,7 @@
onload="Zotero_Feed_Settings.init()">
<dialog>
<script src="include.js"/>
<script src="chrome://global/content/customElements.js"/>
<script src="chrome://zotero/content/customElements.js"/>
<script src="feedSettings.js"/>
<html:div class="form-grid">

View file

@ -40,7 +40,7 @@
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/ingester/selectitems.js", this);
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<vbox id="zotero-select-items-container" flex="1">

View file

@ -23,11 +23,7 @@
Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
Services.scriptloader.loadSubScript("resource://zotero/require.js", this);
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/shadowAutocompleteInput.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/noteEditor.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/relatedBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/tagsBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/note.js", this);
</script>

View file

@ -67,8 +67,7 @@
}
// Custom elements
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/textLink.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<keyset>

View file

@ -38,8 +38,7 @@
Services.scriptloader.loadSubScript("chrome://global/content/macWindowMenu.js", this);
}
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/shadowAutocompleteInput.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/tagsBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<commandset id="mainCommandSet">

View file

@ -19,7 +19,7 @@
<script>
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/zoteroSearch.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<script src="include.js"/>

View file

@ -56,8 +56,7 @@
Services.scriptloader.loadSubScript("chrome://zotero/content/selectItemsDialog.js", this);
// Custom elements
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/quickSearchTextbox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>
<vbox id="zotero-select-items-container" flex="1">

View file

@ -78,16 +78,7 @@
}
// Custom elements
Services.scriptloader.loadSubScript("chrome://global/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/menulistItemTypes.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/itemBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/noteEditor.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/notesBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/tagsBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/relatedBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/attachmentBox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/quickSearchTextbox.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/splitMenuButton.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/tabs.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/zoteroPane.js", this);