toolkit/content/widgets/wizard.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6
michael@0 7 <!DOCTYPE bindings [
michael@0 8 <!ENTITY % wizardDTD SYSTEM "chrome://global/locale/wizard.dtd">
michael@0 9 %wizardDTD;
michael@0 10 ]>
michael@0 11
michael@0 12 <bindings id="wizardBindings"
michael@0 13 xmlns="http://www.mozilla.org/xbl"
michael@0 14 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 15 xmlns:xbl="http://www.mozilla.org/xbl">
michael@0 16
michael@0 17 <binding id="wizard-base">
michael@0 18 <resources>
michael@0 19 <stylesheet src="chrome://global/skin/wizard.css"/>
michael@0 20 </resources>
michael@0 21 </binding>
michael@0 22
michael@0 23 <binding id="wizard" extends="chrome://global/content/bindings/general.xml#root-element">
michael@0 24 <resources>
michael@0 25 <stylesheet src="chrome://global/skin/wizard.css"/>
michael@0 26 </resources>
michael@0 27 <content>
michael@0 28 <xul:hbox class="wizard-header" anonid="Header"/>
michael@0 29
michael@0 30 <xul:deck class="wizard-page-box" flex="1" anonid="Deck">
michael@0 31 <children includes="wizardpage"/>
michael@0 32 </xul:deck>
michael@0 33 <children/>
michael@0 34
michael@0 35 <xul:hbox class="wizard-buttons" anonid="Buttons" xbl:inherits="pagestep,firstpage,lastpage"/>
michael@0 36 </content>
michael@0 37
michael@0 38 <implementation>
michael@0 39 <property name="title" onget="return document.title;"
michael@0 40 onset="return document.title = val;"/>
michael@0 41
michael@0 42 <property name="canAdvance" onget="return this._canAdvance;"
michael@0 43 onset="this._nextButton.disabled = !val; return this._canAdvance = val;"/>
michael@0 44 <property name="canRewind" onget="return this._canRewind;"
michael@0 45 onset="this._backButton.disabled = !val; return this._canRewind = val;"/>
michael@0 46
michael@0 47 <property name="pageStep" readonly="true" onget="return this._pageStack.length"/>
michael@0 48
michael@0 49 <field name="pageCount">0</field>
michael@0 50
michael@0 51 <field name="_accessMethod">null</field>
michael@0 52 <field name="_pageStack">null</field>
michael@0 53 <field name="_currentPage">null</field>
michael@0 54
michael@0 55 <property name="wizardPages">
michael@0 56 <getter>
michael@0 57 <![CDATA[
michael@0 58 var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 59 return this.getElementsByTagNameNS(xulns, "wizardpage");
michael@0 60 ]]>
michael@0 61 </getter>
michael@0 62 </property>
michael@0 63
michael@0 64 <property name="currentPage" onget="return this._currentPage">
michael@0 65 <setter>
michael@0 66 <![CDATA[
michael@0 67 if (!val)
michael@0 68 return val;
michael@0 69
michael@0 70 this._currentPage = val;
michael@0 71
michael@0 72 // Setting this attribute allows wizard's clients to dynamically
michael@0 73 // change the styles of each page based on purpose of the page.
michael@0 74 this.setAttribute("currentpageid", val.pageid);
michael@0 75
michael@0 76 if (this.onFirstPage) {
michael@0 77 this.canRewind = false;
michael@0 78 this.setAttribute("firstpage", "true");
michael@0 79 #ifdef XP_UNIX
michael@0 80 #ifndef XP_MACOSX
michael@0 81 this._backButton.setAttribute('hidden', 'true');
michael@0 82 #endif
michael@0 83 #endif
michael@0 84 } else {
michael@0 85 this.canRewind = true;
michael@0 86 this.setAttribute("firstpage", "false");
michael@0 87 #ifdef XP_UNIX
michael@0 88 #ifndef XP_MACOSX
michael@0 89 this._backButton.setAttribute('hidden', 'false');
michael@0 90 #endif
michael@0 91 #endif
michael@0 92 }
michael@0 93
michael@0 94 if (this.onLastPage) {
michael@0 95 this.canAdvance = true;
michael@0 96 this.setAttribute("lastpage", "true");
michael@0 97 } else {
michael@0 98 this.setAttribute("lastpage", "false");
michael@0 99 }
michael@0 100
michael@0 101 this._deck.setAttribute("selectedIndex", val.pageIndex);
michael@0 102 this._advanceFocusToPage(val);
michael@0 103
michael@0 104 this._adjustWizardHeader();
michael@0 105 this._wizardButtons.onPageChange();
michael@0 106
michael@0 107 this._fireEvent(val, "pageshow");
michael@0 108
michael@0 109 return val;
michael@0 110 ]]>
michael@0 111 </setter>
michael@0 112 </property>
michael@0 113
michael@0 114 <property name="pageIndex"
michael@0 115 onget="return this._currentPage ? this._currentPage.pageIndex : -1;">
michael@0 116 <setter>
michael@0 117 <![CDATA[
michael@0 118 if (val < 0 || val >= this.pageCount)
michael@0 119 return val;
michael@0 120
michael@0 121 var page = this.wizardPages[val];
michael@0 122 this._pageStack[this._pageStack.length-1] = page;
michael@0 123 this.currentPage = page;
michael@0 124
michael@0 125 return val;
michael@0 126 ]]>
michael@0 127 </setter>
michael@0 128 </property>
michael@0 129
michael@0 130 <property name="onFirstPage" readonly="true"
michael@0 131 onget="return this._pageStack.length == 1;"/>
michael@0 132
michael@0 133 <property name="onLastPage" readonly="true">
michael@0 134 <getter><![CDATA[
michael@0 135 var cp = this.currentPage;
michael@0 136 return cp && ((this._accessMethod == "sequential" && cp.pageIndex == this.pageCount-1) ||
michael@0 137 (this._accessMethod == "random" && cp.next == ""));
michael@0 138 ]]></getter>
michael@0 139 </property>
michael@0 140
michael@0 141 <method name="getButton">
michael@0 142 <parameter name="aDlgType"/>
michael@0 143 <body>
michael@0 144 <![CDATA[
michael@0 145 var btns = this.getElementsByAttribute("dlgtype", aDlgType);
michael@0 146 return btns.item(0) ? btns[0] : document.getAnonymousElementByAttribute(this._wizardButtons, "dlgtype", aDlgType);
michael@0 147 ]]>
michael@0 148 </body>
michael@0 149 </method>
michael@0 150
michael@0 151 <field name="_canAdvance"/>
michael@0 152 <field name="_canRewind"/>
michael@0 153 <field name="_wizardHeader"/>
michael@0 154 <field name="_wizardButtons"/>
michael@0 155 <field name="_deck"/>
michael@0 156 <field name="_backButton"/>
michael@0 157 <field name="_nextButton"/>
michael@0 158 <field name="_cancelButton"/>
michael@0 159
michael@0 160 <!-- functions to be added as oncommand listeners to the wizard buttons -->
michael@0 161 <field name="_backFunc">(function() { document.documentElement.rewind(); })</field>
michael@0 162 <field name="_nextFunc">(function() { document.documentElement.advance(); })</field>
michael@0 163 <field name="_finishFunc">(function() { document.documentElement.advance(); })</field>
michael@0 164 <field name="_cancelFunc">(function() { document.documentElement.cancel(); })</field>
michael@0 165 <field name="_extra1Func">(function() { document.documentElement.extra1(); })</field>
michael@0 166 <field name="_extra2Func">(function() { document.documentElement.extra2(); })</field>
michael@0 167
michael@0 168 <field name="_closeHandler">(function(event) {
michael@0 169 if (document.documentElement.cancel())
michael@0 170 event.preventDefault();
michael@0 171 })</field>
michael@0 172
michael@0 173 <constructor><![CDATA[
michael@0 174 this._canAdvance = true;
michael@0 175 this._canRewind = false;
michael@0 176 this._hasLoaded = false;
michael@0 177
michael@0 178 this._pageStack = [];
michael@0 179
michael@0 180 try {
michael@0 181 // need to create string bundle manually instead of using <xul:stringbundle/>
michael@0 182 // see bug 63370 for details
michael@0 183 this._bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
michael@0 184 .getService(Components.interfaces.nsIStringBundleService)
michael@0 185 .createBundle("chrome://global/locale/wizard.properties");
michael@0 186 } catch (e) {
michael@0 187 // This fails in remote XUL, which has to provide titles for all pages
michael@0 188 // see bug 142502
michael@0 189 }
michael@0 190
michael@0 191 // get anonymous content references
michael@0 192 this._wizardHeader = document.getAnonymousElementByAttribute(this, "anonid", "Header");
michael@0 193 this._wizardButtons = document.getAnonymousElementByAttribute(this, "anonid", "Buttons");
michael@0 194 this._deck = document.getAnonymousElementByAttribute(this, "anonid", "Deck");
michael@0 195
michael@0 196 this._initWizardButton("back");
michael@0 197 this._initWizardButton("next");
michael@0 198 this._initWizardButton("finish");
michael@0 199 this._initWizardButton("cancel");
michael@0 200 this._initWizardButton("extra1");
michael@0 201 this._initWizardButton("extra2");
michael@0 202
michael@0 203 this._initPages();
michael@0 204
michael@0 205 window.addEventListener("close", this._closeHandler, false);
michael@0 206
michael@0 207 // start off on the first page
michael@0 208 this.pageCount = this.wizardPages.length;
michael@0 209 this.advance();
michael@0 210
michael@0 211 // give focus to the first focusable element in the dialog
michael@0 212 window.addEventListener("load", this._setInitialFocus, false);
michael@0 213 ]]></constructor>
michael@0 214
michael@0 215 <method name="getPageById">
michael@0 216 <parameter name="aPageId"/>
michael@0 217 <body><![CDATA[
michael@0 218 var els = this.getElementsByAttribute("pageid", aPageId);
michael@0 219 return els.item(0);
michael@0 220 ]]></body>
michael@0 221 </method>
michael@0 222
michael@0 223 <method name="extra1">
michael@0 224 <body><![CDATA[
michael@0 225 if (this.currentPage)
michael@0 226 this._fireEvent(this.currentPage, "extra1");
michael@0 227 ]]></body>
michael@0 228 </method>
michael@0 229
michael@0 230 <method name="extra2">
michael@0 231 <body><![CDATA[
michael@0 232 if (this.currentPage)
michael@0 233 this._fireEvent(this.currentPage, "extra2");
michael@0 234 ]]></body>
michael@0 235 </method>
michael@0 236
michael@0 237 <method name="rewind">
michael@0 238 <body><![CDATA[
michael@0 239 if (!this.canRewind)
michael@0 240 return;
michael@0 241
michael@0 242 if (this.currentPage && !this._fireEvent(this.currentPage, "pagehide"))
michael@0 243 return;
michael@0 244
michael@0 245 if (this.currentPage && !this._fireEvent(this.currentPage, "pagerewound"))
michael@0 246 return;
michael@0 247
michael@0 248 if (!this._fireEvent(this, "wizardback"))
michael@0 249 return;
michael@0 250
michael@0 251
michael@0 252 this._pageStack.pop();
michael@0 253 this.currentPage = this._pageStack[this._pageStack.length-1];
michael@0 254 this.setAttribute("pagestep", this._pageStack.length);
michael@0 255 ]]></body>
michael@0 256 </method>
michael@0 257
michael@0 258 <method name="advance">
michael@0 259 <parameter name="aPageId"/>
michael@0 260 <body><![CDATA[
michael@0 261 if (!this.canAdvance)
michael@0 262 return;
michael@0 263
michael@0 264 if (this.currentPage && !this._fireEvent(this.currentPage, "pagehide"))
michael@0 265 return;
michael@0 266
michael@0 267 if (this.currentPage && !this._fireEvent(this.currentPage, "pageadvanced"))
michael@0 268 return;
michael@0 269
michael@0 270 if (this.onLastPage && !aPageId) {
michael@0 271 if (this._fireEvent(this, "wizardfinish"))
michael@0 272 window.setTimeout(function() {window.close();}, 1);
michael@0 273 } else {
michael@0 274 if (!this._fireEvent(this, "wizardnext"))
michael@0 275 return;
michael@0 276
michael@0 277 var page;
michael@0 278 if (aPageId)
michael@0 279 page = this.getPageById(aPageId);
michael@0 280 else {
michael@0 281 if (this.currentPage) {
michael@0 282 if (this._accessMethod == "random")
michael@0 283 page = this.getPageById(this.currentPage.next);
michael@0 284 else
michael@0 285 page = this.wizardPages[this.currentPage.pageIndex+1];
michael@0 286 } else
michael@0 287 page = this.wizardPages[0];
michael@0 288 }
michael@0 289
michael@0 290 if (page) {
michael@0 291 this._pageStack.push(page);
michael@0 292 this.setAttribute("pagestep", this._pageStack.length);
michael@0 293
michael@0 294 this.currentPage = page;
michael@0 295 }
michael@0 296 }
michael@0 297 ]]></body>
michael@0 298 </method>
michael@0 299
michael@0 300 <method name="goTo">
michael@0 301 <parameter name="aPageId"/>
michael@0 302 <body><![CDATA[
michael@0 303 var page = this.getPageById(aPageId);
michael@0 304 if (page) {
michael@0 305 this._pageStack[this._pageStack.length-1] = page;
michael@0 306 this.currentPage = page;
michael@0 307 }
michael@0 308 ]]></body>
michael@0 309 </method>
michael@0 310
michael@0 311 <method name="cancel">
michael@0 312 <body><![CDATA[
michael@0 313 if (!this._fireEvent(this, "wizardcancel"))
michael@0 314 return true;
michael@0 315
michael@0 316 window.close();
michael@0 317 window.setTimeout(function() {window.close();}, 1);
michael@0 318 return false;
michael@0 319 ]]></body>
michael@0 320 </method>
michael@0 321
michael@0 322 <method name="_setInitialFocus">
michael@0 323 <parameter name="aEvent"/>
michael@0 324 <body>
michael@0 325 <![CDATA[
michael@0 326 document.documentElement._hasLoaded = true;
michael@0 327 var focusInit =
michael@0 328 function() {
michael@0 329 // give focus to the first focusable element in the dialog
michael@0 330 if (!document.commandDispatcher.focusedElement)
michael@0 331 document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
michael@0 332
michael@0 333 try {
michael@0 334 var button =
michael@0 335 document.documentElement._wizardButtons.defaultButton;
michael@0 336 if (button)
michael@0 337 window.notifyDefaultButtonLoaded(button);
michael@0 338 } catch (e) { }
michael@0 339 };
michael@0 340
michael@0 341 // Give focus after onload completes, see bug 103197.
michael@0 342 setTimeout(focusInit, 0);
michael@0 343 ]]>
michael@0 344 </body>
michael@0 345 </method>
michael@0 346
michael@0 347 <method name="_advanceFocusToPage">
michael@0 348 <parameter name="aPage"/>
michael@0 349 <body>
michael@0 350 <![CDATA[
michael@0 351 if (!this._hasLoaded)
michael@0 352 return;
michael@0 353
michael@0 354 document.commandDispatcher.advanceFocusIntoSubtree(aPage);
michael@0 355
michael@0 356 // if advanceFocusIntoSubtree tries to focus one of our
michael@0 357 // dialog buttons, then remove it and put it on the root
michael@0 358 var focused = document.commandDispatcher.focusedElement;
michael@0 359 if (focused && focused.hasAttribute("dlgtype"))
michael@0 360 this.focus();
michael@0 361 ]]>
michael@0 362 </body>
michael@0 363 </method>
michael@0 364
michael@0 365 <method name="_initPages">
michael@0 366 <body><![CDATA[
michael@0 367 var meth = "sequential";
michael@0 368 var pages = this.wizardPages;
michael@0 369 for (var i = 0; i < pages.length; ++i) {
michael@0 370 var page = pages[i];
michael@0 371 page.pageIndex = i;
michael@0 372 if (page.next != "")
michael@0 373 meth = "random";
michael@0 374 }
michael@0 375 this._accessMethod = meth;
michael@0 376 ]]></body>
michael@0 377 </method>
michael@0 378
michael@0 379 <method name="_initWizardButton">
michael@0 380 <parameter name="aName"/>
michael@0 381 <body><![CDATA[
michael@0 382 var btn = document.getAnonymousElementByAttribute(this._wizardButtons, "dlgtype", aName);
michael@0 383 if (btn) {
michael@0 384 btn.addEventListener("command", this["_"+aName+"Func"], false);
michael@0 385 this["_"+aName+"Button"] = btn;
michael@0 386 }
michael@0 387 return btn;
michael@0 388 ]]></body>
michael@0 389 </method>
michael@0 390
michael@0 391 <method name="_adjustWizardHeader">
michael@0 392 <body><![CDATA[
michael@0 393 var label = this.currentPage.getAttribute("label");
michael@0 394 if (!label && this.onFirstPage && this._bundle)
michael@0 395 #ifdef XP_MACOSX
michael@0 396 label = this._bundle.GetStringFromName("default-first-title-mac");
michael@0 397 #else
michael@0 398 label = this._bundle.formatStringFromName("default-first-title", [this.title], 1);
michael@0 399 #endif
michael@0 400 else if (!label && this.onLastPage && this._bundle)
michael@0 401 #ifdef XP_MACOSX
michael@0 402 label = this._bundle.GetStringFromName("default-last-title-mac");
michael@0 403 #else
michael@0 404 label = this._bundle.formatStringFromName("default-last-title", [this.title], 1);
michael@0 405 #endif
michael@0 406 this._wizardHeader.setAttribute("label", label);
michael@0 407 this._wizardHeader.setAttribute("description", this.currentPage.getAttribute("description"));
michael@0 408 ]]></body>
michael@0 409 </method>
michael@0 410
michael@0 411 <method name="_hitEnter">
michael@0 412 <parameter name="evt"/>
michael@0 413 <body>
michael@0 414 <![CDATA[
michael@0 415 if (!evt.defaultPrevented)
michael@0 416 this.advance();
michael@0 417 ]]>
michael@0 418 </body>
michael@0 419 </method>
michael@0 420
michael@0 421 <method name="_fireEvent">
michael@0 422 <parameter name="aTarget"/>
michael@0 423 <parameter name="aType"/>
michael@0 424 <body>
michael@0 425 <![CDATA[
michael@0 426 var event = document.createEvent("Events");
michael@0 427 event.initEvent(aType, true, true);
michael@0 428
michael@0 429 // handle dom event handlers
michael@0 430 var noCancel = aTarget.dispatchEvent(event);
michael@0 431
michael@0 432 // handle any xml attribute event handlers
michael@0 433 var handler = aTarget.getAttribute("on"+aType);
michael@0 434 if (handler != "") {
michael@0 435 var fn = new Function("event", handler);
michael@0 436 var returned = fn.apply(aTarget, [event]);
michael@0 437 if (returned == false)
michael@0 438 noCancel = false;
michael@0 439 }
michael@0 440
michael@0 441 return noCancel;
michael@0 442 ]]>
michael@0 443 </body>
michael@0 444 </method>
michael@0 445
michael@0 446 </implementation>
michael@0 447
michael@0 448 <handlers>
michael@0 449 <handler event="keypress" keycode="VK_RETURN"
michael@0 450 group="system" action="this._hitEnter(event)"/>
michael@0 451 <handler event="keypress" keycode="VK_ESCAPE" group="system">
michael@0 452 if (!event.defaultPrevented)
michael@0 453 this.cancel();
michael@0 454 </handler>
michael@0 455 </handlers>
michael@0 456 </binding>
michael@0 457
michael@0 458 <binding id="wizardpage" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
michael@0 459 <implementation>
michael@0 460 <field name="pageIndex">-1</field>
michael@0 461
michael@0 462 <property name="pageid" onget="return this.getAttribute('pageid');"
michael@0 463 onset="this.setAttribute('pageid', val);"/>
michael@0 464
michael@0 465 <property name="next" onget="return this.getAttribute('next');"
michael@0 466 onset="this.setAttribute('next', val);
michael@0 467 this.parentNode._accessMethod = 'random';
michael@0 468 return val;"/>
michael@0 469 </implementation>
michael@0 470 </binding>
michael@0 471
michael@0 472 #ifdef XP_MACOSX
michael@0 473 <binding id="wizard-header" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
michael@0 474 <content>
michael@0 475 <xul:stack class="wizard-header-stack" flex="1">
michael@0 476 <xul:vbox class="wizard-header-box-1">
michael@0 477 <xul:vbox class="wizard-header-box-text">
michael@0 478 <xul:label class="wizard-header-label" xbl:inherits="xbl:text=label"/>
michael@0 479 </xul:vbox>
michael@0 480 </xul:vbox>
michael@0 481 <xul:hbox class="wizard-header-box-icon">
michael@0 482 <xul:spacer flex="1"/>
michael@0 483 <xul:image class="wizard-header-icon" xbl:inherits="src=iconsrc"/>
michael@0 484 </xul:hbox>
michael@0 485 </xul:stack>
michael@0 486 </content>
michael@0 487 </binding>
michael@0 488
michael@0 489 <binding id="wizard-buttons" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
michael@0 490 <content>
michael@0 491 <xul:vbox flex="1">
michael@0 492 <xul:hbox class="wizard-buttons-btm">
michael@0 493 <xul:button class="wizard-button" dlgtype="extra1" hidden="true"/>
michael@0 494 <xul:button class="wizard-button" dlgtype="extra2" hidden="true"/>
michael@0 495 <xul:button label="&button-cancel-mac.label;" class="wizard-button" dlgtype="cancel"/>
michael@0 496 <xul:spacer flex="1"/>
michael@0 497 <xul:button label="&button-back-mac.label;" accesskey="&button-back-mac.accesskey;"
michael@0 498 class="wizard-button wizard-nav-button" dlgtype="back"/>
michael@0 499 <xul:button label="&button-next-mac.label;" accesskey="&button-next-mac.accesskey;"
michael@0 500 class="wizard-button wizard-nav-button" dlgtype="next"
michael@0 501 default="true" xbl:inherits="hidden=lastpage" />
michael@0 502 <xul:button label="&button-finish-mac.label;" class="wizard-button"
michael@0 503 dlgtype="finish" default="true" xbl:inherits="hidden=hidefinishbutton" />
michael@0 504 </xul:hbox>
michael@0 505 </xul:vbox>
michael@0 506 </content>
michael@0 507
michael@0 508 <implementation>
michael@0 509 <method name="onPageChange">
michael@0 510 <body><![CDATA[
michael@0 511 this.setAttribute("hidefinishbutton", !(this.getAttribute("lastpage") == "true"));
michael@0 512 ]]></body>
michael@0 513 </method>
michael@0 514 </implementation>
michael@0 515
michael@0 516 </binding>
michael@0 517
michael@0 518 #else
michael@0 519
michael@0 520 <binding id="wizard-header" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
michael@0 521 <content>
michael@0 522 <xul:hbox class="wizard-header-box-1" flex="1">
michael@0 523 <xul:vbox class="wizard-header-box-text" flex="1">
michael@0 524 <xul:label class="wizard-header-label" xbl:inherits="xbl:text=label"/>
michael@0 525 <xul:label class="wizard-header-description" xbl:inherits="xbl:text=description"/>
michael@0 526 </xul:vbox>
michael@0 527 <xul:image class="wizard-header-icon" xbl:inherits="src=iconsrc"/>
michael@0 528 </xul:hbox>
michael@0 529 </content>
michael@0 530 </binding>
michael@0 531
michael@0 532 <binding id="wizard-buttons" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
michael@0 533 <content>
michael@0 534 <xul:vbox class="wizard-buttons-box-1" flex="1">
michael@0 535 <xul:separator class="wizard-buttons-separator groove"/>
michael@0 536 <xul:hbox class="wizard-buttons-box-2">
michael@0 537 <xul:button class="wizard-button" dlgtype="extra1" hidden="true"/>
michael@0 538 <xul:button class="wizard-button" dlgtype="extra2" hidden="true"/>
michael@0 539 <xul:spacer flex="1" anonid="spacer"/>
michael@0 540 #ifdef XP_UNIX
michael@0 541 <xul:button label="&button-cancel-unix.label;" class="wizard-button"
michael@0 542 dlgtype="cancel" icon="cancel"/>
michael@0 543 <xul:spacer style="width: 24px"/>
michael@0 544 <xul:button label="&button-back-unix.label;" accesskey="&button-back-unix.accesskey;"
michael@0 545 class="wizard-button" dlgtype="back" icon="go-back"/>
michael@0 546 <xul:deck class="wizard-next-deck" anonid="WizardButtonDeck">
michael@0 547 <xul:hbox>
michael@0 548 <xul:button label="&button-finish-unix.label;" class="wizard-button"
michael@0 549 dlgtype="finish" default="true" flex="1"/>
michael@0 550 </xul:hbox>
michael@0 551 <xul:hbox>
michael@0 552 <xul:button label="&button-next-unix.label;" accesskey="&button-next-unix.accesskey;"
michael@0 553 class="wizard-button" dlgtype="next" icon="go-forward"
michael@0 554 default="true" flex="1"/>
michael@0 555 </xul:hbox>
michael@0 556 </xul:deck>
michael@0 557 #else
michael@0 558 <xul:button label="&button-back-win.label;" accesskey="&button-back-win.accesskey;"
michael@0 559 class="wizard-button" dlgtype="back" icon="go-back"/>
michael@0 560 <xul:deck class="wizard-next-deck" anonid="WizardButtonDeck">
michael@0 561 <xul:hbox>
michael@0 562 <xul:button label="&button-finish-win.label;" class="wizard-button"
michael@0 563 dlgtype="finish" default="true" flex="1"/>
michael@0 564 </xul:hbox>
michael@0 565 <xul:hbox>
michael@0 566 <xul:button label="&button-next-win.label;" accesskey="&button-next-win.accesskey;"
michael@0 567 class="wizard-button" dlgtype="next" icon="go-forward"
michael@0 568 default="true" flex="1"/>
michael@0 569 </xul:hbox>
michael@0 570 </xul:deck>
michael@0 571 <xul:button label="&button-cancel-win.label;" class="wizard-button"
michael@0 572 dlgtype="cancel" icon="cancel"/>
michael@0 573 #endif
michael@0 574 </xul:hbox>
michael@0 575 </xul:vbox>
michael@0 576 </content>
michael@0 577
michael@0 578 <implementation>
michael@0 579 <field name="_wizardButtonDeck" readonly="true">
michael@0 580 document.getAnonymousElementByAttribute(this, "anonid", "WizardButtonDeck");
michael@0 581 </field>
michael@0 582
michael@0 583 <method name="onPageChange">
michael@0 584 <body><![CDATA[
michael@0 585 if (this.getAttribute("lastpage") == "true") {
michael@0 586 this._wizardButtonDeck.setAttribute("selectedIndex", 0);
michael@0 587 } else {
michael@0 588 this._wizardButtonDeck.setAttribute("selectedIndex", 1);
michael@0 589 }
michael@0 590 ]]></body>
michael@0 591 </method>
michael@0 592
michael@0 593 <property name="defaultButton" readonly="true">
michael@0 594 <getter><![CDATA[
michael@0 595 const kXULNS =
michael@0 596 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 597 var buttons = this._wizardButtonDeck.selectedPanel
michael@0 598 .getElementsByTagNameNS(kXULNS, "button");
michael@0 599 for (var i = 0; i < buttons.length; i++) {
michael@0 600 if (buttons[i].getAttribute("default") == "true" &&
michael@0 601 !buttons[i].hidden && !buttons[i].disabled)
michael@0 602 return buttons[i];
michael@0 603 }
michael@0 604 return null;
michael@0 605 ]]></getter>
michael@0 606 </property>
michael@0 607 </implementation>
michael@0 608 </binding>
michael@0 609 #endif
michael@0 610
michael@0 611 </bindings>

mercurial