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;
102 Normal: function(elem){},
103 "CSS Hidden": function(elem){
104 $(this).addClass("hidden");
106 "JS Hidden": function(elem){
112 "CSS Auto": function(elem,prop){
113 $(elem).addClass("auto" + prop)
114 .text("This is a long string of text.");
117 "JS Auto": function(elem,prop){
118 $(elem).css(prop,"auto")
119 .text("This is a long string of text.");
122 "CSS 100": function(elem,prop){
123 $(elem).addClass("large" + prop);
126 "JS 100": function(elem,prop){
127 $(elem).css(prop,prop == "opacity" ? 1 : "100px");
128 return prop == "opacity" ? 1 : 100;
130 "CSS 50": function(elem,prop){
131 $(elem).addClass("med" + prop);
134 "JS 50": function(elem,prop){
135 $(elem).css(prop,prop == "opacity" ? 0.50 : "50px");
136 return prop == "opacity" ? 0.5 : 50;
138 "CSS 0": function(elem,prop){
139 $(elem).addClass("no" + prop);
142 "JS 0": function(elem,prop){
143 $(elem).css(prop,prop == "opacity" ? 0 : "0px");
149 /*"Auto": function(elem,prop){
150 $(elem).addClass("wide"+prop);
153 /*"toggle (show)": function(elem,prop){
154 $(elem).hide().addClass("wide"+prop);
157 "show": function(elem,prop){
158 $(elem).hide().addClass("wide"+prop);
161 "hide": function(elem,prop){
162 $(elem).addClass("wide"+prop);
165 "100": function(elem,prop){
166 $(elem).addClass("wide"+prop);
167 return prop == "opacity" ? 1 : 100;
169 "50": function(elem,prop){
170 return prop == "opacity" ? 0.50 : 50;
172 "0": function(elem,prop){
173 $(elem).addClass("noback");
178 /*var oldAttr = jQuery.attr;
180 jQuery.attr = function( elem, name, value ){
181 if ( arguments.length == 3 ) {
182 var prev = elem.previousSibling;
183 if ( prev && prev.nodeName == "UL" ) {
184 $(prev).append( name + ": " + value );
188 return oldAttr.apply( jQuery, arguments );
191 $(document).ready(function(){
192 makeTest( "JS Overflow and Display" )
193 .addClass("widewidth")
194 .css({ overflow: "visible", display: "inline" })
195 .add( makeTest( "CSS Overflow and Display" ).addClass("overflow inline") )
196 .addClass("widewidth")
197 .text("Some sample text.")
198 .before("text before")
200 .animate({ opacity: 0.5 }, "slow", function(){
201 var o = jQuery.css( this, "overflow" );
202 if ( o != "visible" )
203 return msg(this, "Overflow should be visible: " + o);
205 if ( jQuery.css( this, "display" ) != "inline" )
206 return msg(this, "Display has been tampered with.");
211 jQuery.each( from, function(fn, f){
212 jQuery.each( to, function(tn, t){
213 var elem = makeTest( fn + " to " + tn );
215 var t_w = t( elem, "width" );
216 var f_w = f( elem, "width" );
217 var t_h = t( elem, "height" );
218 var f_h = f( elem, "height" );
219 var t_o = t( elem, "opacity" );
220 var f_o = f( elem, "opacity" );
222 var anim = { width: t_w, height: t_h, opacity: t_o };
224 elem.animate(anim, "slow", function(){
225 if ( t_w == "show" && this.style.display != "block" )
226 return msg(this, "Showing, display not block: " + this.style.display);
228 if ( (t_w == "hide"||t_w == "show") && this.style.width.indexOf(f_w) != 0 )
229 return msg(this, "Width not reset to " + f_w + ": " + this.style.width);
231 if ( (t_h == "hide"||t_h == "show") && this.style.height.indexOf(f_h) != 0 )
232 return msg(this, "Height not reset to " + f_h + ": " + this.style.height);
234 var cur_o = jQuery.attr(this.style, "opacity");
235 if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
237 if ( (t_o == "hide"||t_o == "show") && cur_o != f_o ) {
238 return msg(this, "Opacity not reset to " + f_o + ": " + cur_o);
241 if ( t_w == "hide" && this.style.display != "none" )
242 return msg(this, "Hiding, display not none: " + this.style.display);
244 if ( t_o.constructor == Number && cur_o != t_o )
245 return msg(this, "Final opacity is not " + t_o + ": " + cur_o);
247 if ( t_w.constructor == Number && this.style.width != t_w + "px" )
248 return msg(this, "Final width is not " + t_w + ": " + this.style.width);
250 if ( t_h.constructor == Number && this.style.height != t_h + "px" )
251 return msg(this, "Final height is not " + t_h + ": " + this.style.height);
253 var cur_w = jQuery.css(this,"width");
254 if ( t_w.constructor == Number && this.style.width == "" && cur_w != t_w )
255 return msg(this, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
257 var cur_h = jQuery.css(this,"height");
258 if ( t_h.constructor == Number && this.style.height == "" && cur_h != t_h )
259 return msg(this, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
261 if ( t_o.constructor == Number && jQuery.curCSS(this, "opacity") == "" && cur_o != t_o )
262 return msg(this, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
264 if ( t_h == "show" ) {
265 var old_h = jQuery.curCSS(this, "height");
266 $(elem).append("<br>Some more text<br>and some more...");
267 if ( old_h == jQuery.css(this, "height" ) )
268 return msg(this, "Height is not truly auto.");
277 function pass( elem ) {
278 $(elem).prev().addClass("pass");
281 function makeTest( text ){
282 var elem = $("<div></div>")
283 .attr("id", "test" + makeTest.id++)
290 $(this).next().toggle();
299 function msg(elem,txt){
300 $(elem).prev().append( "<tt> " + txt + "</tt>" );
305 <div id="tests"></div>