You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7KB

  1. define( [
  2. "./core",
  3. "./core/access",
  4. "./css"
  5. ], function( jQuery, access ) {
  6. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  7. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  9. function( defaultExtra, funcName ) {
  10. // Margin is only for outerHeight, outerWidth
  11. jQuery.fn[ funcName ] = function( margin, value ) {
  12. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  13. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  14. return access( this, function( elem, type, value ) {
  15. var doc;
  16. if ( jQuery.isWindow( elem ) ) {
  17. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  18. // isn't a whole lot we can do. See pull request at this URL for discussion:
  19. // https://github.com/jquery/jquery/pull/764
  20. return elem.document.documentElement[ "client" + name ];
  21. }
  22. // Get document width or height
  23. if ( elem.nodeType === 9 ) {
  24. doc = elem.documentElement;
  25. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  26. // whichever is greatest
  27. return Math.max(
  28. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  29. elem.body[ "offset" + name ], doc[ "offset" + name ],
  30. doc[ "client" + name ]
  31. );
  32. }
  33. return value === undefined ?
  34. // Get width or height on the element, requesting but not forcing parseFloat
  35. jQuery.css( elem, type, extra ) :
  36. // Set width or height on the element
  37. jQuery.style( elem, type, value, extra );
  38. }, type, chainable ? margin : undefined, chainable, null );
  39. };
  40. } );
  41. } );
  42. return jQuery;
  43. } );