/* 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.importESModule( "resource://gre/modules/AppConstants.sys.mjs"
);
// Note: MozWizard currently supports adding, but not removing MozWizardPage // children. class MozWizard extends MozXULElement {
constructor() { super();
// About this._accessMethod: // There are two possible access methods: "sequential" and "random". // "sequential" causes the MozWizardPage's to be displayed in the order // that they are added to the DOM. // The "random" method name is a bit misleading since the pages aren't // displayed in a random order. Instead, each MozWizardPage must have // a "next" attribute containing the id of the MozWizardPage that should // be loaded next. this._accessMethod = null; this._currentPage = null; this._canAdvance = true; this._canRewind = false; this._hasLoaded = false; this._hasStarted = false; // Whether any MozWizardPage has been shown yet this._wizardButtonsReady = false; this.pageCount = 0; this._pageStack = [];
window.addEventListener("close", event => { if (this.cancel()) {
event.preventDefault();
}
});
// Give focus to the first focusable element in the wizard, do it after // onload completes, see bug 103197.
window.addEventListener("load", () =>
window.setTimeout(() => { this._hasLoaded = true; if (!document.commandDispatcher.focusedElement) {
document.commandDispatcher.advanceFocusIntoSubtree(this);
} try {
let button = this._wizardButtons.defaultButton; if (button) {
window.notifyDefaultButtonLoaded(button);
}
} catch (e) {}
}, 0)
);
}
set title(val) {
document.title = val;
}
get title() { return document.title;
}
set canAdvance(val) { this.getButton("next").disabled = !val; this._canAdvance = val;
}
get canAdvance() { returnthis._canAdvance;
}
set canRewind(val) { this.getButton("back").disabled = !val; this._canRewind = val;
}
get canRewind() { returnthis._canRewind;
}
get pageStep() { returnthis._pageStack.length;
}
get wizardPages() { returnthis.getElementsByTagNameNS(XUL_NS, "wizardpage");
}
// Setting this attribute allows wizard's clients to dynamically // change the styles of each page based on purpose of the page. this.setAttribute("currentpageid", val.pageid);
this._initCurrentPage();
this._advanceFocusToPage(val);
this._fireEvent(val, "pageshow");
}
get currentPage() { returnthis._currentPage;
}
set pageIndex(val) { if (val < 0 || val >= this.pageCount) { return;
}
_advanceFocusToPage() { if (!this._hasLoaded) { return;
}
// XXX: it'd be correct to advance focus into the panel, however we can't do // it until bug 1558990 is fixed, so moving the focus into a wizard itsef // as a workaround - it's same behavior but less optimal.
document.commandDispatcher.advanceFocusIntoSubtree(this);
// if advanceFocusIntoSubtree tries to focus one of our // dialog buttons, then remove it and put it on the root var focused = document.commandDispatcher.focusedElement; if (focused && focused.hasAttribute("dlgtype")) { this.focus();
}
}
_registerPage(aPage) {
aPage.pageIndex = this.pageCount; this.pageCount += 1; if (!this._accessMethod) { this._accessMethod = aPage.next ? "random" : "sequential";
} if (!this._maybeStartWizard() && this._hasStarted) { // If the wizard has already started, adding a page might require // updating elements to reflect that (ex: changing the Finish button to // the Next button). this._initCurrentPage();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.