Moved dimensions to the plugins area.
authorJohn Resig <jeresig@gmail.com>
Thu, 26 Oct 2006 19:21:54 +0000 (19:21 +0000)
committerJohn Resig <jeresig@gmail.com>
Thu, 26 Oct 2006 19:21:54 +0000 (19:21 +0000)
src/dimensions/dimensions.js [deleted file]

diff --git a/src/dimensions/dimensions.js b/src/dimensions/dimensions.js
deleted file mode 100644 (file)
index 1a8e87a..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/** \r
- * This plugin overrides jQuery's height() and width() functions and\r
- * adds more handy stuff for cross-browser compatibility.\r
- */\r
-\r
-/**\r
- * Returns the css height value for the first matched element.\r
- * If used on document, returns the document's height (innerHeight)\r
- * If used on window, returns the viewport's (window) height\r
- *\r
- * @example $("#testdiv").height()\r
- * @result "200px"\r
- *\r
- * @example $(document).height();\r
- * @result 800\r
- *\r
- * @example $(window).height();\r
- * @result 400\r
- * \r
- * @name height\r
- * @type Object\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.height = function() {\r
-       if ( this.get(0) == window )\r
-               return self.innerHeight ||\r
-                       jQuery.boxModel && document.documentElement.clientHeight ||\r
-                       document.body.clientHeight;\r
-       \r
-       if ( this.get(0) == document )\r
-               return Math.max( document.body.scrollHeight, document.body.offsetHeight );\r
-       \r
-       return this.css("height", arguments[0]);\r
-};\r
-\r
-/**\r
- * Returns the css width value for the first matched element.\r
- * If used on document, returns the document's width (innerWidth)\r
- * If used on window, returns the viewport's (window) width\r
- *\r
- * @example $("#testdiv").width()\r
- * @result "200px"\r
- *\r
- * @example $(document).width();\r
- * @result 800\r
- *\r
- * @example $(window).width();\r
- * @result 400\r
- * \r
- * @name width\r
- * @type Object\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.width = function() {\r
-       if ( this.get(0) == window )\r
-               return self.innerWidth ||\r
-                       jQuery.boxModel && document.documentElement.clientWidth ||\r
-                       document.body.clientWidth;\r
-       \r
-       if ( this.get(0) == document )\r
-               return Math.max( document.body.scrollWidth, document.body.offsetWidth );\r
-       \r
-       return this.css("width", arguments[0]);\r
-};\r
-\r
-/**\r
- * Returns the inner height value (without border) for the first matched element.\r
- * If used on document, returns the document's height (innerHeight)\r
- * If used on window, returns the viewport's (window) height\r
- *\r
- * @example $("#testdiv").innerHeight()\r
- * @result 800\r
- * \r
- * @name innerHeight\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.innerHeight = function() {\r
-       return this.get(0) == window || this.get(0) == document ?\r
-               this.height() :\r
-               this.get(0).offsetHeight - parseInt(this.css("borderTop") || 0) - parseInt(this.css("borderBottom") || 0);\r
-};\r
-\r
-/**\r
- * Returns the inner width value (without border) for the first matched element.\r
- * If used on document, returns the document's Width (innerWidth)\r
- * If used on window, returns the viewport's (window) width\r
- *\r
- * @example $("#testdiv").innerWidth()\r
- * @result 1000\r
- * \r
- * @name innerWidth\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.innerWidth = function() {\r
-       return this.get(0) == window || this.get(0) == document ?\r
-               this.width() :\r
-               this.get(0).offsetWidth - parseInt(this.css("borderLeft") || 0) - parseInt(this.css("borderRight") || 0);\r
-};\r
-\r
-/**\r
- * Returns the outer height value (including border) for the first matched element.\r
- * Cannot be used on document or window.\r
- *\r
- * @example $("#testdiv").outerHeight()\r
- * @result 1000\r
- * \r
- * @name outerHeight\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.outerHeight = function() {\r
-       return this.get(0) == window || this.get(0) == document ?\r
-               this.height() :\r
-               this.get(0).offsetHeight;       \r
-};\r
-\r
-/**\r
- * Returns the outer width value (including border) for the first matched element.\r
- * Cannot be used on document or window.\r
- *\r
- * @example $("#testdiv").outerWidth()\r
- * @result 1000\r
- * \r
- * @name outerWidth\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.outerWidth = function() {\r
-       return this.get(0) == window || this.get(0) == document ?\r
-               this.width() :\r
-               this.get(0).offsetWidth;        \r
-};\r
-\r
-/**\r
- * Returns how many pixels the user has scrolled to the right (scrollLeft).\r
- * Works on containers with overflow: auto and window/document.\r
- *\r
- * @example $("#testdiv").scrollLeft()\r
- * @result 100\r
- * \r
- * @name scrollLeft\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.scrollLeft = function() {\r
-       if ( this.get(0) == window || this.get(0) == document )\r
-               return self.pageXOffset ||\r
-                       jQuery.boxModel && document.documentElement.scrollLeft ||\r
-                       document.body.scrollLeft;\r
-       \r
-       return this.get(0).scrollLeft;\r
-};\r
-\r
-/**\r
- * Returns how many pixels the user has scrolled to the bottom (scrollTop).\r
- * Works on containers with overflow: auto and window/document.\r
- *\r
- * @example $("#testdiv").scrollTop()\r
- * @result 100\r
- * \r
- * @name scrollTop\r
- * @type Number\r
- * @cat Dimensions\r
- */\r
-jQuery.fn.scrollTop = function() {\r
-       if ( this.get(0) == window || this.get(0) == document )\r
-               return self.pageYOffset ||\r
-                       jQuery.boxModel && document.documentElement.scrollTop ||\r
-                       document.body.scrollTop;\r
-\r
-       return this.get(0).scrollTop;\r
-};\r
-\r
-/**\r
- * This returns an object with top, left, width, height, borderLeft,\r
- * borderTop, marginLeft, marginTop, scrollLeft, scrollTop, \r
- * pageXOffset, pageYOffset.\r
- *\r
- * The top and left values include the scroll offsets but the\r
- * scrollLeft and scrollTop properties of the returned object\r
- * are the combined scroll offets of the parent elements \r
- * (not including the window scroll offsets). This is not the\r
- * same as the element's scrollTop and scrollLeft.\r
- * \r
- * For accurate readings make sure to use pixel values.\r
- *\r
- * @name offset        \r
- * @type Object\r
- * @cat Dimensions\r
- * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)\r
- */\r
-/**\r
- * This returns an object with top, left, width, height, borderLeft,\r
- * borderTop, marginLeft, marginTop, scrollLeft, scrollTop, \r
- * pageXOffset, pageYOffset.\r
- *\r
- * The top and left values include the scroll offsets but the\r
- * scrollLeft and scrollTop properties of the returned object\r
- * are the combined scroll offets of the parent elements \r
- * (not including the window scroll offsets). This is not the\r
- * same as the element's scrollTop and scrollLeft.\r
- * \r
- * For accurate readings make sure to use pixel values.\r
- *\r
- * @name offset        \r
- * @type Object\r
- * @param String refElement This is an expression. The offset returned will be relative to the first matched element.\r
- * @cat Dimensions\r
- * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)\r
- */\r
-/**\r
- * This returns an object with top, left, width, height, borderLeft,\r
- * borderTop, marginLeft, marginTop, scrollLeft, scrollTop, \r
- * pageXOffset, pageYOffset.\r
- *\r
- * The top and left values include the scroll offsets but the\r
- * scrollLeft and scrollTop properties of the returned object\r
- * are the combined scroll offets of the parent elements \r
- * (not including the window scroll offsets). This is not the\r
- * same as the element's scrollTop and scrollLeft.\r
- * \r
- * For accurate readings make sure to use pixel values.\r
- *\r
- * @name offset        \r
- * @type Object\r
- * @param jQuery refElement The offset returned will be relative to the first matched element.\r
- * @cat Dimensions\r
- * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)\r
- */\r
-/**\r
- * This returns an object with top, left, width, height, borderLeft,\r
- * borderTop, marginLeft, marginTop, scrollLeft, scrollTop, \r
- * pageXOffset, pageYOffset.\r
- *\r
- * The top and left values include the scroll offsets but the\r
- * scrollLeft and scrollTop properties of the returned object\r
- * are the combined scroll offets of the parent elements \r
- * (not including the window scroll offsets). This is not the\r
- * same as the element's scrollTop and scrollLeft.\r
- * \r
- * For accurate readings make sure to use pixel values.\r
- *\r
- * @name offset        \r
- * @type Object\r
- * @param HTMLElement refElement The offset returned will be relative to this element.\r
- * @cat Dimensions\r
- * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)\r
- */\r
-jQuery.fn.offset = function(refElem) {\r
-       if (!this[0]) throw 'jQuery.fn.offset requires an element.';\r
-\r
-       refElem = (refElem) ? jQuery(refElem)[0] : null;\r
-       var x = 0, y = 0, elem = this[0], parent = this[0], sl = 0, st = 0;\r
-       do {\r
-               if (parent.tagName == 'BODY' || parent.tagName == 'HTML') {\r
-                       // Safari and IE don't add margin for static and relative\r
-                       if ((jQuery.browser.safari || jQuery.browser.msie) && jQuery.css(parent, 'position') != 'absolute') {\r
-                               x += parseInt(jQuery.css(parent, 'marginLeft')) || 0;\r
-                               y += parseInt(jQuery.css(parent, 'marginTop'))  || 0;\r
-                       }\r
-                       break;\r
-               }\r
-\r
-               x += parent.offsetLeft || 0;\r
-               y += parent.offsetTop  || 0;\r
-\r
-               // Mozilla and IE do not add the border\r
-               if (jQuery.browser.mozilla || jQuery.browser.msie) {\r
-                       x += parseInt(jQuery.css(parent, 'borderLeftWidth')) || 0;\r
-                       y += parseInt(jQuery.css(parent, 'borderTopWidth'))  || 0;\r
-               }\r
-\r
-               // Need to get scroll offsets in-between offsetParents\r
-               var op = parent.offsetParent;\r
-               do {\r
-                       sl += parent.scrollLeft || 0;\r
-                       st += parent.scrollTop  || 0;\r
-                       parent = parent.parentNode;\r
-               } while (parent != op);\r
-       } while (parent);\r
-\r
-       if (refElem) { // Get the relative offset\r
-               var offset = jQuery(refElem).offset();\r
-               x  = x  - offset.left;\r
-               y  = y  - offset.top;\r
-               sl = sl - offset.scrollLeft;\r
-               st = st - offset.scrollTop;\r
-       }\r
-\r
-       // Safari and Opera do not add the border for the element\r
-       if (jQuery.browser.safari || jQuery.browser.opera) {\r
-               x += parseInt(jQuery.css(elem, 'borderLeftWidth')) || 0;\r
-               y += parseInt(jQuery.css(elem, 'borderTopWidth'))  || 0;\r
-       }\r
-\r
-       return {\r
-               top:  y - st,\r
-               left: x - sl,\r
-               width:  elem.offsetWidth,\r
-               height: elem.offsetHeight,\r
-               borderTop:  parseInt(jQuery.css(elem, 'borderTopWidth'))  || 0,\r
-               borderLeft: parseInt(jQuery.css(elem, 'borderLeftWidth')) || 0,\r
-               marginTop:  parseInt(jQuery.css(elem, 'marginTopWidth'))  || 0,\r
-               marginLeft: parseInt(jQuery.css(elem, 'marginLeftWidth')) || 0,\r
-               scrollTop:  st,\r
-               scrollLeft: sl,\r
-               pageYOffset: window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop  || 0,\r
-               pageXOffset: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0\r
-       };\r
-};
\ No newline at end of file