Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

dimensions.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. define( [
  2. "./core",
  3. "./core/access",
  4. "./var/isWindow",
  5. "./css"
  6. ], function( jQuery, access, isWindow ) {
  7. "use strict";
  8. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  9. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  10. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  11. function( defaultExtra, funcName ) {
  12. // Margin is only for outerHeight, outerWidth
  13. jQuery.fn[ funcName ] = function( margin, value ) {
  14. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16. return access( this, function( elem, type, value ) {
  17. var doc;
  18. if ( isWindow( elem ) ) {
  19. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  20. return funcName.indexOf( "outer" ) === 0 ?
  21. elem[ "inner" + name ] :
  22. elem.document.documentElement[ "client" + name ];
  23. }
  24. // Get document width or height
  25. if ( elem.nodeType === 9 ) {
  26. doc = elem.documentElement;
  27. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  28. // whichever is greatest
  29. return Math.max(
  30. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  31. elem.body[ "offset" + name ], doc[ "offset" + name ],
  32. doc[ "client" + name ]
  33. );
  34. }
  35. return value === undefined ?
  36. // Get width or height on the element, requesting but not forcing parseFloat
  37. jQuery.css( elem, type, extra ) :
  38. // Set width or height on the element
  39. jQuery.style( elem, type, value, extra );
  40. }, type, chainable ? margin : undefined, chainable );
  41. };
  42. } );
  43. } );
  44. return jQuery;
  45. } );