tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

dimensions.js (1756B)


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