aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/effects/effects_scale.js
blob: 6abbcb5382f740f7201a04dfe061678ed985d559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(function( $ ) {
module( "effect.scale: Scale" );

function run( position, v, h, vo, ho ) {
	var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
	asyncTest( desc, function() {
		expect( 2 );
		function complete() {
			equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
			equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
			start();
		}
		var test = $( ".testScale" ),
			css = {
				position: position
			},
			effect = {
				effect: "scale",
				mode: "effect",
				percent: 200,
				origin: [ vo, ho ],
				complete: complete,
				duration: 1
			},
			target = {},
			relative = position === "relative";

		css[ h ] = 33;
		css[ v ] = 33;
		target[ h ] = h === ho ? css[ h ] : ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
		target[ v ] = v === vo ? css[ v ] : vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
		if ( relative && h === "right" ) {
			target[ h ] += 70;
		}
		if ( relative && v === "bottom" ) {
			target[ v ] += 70;
		}
		test.css( css );
		test.effect( effect );
	});
}

function suite( position ) {
	run( position, "top", "left", "top", "left" );
	run( position, "top", "left", "middle", "center" );
	run( position, "top", "left", "bottom", "right" );
	/* Firefox is currently not capable of supporting detection of bottom and right....
	run( position, "bottom", "right", "top", "left" );
	run( position, "bottom", "right", "middle", "center" );
	run( position, "bottom", "right", "bottom", "right" );
	*/
}

$(function() {
	suite( "absolute" );
	suite( "relative" );
	var fixedElem = $( "<div>" )
		.css({
			position: "fixed",
			top: 10
		})
		.appendTo( "body" );
	if ( fixedElem.offset().top === 10 ) {
		suite( "fixed" );
	}
});

})( jQuery );