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.lfx.html");
|
|
|
14 |
dojo.require("dojo.gfx.color");
|
|
|
15 |
dojo.require("dojo.lfx.Animation");
|
|
|
16 |
dojo.require("dojo.lang.array");
|
|
|
17 |
dojo.require("dojo.html.display");
|
|
|
18 |
dojo.require("dojo.html.color");
|
|
|
19 |
dojo.require("dojo.html.layout");
|
|
|
20 |
dojo.lfx.html._byId = function (nodes) {
|
|
|
21 |
if (!nodes) {
|
|
|
22 |
return [];
|
|
|
23 |
}
|
|
|
24 |
if (dojo.lang.isArrayLike(nodes)) {
|
|
|
25 |
if (!nodes.alreadyChecked) {
|
|
|
26 |
var n = [];
|
|
|
27 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
28 |
n.push(dojo.byId(node));
|
|
|
29 |
});
|
|
|
30 |
n.alreadyChecked = true;
|
|
|
31 |
return n;
|
|
|
32 |
} else {
|
|
|
33 |
return nodes;
|
|
|
34 |
}
|
|
|
35 |
} else {
|
|
|
36 |
var n = [];
|
|
|
37 |
n.push(dojo.byId(nodes));
|
|
|
38 |
n.alreadyChecked = true;
|
|
|
39 |
return n;
|
|
|
40 |
}
|
|
|
41 |
};
|
|
|
42 |
dojo.lfx.html.propertyAnimation = function (nodes, propertyMap, duration, easing, handlers) {
|
|
|
43 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
44 |
var targs = {"propertyMap":propertyMap, "nodes":nodes, "duration":duration, "easing":easing || dojo.lfx.easeDefault};
|
|
|
45 |
var setEmUp = function (args) {
|
|
|
46 |
if (args.nodes.length == 1) {
|
|
|
47 |
var pm = args.propertyMap;
|
|
|
48 |
if (!dojo.lang.isArray(args.propertyMap)) {
|
|
|
49 |
var parr = [];
|
|
|
50 |
for (var pname in pm) {
|
|
|
51 |
pm[pname].property = pname;
|
|
|
52 |
parr.push(pm[pname]);
|
|
|
53 |
}
|
|
|
54 |
pm = args.propertyMap = parr;
|
|
|
55 |
}
|
|
|
56 |
dojo.lang.forEach(pm, function (prop) {
|
|
|
57 |
if (dj_undef("start", prop)) {
|
|
|
58 |
if (prop.property != "opacity") {
|
|
|
59 |
prop.start = parseInt(dojo.html.getComputedStyle(args.nodes[0], prop.property));
|
|
|
60 |
} else {
|
|
|
61 |
prop.start = dojo.html.getOpacity(args.nodes[0]);
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
});
|
|
|
65 |
}
|
|
|
66 |
};
|
|
|
67 |
var coordsAsInts = function (coords) {
|
|
|
68 |
var cints = [];
|
|
|
69 |
dojo.lang.forEach(coords, function (c) {
|
|
|
70 |
cints.push(Math.round(c));
|
|
|
71 |
});
|
|
|
72 |
return cints;
|
|
|
73 |
};
|
|
|
74 |
var setStyle = function (n, style) {
|
|
|
75 |
n = dojo.byId(n);
|
|
|
76 |
if (!n || !n.style) {
|
|
|
77 |
return;
|
|
|
78 |
}
|
|
|
79 |
for (var s in style) {
|
|
|
80 |
try {
|
|
|
81 |
if (s == "opacity") {
|
|
|
82 |
dojo.html.setOpacity(n, style[s]);
|
|
|
83 |
} else {
|
|
|
84 |
n.style[s] = style[s];
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
catch (e) {
|
|
|
88 |
dojo.debug(e);
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
};
|
|
|
92 |
var propLine = function (properties) {
|
|
|
93 |
this._properties = properties;
|
|
|
94 |
this.diffs = new Array(properties.length);
|
|
|
95 |
dojo.lang.forEach(properties, function (prop, i) {
|
|
|
96 |
if (dojo.lang.isFunction(prop.start)) {
|
|
|
97 |
prop.start = prop.start(prop, i);
|
|
|
98 |
}
|
|
|
99 |
if (dojo.lang.isFunction(prop.end)) {
|
|
|
100 |
prop.end = prop.end(prop, i);
|
|
|
101 |
}
|
|
|
102 |
if (dojo.lang.isArray(prop.start)) {
|
|
|
103 |
this.diffs[i] = null;
|
|
|
104 |
} else {
|
|
|
105 |
if (prop.start instanceof dojo.gfx.color.Color) {
|
|
|
106 |
prop.startRgb = prop.start.toRgb();
|
|
|
107 |
prop.endRgb = prop.end.toRgb();
|
|
|
108 |
} else {
|
|
|
109 |
this.diffs[i] = prop.end - prop.start;
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
}, this);
|
|
|
113 |
this.getValue = function (n) {
|
|
|
114 |
var ret = {};
|
|
|
115 |
dojo.lang.forEach(this._properties, function (prop, i) {
|
|
|
116 |
var value = null;
|
|
|
117 |
if (dojo.lang.isArray(prop.start)) {
|
|
|
118 |
} else {
|
|
|
119 |
if (prop.start instanceof dojo.gfx.color.Color) {
|
|
|
120 |
value = (prop.units || "rgb") + "(";
|
|
|
121 |
for (var j = 0; j < prop.startRgb.length; j++) {
|
|
|
122 |
value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : "");
|
|
|
123 |
}
|
|
|
124 |
value += ")";
|
|
|
125 |
} else {
|
|
|
126 |
value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units || "px" : "");
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
ret[dojo.html.toCamelCase(prop.property)] = value;
|
|
|
130 |
}, this);
|
|
|
131 |
return ret;
|
|
|
132 |
};
|
|
|
133 |
};
|
|
|
134 |
var anim = new dojo.lfx.Animation({beforeBegin:function () {
|
|
|
135 |
setEmUp(targs);
|
|
|
136 |
anim.curve = new propLine(targs.propertyMap);
|
|
|
137 |
}, onAnimate:function (propValues) {
|
|
|
138 |
dojo.lang.forEach(targs.nodes, function (node) {
|
|
|
139 |
setStyle(node, propValues);
|
|
|
140 |
});
|
|
|
141 |
}}, targs.duration, null, targs.easing);
|
|
|
142 |
if (handlers) {
|
|
|
143 |
for (var x in handlers) {
|
|
|
144 |
if (dojo.lang.isFunction(handlers[x])) {
|
|
|
145 |
anim.connect(x, anim, handlers[x]);
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
return anim;
|
|
|
150 |
};
|
|
|
151 |
dojo.lfx.html._makeFadeable = function (nodes) {
|
|
|
152 |
var makeFade = function (node) {
|
|
|
153 |
if (dojo.render.html.ie) {
|
|
|
154 |
if ((node.style.zoom.length == 0) && (dojo.html.getStyle(node, "zoom") == "normal")) {
|
|
|
155 |
node.style.zoom = "1";
|
|
|
156 |
}
|
|
|
157 |
if ((node.style.width.length == 0) && (dojo.html.getStyle(node, "width") == "auto")) {
|
|
|
158 |
node.style.width = "auto";
|
|
|
159 |
}
|
|
|
160 |
}
|
|
|
161 |
};
|
|
|
162 |
if (dojo.lang.isArrayLike(nodes)) {
|
|
|
163 |
dojo.lang.forEach(nodes, makeFade);
|
|
|
164 |
} else {
|
|
|
165 |
makeFade(nodes);
|
|
|
166 |
}
|
|
|
167 |
};
|
|
|
168 |
dojo.lfx.html.fade = function (nodes, values, duration, easing, callback) {
|
|
|
169 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
170 |
var props = {property:"opacity"};
|
|
|
171 |
if (!dj_undef("start", values)) {
|
|
|
172 |
props.start = values.start;
|
|
|
173 |
} else {
|
|
|
174 |
props.start = function () {
|
|
|
175 |
return dojo.html.getOpacity(nodes[0]);
|
|
|
176 |
};
|
|
|
177 |
}
|
|
|
178 |
if (!dj_undef("end", values)) {
|
|
|
179 |
props.end = values.end;
|
|
|
180 |
} else {
|
|
|
181 |
dojo.raise("dojo.lfx.html.fade needs an end value");
|
|
|
182 |
}
|
|
|
183 |
var anim = dojo.lfx.propertyAnimation(nodes, [props], duration, easing);
|
|
|
184 |
anim.connect("beforeBegin", function () {
|
|
|
185 |
dojo.lfx.html._makeFadeable(nodes);
|
|
|
186 |
});
|
|
|
187 |
if (callback) {
|
|
|
188 |
anim.connect("onEnd", function () {
|
|
|
189 |
callback(nodes, anim);
|
|
|
190 |
});
|
|
|
191 |
}
|
|
|
192 |
return anim;
|
|
|
193 |
};
|
|
|
194 |
dojo.lfx.html.fadeIn = function (nodes, duration, easing, callback) {
|
|
|
195 |
return dojo.lfx.html.fade(nodes, {end:1}, duration, easing, callback);
|
|
|
196 |
};
|
|
|
197 |
dojo.lfx.html.fadeOut = function (nodes, duration, easing, callback) {
|
|
|
198 |
return dojo.lfx.html.fade(nodes, {end:0}, duration, easing, callback);
|
|
|
199 |
};
|
|
|
200 |
dojo.lfx.html.fadeShow = function (nodes, duration, easing, callback) {
|
|
|
201 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
202 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
203 |
dojo.html.setOpacity(node, 0);
|
|
|
204 |
});
|
|
|
205 |
var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback);
|
|
|
206 |
anim.connect("beforeBegin", function () {
|
|
|
207 |
if (dojo.lang.isArrayLike(nodes)) {
|
|
|
208 |
dojo.lang.forEach(nodes, dojo.html.show);
|
|
|
209 |
} else {
|
|
|
210 |
dojo.html.show(nodes);
|
|
|
211 |
}
|
|
|
212 |
});
|
|
|
213 |
return anim;
|
|
|
214 |
};
|
|
|
215 |
dojo.lfx.html.fadeHide = function (nodes, duration, easing, callback) {
|
|
|
216 |
var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function () {
|
|
|
217 |
if (dojo.lang.isArrayLike(nodes)) {
|
|
|
218 |
dojo.lang.forEach(nodes, dojo.html.hide);
|
|
|
219 |
} else {
|
|
|
220 |
dojo.html.hide(nodes);
|
|
|
221 |
}
|
|
|
222 |
if (callback) {
|
|
|
223 |
callback(nodes, anim);
|
|
|
224 |
}
|
|
|
225 |
});
|
|
|
226 |
return anim;
|
|
|
227 |
};
|
|
|
228 |
dojo.lfx.html.wipeIn = function (nodes, duration, easing, callback) {
|
|
|
229 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
230 |
var anims = [];
|
|
|
231 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
232 |
var oprop = {};
|
|
|
233 |
var origTop, origLeft, origPosition;
|
|
|
234 |
with (node.style) {
|
|
|
235 |
origTop = top;
|
|
|
236 |
origLeft = left;
|
|
|
237 |
origPosition = position;
|
|
|
238 |
top = "-9999px";
|
|
|
239 |
left = "-9999px";
|
|
|
240 |
position = "absolute";
|
|
|
241 |
display = "";
|
|
|
242 |
}
|
|
|
243 |
var nodeHeight = dojo.html.getBorderBox(node).height;
|
|
|
244 |
with (node.style) {
|
|
|
245 |
top = origTop;
|
|
|
246 |
left = origLeft;
|
|
|
247 |
position = origPosition;
|
|
|
248 |
display = "none";
|
|
|
249 |
}
|
|
|
250 |
var anim = dojo.lfx.propertyAnimation(node, {"height":{start:1, end:function () {
|
|
|
251 |
return nodeHeight;
|
|
|
252 |
}}}, duration, easing);
|
|
|
253 |
anim.connect("beforeBegin", function () {
|
|
|
254 |
oprop.overflow = node.style.overflow;
|
|
|
255 |
oprop.height = node.style.height;
|
|
|
256 |
with (node.style) {
|
|
|
257 |
overflow = "hidden";
|
|
|
258 |
height = "1px";
|
|
|
259 |
}
|
|
|
260 |
dojo.html.show(node);
|
|
|
261 |
});
|
|
|
262 |
anim.connect("onEnd", function () {
|
|
|
263 |
with (node.style) {
|
|
|
264 |
overflow = oprop.overflow;
|
|
|
265 |
height = oprop.height;
|
|
|
266 |
}
|
|
|
267 |
if (callback) {
|
|
|
268 |
callback(node, anim);
|
|
|
269 |
}
|
|
|
270 |
});
|
|
|
271 |
anims.push(anim);
|
|
|
272 |
});
|
|
|
273 |
return dojo.lfx.combine(anims);
|
|
|
274 |
};
|
|
|
275 |
dojo.lfx.html.wipeOut = function (nodes, duration, easing, callback) {
|
|
|
276 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
277 |
var anims = [];
|
|
|
278 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
279 |
var oprop = {};
|
|
|
280 |
var anim = dojo.lfx.propertyAnimation(node, {"height":{start:function () {
|
|
|
281 |
return dojo.html.getContentBox(node).height;
|
|
|
282 |
}, end:1}}, duration, easing, {"beforeBegin":function () {
|
|
|
283 |
oprop.overflow = node.style.overflow;
|
|
|
284 |
oprop.height = node.style.height;
|
|
|
285 |
with (node.style) {
|
|
|
286 |
overflow = "hidden";
|
|
|
287 |
}
|
|
|
288 |
dojo.html.show(node);
|
|
|
289 |
}, "onEnd":function () {
|
|
|
290 |
dojo.html.hide(node);
|
|
|
291 |
with (node.style) {
|
|
|
292 |
overflow = oprop.overflow;
|
|
|
293 |
height = oprop.height;
|
|
|
294 |
}
|
|
|
295 |
if (callback) {
|
|
|
296 |
callback(node, anim);
|
|
|
297 |
}
|
|
|
298 |
}});
|
|
|
299 |
anims.push(anim);
|
|
|
300 |
});
|
|
|
301 |
return dojo.lfx.combine(anims);
|
|
|
302 |
};
|
|
|
303 |
dojo.lfx.html.slideTo = function (nodes, coords, duration, easing, callback) {
|
|
|
304 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
305 |
var anims = [];
|
|
|
306 |
var compute = dojo.html.getComputedStyle;
|
|
|
307 |
if (dojo.lang.isArray(coords)) {
|
|
|
308 |
dojo.deprecated("dojo.lfx.html.slideTo(node, array)", "use dojo.lfx.html.slideTo(node, {top: value, left: value});", "0.5");
|
|
|
309 |
coords = {top:coords[0], left:coords[1]};
|
|
|
310 |
}
|
|
|
311 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
312 |
var top = null;
|
|
|
313 |
var left = null;
|
|
|
314 |
var init = (function () {
|
|
|
315 |
var innerNode = node;
|
|
|
316 |
return function () {
|
|
|
317 |
var pos = compute(innerNode, "position");
|
|
|
318 |
top = (pos == "absolute" ? node.offsetTop : parseInt(compute(node, "top")) || 0);
|
|
|
319 |
left = (pos == "absolute" ? node.offsetLeft : parseInt(compute(node, "left")) || 0);
|
|
|
320 |
if (!dojo.lang.inArray(["absolute", "relative"], pos)) {
|
|
|
321 |
var ret = dojo.html.abs(innerNode, true);
|
|
|
322 |
dojo.html.setStyleAttributes(innerNode, "position:absolute;top:" + ret.y + "px;left:" + ret.x + "px;");
|
|
|
323 |
top = ret.y;
|
|
|
324 |
left = ret.x;
|
|
|
325 |
}
|
|
|
326 |
};
|
|
|
327 |
})();
|
|
|
328 |
init();
|
|
|
329 |
var anim = dojo.lfx.propertyAnimation(node, {"top":{start:top, end:(coords.top || 0)}, "left":{start:left, end:(coords.left || 0)}}, duration, easing, {"beforeBegin":init});
|
|
|
330 |
if (callback) {
|
|
|
331 |
anim.connect("onEnd", function () {
|
|
|
332 |
callback(nodes, anim);
|
|
|
333 |
});
|
|
|
334 |
}
|
|
|
335 |
anims.push(anim);
|
|
|
336 |
});
|
|
|
337 |
return dojo.lfx.combine(anims);
|
|
|
338 |
};
|
|
|
339 |
dojo.lfx.html.slideBy = function (nodes, coords, duration, easing, callback) {
|
|
|
340 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
341 |
var anims = [];
|
|
|
342 |
var compute = dojo.html.getComputedStyle;
|
|
|
343 |
if (dojo.lang.isArray(coords)) {
|
|
|
344 |
dojo.deprecated("dojo.lfx.html.slideBy(node, array)", "use dojo.lfx.html.slideBy(node, {top: value, left: value});", "0.5");
|
|
|
345 |
coords = {top:coords[0], left:coords[1]};
|
|
|
346 |
}
|
|
|
347 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
348 |
var top = null;
|
|
|
349 |
var left = null;
|
|
|
350 |
var init = (function () {
|
|
|
351 |
var innerNode = node;
|
|
|
352 |
return function () {
|
|
|
353 |
var pos = compute(innerNode, "position");
|
|
|
354 |
top = (pos == "absolute" ? node.offsetTop : parseInt(compute(node, "top")) || 0);
|
|
|
355 |
left = (pos == "absolute" ? node.offsetLeft : parseInt(compute(node, "left")) || 0);
|
|
|
356 |
if (!dojo.lang.inArray(["absolute", "relative"], pos)) {
|
|
|
357 |
var ret = dojo.html.abs(innerNode, true);
|
|
|
358 |
dojo.html.setStyleAttributes(innerNode, "position:absolute;top:" + ret.y + "px;left:" + ret.x + "px;");
|
|
|
359 |
top = ret.y;
|
|
|
360 |
left = ret.x;
|
|
|
361 |
}
|
|
|
362 |
};
|
|
|
363 |
})();
|
|
|
364 |
init();
|
|
|
365 |
var anim = dojo.lfx.propertyAnimation(node, {"top":{start:top, end:top + (coords.top || 0)}, "left":{start:left, end:left + (coords.left || 0)}}, duration, easing).connect("beforeBegin", init);
|
|
|
366 |
if (callback) {
|
|
|
367 |
anim.connect("onEnd", function () {
|
|
|
368 |
callback(nodes, anim);
|
|
|
369 |
});
|
|
|
370 |
}
|
|
|
371 |
anims.push(anim);
|
|
|
372 |
});
|
|
|
373 |
return dojo.lfx.combine(anims);
|
|
|
374 |
};
|
|
|
375 |
dojo.lfx.html.explode = function (start, endNode, duration, easing, callback) {
|
|
|
376 |
var h = dojo.html;
|
|
|
377 |
start = dojo.byId(start);
|
|
|
378 |
endNode = dojo.byId(endNode);
|
|
|
379 |
var startCoords = h.toCoordinateObject(start, true);
|
|
|
380 |
var outline = document.createElement("div");
|
|
|
381 |
h.copyStyle(outline, endNode);
|
|
|
382 |
if (endNode.explodeClassName) {
|
|
|
383 |
outline.className = endNode.explodeClassName;
|
|
|
384 |
}
|
|
|
385 |
with (outline.style) {
|
|
|
386 |
position = "absolute";
|
|
|
387 |
display = "none";
|
|
|
388 |
var backgroundStyle = h.getStyle(start, "background-color");
|
|
|
389 |
backgroundColor = backgroundStyle ? backgroundStyle.toLowerCase() : "transparent";
|
|
|
390 |
backgroundColor = (backgroundColor == "transparent") ? "rgb(221, 221, 221)" : backgroundColor;
|
|
|
391 |
}
|
|
|
392 |
dojo.body().appendChild(outline);
|
|
|
393 |
with (endNode.style) {
|
|
|
394 |
visibility = "hidden";
|
|
|
395 |
display = "block";
|
|
|
396 |
}
|
|
|
397 |
var endCoords = h.toCoordinateObject(endNode, true);
|
|
|
398 |
with (endNode.style) {
|
|
|
399 |
display = "none";
|
|
|
400 |
visibility = "visible";
|
|
|
401 |
}
|
|
|
402 |
var props = {opacity:{start:0.5, end:1}};
|
|
|
403 |
dojo.lang.forEach(["height", "width", "top", "left"], function (type) {
|
|
|
404 |
props[type] = {start:startCoords[type], end:endCoords[type]};
|
|
|
405 |
});
|
|
|
406 |
var anim = new dojo.lfx.propertyAnimation(outline, props, duration, easing, {"beforeBegin":function () {
|
|
|
407 |
h.setDisplay(outline, "block");
|
|
|
408 |
}, "onEnd":function () {
|
|
|
409 |
h.setDisplay(endNode, "block");
|
|
|
410 |
outline.parentNode.removeChild(outline);
|
|
|
411 |
}});
|
|
|
412 |
if (callback) {
|
|
|
413 |
anim.connect("onEnd", function () {
|
|
|
414 |
callback(endNode, anim);
|
|
|
415 |
});
|
|
|
416 |
}
|
|
|
417 |
return anim;
|
|
|
418 |
};
|
|
|
419 |
dojo.lfx.html.implode = function (startNode, end, duration, easing, callback) {
|
|
|
420 |
var h = dojo.html;
|
|
|
421 |
startNode = dojo.byId(startNode);
|
|
|
422 |
end = dojo.byId(end);
|
|
|
423 |
var startCoords = dojo.html.toCoordinateObject(startNode, true);
|
|
|
424 |
var endCoords = dojo.html.toCoordinateObject(end, true);
|
|
|
425 |
var outline = document.createElement("div");
|
|
|
426 |
dojo.html.copyStyle(outline, startNode);
|
|
|
427 |
if (startNode.explodeClassName) {
|
|
|
428 |
outline.className = startNode.explodeClassName;
|
|
|
429 |
}
|
|
|
430 |
dojo.html.setOpacity(outline, 0.3);
|
|
|
431 |
with (outline.style) {
|
|
|
432 |
position = "absolute";
|
|
|
433 |
display = "none";
|
|
|
434 |
backgroundColor = h.getStyle(startNode, "background-color").toLowerCase();
|
|
|
435 |
}
|
|
|
436 |
dojo.body().appendChild(outline);
|
|
|
437 |
var props = {opacity:{start:1, end:0.5}};
|
|
|
438 |
dojo.lang.forEach(["height", "width", "top", "left"], function (type) {
|
|
|
439 |
props[type] = {start:startCoords[type], end:endCoords[type]};
|
|
|
440 |
});
|
|
|
441 |
var anim = new dojo.lfx.propertyAnimation(outline, props, duration, easing, {"beforeBegin":function () {
|
|
|
442 |
dojo.html.hide(startNode);
|
|
|
443 |
dojo.html.show(outline);
|
|
|
444 |
}, "onEnd":function () {
|
|
|
445 |
outline.parentNode.removeChild(outline);
|
|
|
446 |
}});
|
|
|
447 |
if (callback) {
|
|
|
448 |
anim.connect("onEnd", function () {
|
|
|
449 |
callback(startNode, anim);
|
|
|
450 |
});
|
|
|
451 |
}
|
|
|
452 |
return anim;
|
|
|
453 |
};
|
|
|
454 |
dojo.lfx.html.highlight = function (nodes, startColor, duration, easing, callback) {
|
|
|
455 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
456 |
var anims = [];
|
|
|
457 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
458 |
var color = dojo.html.getBackgroundColor(node);
|
|
|
459 |
var bg = dojo.html.getStyle(node, "background-color").toLowerCase();
|
|
|
460 |
var bgImage = dojo.html.getStyle(node, "background-image");
|
|
|
461 |
var wasTransparent = (bg == "transparent" || bg == "rgba(0, 0, 0, 0)");
|
|
|
462 |
while (color.length > 3) {
|
|
|
463 |
color.pop();
|
|
|
464 |
}
|
|
|
465 |
var rgb = new dojo.gfx.color.Color(startColor);
|
|
|
466 |
var endRgb = new dojo.gfx.color.Color(color);
|
|
|
467 |
var anim = dojo.lfx.propertyAnimation(node, {"background-color":{start:rgb, end:endRgb}}, duration, easing, {"beforeBegin":function () {
|
|
|
468 |
if (bgImage) {
|
|
|
469 |
node.style.backgroundImage = "none";
|
|
|
470 |
}
|
|
|
471 |
node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")";
|
|
|
472 |
}, "onEnd":function () {
|
|
|
473 |
if (bgImage) {
|
|
|
474 |
node.style.backgroundImage = bgImage;
|
|
|
475 |
}
|
|
|
476 |
if (wasTransparent) {
|
|
|
477 |
node.style.backgroundColor = "transparent";
|
|
|
478 |
}
|
|
|
479 |
if (callback) {
|
|
|
480 |
callback(node, anim);
|
|
|
481 |
}
|
|
|
482 |
}});
|
|
|
483 |
anims.push(anim);
|
|
|
484 |
});
|
|
|
485 |
return dojo.lfx.combine(anims);
|
|
|
486 |
};
|
|
|
487 |
dojo.lfx.html.unhighlight = function (nodes, endColor, duration, easing, callback) {
|
|
|
488 |
nodes = dojo.lfx.html._byId(nodes);
|
|
|
489 |
var anims = [];
|
|
|
490 |
dojo.lang.forEach(nodes, function (node) {
|
|
|
491 |
var color = new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node));
|
|
|
492 |
var rgb = new dojo.gfx.color.Color(endColor);
|
|
|
493 |
var bgImage = dojo.html.getStyle(node, "background-image");
|
|
|
494 |
var anim = dojo.lfx.propertyAnimation(node, {"background-color":{start:color, end:rgb}}, duration, easing, {"beforeBegin":function () {
|
|
|
495 |
if (bgImage) {
|
|
|
496 |
node.style.backgroundImage = "none";
|
|
|
497 |
}
|
|
|
498 |
node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")";
|
|
|
499 |
}, "onEnd":function () {
|
|
|
500 |
if (callback) {
|
|
|
501 |
callback(node, anim);
|
|
|
502 |
}
|
|
|
503 |
}});
|
|
|
504 |
anims.push(anim);
|
|
|
505 |
});
|
|
|
506 |
return dojo.lfx.combine(anims);
|
|
|
507 |
};
|
|
|
508 |
dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
|
|
|
509 |
|