!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 <?xml version="1.0"?>
2
3 <!DOCTYPE bindings [
4 <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
5 %globalDTD;
6 <!ENTITY % wizardDTD SYSTEM "chrome://global/locale/wizard.dtd">
7 %wizardDTD;
8 ]>
9
10 <bindings id="wizardBindings"
11 xmlns="http://www.mozilla.org/xbl"
12 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
13 xmlns:xbl="http://www.mozilla.org/xbl">
14
15 <binding id="wizard-base">
16 <resources>
17 <stylesheet src="chrome://global/skin/wizard.css"/>
18 </resources>
19 </binding>
20
21 <binding id="wizard" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
22 <content>
23 <xul:hbox class="wizard-header" chromedir="&locale.dir;" anonid="Header"/>
24
25 <xul:deck class="wizard-page-box" flex="1" anonid="Deck">
26 <children includes="wizardpage"/>
27 </xul:deck>
28 <children/>
29
30 <xul:hbox class="wizard-buttons" anonid="Buttons" xbl:inherits="pagestep,firstpage,lastpage"/>
31 </content>
32
33 <implementation>
get_title
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_title
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
34 <property name="title" onget="return document.title;"
35 onset="return document.title = val;"/>
36
get_canAdvance
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_canAdvance
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
37 <property name="canAdvance" onget="return this._canAdvance;"
38 onset="this._nextButton.disabled = !val; return this._canAdvance = val;"/>
get_canRewind
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_canRewind
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
39 <property name="canRewind" onget="return this._canRewind;"
40 onset="this._backButton.disabled = !val; return this._canRewind = val;"/>
41
get_pageStep
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
42 <property name="pageStep" readonly="true" onget="return this._pageStack.length"/>
43
field_pageCount
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
44 <field name="pageCount">0</field>
45
field__accessMethod
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
46 <field name="_accessMethod">null</field>
field__pageStack
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
47 <field name="_pageStack">null</field>
field__currentPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
48 <field name="_currentPage">null</field>
49
50 <property name="wizardPages">
get_wizardPages
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
51 <getter>
52 <![CDATA[
53 var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
54 return this.getElementsByTagNameNS(xulns, "wizardpage");
55 ]]>
56 </getter>
57 </property>
58
get_currentPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
59 <property name="currentPage" onget="return this._currentPage">
set_currentPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
60 <setter>
61 <![CDATA[
62 if (!val)
63 return val;
64
65 this._currentPage = val;
66
67 // Setting this attribute allows wizard's clients to dynamically
68 // change the styles of each page based on purpose of the page.
69 this.setAttribute("currentpageid", val.pageid);
70
71 if (this.onFirstPage) {
72 this.canRewind = false;
73 this.setAttribute("firstpage", "true");
74 } else {
75 this.canRewind = true;
76 this.setAttribute("firstpage", "false");
77 }
78
79 if (this.onLastPage) {
80 this.canAdvance = true;
81 this.setAttribute("lastpage", "true");
82 } else {
83 this.setAttribute("lastpage", "false");
84 }
85
86 this._deck.setAttribute("selectedIndex", val.pageIndex);
87 this._advanceFocusToPage(val);
88
89 this._adjustWizardHeader();
90 this._wizardButtons.onPageChange();
91
92 this._fireEvent(val, "pageshow");
93
94 return val;
95 ]]>
96 </setter>
97 </property>
98
get_pageIndex
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
99 <property name="pageIndex"
100 onget="return this._currentPage ? this._currentPage.pageIndex : -1;">
set_pageIndex
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
101 <setter>
102 <![CDATA[
103 if (val < 0 || val >= this.pageCount)
104 return val;
105
106 var page = this.wizardPages[val];
107 this._pageStack[this._pageStack.length-1] = page;
108 this.currentPage = page;
109
110 return val;
111 ]]>
112 </setter>
113 </property>
114
get_onFirstPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
115 <property name="onFirstPage" readonly="true"
116 onget="return this._pageStack.length == 1;"/>
117
118 <property name="onLastPage" readonly="true">
get_onLastPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
119 <getter><![CDATA[
120 var cp = this.currentPage;
121 return cp && ((this._accessMethod == "sequential" && cp.pageIndex == this.pageCount-1) ||
122 (this._accessMethod == "random" && cp.next == ""));
123 ]]></getter>
124 </property>
125
126 <method name="getButton">
127 <parameter name="aDlgType"/>
getButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
128 <body>
129 <![CDATA[
130 var btns = this.getElementsByAttribute("dlgtype", aDlgType);
131 return btns.item(0) ? btns[0] : document.getAnonymousElementByAttribute(this._wizardButtons, "dlgtype", aDlgType);
132 ]]>
133 </body>
134 </method>
135
field__canAdvance
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
136 <field name="_canAdvance"/>
field__canRewind
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
137 <field name="_canRewind"/>
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
138 <field name="_wizardHeader"/>
field__wizardButtons
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
139 <field name="_wizardButtons"/>
field__deck
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
140 <field name="_deck"/>
field__backButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
141 <field name="_backButton"/>
field__nextButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
142 <field name="_nextButton"/>
field__cancelButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
143 <field name="_cancelButton"/>
144
145 <!-- functions to be added as oncommand listeners to the wizard buttons -->
field__backFunc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:146:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
146 <field name="_backFunc">(function() { document.documentElement.rewind(); })</field>
field__nextFunc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:147:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
147 <field name="_nextFunc">(function() { document.documentElement.advance(); })</field>
field__finishFunc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:148:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
148 <field name="_finishFunc">(function() { document.documentElement.advance(); })</field>
field__cancelFunc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:149:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
149 <field name="_cancelFunc">(function() { document.documentElement.cancel(); })</field>
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:150:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
150 <field name="_extra1Func">(function() { document.documentElement.extra1(); })</field>
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:151:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
151 <field name="_extra2Func">(function() { document.documentElement.extra2(); })</field>
152
field__closeHandler
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
anon:153:7
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
153 <field name="_closeHandler">(function(event) {
154 if (document.documentElement.cancel())
155 event.preventDefault();
156 })</field>
157
constructor
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
158 <constructor><![CDATA[
159 this._canAdvance = true;
160 this._canRewind = false;
161 this._hasLoaded = false;
162
163 this._pageStack = [];
164
165 try {
166 // need to create string bundle manually instead of using <xul:stringbundle/>
167 // see bug 63370 for details
168 var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
169 .getService(Components.interfaces.nsILocaleService);
170 var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
171 .getService(Components.interfaces.nsIStringBundleService);
172 var bundleURL = "chrome://global/locale/wizard.properties";
173 this._bundle = stringBundleService.createBundle(bundleURL);
174 } catch (e) {
175 // This fails in remote XUL, which has to provide titles for all pages
176 // see bug 142502
177 }
178
179 // get anonymous content references
180 this._wizardHeader = document.getAnonymousElementByAttribute(this, "anonid", "Header");
181 this._wizardButtons = document.getAnonymousElementByAttribute(this, "anonid", "Buttons");
182 this._deck = document.getAnonymousElementByAttribute(this, "anonid", "Deck");
183
184 this._initWizardButton("back");
185 this._initWizardButton("next");
186 this._initWizardButton("finish");
187 this._initWizardButton("cancel");
188 this._initWizardButton("extra1");
189 this._initWizardButton("extra2");
190
191 this._initPages();
192
193 window.addEventListener("close", this._closeHandler, false);
194
195 // start off on the first page
196 this.pageCount = this.wizardPages.length;
197 this.advance();
198
199 // give focus to the first focusable element in the dialog
200 window.addEventListener("load", this._setInitialFocus, false);
201 ]]></constructor>
202
203 <method name="getPageById">
204 <parameter name="aPageId"/>
getPageById
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
205 <body><![CDATA[
206 var els = this.getElementsByAttribute("pageid", aPageId);
207 return els.item(0);
208 ]]></body>
209 </method>
210
211 <method name="extra1">
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
212 <body><![CDATA[
213 if (this.currentPage)
214 this._fireEvent(this.currentPage, "extra1");
215 ]]></body>
216 </method>
217
218 <method name="extra2">
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
219 <body><![CDATA[
220 if (this.currentPage)
221 this._fireEvent(this.currentPage, "extra2");
222 ]]></body>
223 </method>
224
225 <method name="rewind">
rewind
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
226 <body><![CDATA[
227 if (!this.canRewind)
228 return;
229
230 if (this.currentPage && !this._fireEvent(this.currentPage, "pagehide"))
231 return;
232
233 if (this.currentPage && !this._fireEvent(this.currentPage, "pagerewound"))
234 return;
235
236 if (!this._fireEvent(this, "wizardback"))
237 return;
238
239
240 this._pageStack.pop();
241 this.currentPage = this._pageStack[this._pageStack.length-1];
242 this.setAttribute("pagestep", this._pageStack.length);
243 ]]></body>
244 </method>
245
246 <method name="advance">
247 <parameter name="aPageId"/>
advance
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
248 <body><![CDATA[
249 if (!this.canAdvance)
250 return;
251
252 if (this.currentPage && !this._fireEvent(this.currentPage, "pagehide"))
253 return;
254
255 if (this.currentPage && !this._fireEvent(this.currentPage, "pageadvanced"))
256 return;
257
258 if (this.onLastPage) {
259 if (this._fireEvent(this, "wizardfinish"))
anon:260:32
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
260 window.setTimeout(function() {window.close();}, 1);
261 } else {
262 if (!this._fireEvent(this, "wizardnext"))
263 return;
264
265 var page;
266 if (aPageId)
267 page = this.getPageById(aPageId);
268 else {
269 if (this.currentPage) {
270 if (this._accessMethod == "random")
271 page = this.getPageById(this.currentPage.next);
272 else
273 page = this.wizardPages[this.currentPage.pageIndex+1];
274 } else
275 page = this.wizardPages[0];
276 }
277
278 if (page) {
279 this._pageStack.push(page);
280 this.setAttribute("pagestep", this._pageStack.length);
281
282 this.currentPage = page;
283 }
284 }
285 ]]></body>
286 </method>
287
288 <method name="goTo">
289 <parameter name="aPageId"/>
goTo
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
290 <body><![CDATA[
291 var page = this.getPageById(aPageId);
292 if (page) {
293 this._pageStack[this._pageStack.length-1] = page;
294 this.currentPage = page;
295 }
296 ]]></body>
297 </method>
298
299 <method name="cancel">
cancel
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
300 <body><![CDATA[
301 if (!this._fireEvent(this, "wizardcancel"))
302 return true;
303
304 window.close();
anon:305:28
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
305 window.setTimeout(function() {window.close();}, 1);
306 return false;
307 ]]></body>
308 </method>
309
310 <method name="_setInitialFocus">
311 <parameter name="aEvent"/>
_setInitialFocus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
312 <body>
313 <![CDATA[
314 document.documentElement._hasLoaded = true;
315 var focusInit =
anon:316:12
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
316 function() {
317 // give focus to the first focusable element in the dialog
318 if (!document.commandDispatcher.focusedElement)
319 document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
320 };
321
322 // Give focus after onload completes, see bug 103197.
323 setTimeout(focusInit, 0);
324 ]]>
325 </body>
326 </method>
327
328 <method name="_advanceFocusToPage">
329 <parameter name="aPage"/>
_advanceFocusToPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
330 <body>
331 <![CDATA[
332 if (!this._hasLoaded)
333 return;
334
335 document.commandDispatcher.advanceFocusIntoSubtree(aPage);
336
337 // if advanceFocusIntoSubtree tries to focus one of our
338 // dialog buttons, then remove it and put it on the root
339 var focused = document.commandDispatcher.focusedElement;
340 if (focused && focused.hasAttribute("dlgtype"))
341 this.focus();
342 ]]>
343 </body>
344 </method>
345
346 <method name="_initPages">
_initPages
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
347 <body><![CDATA[
348 var meth = "sequential";
349 var pages = this.wizardPages;
350 for (var i = 0; i < pages.length; ++i) {
351 var page = pages[i];
352 page.pageIndex = i;
353 if (page.next != "")
354 meth = "random";
355 }
356 this._accessMethod = meth;
357 ]]></body>
358 </method>
359
360 <method name="_initWizardButton">
361 <parameter name="aName"/>
_initWizardButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
362 <body><![CDATA[
363 var btn = document.getAnonymousElementByAttribute(this._wizardButtons, "dlgtype", aName);
364 if (btn) {
365 btn.addEventListener("command", this["_"+aName+"Func"], false);
366 this["_"+aName+"Button"] = btn;
367 }
368 return btn;
369 ]]></body>
370 </method>
371
372 <method name="_adjustWizardHeader">
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
373 <body><![CDATA[
374 var label = this.currentPage.getAttribute("label");
375 if (!label && this.onFirstPage && this._bundle)
376 label = this._bundle.GetStringFromName("default-first-title-mac");
377 else if (!label && this.onLastPage && this._bundle)
378 label = this._bundle.GetStringFromName("default-last-title-mac");
379 this._wizardHeader.setAttribute("label", label);
380 this._wizardHeader.setAttribute("description", this.currentPage.getAttribute("description"));
381 ]]></body>
382 </method>
383
384 <method name="_hitEnter">
385 <parameter name="evt"/>
_hitEnter
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
386 <body>
387 <![CDATA[
388 if (!evt.getPreventDefault())
389 this.advance();
390 ]]>
391 </body>
392 </method>
393
394 <method name="_fireEvent">
395 <parameter name="aTarget"/>
396 <parameter name="aType"/>
_fireEvent
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
397 <body>
398 <![CDATA[
399 var event = document.createEvent("Events");
400 event.initEvent(aType, true, true);
401
402 // handle dom event handlers
403 var noCancel = aTarget.dispatchEvent(event);
404
405 // handle any xml attribute event handlers
406 var handler = aTarget.getAttribute("on"+aType);
407 if (handler != "") {
anon:408:25
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
408 var fn = new Function("event", handler);
409 var returned = fn.apply(aTarget, [event]);
410 if (returned == false)
411 noCancel = false;
412 }
413
414 return noCancel;
415 ]]>
416 </body>
417 </method>
418
419 </implementation>
420
421 <handlers>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
422 <handler event="keypress" keycode="VK_ENTER"
423 group="system" action="this._hitEnter(event)"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
424 <handler event="keypress" keycode="VK_RETURN"
425 group="system" action="this._hitEnter(event)"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
426 <handler event="keypress" keycode="VK_ESCAPE" group="system">
427 if (!event.getPreventDefault())
428 this.cancel();
429 </handler>
430 </handlers>
431 </binding>
432
433 <binding id="wizardpage" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
434 <implementation>
field_pageIndex
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
435 <field name="pageIndex">-1</field>
436
get_pageid
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_pageid
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
437 <property name="pageid" onget="return this.getAttribute('pageid');"
438 onset="this.setAttribute('pageid', val);"/>
439
get_next
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_next
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
440 <property name="next" onget="return this.getAttribute('next');"
441 onset="this.setAttribute('next', val);
442 this.parentNode._accessMethod = 'random';
443 return val;"/>
444 </implementation>
445 </binding>
446
447 <binding id="wizard-header" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
448 <content>
449 <xul:stack class="wizard-header-stack" flex="1">
450 <xul:vbox class="wizard-header-box-1">
451 <xul:vbox class="wizard-header-box-text">
452 <xul:label class="wizard-header-label" xbl:inherits="value=label"/>
453 </xul:vbox>
454 </xul:vbox>
455 <xul:hbox class="wizard-header-box-icon">
456 <xul:spacer flex="1"/>
457 <xul:image class="wizard-header-icon" xbl:inherits="src=iconsrc"/>
458 </xul:hbox>
459 </xul:stack>
460 </content>
461 </binding>
462
463 <binding id="wizard-buttons" extends="chrome://global/content/bindings/wizard.xml#wizard-base">
464 <content>
465 <xul:vbox flex="1">
466 <xul:hbox class="wizard-buttons-btm">
467 <xul:button class="wizard-button" dlgtype="extra1" hidden="true"/>
468 <xul:button class="wizard-button" dlgtype="extra2" hidden="true"/>
469 <xul:button label="&button-cancel-mac.label;" class="wizard-button" dlgtype="cancel"/>
470 <xul:spacer flex="1"/>
471 <xul:button label="&button-back-mac.label;" accesskey="&button-back-mac.accesskey;"
472 class="wizard-button wizard-nav-button" dlgtype="back"/>
473 <xul:hbox class="wizard-label-box" align="center">
474 <xul:label class="wizard-page-label" xbl:inherits="value=pagestep"/>
475 </xul:hbox>
476 <xul:button label="&button-next-mac.label;" accesskey="&button-next-mac.accesskey;"
477 class="wizard-button wizard-nav-button" dlgtype="next"
478 default="true" xbl:inherits="hidden=lastpage" />
479 <xul:button label="&button-finish-mac.label;" class="wizard-button"
480 dlgtype="finish" default="true" xbl:inherits="hidden=hidefinishbutton" />
481 </xul:hbox>
482 </xul:vbox>
483 </content>
484
485 <implementation>
486 <method name="onPageChange">
onPageChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
487 <body><![CDATA[
488 this.setAttribute("hidefinishbutton", !(this.getAttribute("lastpage") == "true"));
489 ]]></body>
490 </method>
491 </implementation>
492
493 </binding>
494
495
496 </bindings>