X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=8751860a8294843c6a48b77a3753eed17695274d;hb=0229b83f7e5bf64edb2888ab349bedcd1a45e7c1;hp=77949aebc60f56fa4237c0f61cbc738d5023a0e9;hpb=0da700a4d03c1c43e75e3ab7f8e719e13c7e444a;p=jquery.git diff --git a/src/css.js b/src/css.js index 77949ae..8751860 100644 --- a/src/css.js +++ b/src/css.js @@ -1,6 +1,6 @@ (function( jQuery ) { -var ralpha = /alpha\([^)]*\)/, +var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, rupper = /([A-Z])/g, @@ -20,6 +20,11 @@ var ralpha = /alpha\([^)]*\)/, }; jQuery.fn.css = function( name, value ) { + // Setting 'undefined' is a no-op + if ( arguments.length === 2 && value === undefined ) { + return this; + } + return jQuery.access( this, name, value, true, function( elem, name, value ) { return value !== undefined ? jQuery.style( elem, name, value ) : @@ -32,10 +37,15 @@ jQuery.extend({ // behavior of getting and setting a style property cssHooks: { opacity: { - get: function( elem ) { - // We should always get a number back from opacity - var ret = curCSS( elem, "opacity", "opacity" ); - return ret === "" ? "1" : ret; + get: function( elem, computed ) { + if ( computed ) { + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity", "opacity" ); + return ret === "" ? "1" : ret; + + } else { + return elem.style.opacity; + } } } }, @@ -176,7 +186,7 @@ if ( !jQuery.support.opacity ) { // IE uses filters for opacity return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? (parseFloat(RegExp.$1) / 100) + "" : - "1"; + computed ? "1" : ""; }, set: function( elem, value ) { @@ -187,15 +197,14 @@ if ( !jQuery.support.opacity ) { style.zoom = 1; // Set the alpha filter to set the opacity - var opacity = isNaN(value) ? + var opacity = jQuery.isNaN(value) ? "" : - "alpha(opacity=" + value * 100 + ")"; - - var filter = style.filter || elem.currentStyle && elem.currentStyle.filter || ""; + "alpha(opacity=" + value * 100 + ")", + filter = style.filter || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : - opacity; + style.filter + ' ' + opacity; } }; } @@ -271,14 +280,9 @@ function getWH( elem, name, extra ) { if ( jQuery.expr && jQuery.expr.filters ) { jQuery.expr.filters.hidden = function( elem ) { - var width = elem.offsetWidth, height = elem.offsetHeight, - skip = elem.nodeName.toLowerCase() === "tr"; - - return width === 0 && height === 0 && !skip ? - true : - width > 0 && height > 0 && !skip ? - false : - (elem.style.display || jQuery.css( elem, "display" )) === "none"; + var width = elem.offsetWidth, height = elem.offsetHeight; + + return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none"); }; jQuery.expr.filters.visible = function( elem ) {