Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
const { AppConstants } = ChromeUtils.importESModule(
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
});
/**
* Account Hub Footer Template
* Template ID: #accountHubFooterTemplate (from accountHubFooterTemplate.inc.xhtml)
*/
class AccountHubFooter extends HTMLElement {
/**
* Property to store disabled state of footer.
*
* @type {boolean}
*/
#disabled = false;
connectedCallback() {
if (this.hasConnected) {
return;
}
this.hasConnected = true;
const template = document
.getElementById("accountHubFooterTemplate")
.content.cloneNode(true);
this.appendChild(template);
this.addEventListener("click", this);
this.#showReleaseNotes();
}
handleEvent(event) {
if (event.target.id === "custom") {
this.dispatchEvent(new CustomEvent("custom-footer-action"));
return;
}
if (["back", "forward"].includes(event.target.id)) {
this.dispatchEvent(new CustomEvent(event.target.id));
return;
}
if (event.target.tagName === "a") {
lazy.openLinkExternally(event.target.href);
event.preventDefault();
event.stopPropagation();
}
}
canBack(value) {
this.querySelector("#back").hidden = !value;
}
/**
* Appends the current subview to the Support link so analytics can capture
* where in Account Hub the user asked for help
*
* @param {string} subview - current subview identifier
*/
setCurrentSubview(subview) {
const supportLink = this.querySelector("#hubSupport");
if (!supportLink) {
return;
}
const url = new URL(
Services.urlFormatter.formatURLPref("app.support.baseURL")
);
url.searchParams.set("utm_source", "thunderbird_account_hub");
url.searchParams.set("utm_medium", "referral");
url.searchParams.set("utm_content", subview);
supportLink.href = url.href;
}
canForward(value) {
this.querySelector("#forward").hidden = !value;
}
toggleForwardDisabled(value) {
this.querySelector("#forward").disabled = value || this.disabled;
}
toggleBackDisabled(value) {
this.querySelector("#back").disabled = value;
}
canCustom(value) {
const customAction = this.querySelector("#custom");
customAction.hidden = !value;
customAction.disabled = !value || this.disabled;
if (value) {
document.l10n.setAttributes(customAction, value);
}
}
/**
* Updates the text of the forward and back buttons
*
* @param {"forward" | "back"} type If the forward or back button should be
* targeted
* @param {string} fluentID The fluent id to use for the label
*/
setDirectionalButtonText(
type,
fluentID = type === "forward"
? "account-hub-email-continue-button"
: "account-hub-email-back-button"
) {
document.l10n.setAttributes(this.querySelector(`#${type}`), fluentID);
}
#showReleaseNotes() {
// We don't have release notes for Daily releases.
if (AppConstants.NIGHTLY_BUILD) {
return;
}
const relNotesPrefType = Services.prefs.getPrefType("app.releaseNotesURL");
if (relNotesPrefType == Services.prefs.PREF_INVALID) {
return;
}
// Show a release notes link if we have a URL.
const relNotesURL = Services.urlFormatter.formatURLPref(
"app.releaseNotesURL"
);
if (relNotesURL == "about:blank") {
return;
}
const relNotesLink = this.querySelector("#hubReleaseNotes");
relNotesLink.href = relNotesURL;
relNotesLink.closest("li[hidden]").hidden = false;
}
get disabled() {
return this.#disabled;
}
set disabled(val) {
this.#disabled = val;
this.toggleForwardDisabled(val);
const customAction = this.querySelector("#custom");
if (!customAction.hidden) {
customAction.disabled = val;
}
}
}
customElements.define("account-hub-footer", AccountHubFooter);