X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=f92125819c3d91267586e6f4ee37e28452bef375;hb=7c8588530abaf4e72154fe1f59c04aae217a32b8;hp=2da19b9c3f3a90142513b870c4f4bd4e53dcd811;hpb=b920f0aeb483f4565ff2f3c1d2a328d5200b23f7;p=jquery.git diff --git a/src/css.js b/src/css.js index 2da19b9..f921258 100644 --- a/src/css.js +++ b/src/css.js @@ -1,3 +1,5 @@ +(function( jQuery ) { + var ralpha = /alpha\([^)]*\)/, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, @@ -19,7 +21,7 @@ var ralpha = /alpha\([^)]*\)/, jQuery.fn.css = function( name, value ) { return jQuery.access( this, name, value, true, function( elem, name, value ) { - jQuery.css( elem, name, value ); + return jQuery.css( elem, name, value ); }); }; @@ -64,16 +66,16 @@ jQuery.extend({ value += "px"; } - if ( !("set" in hooks) || (value = hooks.set( elem, value )) === false ) { + if ( !("set" in hooks) || (value = hooks.set( elem, value )) === undefined ) { style[ name ] = value; } } else { - if ( "get" in hooks && (ret = hooks.get( elem, force, extra )) !== false ) { + if ( "get" in hooks && (ret = hooks.get( elem, force, extra )) !== undefined ) { return ret; } - if ( !force && name in style ) { + if ( !force && style && style[ name ] ) { ret = style[ name ]; } else if ( curCSS ) { @@ -106,6 +108,8 @@ jQuery.extend({ jQuery.each(["height", "width"], function( i, name ) { jQuery.cssHooks[ name ] = { get: function( elem, force, extra ) { + var val; + if ( elem.offsetWidth !== 0 ) { val = getWH( elem, name, extra ); @@ -114,11 +118,13 @@ jQuery.each(["height", "width"], function( i, name ) { val = getWH( elem, name, extra ); }); } + + return val + "px"; }, set: function( elem, value ) { // ignore negative width and height values #1599 - elem.style[ name ] = Math.max( parseFloat(value), 0 ) + "px"; + return Math.max( parseFloat(value), 0 ) + "px"; } }; }); @@ -172,7 +178,7 @@ if ( getComputedStyle ) { } else if ( document.documentElement.currentStyle ) { curCSS = function( elem, name ) { - var left, rsLeft, ret = elem.currentStyle[ name ]; + var left, rsLeft, ret = elem.currentStyle[ name ], style = elem.style; // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 @@ -238,3 +244,5 @@ if ( jQuery.expr && jQuery.expr.filters ) { return !jQuery.expr.filters.hidden( elem ); }; } + +})( jQuery );