6abbcb5382f740f7201a04dfe061678ed985d559
[myslice.git] / third-party / jquery-ui-1.10.2 / tests / unit / effects / effects_scale.js
1 (function( $ ) {
2 module( "effect.scale: Scale" );
3
4 function run( position, v, h, vo, ho ) {
5         var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
6         asyncTest( desc, function() {
7                 expect( 2 );
8                 function complete() {
9                         equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
10                         equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
11                         start();
12                 }
13                 var test = $( ".testScale" ),
14                         css = {
15                                 position: position
16                         },
17                         effect = {
18                                 effect: "scale",
19                                 mode: "effect",
20                                 percent: 200,
21                                 origin: [ vo, ho ],
22                                 complete: complete,
23                                 duration: 1
24                         },
25                         target = {},
26                         relative = position === "relative";
27
28                 css[ h ] = 33;
29                 css[ v ] = 33;
30                 target[ h ] = h === ho ? css[ h ] : ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
31                 target[ v ] = v === vo ? css[ v ] : vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
32                 if ( relative && h === "right" ) {
33                         target[ h ] += 70;
34                 }
35                 if ( relative && v === "bottom" ) {
36                         target[ v ] += 70;
37                 }
38                 test.css( css );
39                 test.effect( effect );
40         });
41 }
42
43 function suite( position ) {
44         run( position, "top", "left", "top", "left" );
45         run( position, "top", "left", "middle", "center" );
46         run( position, "top", "left", "bottom", "right" );
47         /* Firefox is currently not capable of supporting detection of bottom and right....
48         run( position, "bottom", "right", "top", "left" );
49         run( position, "bottom", "right", "middle", "center" );
50         run( position, "bottom", "right", "bottom", "right" );
51         */
52 }
53
54 $(function() {
55         suite( "absolute" );
56         suite( "relative" );
57         var fixedElem = $( "<div>" )
58                 .css({
59                         position: "fixed",
60                         top: 10
61                 })
62                 .appendTo( "body" );
63         if ( fixedElem.offset().top === 10 ) {
64                 suite( "fixed" );
65         }
66 });
67
68 })( jQuery );