]> source.dussan.org Git - jquery-ui.git/commitdiff
Core: Check if jQuery supports inner/outer/Width/Height setters.
authorScott González <scott.gonzalez@gmail.com>
Mon, 21 May 2012 19:29:53 +0000 (15:29 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 21 May 2012 19:29:53 +0000 (15:29 -0400)
ui/jquery.ui.core.js

index 93353996ec4d5661db8b6e1e8d90a42be54c74b6..d8fff91e1da157b51429fb738365d764b379653a 100644 (file)
@@ -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 ) {