Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / docs / source / ext-base-dom.html
index 6c12d37..89b722c 100644 (file)
-<html>\r
-<head>\r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js">(function(){\r
-       var doc = document,\r
-               isCSS1 = doc.compatMode == "CSS1Compat",\r
-               MAX = Math.max,         \r
-               PARSEINT = parseInt;\r
-               \r
-       Ext.lib.Dom = {\r
-           isAncestor : function(p, c) {\r
-                   var ret = false;\r
-                       \r
-                       p = Ext.getDom(p);\r
-                       c = Ext.getDom(c);\r
-                       if (p && c) {\r
-                               if (p.contains) {\r
-                                       return p.contains(c);\r
-                               } else if (p.compareDocumentPosition) {\r
-                                       return !!(p.compareDocumentPosition(c) & 16);\r
-                               } else {\r
-                                       while (c = c.parentNode) {\r
-                                               ret = c == p || ret;                                    \r
-                                       }\r
-                               }                   \r
-                       }       \r
-                       return ret;\r
-               },\r
-               \r
-        getViewWidth : function(full) {\r
-            return full ? this.getDocumentWidth() : this.getViewportWidth();\r
-        },\r
-\r
-        getViewHeight : function(full) {\r
-            return full ? this.getDocumentHeight() : this.getViewportHeight();\r
-        },\r
-\r
-        getDocumentHeight: function() {            \r
-            return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());\r
-        },\r
-\r
-        getDocumentWidth: function() {            \r
-            return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());\r
-        },\r
-\r
-        getViewportHeight: function(){\r
-               return Ext.isIE ? \r
-                          (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :\r
-                          self.innerHeight;\r
-        },\r
-\r
-        getViewportWidth : function() {\r
-               return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :\r
-                          Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;\r
-        },\r
-        \r
-        getY : function(el) {\r
-            return this.getXY(el)[1];\r
-        },\r
-\r
-        getX : function(el) {\r
-            return this.getXY(el)[0];\r
-        },\r
-\r
-        getXY : function(el) {\r
-            var p, \r
-               pe, \r
-               b,\r
-               bt, \r
-               bl,     \r
-               dbd,            \r
-               x = 0,\r
-               y = 0, \r
-               scroll,\r
-               hasAbsolute, \r
-               bd = (doc.body || doc.documentElement),\r
-               ret = [0,0];\r
-               \r
-            el = Ext.getDom(el);\r
-\r
-            if(el != bd){\r
-                   if (el.getBoundingClientRect) {\r
-                       b = el.getBoundingClientRect();\r
-                       scroll = fly(document).getScroll();\r
-                       ret = [b.left + scroll.left, b.top + scroll.top];\r
-                   } else {  \r
-                           p = el;             \r
-                           hasAbsolute = fly(el).isStyle("position", "absolute");\r
-               \r
-                           while (p) {\r
-                                   pe = fly(p);                \r
-                               x += p.offsetLeft;\r
-                               y += p.offsetTop;\r
-               \r
-                               hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");\r
-                                               \r
-                               if (Ext.isGecko) {                                  \r
-                                   y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;\r
-                                   x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;        \r
-               \r
-                                   if (p != el && !pe.isStyle('overflow','visible')) {\r
-                                       x += bl;\r
-                                       y += bt;\r
-                                   }\r
-                               }\r
-                               p = p.offsetParent;\r
-                           }\r
-               \r
-                           if (Ext.isSafari && hasAbsolute) {\r
-                               x -= bd.offsetLeft;\r
-                               y -= bd.offsetTop;\r
-                           }\r
-               \r
-                           if (Ext.isGecko && !hasAbsolute) {\r
-                               dbd = fly(bd);\r
-                               x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;\r
-                               y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;\r
-                           }\r
-               \r
-                           p = el.parentNode;\r
-                           while (p && p != bd) {\r
-                               if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {\r
-                                   x -= p.scrollLeft;\r
-                                   y -= p.scrollTop;\r
-                               }\r
-                               p = p.parentNode;\r
-                           }\r
-                           ret = [x,y];\r
-                   }\r
-               }\r
-            return ret\r
-        },\r
-\r
-        setXY : function(el, xy) {\r
-            (el = Ext.fly(el, '_setXY')).position();\r
-            \r
-            var pts = el.translatePoints(xy),\r
-               style = el.dom.style,\r
-               pos;                    \r
-            \r
-            for (pos in pts) {             \r
-                   if(!isNaN(pts[pos])) style[pos] = pts[pos] + "px"\r
-            }\r
-        },\r
-\r
-        setX : function(el, x) {\r
-            this.setXY(el, [x, false]);\r
-        },\r
-\r
-        setY : function(el, y) {\r
-            this.setXY(el, [false, y]);\r
-        }\r
-    };\r
-})();</pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+(function(){
+       var doc = document,
+               isCSS1 = doc.compatMode == "CSS1Compat",
+               MAX = Math.max,         
+        ROUND = Math.round,
+               PARSEINT = parseInt;
+               
+       Ext.lib.Dom = {
+           isAncestor : function(p, c) {
+                   var ret = false;
+                       
+                       p = Ext.getDom(p);
+                       c = Ext.getDom(c);
+                       if (p && c) {
+                               if (p.contains) {
+                                       return p.contains(c);
+                               } else if (p.compareDocumentPosition) {
+                                       return !!(p.compareDocumentPosition(c) & 16);
+                               } else {
+                                       while (c = c.parentNode) {
+                                               ret = c == p || ret;                                    
+                                       }
+                               }                   
+                       }       
+                       return ret;
+               },
+               
+        getViewWidth : function(full) {
+            return full ? this.getDocumentWidth() : this.getViewportWidth();
+        },
+
+        getViewHeight : function(full) {
+            return full ? this.getDocumentHeight() : this.getViewportHeight();
+        },
+
+        getDocumentHeight: function() {            
+            return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());
+        },
+
+        getDocumentWidth: function() {            
+            return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());
+        },
+
+        getViewportHeight: function(){
+               return Ext.isIE ? 
+                          (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
+                          self.innerHeight;
+        },
+
+        getViewportWidth : function() {
+               return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :
+                          Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
+        },
+        
+        getY : function(el) {
+            return this.getXY(el)[1];
+        },
+
+        getX : function(el) {
+            return this.getXY(el)[0];
+        },
+
+        getXY : function(el) {
+            var p, 
+               pe, 
+               b,
+               bt, 
+               bl,     
+               dbd,            
+               x = 0,
+               y = 0, 
+               scroll,
+               hasAbsolute, 
+               bd = (doc.body || doc.documentElement),
+               ret = [0,0];
+               
+            el = Ext.getDom(el);
+
+            if(el != bd){
+                   if (el.getBoundingClientRect) {
+                       b = el.getBoundingClientRect();
+                       scroll = fly(document).getScroll();
+                       ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)];
+                   } else {  
+                           p = el;             
+                           hasAbsolute = fly(el).isStyle("position", "absolute");
+               
+                           while (p) {
+                                   pe = fly(p);                
+                               x += p.offsetLeft;
+                               y += p.offsetTop;
+               
+                               hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
+                                               
+                               if (Ext.isGecko) {                                  
+                                   y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;
+                                   x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;        
+               
+                                   if (p != el && !pe.isStyle('overflow','visible')) {
+                                       x += bl;
+                                       y += bt;
+                                   }
+                               }
+                               p = p.offsetParent;
+                           }
+               
+                           if (Ext.isSafari && hasAbsolute) {
+                               x -= bd.offsetLeft;
+                               y -= bd.offsetTop;
+                           }
+               
+                           if (Ext.isGecko && !hasAbsolute) {
+                               dbd = fly(bd);
+                               x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;
+                               y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;
+                           }
+               
+                           p = el.parentNode;
+                           while (p && p != bd) {
+                               if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
+                                   x -= p.scrollLeft;
+                                   y -= p.scrollTop;
+                               }
+                               p = p.parentNode;
+                           }
+                           ret = [x,y];
+                   }
+               }
+            return ret
+        },
+
+        setXY : function(el, xy) {
+            (el = Ext.fly(el, '_setXY')).position();
+            
+            var pts = el.translatePoints(xy),
+               style = el.dom.style,
+               pos;                    
+            
+            for (pos in pts) {             
+                   if(!isNaN(pts[pos])) style[pos] = pts[pos] + "px"
+            }
+        },
+
+        setX : function(el, x) {
+            this.setXY(el, [x, false]);
+        },
+
+        setY : function(el, y) {
+            this.setXY(el, [false, y]);
+        }
+    };
+})();</pre>    
+</body>
 </html>
\ No newline at end of file