1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < title > jQuery UI Effects Test Suite</ title >
6+ < link rel ="stylesheet " href ="effects.all.css " type ="text/css ">
7+ < script src ="../../../jquery-1.5.1.js "> </ script >
8+ < script src ="../../../ui/jquery.effects.core.js "> </ script >
9+ < script src ="../../../ui/jquery.effects.scale.js "> </ script >
10+ < script src ="effects.all.js "> </ script >
11+ < script type ="text/javascript " charset ="utf-8 ">
12+ jQuery ( function ( $ ) {
13+ var test = $ ( "#testBox" ) ,
14+ opts = $ ( ".arg" ) ,
15+ optsRev = $ ( opts . get ( ) . reverse ( ) ) ,
16+ doer = $ ( "#doAnim" ) ,
17+ current = $ ( "#current" ) ,
18+ cleanStyle = test [ 0 ] . style ,
19+ total = 1 ;
20+
21+ opts . each ( function ( ) {
22+ total *= this . options . length ;
23+ } ) ;
24+
25+ opts . change ( doAnim ) ;
26+ doer . click ( doAnim ) ;
27+ $ ( "#cyclePrev" ) . click ( function ( ) {
28+ cycle ( - 1 ) ;
29+ } ) ;
30+ $ ( "#cycleNext" ) . click ( function ( ) {
31+ cycle ( 1 ) ;
32+ } ) ;
33+
34+ function cycle ( direction ) {
35+ optsRev . each ( function ( ) {
36+ var cur = this . selectedIndex ,
37+ next = cur + direction ,
38+ len = this . options . length ;
39+
40+ this . selectedIndex = ( next + len ) % len ;
41+
42+ if ( ( next + len ) % len === next ) return false ;
43+ } ) ;
44+ doAnim ( ) ;
45+ }
46+
47+
48+ function doAnim ( ) {
49+ var cur = 0 ;
50+ opts . each ( function ( ) {
51+ cur *= this . options . length
52+ cur += this . selectedIndex ;
53+ } ) ;
54+ cur ++ ;
55+ current . text ( "Configuration: " + cur + " of " + total ) ;
56+ run . apply ( test , opts . map ( function ( ) {
57+ return $ ( this ) . val ( ) ;
58+ } ) . get ( ) ) ;
59+ }
60+
61+ function run ( position , v , h , vo , ho ) {
62+ var el = this ,
63+ style = el [ 0 ] . style ,
64+ effect = {
65+ effect : "scale" ,
66+ mode : "effect" ,
67+ percent : 200 ,
68+ origin : [ vo , ho ] ,
69+ duration : 500
70+ } ;
71+ el . stop ( true , true ) ;
72+ if ( typeof style === "object" ) {
73+ style . cssText = "" ;
74+ } else {
75+ el [ 0 ] . style = "" ;
76+ }
77+ el . css ( "position" , position )
78+ . css ( h , 5 )
79+ . css ( v , 5 )
80+ . delay ( 100 )
81+ . effect ( effect ) ;
82+ }
83+ } ) ;
84+ </ script >
85+ < style type ="text/css ">
86+ # testArea {
87+ /* border: 5px dashed #777;*/
88+ width : 200px ;
89+ height : 200px ;
90+ position : relative;
91+ }
92+ # testBox {
93+ width : 50px ;
94+ height : 50px ;
95+ background-color : # bada55 ;
96+ color : black;
97+ border : 10px solid # fff ;
98+ margin : 10px ;
99+ padding : 10px ;
100+ }
101+ label {
102+ display : block;
103+ }
104+ # controls {
105+ position : absolute;
106+ z-index : 300 ;
107+ left : 50% ;
108+ top : 50% ;
109+ margin-left : -200px ;
110+ width : 400px ;
111+ opacity : 0.8 ;
112+ }
113+ </ style >
114+ </ head >
115+ < body >
116+ < div id ="testArea ">
117+ < div id ="testBox ">
118+ </ div >
119+ </ div >
120+ < div id ="controls ">
121+ < label for ="pos "> Positioning
122+ < select id ="pos " class ="arg ">
123+ < option value ="absolute "> absolute</ option >
124+ < option value ="relative "> relative</ option >
125+ < option value ="fixed "> fixed</ option >
126+ </ select >
127+ </ label >
128+ < label for ="vertPos "> Vertical Positioning
129+ < select id ="vertPos " class ="arg ">
130+ < option value ="top "> top</ option >
131+ < option value ="bottom "> bottom</ option >
132+ </ select >
133+ </ label >
134+ < label for ="horizPos "> Horizontal Positioning
135+ < select id ="horizPos " class ="arg ">
136+ < option value ="left "> left</ option >
137+ < option value ="right "> right</ option >
138+ </ select >
139+ </ label >
140+ < label for ="vertOrigin "> Vertical Origin
141+ < select id ="vertOrigin " class ="arg ">
142+ < option value ="top "> top</ option >
143+ < option value ="middle "> middle</ option >
144+ < option value ="bottom "> bottom</ option >
145+ </ select >
146+ </ label >
147+ < label for ="horizOrigin "> Horizontal Origin
148+ < select id ="horizOrigin " class ="arg ">
149+ < option value ="left "> left</ option >
150+ < option value ="center "> center</ option >
151+ < option value ="right "> right</ option >
152+ </ select >
153+ </ label > < br />
154+ < label id ="current "> jQuery UI Scale Animation Test</ label >
155+ < button id ="cyclePrev "> Back</ button >
156+ < button id ="doAnim "> Run Animation</ button >
157+ < button id ="cycleNext "> Forward</ button >
158+ </ div >
159+ </ body >
0 commit comments