]> source.dussan.org Git - jquery-ui.git/commitdiff
Core: Move backcompat for core 1.7 into its own module
authorAlexander Schmitz <arschmitz@gmail.com>
Wed, 15 Jul 2015 22:28:30 +0000 (18:28 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Sat, 8 Aug 2015 04:29:36 +0000 (00:29 -0400)
Ref #9647

ui/core.js
ui/jquery-1-7.js [new file with mode: 0644]

index 412354151b8ff108f190250581ac0cb9b16495df..7771c74ee0c2483ffecfe220a3c0590f61b57e43 100644 (file)
@@ -27,6 +27,7 @@
                        "./ie",
                        "./keycode",
                        "./labels",
+                       "./jquery-1-7",
                        "./version"
                ], factory );
        } else {
@@ -124,68 +125,6 @@ $.extend( $.expr[ ":" ], {
        }
 } );
 
-// support: jQuery 1.7 only
-// Not a great way to check versions, but since we only support 1.7+ and only
-// need to detect <1.8, this is a simple check that should suffice. Checking
-// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
-// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
-// 1.7 anymore). See #11197 for why we're not using feature detection.
-if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
-
-       // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
-       // Unlike jQuery Core 1.8+, these only support numeric values to set the
-       // dimensions in pixels
-       $.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;
-               }
-
-               $.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 );
-                       }
-
-                       return this.each( function() {
-                               $( this ).css( type, reduce( this, size, true, margin ) + "px" );
-                       } );
-               };
-       } );
-
-       $.fn.addBack = function( selector ) {
-               return this.add( selector == null ?
-                       this.prevObject : this.prevObject.filter( selector )
-               );
-       };
-}
-
 // $.ui.plugin is deprecated. Use $.widget() extensions instead.
 $.ui.plugin = {
        add: function( module, option, set ) {
diff --git a/ui/jquery-1-7.js b/ui/jquery-1-7.js
new file mode 100644 (file)
index 0000000..29e008e
--- /dev/null
@@ -0,0 +1,89 @@
+/*!
+ * jQuery UI Support for jQuery core 1.7.x @VERSION
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ */
+
+//>>label: jQuery 1.7 Support
+//>>group: UI Core
+//>>description: Support version 1.7.x of jQuery core
+
+( function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+
+               // AMD. Register as an anonymous module.
+               define( [ "jquery", "./version" ], factory );
+       } else {
+
+               // Browser globals
+               factory( jQuery );
+       }
+}( function( $ ) {
+
+// support: jQuery 1.7 only
+// Not a great way to check versions, but since we only support 1.7+ and only
+// need to detect <1.8, this is a simple check that should suffice. Checking
+// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
+// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
+// 1.7 anymore). See #11197 for why we're not using feature detection.
+if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
+
+       // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
+       // Unlike jQuery Core 1.8+, these only support numeric values to set the
+       // dimensions in pixels
+       $.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;
+               }
+
+               $.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 );
+                       }
+
+                       return this.each( function() {
+                               $( this ).css( type, reduce( this, size, true, margin ) + "px" );
+                       } );
+               };
+       } );
+
+       $.fn.addBack = function( selector ) {
+               return this.add( selector == null ?
+                       this.prevObject : this.prevObject.filter( selector )
+               );
+       };
+}
+
+} ) );