Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.widget.Wizard");
12
dojo.require("dojo.widget.*");
13
dojo.require("dojo.widget.LayoutContainer");
14
dojo.require("dojo.widget.ContentPane");
15
dojo.require("dojo.event.*");
16
dojo.require("dojo.html.style");
17
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) {
18
	dojo.event.connect(this.nextButton, "onclick", this, "_onNextButtonClick");
19
	dojo.event.connect(this.previousButton, "onclick", this, "_onPreviousButtonClick");
20
	if (this.cancelFunction) {
21
		dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction);
22
	} else {
23
		this.cancelButton.style.display = "none";
24
	}
25
	dojo.event.connect(this.doneButton, "onclick", this, "done");
26
	this.nextButton.value = this.nextButtonLabel;
27
	this.previousButton.value = this.previousButtonLabel;
28
	this.cancelButton.value = this.cancelButtonLabel;
29
	this.doneButton.value = this.doneButtonLabel;
30
}, _checkButtons:function () {
31
	var lastStep = !this.hasNextPanel();
32
	this.nextButton.disabled = lastStep;
33
	this._setButtonClass(this.nextButton);
34
	if (this.selected.doneFunction) {
35
		this.doneButton.style.display = "";
36
		if (lastStep) {
37
			this.nextButton.style.display = "none";
38
		}
39
	} else {
40
		this.doneButton.style.display = "none";
41
	}
42
	this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack));
43
	this._setButtonClass(this.previousButton);
44
}, _setButtonClass:function (button) {
45
	if (!this.hideDisabledButtons) {
46
		button.style.display = "";
47
		dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton");
48
	} else {
49
		button.style.display = button.disabled ? "none" : "";
50
	}
51
}, registerChild:function (panel, insertionIndex) {
52
	dojo.widget.WizardContainer.superclass.registerChild.call(this, panel, insertionIndex);
53
	this.wizardPanelContainerNode.appendChild(panel.domNode);
54
	panel.hide();
55
	if (!this.selected) {
56
		this.onSelected(panel);
57
	}
58
	this._checkButtons();
59
}, onSelected:function (panel) {
60
	if (this.selected) {
61
		if (this.selected._checkPass()) {
62
			this.selected.hide();
63
		} else {
64
			return;
65
		}
66
	}
67
	panel.show();
68
	this.selected = panel;
69
}, getPanels:function () {
70
	return this.getChildrenOfType("WizardPane", false);
71
}, selectedIndex:function () {
72
	if (this.selected) {
73
		return dojo.lang.indexOf(this.getPanels(), this.selected);
74
	}
75
	return -1;
76
}, _onNextButtonClick:function () {
77
	var selectedIndex = this.selectedIndex();
78
	if (selectedIndex > -1) {
79
		var childPanels = this.getPanels();
80
		if (childPanels[selectedIndex + 1]) {
81
			this.onSelected(childPanels[selectedIndex + 1]);
82
		}
83
	}
84
	this._checkButtons();
85
}, _onPreviousButtonClick:function () {
86
	var selectedIndex = this.selectedIndex();
87
	if (selectedIndex > -1) {
88
		var childPanels = this.getPanels();
89
		if (childPanels[selectedIndex - 1]) {
90
			this.onSelected(childPanels[selectedIndex - 1]);
91
		}
92
	}
93
	this._checkButtons();
94
}, hasNextPanel:function () {
95
	var selectedIndex = this.selectedIndex();
96
	return (selectedIndex < (this.getPanels().length - 1));
97
}, hasPreviousPanel:function () {
98
	var selectedIndex = this.selectedIndex();
99
	return (selectedIndex > 0);
100
}, done:function () {
101
	this.selected.done();
102
}});
103
dojo.widget.defineWidget("dojo.widget.WizardPane", dojo.widget.ContentPane, {canGoBack:true, passFunction:"", doneFunction:"", postMixInProperties:function (args, frag) {
104
	if (this.passFunction) {
105
		this.passFunction = dj_global[this.passFunction];
106
	}
107
	if (this.doneFunction) {
108
		this.doneFunction = dj_global[this.doneFunction];
109
	}
110
	dojo.widget.WizardPane.superclass.postMixInProperties.apply(this, arguments);
111
}, _checkPass:function () {
112
	if (this.passFunction && dojo.lang.isFunction(this.passFunction)) {
113
		var failMessage = this.passFunction();
114
		if (failMessage) {
115
			alert(failMessage);
116
			return false;
117
		}
118
	}
119
	return true;
120
}, done:function () {
121
	if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) {
122
		this.doneFunction();
123
	}
124
}});
125