Skip to content
Permalink
Browse files
Merge branch 'master' of github.com:jquery/jquery
  • Loading branch information
jeresig committed Jan 23, 2010
2 parents f6ec9d5 + 2c28f22 commit 8ea634f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
@@ -13,7 +13,7 @@ var elemdisplay = {},

jQuery.fn.extend({
show: function( speed, callback ) {
if ( speed != null ) {
if ( speed || speed === 0) {
return this.animate( genFx("show", 3), speed, callback);

} else {
@@ -57,7 +57,7 @@ jQuery.fn.extend({
},

hide: function( speed, callback ) {
if ( speed != null ) {
if ( speed || speed === 0 ) {
return this.animate( genFx("hide", 3), speed, callback);

} else {
@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) {
var elem = this[0];

if ( !elem || !elem.ownerDocument ) {
return null;
}

if ( options ) {
return this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
});
}

if ( !elem || !elem.ownerDocument ) {
return null;
}

if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem );
}
@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) {
var elem = this[0];

if ( !elem || !elem.ownerDocument ) {
return null;
}

if ( options ) {
return this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
});
}

if ( !elem || !elem.ownerDocument ) {
return null;
}

if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem );
}
@@ -1,18 +1,36 @@
module("effects");

test("show()", function() {
expect(16);
expect(23);
var pass = true, div = jQuery("#main div");
div.show().each(function(){
if ( this.style.display == "none" ) pass = false;
});
ok( pass, "Show" );

pass = true;
div.hide().show(null).each(function() {
if ( this.style.display == "none" ) pass = false;
var speeds = {
"null speed": null,
"undefined speed": undefined,
"empty string speed": "",
"false speed": false
};

jQuery.each(speeds, function(name, speed) {
pass = true;
div.hide().show(speed).each(function() {
if ( this.style.display == "none" ) pass = false;
});
ok( pass, "Show with " + name);
});


jQuery.each(speeds, function(name, speed) {
pass = true;
div.hide().show(speed, function() {
pass = false;
});
ok( pass, "Show with " + name + " does not call animate callback" );
});
ok( pass, "Show will null speed");

jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');

@@ -305,6 +305,13 @@ testoffset("body", function( jQuery ) {
equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
});

test("Chaining offset(coords) returns jQuery object", function() {
expect(2);
var coords = { top: 1, left: 1 };
equals( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
equals( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
});

test("offsetParent", function(){
expect(11);

0 comments on commit 8ea634f

Please sign in to comment.