* Applied patch for #204
[jquery.git] / src / dimensions / dimensions.js
index ce87862..6a7d20a 100644 (file)
@@ -9,21 +9,21 @@
  * If used on window, returns the viewport's (window) height\r
  *\r
  * @example $("#testdiv").height()\r
- * @result "200px"
- *
- * @example $(document).height();
- * @result 800
- *
- * @example $(window).height();
+ * @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
-$.fn.height = function() {\r
-       if ( this.get(0) == window )
-               return self.innerHeight ||
+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
@@ -31,7 +31,7 @@ $.fn.height = function() {
                return Math.max( document.body.scrollHeight, document.body.offsetHeight );\r
        \r
        return this.css("height");\r
-};
+};\r
 \r
 /**\r
  * Returns the css width value for the first matched element.\r
@@ -39,21 +39,21 @@ $.fn.height = function() {
  * If used on window, returns the viewport's (window) width\r
  *\r
  * @example $("#testdiv").width()\r
- * @result "200px"
- *
- * @example $(document).width();
- * @result 800
- *
- * @example $(window).width();
+ * @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
-$.fn.width = function() {\r
-       if ( this.get(0) == window )
-               return self.innerWidth ||
+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
@@ -61,7 +61,7 @@ $.fn.width = function() {
                return Math.max( document.body.scrollWidth, document.body.offsetWidth );\r
        \r
        return this.css("width");\r
-};
+};\r
 \r
 /**\r
  * Returns the inner height value (without border) for the first matched element.\r
@@ -75,11 +75,11 @@ $.fn.width = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.innerHeight = function() {\r
-       return this.get(0) == window || this.get(0) == document ?
-               this.height() :
+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
@@ -93,11 +93,11 @@ $.fn.innerHeight = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.innerWidth = function() {\r
-       return this.get(0) == window || this.get(0) == document ?
-               this.width() :
+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
@@ -110,11 +110,11 @@ $.fn.innerWidth = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.outerHeight = function() {\r
-       return this.get(0) == window || this.get(0) == document ?
-               this.height() :
+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
@@ -127,11 +127,11 @@ $.fn.outerHeight = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.outerWidth = function() {\r
-       return this.get(0) == window || this.get(0) == document ?
-               this.width() :
+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
@@ -144,14 +144,14 @@ $.fn.outerWidth = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.scrollLeft = function() {\r
-       if ( this.get(0) == window || this.get(0) == document )
-               return self.pageXOffset ||
-                       jQuery.boxModel && document.documentElement.scrollLeft ||
-                       document.body.scrollLeft;
+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
@@ -164,20 +164,15 @@ $.fn.scrollLeft = function() {
  * @type Number\r
  * @cat Dimensions\r
  */\r
-$.fn.scrollTop = function() {\r
-       if ( this.get(0) == window || this.get(0) == document )
-               return self.pageYOffset ||
-                       jQuery.boxModel && document.documentElement.scrollTop ||
-                       document.body.scrollTop;
+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
-/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)\r
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) \r
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.\r
- */\r
-\r
 /**\r
  * This returns an object with top, left, width, height, borderLeft,\r
  * borderTop, marginLeft, marginTop, scrollLeft, scrollTop, \r
@@ -253,24 +248,24 @@ $.fn.scrollTop = function() {
  * @cat Dimensions\r
  * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)\r
  */\r
-$.fn.offset = function(refElem) {\r
-       if (!this[0]) throw '$.fn.offset requires an element.';\r
+jQuery.fn.offset = function(refElem) {\r
+       if (!this[0]) throw 'jQuery.fn.offset requires an element.';\r
        \r
-       refElem = (refElem) ? $(refElem)[0] : null;\r
+       refElem = (refElem) ? jQuery(refElem)[0] : null;\r
        var x = 0, y = 0, elm = this[0], parent = this[0], pos = null, borders = [0,0], isElm = true, 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 (($.browser.safari || $.browser.msie) && pos != 'absolute') {\r
-                               x += parseInt($.css(parent, 'marginLeft')) || 0;\r
-                               y += parseInt($.css(parent, 'marginTop'))  || 0;\r
+                       if ((jQuery.browser.safari || jQuery.browser.msie) && pos != 'absolute') {\r
+                               x += parseInt(jQuery.css(parent, 'marginLeft')) || 0;\r
+                               y += parseInt(jQuery.css(parent, 'marginTop'))  || 0;\r
                        }\r
                        break;\r
                }\r
                \r
-               pos    = $.css(parent, 'position');\r
-               border = [parseInt($.css(parent, 'borderLeftWidth')) || 0,\r
-                                                       parseInt($.css(parent, 'borderTopWidth'))  || 0];\r
+               pos    = jQuery.css(parent, 'position');\r
+               border = [parseInt(jQuery.css(parent, 'borderLeftWidth')) || 0,\r
+                                                       parseInt(jQuery.css(parent, 'borderTopWidth'))  || 0];\r
                sl = parent.scrollLeft;\r
                st = parent.scrollTop;\r
                \r
@@ -278,7 +273,7 @@ $.fn.offset = function(refElem) {
                y += (parent.offsetTop  || 0) + border[1] - st;\r
                \r
                // Safari and Opera include the border already for parents with position = absolute|relative\r
-               if (($.browser.safari || $.browser.opera) && !isElm && (pos == 'absolute' || pos == 'relative')) {\r
+               if ((jQuery.browser.safari || jQuery.browser.opera) && !isElm && (pos == 'absolute' || pos == 'relative')) {\r
                        x -= border[0];\r
                        y -= border[1];\r
                }\r
@@ -288,7 +283,7 @@ $.fn.offset = function(refElem) {
        } while(parent);\r
        \r
        if (refElem) {\r
-               var offset = $(refElem).offset();\r
+               var offset = jQuery(refElem).offset();\r
                x  = x  - offset.left;\r
                y  = y  - offset.top;\r
                sl = sl - offset.scrollLeft;\r
@@ -300,10 +295,10 @@ $.fn.offset = function(refElem) {
                left: x,\r
                width:  elm.offsetWidth,\r
                height: elm.offsetHeight,\r
-               borderTop:  parseInt($.css(elm, 'borderTopWidth'))  || 0,\r
-               borderLeft: parseInt($.css(elm, 'borderLeftWidth')) || 0,\r
-               marginTop:  parseInt($.css(elm, 'marginTopWidth'))  || 0,\r
-               marginLeft: parseInt($.css(elm, 'marginLeftWidth')) || 0,\r
+               borderTop:  parseInt(jQuery.css(elm, 'borderTopWidth'))  || 0,\r
+               borderLeft: parseInt(jQuery.css(elm, 'borderLeftWidth')) || 0,\r
+               marginTop:  parseInt(jQuery.css(elm, 'marginTopWidth'))  || 0,\r
+               marginLeft: parseInt(jQuery.css(elm, 'marginLeftWidth')) || 0,\r
                scrollTop:  st,\r
                scrollLeft: sl,\r
                pageYOffset: window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop  || 0,\r