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