X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=84b6e6023f2321c01763bd84ca5d0bac1be41ccd;hb=ae9df1412c41b1ae676d3808c323b0f01e0b0600;hp=9113be2aea3308c40e22eb1cefce715b4527101a;hpb=d1f3dc9a04225b327b6fd6deb9d3913918054a9f;p=jquery.git diff --git a/src/css.js b/src/css.js index 9113be2..84b6e60 100644 --- a/src/css.js +++ b/src/css.js @@ -21,7 +21,9 @@ var ralpha = /alpha\([^)]*\)/, jQuery.fn.css = function( name, value ) { return jQuery.access( this, name, value, true, function( elem, name, value ) { - return jQuery.css( elem, name, value ); + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); }); }; @@ -62,7 +64,7 @@ jQuery.extend({ } // Make sure that we're working with the right name - var ret, origName = name.replace( rdashAlpha, fcamelCase ), + var ret, origName = jQuery.camelCase( name ), style = elem.style, hooks = jQuery.cssHooks[ origName ]; name = jQuery.cssProps[ origName ] || origName; @@ -90,19 +92,15 @@ jQuery.extend({ } }, - css: function( elem, name, value, extra ) { + css: function( elem, name, extra ) { // Make sure that we're working with the right name - var ret, origName = name.replace( rdashAlpha, fcamelCase ), + var ret, origName = jQuery.camelCase( name ), hooks = jQuery.cssHooks[ origName ]; name = jQuery.cssProps[ origName ] || origName; - // Check if we're setting a value, just use jQuery.style (DEPRECATED) - if ( value !== undefined ) { - jQuery.style( elem, name, value ); - // If a hook was provided get the computed value from there - } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { return ret; // Otherwise, if a way to get the computed value exists, use that @@ -127,9 +125,16 @@ jQuery.extend({ for ( name in options ) { elem.style[ name ] = old[ name ]; } + }, + + camelCase: function( string ) { + return string.replace( rdashAlpha, fcamelCase ); } }); +// DEPRECATED, Use jQuery.css() instead +jQuery.curCSS = jQuery.css; + jQuery.each(["height", "width"], function( i, name ) { jQuery.cssHooks[ name ] = { get: function( elem, computed, extra ) {