- css: function( elem, name ) {\r
- if ( name == "height" || name == "width" ) {\r
- var old = {}, height, width;\r
-\r
- // Revert the padding and border widths to get the\r
- // correct height/width values\r
- jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){\r
- old[ "padding" + this ] = 0;\r
- old[ "border" + this + "Width" ] = 0;\r
- });\r
-\r
- // Swap out the padding/border values temporarily\r
- jQuery.swap( elem, old, function() {\r
-\r
- // If the element is visible, then the calculation is easy\r
- if ( jQuery( elem ).is(":visible") ) {\r
- height = elem.offsetHeight;\r
- width = elem.offsetWidth;\r
-\r
- // Otherwise, we need to flip out more values\r
- } else {\r
- elem = jQuery( elem.cloneNode(true) )\r
- .find(":radio").removeAttr("checked").end()\r
- .css({\r
- visibility: "hidden",\r
- position: "absolute",\r
- display: "block",\r
- right: "0",\r
- left: "0"\r
- }).appendTo( elem.parentNode )[0];\r
-\r
- var position = jQuery.css( elem.parentNode, "position" ) || "static";\r
- if ( position == "static" )\r
- elem.parentNode.style.position = "relative";\r
-\r
- height = elem.clientHeight;\r
- width = elem.clientWidth;\r
-\r
- if ( position == "static" )\r
- elem.parentNode.style.position = "static";\r
-\r
- elem.parentNode.removeChild( elem );\r
- }\r
- });\r
-\r
- return name == "height" ?\r
- height :\r
- width;\r
+ css: function( elem, name, force ) {\r
+ if ( name == "width" || name == "height" ) {\r
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];\r
+ \r
+ function getWH() {\r
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;\r
+ var padding = 0, border = 0;\r
+ jQuery.each( which, function() {\r
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;\r
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;\r
+ });\r
+ val -= Math.round(padding + border);\r
+ }\r
+ \r
+ if ( jQuery(elem).is(":visible") )\r
+ getWH();\r
+ else\r
+ jQuery.swap( elem, props, getWH );\r
+ \r
+ return Math.max(0, val);\r