| 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" |
| 13 |
], function (lang, declare, connect, StackContainer, _TemplatedMixin, _WidgetsInTemplateMixin, i18n, template) { |
| 14 |
|
| 15 |
var Wizard = declare("dojox.widget.Wizard", [StackContainer, _TemplatedMixin, _WidgetsInTemplateMixin], { |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
templateString: template, |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
nextButtonLabel: "", |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
previousButtonLabel: "", |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
cancelButtonLabel: "", |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
doneButtonLabel: "", |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
cancelFunction: null, |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 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 |
|
| 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 |
|
| 98 |
this.doneButton.domNode.style.display = ""; |
| 99 |
if(lastStep){ |
| 100 |
this.nextButton.domNode.style.display = "none"; |
| 101 |
} |
| 102 |
}else{ |
| 103 |
|
| 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 |
|
| 116 |
|
| 117 |
if(this.selectedChildWidget._checkPass()){ |
| 118 |
this.forward(); |
| 119 |
} |
| 120 |
}, |
| 121 |
|
| 122 |
done: function(){ |
| 123 |
|
| 124 |
|
| 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 |
}); |