jquery-1-7.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*!
  2. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  3. * http://jqueryui.com
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. *
  9. */
  10. //>>label: jQuery 1.7 Support
  11. //>>group: Core
  12. //>>description: Support version 1.7.x of jQuery core
  13. ( function( factory ) {
  14. if ( typeof define === "function" && define.amd ) {
  15. // AMD. Register as an anonymous module.
  16. define( [ "jquery", "./version" ], factory );
  17. } else {
  18. // Browser globals
  19. factory( jQuery );
  20. }
  21. }( function( $ ) {
  22. // Support: jQuery 1.7 only
  23. // Not a great way to check versions, but since we only support 1.7+ and only
  24. // need to detect <1.8, this is a simple check that should suffice. Checking
  25. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  26. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  27. // 1.7 anymore). See #11197 for why we're not using feature detection.
  28. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  29. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  30. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  31. // dimensions in pixels
  32. $.each( [ "Width", "Height" ], function( i, name ) {
  33. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  34. type = name.toLowerCase(),
  35. orig = {
  36. innerWidth: $.fn.innerWidth,
  37. innerHeight: $.fn.innerHeight,
  38. outerWidth: $.fn.outerWidth,
  39. outerHeight: $.fn.outerHeight
  40. };
  41. function reduce( elem, size, border, margin ) {
  42. $.each( side, function() {
  43. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  44. if ( border ) {
  45. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  46. }
  47. if ( margin ) {
  48. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  49. }
  50. } );
  51. return size;
  52. }
  53. $.fn[ "inner" + name ] = function( size ) {
  54. if ( size === undefined ) {
  55. return orig[ "inner" + name ].call( this );
  56. }
  57. return this.each( function() {
  58. $( this ).css( type, reduce( this, size ) + "px" );
  59. } );
  60. };
  61. $.fn[ "outer" + name ] = function( size, margin ) {
  62. if ( typeof size !== "number" ) {
  63. return orig[ "outer" + name ].call( this, size );
  64. }
  65. return this.each( function() {
  66. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  67. } );
  68. };
  69. } );
  70. $.fn.addBack = function( selector ) {
  71. return this.add( selector == null ?
  72. this.prevObject : this.prevObject.filter( selector )
  73. );
  74. };
  75. }
  76. } ) );