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