Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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