aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.core.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-05-21 15:29:53 -0400
committerScott González <scott.gonzalez@gmail.com>2012-05-21 15:29:53 -0400
commit033f83ffebf2c25284796d661c01613936674a47 (patch)
tree46de8cd014771f76c22819e59d1e2144d8fd3543 /ui/jquery.ui.core.js
parent15ece1f51a0fcbe718ad2836b078bdef72301de8 (diff)
downloadjquery-ui-033f83ffebf2c25284796d661c01613936674a47.tar.gz
jquery-ui-033f83ffebf2c25284796d661c01613936674a47.zip
Core: Check if jQuery supports inner/outer/Width/Height setters.
Diffstat (limited to 'ui/jquery.ui.core.js')
-rw-r--r--ui/jquery.ui.core.js79
1 files changed, 41 insertions, 38 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index 93353996e..d8fff91e1 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -119,49 +119,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
- };
+// 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
+ };
+
+ function reduce( elem, size, border, margin ) {
+ $.each( side, function() {
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
+ if ( border ) {
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
+ }
+ if ( margin ) {
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
+ }
+ });
+ return size;
+ }
- function reduce( elem, size, border, margin ) {
- $.each( side, function() {
- size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
- if ( border ) {
- size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
+ $.fn[ "inner" + name ] = function( size ) {
+ if ( size === undefined ) {
+ return orig[ "inner" + name ].call( this );
}
- if ( margin ) {
- size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
- }
- });
- return size;
- }
-
- $.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" );
- });
- };
+ 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 ) {