Subversion Repositories Applications.papyrus

Rev

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
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.lfx.extras");
14
dojo.require("dojo.lfx.html");
15
dojo.require("dojo.lfx.Animation");
16
dojo.lfx.html.fadeWipeIn = function (nodes, duration, easing, callback) {
17
	nodes = dojo.lfx.html._byId(nodes);
18
	var anim = dojo.lfx.combine(dojo.lfx.fadeIn(nodes, duration, easing), dojo.lfx.wipeIn(nodes, duration, easing));
19
	if (callback) {
20
		anim.connect("onEnd", function () {
21
			callback(nodes, anim);
22
		});
23
	}
24
	return anim;
25
};
26
dojo.lfx.html.fadeWipeOut = function (nodes, duration, easing, callback) {
27
	nodes = dojo.lfx.html._byId(nodes);
28
	var anim = dojo.lfx.combine(dojo.lfx.fadeOut(nodes, duration, easing), dojo.lfx.wipeOut(nodes, duration, easing));
29
	if (callback) {
30
		anim.connect("onEnd", function () {
31
			callback(nodes, anim);
32
		});
33
	}
34
	return anim;
35
};
36
dojo.lfx.html.scale = function (nodes, percentage, scaleContent, fromCenter, duration, easing, callback) {
37
	nodes = dojo.lfx.html._byId(nodes);
38
	var anims = [];
39
	dojo.lang.forEach(nodes, function (node) {
40
		var outer = dojo.html.getMarginBox(node);
41
		var actualPct = percentage / 100;
42
		var props = [{property:"width", start:outer.width, end:outer.width * actualPct}, {property:"height", start:outer.height, end:outer.height * actualPct}];
43
		if (scaleContent) {
44
			var fontSize = dojo.html.getStyle(node, "font-size");
45
			var fontSizeType = null;
46
			if (!fontSize) {
47
				fontSize = parseFloat("100%");
48
				fontSizeType = "%";
49
			} else {
50
				dojo.lang.some(["em", "px", "%"], function (item, index, arr) {
51
					if (fontSize.indexOf(item) > 0) {
52
						fontSize = parseFloat(fontSize);
53
						fontSizeType = item;
54
						return true;
55
					}
56
				});
57
			}
58
			props.push({property:"font-size", start:fontSize, end:fontSize * actualPct, units:fontSizeType});
59
		}
60
		if (fromCenter) {
61
			var positioning = dojo.html.getStyle(node, "position");
62
			var originalTop = node.offsetTop;
63
			var originalLeft = node.offsetLeft;
64
			var endTop = ((outer.height * actualPct) - outer.height) / 2;
65
			var endLeft = ((outer.width * actualPct) - outer.width) / 2;
66
			props.push({property:"top", start:originalTop, end:(positioning == "absolute" ? originalTop - endTop : (-1 * endTop))});
67
			props.push({property:"left", start:originalLeft, end:(positioning == "absolute" ? originalLeft - endLeft : (-1 * endLeft))});
68
		}
69
		var anim = dojo.lfx.propertyAnimation(node, props, duration, easing);
70
		if (callback) {
71
			anim.connect("onEnd", function () {
72
				callback(node, anim);
73
			});
74
		}
75
		anims.push(anim);
76
	});
77
	return dojo.lfx.combine(anims);
78
};
79
dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
80