3 <title>Animation Test Suite</title>
4 <script src="../dist/jquery.js"></script>
15 background: red url(cow.jpg) no-repeat;
17 border: 2px solid #000;
20 div#tests div.overflow {
49 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
62 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
75 filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
82 div#tests div.widewidth {
83 background-repeat: repeat-x;
86 div#tests div.wideheight {
87 background-repeat: repeat-y;
90 div#tests div.widewidth.wideheight {
91 background-repeat: repeat;
94 div#tests div.noback {
95 background-image: none;
100 Normal: function(elem){},
101 "CSS Hidden": function(elem){
102 $(this).addClass("hidden");
104 "JS Hidden": function(elem){
110 "CSS Auto": function(elem,prop){
111 $(elem).addClass("auto" + prop)
112 .text("This is a long string of text.");
115 "JS Auto": function(elem,prop){
116 $(elem).css(prop,"auto")
117 .text("This is a long string of text.");
120 "CSS 100": function(elem,prop){
121 $(elem).addClass("large" + prop);
124 "JS 100": function(elem,prop){
125 $(elem).css(prop,prop == "opacity" ? 1 : "100px");
126 return prop == "opacity" ? 1 : 100;
128 "CSS 50": function(elem,prop){
129 $(elem).addClass("med" + prop);
132 "JS 50": function(elem,prop){
133 $(elem).css(prop,prop == "opacity" ? 0.50 : "50px");
134 return prop == "opacity" ? 0.5 : 50;
136 "CSS 0": function(elem,prop){
137 $(elem).addClass("no" + prop);
140 "JS 0": function(elem,prop){
141 $(elem).css(prop,prop == "opacity" ? 0 : "0px");
147 /*"Auto": function(elem,prop){
148 $(elem).addClass("wide"+prop);
151 /*"toggle (show)": function(elem,prop){
152 $(elem).hide().addClass("wide"+prop);
155 "show": function(elem,prop){
156 $(elem).hide().addClass("wide"+prop);
159 "hide": function(elem,prop){
160 $(elem).addClass("wide"+prop);
163 "100": function(elem,prop){
164 $(elem).addClass("wide"+prop);
165 return prop == "opacity" ? 1 : 100;
167 "50": function(elem,prop){
168 return prop == "opacity" ? 0.50 : 50;
170 "0": function(elem,prop){
171 $(elem).addClass("noback");
176 /*var oldAttr = jQuery.attr;
178 jQuery.attr = function( elem, name, value ){
179 if ( arguments.length == 3 ) {
180 var prev = elem.previousSibling;
181 if ( prev && prev.nodeName == "UL" ) {
182 $(prev).append( name + ": " + value );
186 return oldAttr.apply( jQuery, arguments );
189 $(document).ready(function(){
190 makeTest( "JS Overflow and Display" )
191 .addClass("widewidth")
192 .css({ overflow: "visible", display: "inline" })
193 .add( makeTest( "CSS Overflow and Display" ).addClass("overflow inline") )
194 .addClass("widewidth")
195 .text("Some sample text.")
196 .before("text before")
198 .animate({ opacity: 0.5 }, "slow", function(){
199 var o = jQuery.css( this, "overflow" );
200 if ( o != "visible" )
201 return msg(this, "Overflow should be visible: " + o);
203 if ( jQuery.css( this, "display" ) != "inline" )
204 return msg(this, "Display has been tampered with.");
209 jQuery.each( from, function(fn, f){
210 jQuery.each( to, function(tn, t){
211 var elem = makeTest( fn + " to " + tn );
213 var t_w = t( elem, "width" );
214 var f_w = f( elem, "width" );
215 var t_h = t( elem, "height" );
216 var f_h = f( elem, "height" );
217 var t_o = t( elem, "opacity" );
218 var f_o = f( elem, "opacity" );
220 var anim = { width: t_w, height: t_h, opacity: t_o };
222 elem.animate(anim, "slow", function(){
223 if ( t_w == "show" && this.style.display != "block" )
224 return msg(this, "Showing, display not block: " + this.style.display);
226 if ( (t_w == "hide"||t_w == "show") && this.style.width.indexOf(f_w) != 0 )
227 return msg(this, "Width not reset to " + f_w + ": " + this.style.width);
229 if ( (t_h == "hide"||t_h == "show") && this.style.height.indexOf(f_h) != 0 )
230 return msg(this, "Height not reset to " + f_h + ": " + this.style.height);
232 var cur_o = jQuery.attr(this.style, "opacity");
233 if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
235 if ( (t_o == "hide"||t_o == "show") && cur_o != f_o )
236 return msg(this, "Opacity not reset to " + f_o + ": " + cur_o);
238 if ( t_w == "hide" && this.style.display != "none" )
239 return msg(this, "Hiding, display not none: " + this.style.display);
241 if ( t_o.constructor == Number && cur_o != t_o )
242 return msg(this, "Final opacity is not " + t_o + ": " + cur_o);
244 if ( t_w.constructor == Number && this.style.width != t_w + "px" )
245 return msg(this, "Final width is not " + t_w + ": " + this.style.width);
247 if ( t_h.constructor == Number && this.style.height != t_h + "px" )
248 return msg(this, "Final height is not " + t_h + ": " + this.style.height);
250 var cur_w = jQuery.css(this,"width");
251 if ( t_w.constructor == Number && this.style.width == "" && cur_w != t_w )
252 return msg(this, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
254 var cur_h = jQuery.css(this,"height");
255 if ( t_h.constructor == Number && this.style.height == "" && cur_h != t_h )
256 return msg(this, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
258 if ( t_o.constructor == Number && jQuery.curCSS(this, "opacity") == "" && cur_o != t_o )
259 return msg(this, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
261 if ( t_h == "show" ) {
262 var old_h = jQuery.curCSS(this, "height");
263 $(elem).append("<br>Some more text<br>and some more...");
264 if ( old_h == jQuery.css(this, "height" ) )
265 return msg(this, "Height is not truly auto.");
274 function pass( elem ) {
275 $(elem).prev().addClass("pass");
278 function makeTest( text ){
279 var elem = $("<div></div>")
280 .attr("id", "test" + makeTest.id++)
287 $(this).next().toggle();
296 function msg(elem,txt){
297 $(elem).prev().append( "<tt> " + txt + "</tt>" );
302 <div id="tests"></div>