/* 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 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; // This is loaded into chrome windows with the subscript loader. Wrap in // a block to prevent accidentally leaking globals onto `window`. { const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); const kDTDs = [ "chrome://global/locale/wizard.dtd" ]; class MozWizardPage extends MozXULElement { constructor() { super(); this.pageIndex = -1; } get pageid() { return this.getAttribute("pageid"); } set pageid(val) { this.setAttribute("pageid", val); } get next() { return this.getAttribute("next"); } set next(val) { this.setAttribute("next", val); this.parentNode._accessMethod = "random"; return val; } } customElements.define("wizardpage", MozWizardPage); class MozWizardButtons extends MozXULElement { connectedCallback() { this.textContent = ""; this.appendChild(MozXULElement.parseXULToFragment(this._markup, kDTDs)); this._wizardButtonDeck = this.querySelector(".wizard-next-deck"); this.initializeAttributeInheritance(); const listeners = [ ["back", () => document.documentElement.rewind()], ["next", () => document.documentElement.advance()], ["finish", () => document.documentElement.advance()], ["cancel", () => document.documentElement.cancel()], ["extra1", () => document.documentElement.extra1()], ["extra2", () => document.documentElement.extra2()], ]; for (let [name, listener] of listeners) { let btn = this.getButton(name); if (btn) { btn.addEventListener("command", listener); } } } static get inheritedAttributes() { return AppConstants.platform == "macosx" ? { "[dlgtype='next']": "hidden=lastpage", } : null; } get _markup() { if (AppConstants.platform == "macosx") { return `