root / trunk / web / dojo / dojox / widget / Wizard.js @ 11
History | View | Annotate | Download (4.26 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.widget.Wizard"]){ |
9 |
dojo._hasResource["dojox.widget.Wizard"]=true; |
10 |
dojo.provide("dojox.widget.Wizard");
|
11 |
dojo.require("dijit.layout.StackContainer");
|
12 |
dojo.require("dijit.layout.ContentPane");
|
13 |
dojo.require("dijit.form.Button");
|
14 |
dojo.require("dojo.i18n");
|
15 |
dojo.requireLocalization("dijit","common",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
16 |
dojo.requireLocalization("dojox.widget","Wizard",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
17 |
dojo.declare("dojox.widget.Wizard",[dijit.layout.StackContainer,dijit._Templated],{widgetsInTemplate:true,templateString:dojo.cache("dojox.widget","Wizard/Wizard.html","<div class=\"dojoxWizard\" dojoAttachPoint=\"wizardNode\">\n <div class=\"dojoxWizardContainer\" dojoAttachPoint=\"containerNode\"></div>\n <div class=\"dojoxWizardButtons\" dojoAttachPoint=\"wizardNav\">\n <button dojoType=\"dijit.form.Button\" type=\"button\" dojoAttachPoint=\"previousButton\">${previousButtonLabel}</button>\n <button dojoType=\"dijit.form.Button\" type=\"button\" dojoAttachPoint=\"nextButton\">${nextButtonLabel}</button>\n <button dojoType=\"dijit.form.Button\" type=\"button\" dojoAttachPoint=\"doneButton\" style=\"display:none\">${doneButtonLabel}</button>\n <button dojoType=\"dijit.form.Button\" type=\"button\" dojoAttachPoint=\"cancelButton\">${cancelButtonLabel}</button>\n </div>\n</div>\n"),nextButtonLabel:"",previousButtonLabel:"",cancelButtonLabel:"",doneButtonLabel:"",cancelFunction:null,hideDisabled:false,postMixInProperties:function(){ |
18 |
this.inherited(arguments); |
19 |
var _1=dojo.mixin({cancel:dojo.i18n.getLocalization("dijit","common",this.lang).buttonCancel},dojo.i18n.getLocalization("dojox.widget","Wizard",this.lang)); |
20 |
var _2;
|
21 |
for(_2 in _1){ |
22 |
if(!this[_2+"ButtonLabel"]){ |
23 |
this[_2+"ButtonLabel"]=_1[_2]; |
24 |
} |
25 |
} |
26 |
},startup:function(){ |
27 |
if(this._started){ |
28 |
return;
|
29 |
} |
30 |
this.inherited(arguments); |
31 |
this.connect(this.nextButton,"onClick","_forward"); |
32 |
this.connect(this.previousButton,"onClick","back"); |
33 |
if(this.cancelFunction){ |
34 |
if(dojo.isString(this.cancelFunction)){ |
35 |
this.cancelFunction=dojo.getObject(this.cancelFunction); |
36 |
} |
37 |
this.connect(this.cancelButton,"onClick",this.cancelFunction); |
38 |
}else{
|
39 |
this.cancelButton.domNode.style.display="none"; |
40 |
} |
41 |
this.connect(this.doneButton,"onClick","done"); |
42 |
this._subscription=dojo.subscribe(this.id+"-selectChild",dojo.hitch(this,"_checkButtons")); |
43 |
this._checkButtons();
|
44 |
this._started=true; |
45 |
},_checkButtons:function(){ |
46 |
var sw=this.selectedChildWidget; |
47 |
var _3=sw.isLastChild;
|
48 |
this.nextButton.set("disabled",_3); |
49 |
this._setButtonClass(this.nextButton); |
50 |
if(sw.doneFunction){
|
51 |
this.doneButton.domNode.style.display=""; |
52 |
if(_3){
|
53 |
this.nextButton.domNode.style.display="none"; |
54 |
} |
55 |
}else{
|
56 |
this.doneButton.domNode.style.display="none"; |
57 |
} |
58 |
this.previousButton.set("disabled",!this.selectedChildWidget.canGoBack); |
59 |
this._setButtonClass(this.previousButton); |
60 |
},_setButtonClass:function(_4){ |
61 |
_4.domNode.style.display=(this.hideDisabled&&_4.disabled)?"none":""; |
62 |
},_forward:function(){ |
63 |
if(this.selectedChildWidget._checkPass()){ |
64 |
this.forward();
|
65 |
} |
66 |
},done:function(){ |
67 |
this.selectedChildWidget.done();
|
68 |
},destroy:function(){ |
69 |
dojo.unsubscribe(this._subscription);
|
70 |
this.inherited(arguments); |
71 |
}}); |
72 |
dojo.declare("dojox.widget.WizardPane",dijit.layout.ContentPane,{canGoBack:true,passFunction:null,doneFunction:null,startup:function(){ |
73 |
this.inherited(arguments); |
74 |
if(this.isFirstChild){ |
75 |
this.canGoBack=false; |
76 |
} |
77 |
if(dojo.isString(this.passFunction)){ |
78 |
this.passFunction=dojo.getObject(this.passFunction); |
79 |
} |
80 |
if(dojo.isString(this.doneFunction)&&this.doneFunction){ |
81 |
this.doneFunction=dojo.getObject(this.doneFunction); |
82 |
} |
83 |
},_onShow:function(){ |
84 |
if(this.isFirstChild){ |
85 |
this.canGoBack=false; |
86 |
} |
87 |
this.inherited(arguments); |
88 |
},_checkPass:function(){ |
89 |
var r=true; |
90 |
if(this.passFunction&&dojo.isFunction(this.passFunction)){ |
91 |
var _5=this.passFunction(); |
92 |
switch(typeof _5){ |
93 |
case "boolean": |
94 |
r=_5; |
95 |
break;
|
96 |
case "string": |
97 |
alert(_5); |
98 |
r=false;
|
99 |
break;
|
100 |
} |
101 |
} |
102 |
return r;
|
103 |
},done:function(){ |
104 |
if(this.doneFunction&&dojo.isFunction(this.doneFunction)){ |
105 |
this.doneFunction();
|
106 |
} |
107 |
}}); |
108 |
} |