Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.widget.Wizard");
14
dojo.require("dojo.widget.*");
15
dojo.require("dojo.widget.LayoutContainer");
16
dojo.require("dojo.widget.ContentPane");
17
dojo.require("dojo.event.*");
18
dojo.require("dojo.html.style");
19
dojo.widget.defineWidget("dojo.widget.WizardContainer", dojo.widget.LayoutContainer, {templateString:"<div class=\"WizardContainer\" dojoAttachPoint=\"wizardNode\">\n	<div class=\"WizardText\" dojoAttachPoint=\"wizardPanelContainerNode\">\n	</div>\n	<div class=\"WizardButtonHolder\" dojoAttachPoint=\"wizardControlContainerNode\">\n		<input class=\"WizardButton\" type=\"button\" dojoAttachPoint=\"previousButton\"/>\n		<input class=\"WizardButton\" type=\"button\" dojoAttachPoint=\"nextButton\"/>\n		<input class=\"WizardButton\" type=\"button\" dojoAttachPoint=\"doneButton\" style=\"display:none\"/>\n		<input class=\"WizardButton\" type=\"button\" dojoAttachPoint=\"cancelButton\"/>\n	</div>\n</div>\n", templateCssString:".WizardContainer {\n\tbackground: #EEEEEE;\n\tborder: #798EC5 1px solid;\n\tpadding: 2px;\n}\n\n.WizardTitle {\n\tcolor: #003366;\n\tpadding: 8px 5px 15px 2px;\n\tfont-weight: bold;\n\tfont-size: x-small;\n\tfont-style: normal;\n\tfont-family: Verdana, Arial, Helvetica;\n\ttext-align: left;\n}\n\n.WizardText {\n\tcolor: #000033;\n\tfont-weight: normal;\n\tfont-size: xx-small;\n\tfont-family: Verdana, Arial, Helvetica;\n\tpadding: 2 50; text-align: justify;\n}\n\n.WizardLightText {\n\tcolor: #666666;\n\tfont-weight: normal;\n\tfont-size: xx-small;\n\tfont-family: verdana, arial, helvetica;\n\tpadding: 2px 50px;\n\ttext-align: justify;\n}\n\n.WizardButtonHolder {\n\ttext-align: right;\n\tpadding: 10px 5px;\n}\n\n.WizardButton {\n\tcolor: #ffffff;\n\tbackground: #798EC5;\n\tfont-size: xx-small;\n\tfont-family: verdana, arial, helvetica, sans-serif;\n\tborder-right: #000000 1px solid;\n\tborder-bottom: #000000 1px solid;\n\tborder-left: #666666 1px solid;\n\tborder-top: #666666 1px solid;\n\tpadding-right: 4px;\n\tpadding-left: 4px;\n\ttext-decoration: none; height: 18px;\n}\n\n.WizardButton:hover {\n\tcursor: pointer;\n}\n\n.WizardButtonDisabled {\n\tcolor: #eeeeee;\n\tbackground-color: #999999;\n\tfont-size: xx-small;\n\tFONT-FAMILY: verdana, arial, helvetica, sans-serif;\n\tborder-right: #000000 1px solid;\n\tborder-bottom: #000000 1px solid;\n\tborder-left: #798EC5 1px solid;\n\tborder-top: #798EC5 1px solid;\n\tpadding-right: 4px;\n\tpadding-left: 4px;\n\ttext-decoration: none;\n\theight: 18px;\n}\n\n\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/Wizard.css"), selected:null, nextButtonLabel:"next", previousButtonLabel:"previous", cancelButtonLabel:"cancel", doneButtonLabel:"done", cancelFunction:"", hideDisabledButtons:false, fillInTemplate:function (args, frag) {
20
	dojo.event.connect(this.nextButton, "onclick", this, "_onNextButtonClick");
21
	dojo.event.connect(this.previousButton, "onclick", this, "_onPreviousButtonClick");
22
	if (this.cancelFunction) {
23
		dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction);
24
	} else {
25
		this.cancelButton.style.display = "none";
26
	}
27
	dojo.event.connect(this.doneButton, "onclick", this, "done");
28
	this.nextButton.value = this.nextButtonLabel;
29
	this.previousButton.value = this.previousButtonLabel;
30
	this.cancelButton.value = this.cancelButtonLabel;
31
	this.doneButton.value = this.doneButtonLabel;
32
}, _checkButtons:function () {
33
	var lastStep = !this.hasNextPanel();
34
	this.nextButton.disabled = lastStep;
35
	this._setButtonClass(this.nextButton);
36
	if (this.selected.doneFunction) {
37
		this.doneButton.style.display = "";
38
		if (lastStep) {
39
			this.nextButton.style.display = "none";
40
		}
41
	} else {
42
		this.doneButton.style.display = "none";
43
	}
44
	this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack));
45
	this._setButtonClass(this.previousButton);
46
}, _setButtonClass:function (button) {
47
	if (!this.hideDisabledButtons) {
48
		button.style.display = "";
49
		dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton");
50
	} else {
51
		button.style.display = button.disabled ? "none" : "";
52
	}
53
}, registerChild:function (panel, insertionIndex) {
54
	dojo.widget.WizardContainer.superclass.registerChild.call(this, panel, insertionIndex);
55
	this.wizardPanelContainerNode.appendChild(panel.domNode);
56
	panel.hide();
57
	if (!this.selected) {
58
		this.onSelected(panel);
59
	}
60
	this._checkButtons();
61
}, onSelected:function (panel) {
62
	if (this.selected) {
63
		if (this.selected._checkPass()) {
64
			this.selected.hide();
65
		} else {
66
			return;
67
		}
68
	}
69
	panel.show();
70
	this.selected = panel;
71
}, getPanels:function () {
72
	return this.getChildrenOfType("WizardPane", false);
73
}, selectedIndex:function () {
74
	if (this.selected) {
75
		return dojo.lang.indexOf(this.getPanels(), this.selected);
76
	}
77
	return -1;
78
}, _onNextButtonClick:function () {
79
	var selectedIndex = this.selectedIndex();
80
	if (selectedIndex > -1) {
81
		var childPanels = this.getPanels();
82
		if (childPanels[selectedIndex + 1]) {
83
			this.onSelected(childPanels[selectedIndex + 1]);
84
		}
85
	}
86
	this._checkButtons();
87
}, _onPreviousButtonClick:function () {
88
	var selectedIndex = this.selectedIndex();
89
	if (selectedIndex > -1) {
90
		var childPanels = this.getPanels();
91
		if (childPanels[selectedIndex - 1]) {
92
			this.onSelected(childPanels[selectedIndex - 1]);
93
		}
94
	}
95
	this._checkButtons();
96
}, hasNextPanel:function () {
97
	var selectedIndex = this.selectedIndex();
98
	return (selectedIndex < (this.getPanels().length - 1));
99
}, hasPreviousPanel:function () {
100
	var selectedIndex = this.selectedIndex();
101
	return (selectedIndex > 0);
102
}, done:function () {
103
	this.selected.done();
104
}});
105
dojo.widget.defineWidget("dojo.widget.WizardPane", dojo.widget.ContentPane, {canGoBack:true, passFunction:"", doneFunction:"", postMixInProperties:function (args, frag) {
106
	if (this.passFunction) {
107
		this.passFunction = dj_global[this.passFunction];
108
	}
109
	if (this.doneFunction) {
110
		this.doneFunction = dj_global[this.doneFunction];
111
	}
112
	dojo.widget.WizardPane.superclass.postMixInProperties.apply(this, arguments);
113
}, _checkPass:function () {
114
	if (this.passFunction && dojo.lang.isFunction(this.passFunction)) {
115
		var failMessage = this.passFunction();
116
		if (failMessage) {
117
			alert(failMessage);
118
			return false;
119
		}
120
	}
121
	return true;
122
}, done:function () {
123
	if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) {
124
		this.doneFunction();
125
	}
126
}});
127