ction-status-box component in Bug 2008854 handleOnOffButtonClick() { let isEnabled = !this._toggleEnabled; if (isEnabled) { this.dispatchEvent( new CustomEvent(this.TOGGLE_ON_EVENT, { bubbles: true, composed: true, }) ); } else { this.dispatchEvent( new CustomEvent(this.TOGGLE_OFF_EVENT, { bubbles: true, composed: true, }) ); } this._toggleEnabled = isEnabled; } focus() { this.connectionToggleEl?.focus(); } #keyListener(event) { let keyCode = event.code; switch (keyCode) { case "ArrowUp": // Intentional fall-through case "ArrowDown": { event.stopPropagation(); event.preventDefault(); let direction = keyCode == "ArrowDown" ? Services.focus.MOVEFOCUS_FORWARD : Services.focus.MOVEFOCUS_BACKWARD; Services.focus.moveFocus( window, null, direction, Services.focus.FLAG_BYKEY ); break; } } } updated(changedProperties) { super.updated(changedProperties); // If the toggle state isn't set, do so now and let it // match the protection state. if (!changedProperties.has("_toggleEnabled")) { this._toggleEnabled = this.protectionEnabled; } if (!this.protectionEnabled && this._toggleEnabled) { // After pressing the toggle, if somehow protection was turned off // (eg. error thrown), unset the toggle. this._toggleEnabled = false; } } cardContentTemplate() { const statusCardL10nId = this.protectionEnabled ? "ipprotection-connection-status-on" : "ipprotection-connection-status-off"; const toggleL10nId = this.protectionEnabled ? "ipprotection-toggle-active" : "ipprotection-toggle-inactive"; const toggleButtonType = this.protectionEnabled ? "secondary" : "primary"; const toggleButtonL10nId = this.protectionEnabled ? "ipprotection-button-turn-vpn-off" : "ipprotection-button-turn-vpn-on"; const siteSettingsTemplate = this.protectionEnabled ? this.siteSettingsTemplate() : null; return html` ${siteSettingsTemplate} `; } siteSettingsTemplate() { // TODO: Once we're able to detect the current site and its exception status, show // ipprotection-site-settings-control (Bug 1997412). if (!this.siteData?.siteName) { return null; } return html` `; } cardDescriptionTemplate() { // To work around mox-box-item description elements being hard to reach because of the shadowDOM, // let's use a lit stylemap to apply style changes directly. let labelStyles = styleMap({ display: "flex", gap: "var(--space-small)", }); let imgStyles = styleMap({ "-moz-context-properties": "fill", fill: "currentColor", }); return this.location ? html`
${this.location.name}
` : null; } render() { let content = this.cardContentTemplate(); return html`${content}`; } } customElements.define("ipprotection-status-card", IPProtectionStatusCard); PK