| 778 | | // Revert the padding and border widths to get the |
| 779 | | // correct height/width values |
| 780 | | jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){ |
| 781 | | old[ "padding" + this ] = 0; |
| 782 | | old[ "border" + this + "Width" ] = 0; |
| 783 | | }); |
| | 778 | function setWH() { |
| | 779 | width = elem.clientWidth; |
| | 780 | height = elem.clientHeight; |
| | 781 | } |
| | 782 | if ( jQuery(elem).is(":visible") ) |
| | 783 | setWH(); |
| | 784 | else |
| | 785 | jQuery.swap( elem, props, setWH ); |
| 785 | | // Swap out the padding/border values temporarily |
| 786 | | jQuery.swap( elem, old, function() { |
| 787 | | |
| 788 | | // If the element is visible, then the calculation is easy |
| 789 | | if ( jQuery( elem ).is(":visible") ) { |
| 790 | | height = elem.offsetHeight; |
| 791 | | width = elem.offsetWidth; |
| 792 | | |
| 793 | | // Otherwise, we need to flip out more values |
| 794 | | } else { |
| 795 | | elem = jQuery( elem.cloneNode(true) ) |
| 796 | | .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end() |
| 797 | | .css({ |
| 798 | | visibility: "hidden", |
| 799 | | position: "absolute", |
| 800 | | display: "block", |
| 801 | | right: "0", |
| 802 | | left: "0" |
| 803 | | }).appendTo( elem.parentNode )[0]; |
| 804 | | |
| 805 | | var position = jQuery.css( elem.parentNode, "position" ) || "static"; |
| 806 | | if ( position == "static" ) |
| 807 | | elem.parentNode.style.position = "relative"; |
| 808 | | |
| 809 | | height = elem.clientHeight; |
| 810 | | width = elem.clientWidth; |
| 811 | | |
| 812 | | if ( position == "static" ) |
| 813 | | elem.parentNode.style.position = "static"; |
| 814 | | |
| 815 | | elem.parentNode.removeChild( elem ); |
| 816 | | } |
| 817 | | }); |
| 818 | | |
| 819 | | return name == "height" ? |
| 820 | | height : |
| 821 | | width; |
| | 787 | return name == "width" ? width : height; |