Added in some more bug fixes - and added the slideToggle method.

This commit is contained in:
John Resig 2006-08-24 21:30:21 +00:00
parent ccf9d44062
commit 8a1adfcd2a
2 changed files with 10 additions and 3 deletions

View file

@ -141,6 +141,13 @@ jQuery.fn.extend({
slideUp: function(speed,callback){ slideUp: function(speed,callback){
return this.animate({height: "hide"}, speed, callback); return this.animate({height: "hide"}, speed, callback);
}, },
slideToggle: function(speed,callback){
return this.each(function(){
var state = $(this).is(":hidden") ? "show" : "hide";
$(this).animate({height: state}, speed, callback);
});
},
/** /**
* Fade in all matched elements by adjusting their opacity. * Fade in all matched elements by adjusting their opacity.

View file

@ -937,7 +937,7 @@ jQuery.extend({
oHeight = e.offsetHeight; oHeight = e.offsetHeight;
oWidth = e.offsetWidth; oWidth = e.offsetWidth;
} else } else
jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "" }, jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "block" },
function(){ function(){
oHeight = e.clientHeight; oHeight = e.clientHeight;
oWidth = e.clientWidth; oWidth = e.clientWidth;
@ -1405,7 +1405,7 @@ jQuery.extend({
return jQuery.extend( elems, { return jQuery.extend( elems, {
last: elems.n == elems.length - 1, last: elems.n == elems.length - 1,
cur: n == "even" && elems.n % 2 == 0 || n == "odd" && elems.n % 2 || elems[pos] == a, cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
prev: elems[elems.n - 1], prev: elems[elems.n - 1],
next: elems[elems.n + 1] next: elems[elems.n + 1]
}); });
@ -1426,7 +1426,7 @@ jQuery.extend({
// Move b over to the new array (this helps to avoid // Move b over to the new array (this helps to avoid
// StaticNodeList instances) // StaticNodeList instances)
for ( var k = 0; k < first.length; k++ ) for ( var k = 0; k < first.length; k++ )
result[k] = second[k]; result[k] = first[k];
// Now check for duplicates between a and b and only // Now check for duplicates between a and b and only
// add the unique items // add the unique items