diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-07-11 08:48:03 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-07-11 08:48:03 -0400 |
commit | 8fcbe502ee548fe8c10cf64d7053c70837fdcca3 (patch) | |
tree | fb7e898636f74952709c20d8bf8da34352151c52 | |
parent | b892b7272183180ba5cff8e912671a89cc6358a1 (diff) | |
download | jquery-ui-8fcbe502ee548fe8c10cf64d7053c70837fdcca3.tar.gz jquery-ui-8fcbe502ee548fe8c10cf64d7053c70837fdcca3.zip |
Core: Check if jQuery supports inner/outer/Width/Height setters.
(cherry picked from commit 033f83ffebf2c25284796d661c01613936674a47)
Conflicts:
ui/jquery.ui.core.js
-rw-r--r-- | ui/jquery.ui.core.js | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 1d002ecea..3c9f90054 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -131,49 +131,52 @@ $.fn.extend({ } }); -$.each( [ "Width", "Height" ], function( i, name ) { - var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], - type = name.toLowerCase(), - orig = { - innerWidth: $.fn.innerWidth, - innerHeight: $.fn.innerHeight, - outerWidth: $.fn.outerWidth, - outerHeight: $.fn.outerHeight - }; - - function reduce( elem, size, border, margin ) { - $.each( side, function() { - size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0; - if ( border ) { - size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0; - } - if ( margin ) { - size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0; - } - }); - return size; - } +// support: jQuery <1.8 +if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { + $.each( [ "Width", "Height" ], function( i, name ) { + var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], + type = name.toLowerCase(), + orig = { + innerWidth: $.fn.innerWidth, + innerHeight: $.fn.innerHeight, + outerWidth: $.fn.outerWidth, + outerHeight: $.fn.outerHeight + }; - $.fn[ "inner" + name ] = function( size ) { - if ( size === undefined ) { - return orig[ "inner" + name ].call( this ); + function reduce( elem, size, border, margin ) { + $.each( side, function() { + size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0; + if ( border ) { + size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0; + } + if ( margin ) { + size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0; + } + }); + return size; } - return this.each(function() { - $( this ).css( type, reduce( this, size ) + "px" ); - }); - }; + $.fn[ "inner" + name ] = function( size ) { + if ( size === undefined ) { + return orig[ "inner" + name ].call( this ); + } + + return this.each(function() { + $( this ).css( type, reduce( this, size ) + "px" ); + }); + }; - $.fn[ "outer" + name] = function( size, margin ) { - if ( typeof size !== "number" ) { - return orig[ "outer" + name ].call( this, size ); - } + $.fn[ "outer" + name] = function( size, margin ) { + if ( typeof size !== "number" ) { + return orig[ "outer" + name ].call( this, size ); + } - return this.each(function() { - $( this).css( type, reduce( this, size, true, margin ) + "px" ); - }); - }; -}); + return this.each(function() { + $( this).css( type, reduce( this, size, true, margin ) + "px" ); + }); + }; + }); +} // selectors function focusable( element, isTabIndexNotNaN ) { |