49 Components.utils.import(
"resource://app/jsmodules/DOMUtils.jsm");
59 if (typeof(
Cc) ==
"undefined")
60 var
Cc = Components.classes;
61 if (typeof(
Ci) ==
"undefined")
62 var
Ci = Components.interfaces;
63 if (typeof(
Cr) ==
"undefined")
64 var
Cr = Components.results;
65 if (typeof(
Cu) ==
"undefined")
66 var
Cu = Components.utils;
85 this._widget = aWidget;
101 _domEventListenerSet:
null,
114 initialize:
function sbWizardSvc_initialize() {
122 func =
function(aEvent) {
return _this._doKeyPress(aEvent); };
123 this._domEventListenerSet.add(this._widget,
"keypress", func,
false);
124 func =
function(aEvent) {
return _this._doFinish(aEvent); };
125 this._domEventListenerSet.add(this._widget,
"wizardfinish", func,
false);
133 finalize:
function sbWizardSvc_finalize() {
135 if (this._domEventListenerSet) {
136 this._domEventListenerSet.removeAll();
138 this._domEventListenerSet =
null;
157 _doKeyPress:
function sbWizardSvc__doKeyPress(aEvent) {
162 var currentPage = this._widget.currentPage;
165 if (keyCode == Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE) {
167 var hideWizardButton =
168 cancelButton.getAttribute(
"hidewizardbutton") ==
"true";
169 if (cancelButton.disabled || cancelButton.hidden || hideWizardButton) {
170 aEvent.stopPropagation();
171 aEvent.preventDefault();
177 if ((keyCode == Ci.nsIDOMKeyEvent.DOM_VK_ENTER) ||
178 (keyCode == Ci.nsIDOMKeyEvent.DOM_VK_RETURN)) {
179 var nextButton = this._widget.getButton(
"next");
181 nextButton.getAttribute(
"hidewizardbutton") ==
"true";
182 var finishButton = this._widget.getButton(
"finish");
183 var hideFinishButton =
184 finishButton.getAttribute(
"hidewizardbutton") ==
"true";
185 if ((nextButton.disabled || nextButton.hidden || hideNextButton) &&
186 (finishButton.disabled || finishButton.hidden || hideFinishButton)) {
187 aEvent.stopPropagation();
188 aEvent.preventDefault();
200 _doFinish:
function sbWizardSvc__doFinish(aEvent) {
203 var currentPage = this._widget.currentPage;
204 if (currentPage.hasAttribute(
"postfinish")) {
206 this._widget._postFinish =
true;
209 var postFinishPageID = currentPage.getAttribute(
"postfinish");
210 this._widget.goTo(postFinishPageID);
213 aEvent.preventDefault();
237 function sbWizardPageSvc(aWidget) {
238 this._widget = aWidget;
242 sbWizardPageSvc.prototype = {
255 _domEventListenerSet:
null,
269 initialize:
function sbWizardPageSvc_initialize() {
277 this._wizardElem = this._widget.parentNode;
280 func =
function() {
return _this._doPageShow(); };
281 this._domEventListenerSet.add(this._widget,
"pageshow", func,
false);
284 func =
function(aEvent) {
return _this._doButtonDOMAttrModified(aEvent); };
285 var buttonAttributesElem = this._getElement(
"button_attributes");
286 this._domEventListenerSet.add(buttonAttributesElem,
297 finalize:
function sbWizardPageSvc_finalize() {
299 if (this._domEventListenerSet) {
300 this._domEventListenerSet.removeAll();
302 this._domEventListenerSet =
null;
306 this._wizardElem =
null;
320 _doPageShow:
function sbWizardPageSvc__doPageShow() {
322 this._updateButtons();
332 _doButtonDOMAttrModified:
333 function sbWizardPageSvc__doButtonDOMAttrModified(aEvent) {
335 this._updateButtons();
349 _updateButtons:
function sbWizardPageSvc__updateButtons() {
351 var currentPage = this._wizardElem.currentPage;
354 var hideBackButton = currentPage.getAttribute(
"hideback") ==
"true";
355 var hideCancelButton = currentPage.getAttribute(
"hidecancel") ==
"true";
356 var hideNextButton = currentPage.getAttribute(
"hidenext") ==
"true";
357 var hideFinishButton = currentPage.getAttribute(
"hidefinish") ==
"true";
358 var showBackButton = currentPage.getAttribute(
"showback") ==
"true";
359 var showCancelButton = currentPage.getAttribute(
"showcancel") ==
"true";
360 var showNextButton = currentPage.getAttribute(
"shownext") ==
"true";
361 var showFinishButton = currentPage.getAttribute(
"showfinish") ==
"true";
362 var showExtra1Button = currentPage.getAttribute(
"showextra1") ==
"true";
363 var showExtra2Button = currentPage.getAttribute(
"showextra2") ==
"true";
366 if (this._wizardElem.postFinish) {
367 hideBackButton =
true;
368 hideNextButton =
true;
369 hideFinishButton =
true;
373 this._showHideButton(
"back", showBackButton, hideBackButton);
374 this._showHideButton(
"cancel", showCancelButton, hideCancelButton);
375 this._showHideButton(
"next", showNextButton, hideNextButton);
376 this._showHideButton(
"finish", showFinishButton, hideFinishButton);
377 this._showHideButton(
"extra1", showExtra1Button,
true);
378 this._showHideButton(
"extra2", showExtra2Button,
true);
381 var finishButton = this._wizardElem.getButton(
"finish");
382 var hideFinishButton =
383 finishButton.getAttribute(
"hidewizardbutton") ==
"true";
384 var nextButton = this._wizardElem.getButton(
"next");
386 nextButton.getAttribute(
"hidewizardbutton") ==
"true";
387 if (!finishButton.hidden && !finishButton.disabled && !hideFinishButton)
388 finishButton.focus();
389 else if (!nextButton.hidden && !nextButton.disabled && !hideNextButton)
399 _showHideButton:
function sbWizardPageSvc__showHideButton(aButtonID,
403 var button = this._wizardElem.getButton(aButtonID);
412 button.removeAttribute(
"hidewizardbutton");
413 button.hidden =
false;
415 button.setAttribute(
"hidewizardbutton",
"true");
417 button.removeAttribute(
"hidewizardbutton");
431 _getElement:
function sbWizardPageSvc__getElement(aElementID) {
432 return document.getAnonymousElementByAttribute(this._widget,
function DOMEventListenerSet()
DataRemote prototype constructor
function sbWizardSvc(aWidget)