Debian Codegraph @

dojox/widget/Wizard.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/connect",
5 "dijit/layout/StackContainer",
6 "dijit/_TemplatedMixin",
7 "dijit/_WidgetsInTemplateMixin",
8 "dojo/i18n",
9 "dojo/text!./Wizard/Wizard.html",
10 "dojo/i18n!dijit/nls/common",
11 "dojo/i18n!./nls/Wizard",
12 "dijit/form/Button" // used by template
13 ], function (lang, declare, connect, StackContainer, _TemplatedMixin, _WidgetsInTemplateMixin, i18n, template) {
14
15 var Wizard = declare("dojox.widget.Wizard", [StackContainer, _TemplatedMixin, _WidgetsInTemplateMixin], {
16 // summary:
17 // A set of panels that display sequentially, typically notating a step-by-step
18 // procedure like an install
19
20 templateString: template,
21
22 // nextButtonLabel: String
23 // Label override for the "Next" button.
24 nextButtonLabel: "",
25
26 // previousButtonLabel: String
27 // Label override for the "Previous" button.
28 previousButtonLabel: "",
29
30 // cancelButtonLabel: String
31 // Label override for the "Cancel" button.
32 cancelButtonLabel: "",
33
34 // doneButtonLabel: String
35 // Label override for the "Done" button.
36 doneButtonLabel: "",
37
38 // cancelFunction: Function|String
39 // Name of function to call if user presses cancel button.
40 // Cancel button is not displayed if function is not specified.
41 cancelFunction: null,
42
43 // hideDisabled: Boolean
44 // If true, disabled buttons are hidden; otherwise, they are assigned the
45 // "WizardButtonDisabled" CSS class
46 hideDisabled: false,
47
48 postMixInProperties: function(){
49 this.inherited(arguments);
50 var labels = lang.mixin({cancel: i18n.getLocalization("dijit", "common", this.lang).buttonCancel},
51 i18n.getLocalization("dojox.widget", "Wizard", this.lang));
52 var prop;
53 for(prop in labels){
54 if(!this[prop + "ButtonLabel"]){
55 this[prop + "ButtonLabel"] = labels[prop];
56 }
57 }
58 },
59
60 startup: function(){
61 if(this._started){
62 //console.log('started');
63 return;
64 }
65 this.inherited(arguments);
66
67 this.connect(this.nextButton, "onClick", "_forward");
68 this.connect(this.previousButton, "onClick", "back");
69
70 if(this.cancelFunction){
71 if(lang.isString(this.cancelFunction)){
72 this.cancelFunction = lang.getObject(this.cancelFunction);
73 }
74 this.connect(this.cancelButton, "onClick", this.cancelFunction);
75 }else{
76 this.cancelButton.domNode.style.display = "none";
77 }
78 this.connect(this.doneButton, "onClick", "done");
79
80 this._subscription = connect.subscribe(this.id + "-selectChild", lang.hitch(this,"_checkButtons"));
81 this._started = true;
82
83 },
84
85 resize: function(){
86 this.inherited(arguments);
87 this._checkButtons();
88 },
89
90 _checkButtons: function(){
91 var sw = this.selectedChildWidget;
92
93 var lastStep = sw.isLastChild || this.nextButton.get("disabled");
94 this.nextButton.set("disabled", lastStep);
95 this._setButtonClass(this.nextButton);
96 if(sw.doneFunction){
97 //console.log(sw.doneFunction);
98 this.doneButton.domNode.style.display = "";
99 if(lastStep){
100 this.nextButton.domNode.style.display = "none";
101 }
102 }else{
103 // #1438 issue here.
104 this.doneButton.domNode.style.display = "none";
105 }
106 this.previousButton.set("disabled", !this.selectedChildWidget.canGoBack);
107 this._setButtonClass(this.previousButton);
108 },
109
110 _setButtonClass: function(button){
111 button.domNode.style.display = (this.hideDisabled && button.disabled) ? "none" : "";
112 },
113
114 _forward: function(){
115 // summary:
116 // callback when next button is clicked
117 if(this.selectedChildWidget._checkPass()){
118 this.forward();
119 }
120 },
121
122 done: function(){
123 // summary:
124 // Finish the wizard's operation
125 this.selectedChildWidget.done();
126 },
127
128 destroy: function(){
129 connect.unsubscribe(this._subscription);
130 this.inherited(arguments);
131 }
132
133 });
134
135 return Wizard;
136 });