Subversion Repositories Applications.papyrus

Rev

Rev 1422 | 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.ShowSlide");
14
dojo.require("dojo.widget.*");
15
dojo.require("dojo.lang.common");
16
dojo.require("dojo.widget.HtmlWidget");
17
dojo.require("dojo.lfx.html");
18
dojo.require("dojo.html.display");
19
dojo.require("dojo.html.layout");
20
dojo.require("dojo.animation.Animation");
21
dojo.require("dojo.gfx.color");
22
dojo.widget.defineWidget("dojo.widget.ShowSlide", dojo.widget.HtmlWidget, {title:"", _action:-1, isContainer:true, _components:{}, _actions:[], gotoAction:function (action) {
23
	this._action = action;
24
}, _nextAction:function (event) {
25
	if ((this._action + 1) != this._actions.length) {
26
		++this._action;
27
		return true;
28
	}
29
	return false;
30
}, _previousAction:function (event) {
31
	if ((this._action - 1) != -1) {
32
		--this._action;
33
		return true;
34
	}
35
	return false;
36
}, htmlTitle:null, debug:false, noClick:false, templateString:"<div class=\"dojoShowSlide\">\n\t<div class=\"dojoShowSlideTitle\">\n\t\t<h1 dojoAttachPoint=\"htmlTitle\">Title</h1>\n\t</div>\n\t<div class=\"dojoShowSlideBody\" dojoAttachPoint=\"containerNode\"></div>\n</div>\n", templateCssString:".dojoShowSlideTitle {\n\theight: 100px;\n\tbackground: #369;\n}\n.dojoShowSlideTitle h1 {\n\tmargin-top: 0;\n\tline-height: 100px;\n\tmargin-left: 30px;\n}\n.dojoShowSlideBody {\n\tmargin: 15px;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/ShowSlide.css"), postCreate:function () {
37
	this.htmlTitle.innerHTML = this.title;
38
	var actions = this.getChildrenOfType("ShowAction", false);
39
	var atypes = {};
40
	dojo.lang.forEach(actions, function (act) {
41
		atypes[act.on] = true;
42
	});
43
	this._components = {};
44
	var cn = this.containerNode;
45
	var nodes = dojo.render.html.ie ? cn.all : cn.getElementsByTagName("*");
46
	dojo.lang.forEach(nodes, function (node) {
47
		var as = node.getAttribute("as");
48
		if (as) {
49
			if (!this._components[as]) {
50
				this._components[as] = [];
51
			}
52
			this._components[as].push(node);
53
			if (!atypes[as]) {
54
				var tmpAction = dojo.widget.createWidget("ShowAction", {on:as});
55
				this.addChild(tmpAction);
56
				atypes[as] = true;
57
			}
58
		}
59
	}, this);
60
	this._actions = [];
61
	actions = this.getChildrenOfType("ShowAction", false);
62
	dojo.lang.forEach(actions, function (child) {
63
		this._actions.push(child);
64
		var components = this._components[child.on];
65
		for (var j = 0, component; component = components[j]; j++) {
66
			if (child["action"] && ((child.action != "remove") && (child.action != "fadeout") && (child.action != "wipeout"))) {
67
				this.hideComponent(component);
68
			}
69
		}
70
	}, this);
71
}, previousAction:function (event) {
72
	if (!this.parent.stopEvent(event)) {
73
		return false;
74
	}
75
	var action = this._actions[this._action];
76
	if (!action) {
77
		return false;
78
	}
79
	var on = action.on;
80
	while (action.on == on) {
81
		var components = this._components[on];
82
		for (var i = 0, component; component = components[i]; i++) {
83
			if ((action.action == "remove") || (action.action == "fadeout") || (action.action == "wipeout")) {
84
				if (component.style.display == "none") {
85
					component.style.display = "";
86
					component.style.visibility = "visible";
87
					var exits = true;
88
				}
89
				dojo.html.setOpacity(component, 1);
90
			} else {
91
				if (action.action) {
92
					this.hideComponent(component);
93
				}
94
			}
95
		}
96
		--this._action;
97
		if (exits) {
98
			return true;
99
		}
100
		if (action.auto == "true") {
101
			on = this._actions[this._action].on;
102
		}
103
		action = this._actions[this._action];
104
		if (!action) {
105
			return false;
106
		}
107
	}
108
	return true;
109
}, hideComponent:function (component) {
110
	component.style.visibility = "hidden";
111
	component.style.backgroundColor = "transparent";
112
	var parent = component.parentNode;
113
	if ((parent) && (parent.tagName.toLowerCase() == "li")) {
114
		parent.oldType = parent.style.listStyleType;
115
		parent.style.listStyleType = "none";
116
	}
117
}, nextAction:function (event) {
118
	if (!this.parent.stopEvent(event)) {
119
		return false;
120
	}
121
	if (!this._nextAction(this)) {
122
		return false;
123
	}
124
	var action = this._actions[this._action];
125
	if (!action) {
126
		return false;
127
	}
128
	var tmpAction = action["action"];
129
	var components = this._components[action.on];
130
	for (var i = 0, component; component = components[i]; i++) {
131
		if (tmpAction) {
132
			var duration = action.duration || 1000;
133
			if ((tmpAction == "fade") || (tmpAction == "fadeIn")) {
134
				dojo.html.setOpacity(component, 0);
135
				dojo.lfx.html.fadeShow(component, duration).play(true);
136
			} else {
137
				if (tmpAction == "fadeout") {
138
					dojo.lfx.html.fadeHide(component, duration).play(true);
139
				} else {
140
					if (tmpAction == "fly") {
141
						var width = dojo.html.getMarginBox(component).width;
142
						var position = dojo.html.getAbsolutePosition(component);
143
						component.style.position = "relative";
144
						component.style.left = -(width + position.x) + "px";
145
						dojo.lfx.html.slideBy(component, {top:0, left:(width + position.x)}, duration, -1, this.callWith).play(true);
146
					} else {
147
						if ((tmpAction == "wipe") || (tmpAction == "wipein")) {
148
							dojo.lfx.html.wipeIn(component, duration).play();
149
						} else {
150
							if (tmpAction == "wipeout") {
151
								dojo.lfx.html.wipeOut(component, duration).play();
152
							} else {
153
								if (tmpAction == "color") {
154
									var from = new dojo.gfx.color.Color(action.from).toRgb();
155
									var to = new dojo.gfx.color.Color(action.to).toRgb();
156
									var anim = new dojo.animation.Animation(new dojo.math.curves.Line(from, to), duration, 0);
157
									var node = component;
158
									dojo.event.connect(anim, "onAnimate", function (e) {
159
										node.style.color = "rgb(" + e.coordsAsInts().join(",") + ")";
160
									});
161
									anim.play(true);
162
								} else {
163
									if (tmpAction == "bgcolor") {
164
										dojo.lfx.html.unhighlight(component, action.to, duration).play();
165
									} else {
166
										if (tmpAction == "remove") {
167
											component.style.display = "none";
168
										}
169
									}
170
								}
171
							}
172
						}
173
					}
174
				}
175
			}
176
			if (tmpAction == "hide") {
177
				component.style.visibility = "hidden";
178
			} else {
179
				component.style.visibility = "visible";
180
			}
181
		}
182
	}
183
	action = this._actions[this._action + 1];
184
	if (action && action.auto == "true") {
185
		this.nextAction();
186
	}
187
	return true;
188
}, callWith:function (node) {
189
	if (!node) {
190
		return;
191
	}
192
	if (dojo.lang.isArray(node)) {
193
		dojo.lang.forEach(node, arguments.callee);
194
		return;
195
	}
196
	var parent = node.parentNode;
197
	if ((parent) && (parent.tagName.toLowerCase() == "li")) {
198
		parent.style.listStyleType = parent.oldType;
199
	}
200
}});
201