1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>Animation Test Suite</title>
6 <script src="../dist/jquery.js"></script>
17 background: red url(cow.jpg) no-repeat;
19 border: 2px solid #000;
22 div#tests div.overflow {
51 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
64 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
77 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
84 div#tests div.widewidth {
85 background-repeat: repeat-x;
88 div#tests div.wideheight {
89 background-repeat: repeat-y;
92 div#tests div.widewidth.wideheight {
93 background-repeat: repeat;
96 div#tests div.noback {
97 background-image: none;
100 div.chain, div.chain div { width: 100px; height: 20px; position: relative; float: left; }
101 div.chain div { position: absolute; top: 0px; left: 0px; }
103 div.chain.test { background: red; }
104 div.chain.test div { background: green; }
106 div.chain.out { background: green; }
107 div.chain.out div { background: red; display: none; }
111 Normal: function(elem){},
112 "CSS Hidden": function(elem){
113 $(this).addClass("hidden");
115 "JS Hidden": function(elem){
121 "CSS Auto": function(elem,prop){
122 $(elem).addClass("auto" + prop)
123 .text("This is a long string of text.");
126 "JS Auto": function(elem,prop){
127 $(elem).css(prop,"auto")
128 .text("This is a long string of text.");
131 "CSS 100": function(elem,prop){
132 $(elem).addClass("large" + prop);
135 "JS 100": function(elem,prop){
136 $(elem).css(prop,prop == "opacity" ? 1 : "100px");
137 return prop == "opacity" ? 1 : 100;
139 "CSS 50": function(elem,prop){
140 $(elem).addClass("med" + prop);
143 "JS 50": function(elem,prop){
144 $(elem).css(prop,prop == "opacity" ? 0.50 : "50px");
145 return prop == "opacity" ? 0.5 : 50;
147 "CSS 0": function(elem,prop){
148 $(elem).addClass("no" + prop);
151 "JS 0": function(elem,prop){
152 $(elem).css(prop,prop == "opacity" ? 0 : "0px");
158 /*"Auto": function(elem,prop){
159 $(elem).addClass("wide"+prop);
162 /*"toggle (show)": function(elem,prop){
163 $(elem).hide().addClass("wide"+prop);
166 "show": function(elem,prop){
167 $(elem).hide().addClass("wide"+prop);
170 "hide": function(elem,prop){
171 $(elem).addClass("wide"+prop);
174 "100": function(elem,prop){
175 $(elem).addClass("wide"+prop);
176 return prop == "opacity" ? 1 : 100;
178 "50": function(elem,prop){
179 return prop == "opacity" ? 0.50 : 50;
181 "0": function(elem,prop){
182 $(elem).addClass("noback");
187 /*var oldAttr = jQuery.attr;
189 jQuery.attr = function( elem, name, value ){
190 if ( arguments.length == 3 ) {
191 var prev = elem.previousSibling;
192 if ( prev && prev.nodeName == "UL" ) {
193 $(prev).append( name + ": " + value );
197 return oldAttr.apply( jQuery, arguments );
200 $(document).ready(function(){
201 makeTest( "JS Overflow and Display" )
202 .addClass("widewidth")
203 .css({ overflow: "visible", display: "inline" })
204 .add( makeTest( "CSS Overflow and Display" ).addClass("overflow inline") )
205 .addClass("widewidth")
206 .text("Some sample text.")
207 .before("text before")
209 .animate({ opacity: 0.5 }, "slow", function(){
210 var o = jQuery.css( this, "overflow" );
211 if ( o != "visible" )
212 return msg(this, "Overflow should be visible: " + o);
214 if ( jQuery.css( this, "display" ) != "inline" )
215 return msg(this, "Display has been tampered with.");
220 jQuery.each( from, function(fn, f){
221 jQuery.each( to, function(tn, t){
222 var elem = makeTest( fn + " to " + tn );
224 var t_w = t( elem, "width" );
225 var f_w = f( elem, "width" );
226 var t_h = t( elem, "height" );
227 var f_h = f( elem, "height" );
228 var t_o = t( elem, "opacity" );
229 var f_o = f( elem, "opacity" );
231 var anim = { width: t_w, height: t_h, opacity: t_o };
233 elem.animate(anim, "slow", function(){
234 if ( t_w == "show" && this.style.display != "block" )
235 return msg(this, "Showing, display not block: " + this.style.display);
237 if ( (t_w == "hide"||t_w == "show") && this.style.width.indexOf(f_w) != 0 )
238 return msg(this, "Width not reset to " + f_w + ": " + this.style.width);
240 if ( (t_h == "hide"||t_h == "show") && this.style.height.indexOf(f_h) != 0 )
241 return msg(this, "Height not reset to " + f_h + ": " + this.style.height);
243 var cur_o = jQuery.attr(this.style, "opacity");
244 if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
246 if ( (t_o == "hide"||t_o == "show") && cur_o != f_o ) {
247 return msg(this, "Opacity not reset to " + f_o + ": " + cur_o);
250 if ( t_w == "hide" && this.style.display != "none" )
251 return msg(this, "Hiding, display not none: " + this.style.display);
253 if ( t_o.constructor == Number && cur_o != t_o )
254 return msg(this, "Final opacity is not " + t_o + ": " + cur_o);
256 if ( t_w.constructor == Number && this.style.width != t_w + "px" )
257 return msg(this, "Final width is not " + t_w + ": " + this.style.width);
259 if ( t_h.constructor == Number && this.style.height != t_h + "px" )
260 return msg(this, "Final height is not " + t_h + ": " + this.style.height);
262 var cur_w = jQuery.css(this,"width");
263 if ( t_w.constructor == Number && this.style.width == "" && cur_w != t_w )
264 return msg(this, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
266 var cur_h = jQuery.css(this,"height");
267 if ( t_h.constructor == Number && this.style.height == "" && cur_h != t_h )
268 return msg(this, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
270 if ( t_o.constructor == Number && jQuery.curCSS(this, "opacity") == "" && cur_o != t_o )
271 return msg(this, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
273 if ( t_h == "show" ) {
274 var old_h = jQuery.curCSS(this, "height");
275 $(elem).append("<br>Some more text<br>and some more...");
276 if ( old_h == jQuery.css(this, "height" ) )
277 return msg(this, "Height is not truly auto.");
286 $('#fadein div').fadeOut('fast').fadeIn('fast');
287 $('#fadeout div').fadeIn('fast').fadeOut('fast');
289 $('#show div').hide('fast').show('fast');
290 $('#hide div').show('fast').hide('fast');
292 $('#togglein div').toggle('fast').toggle('fast');
293 $('#toggleout div').toggle('fast').toggle('fast');
295 $('#slidedown div').slideDown('fast').slideUp('fast');
296 $('#slideup div').slideUp('fast').slideDown('fast');
298 $('#slidetogglein div').slideToggle('fast').slideToggle('fast');
299 $('#slidetoggleout div').slideToggle('fast').slideToggle('fast');
302 function pass( elem ) {
303 $(elem).prev().addClass("pass");
306 function makeTest( text ){
307 var elem = $("<div></div>")
308 .attr("id", "test" + makeTest.id++)
315 $(this).next().toggle();
324 function msg(elem,txt){
325 $(elem).prev().append( "<tt> " + txt + "</tt>" );
330 <b>Chain Tests:</b><br/>
331 <div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
332 <div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
334 <div id="show" class='chain test'>show<div>show</div></div>
335 <div id="hide" class='chain test out'>hide<div>hide</div></div>
337 <div id="togglein" class='chain test'>togglein<div>togglein</div></div>
338 <div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
339 <br style="clear:both;"/>
341 <div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
342 <div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
344 <div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
345 <div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
346 <br style="clear:both;"/>
348 <div id="tests"></div>