Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / Element.position.html
index a27c5cd..399721b 100644 (file)
@@ -1,90 +1,94 @@
+<!DOCTYPE html>
 <html>
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <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>
+  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
 </head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.3.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-/**
- * @class Ext.Element
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
+</span> * @class Ext.Element
  */
 (function(){
-var D = Ext.lib.Dom,
-        LEFT = "left",
-        RIGHT = "right",
-        TOP = "top",
-        BOTTOM = "bottom",
-        POSITION = "position",
-        STATIC = "static",
-        RELATIVE = "relative",
-        AUTO = "auto",
-        ZINDEX = "z-index";
-
-Ext.Element.addMethods({
-       <div id="method-Ext.Element-getX"></div>/**
-      * Gets the current X position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+
+var ELEMENT = Ext.Element,
+    LEFT = &quot;left&quot;,
+    RIGHT = &quot;right&quot;,
+    TOP = &quot;top&quot;,
+    BOTTOM = &quot;bottom&quot;,
+    POSITION = &quot;position&quot;,
+    STATIC = &quot;static&quot;,
+    RELATIVE = &quot;relative&quot;,
+    AUTO = &quot;auto&quot;,
+    ZINDEX = &quot;z-index&quot;;
+
+Ext.override(Ext.Element, {
+<span id='Ext-Element-method-getX'>    /**
+</span>      * Gets the current X position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
       * @return {Number} The X position of the element
       */
     getX : function(){
-        return D.getX(this.dom);
+        return ELEMENT.getX(this.dom);
     },
 
-    <div id="method-Ext.Element-getY"></div>/**
-      * Gets the current Y position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+<span id='Ext-Element-method-getY'>    /**
+</span>      * Gets the current Y position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
       * @return {Number} The Y position of the element
       */
     getY : function(){
-        return D.getY(this.dom);
+        return ELEMENT.getY(this.dom);
     },
 
-    <div id="method-Ext.Element-getXY"></div>/**
-      * Gets the current position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-      * @return {Array} The XY position of the element
+<span id='Ext-Element-method-getXY'>    /**
+</span>      * Gets the current position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+      * @return {Number[]} The XY position of the element
       */
     getXY : function(){
-        return D.getXY(this.dom);
+        return ELEMENT.getXY(this.dom);
     },
 
-    <div id="method-Ext.Element-getOffsetsTo"></div>/**
-      * Returns the offsets of this element from the passed element. Both element must be part of the DOM tree and not have display:none to have page coordinates.
-      * @param {Mixed} element The element to get the offsets from.
-      * @return {Array} The XY page offsets (e.g. [100, -200])
+<span id='Ext-Element-method-getOffsetsTo'>    /**
+</span>      * Returns the offsets of this element from the passed element. Both element must be part of the DOM tree and not have display:none to have page coordinates.
+      * @param {String/HTMLElement/Ext.Element} element The element to get the offsets from.
+      * @return {Number[]} The XY page offsets (e.g. [100, -200])
       */
     getOffsetsTo : function(el){
         var o = this.getXY(),
-               e = Ext.fly(el, '_internal').getXY();
+            e = Ext.fly(el, '_internal').getXY();
         return [o[0]-e[0],o[1]-e[1]];
     },
 
-    <div id="method-Ext.Element-setX"></div>/**
-     * Sets the X position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+<span id='Ext-Element-method-setX'>    /**
+</span>     * Sets the X position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
      * @param {Number} The X position of the element
      * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
      * @return {Ext.Element} this
      */
-    setX : function(x, animate){           
-           return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
+    setX : function(x, animate){
+        return this.setXY([x, this.getY()], animate);
     },
 
-    <div id="method-Ext.Element-setY"></div>/**
-     * Sets the Y position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+<span id='Ext-Element-method-setY'>    /**
+</span>     * Sets the Y position of the element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
      * @param {Number} The Y position of the element
      * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
      * @return {Ext.Element} this
      */
-    setY : function(y, animate){           
-           return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
+    setY : function(y, animate){
+        return this.setXY([this.getX(), y], animate);
     },
 
-    <div id="method-Ext.Element-setLeft"></div>/**
-     * Sets the element's left position directly using CSS style (instead of {@link #setX}).
+<span id='Ext-Element-method-setLeft'>    /**
+</span>     * Sets the element's left position directly using CSS style (instead of {@link #setX}).
      * @param {String} left The left CSS property value
      * @return {Ext.Element} this
      */
@@ -93,8 +97,8 @@ Ext.Element.addMethods({
         return this;
     },
 
-    <div id="method-Ext.Element-setTop"></div>/**
-     * Sets the element's top position directly using CSS style (instead of {@link #setY}).
+<span id='Ext-Element-method-setTop'>    /**
+</span>     * Sets the element's top position directly using CSS style (instead of {@link #setY}).
      * @param {String} top The top CSS property value
      * @return {Ext.Element} this
      */
@@ -103,8 +107,8 @@ Ext.Element.addMethods({
         return this;
     },
 
-    <div id="method-Ext.Element-setRight"></div>/**
-     * Sets the element's CSS right style.
+<span id='Ext-Element-method-setRight'>    /**
+</span>     * Sets the element's CSS right style.
      * @param {String} right The right CSS property value
      * @return {Ext.Element} this
      */
@@ -113,8 +117,8 @@ Ext.Element.addMethods({
         return this;
     },
 
-    <div id="method-Ext.Element-setBottom"></div>/**
-     * Sets the element's CSS bottom style.
+<span id='Ext-Element-method-setBottom'>    /**
+</span>     * Sets the element's CSS bottom style.
      * @param {String} bottom The bottom CSS property value
      * @return {Ext.Element} this
      */
@@ -123,25 +127,29 @@ Ext.Element.addMethods({
         return this;
     },
 
-    <div id="method-Ext.Element-setXY"></div>/**
-     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
+<span id='Ext-Element-method-setXY'>    /**
+</span>     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
      * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
-     * @param {Array} pos Contains X & Y [x, y] values for new position (coordinates are page-based)
+     * @param {Number[]} pos Contains X &amp; Y [x, y] values for new position (coordinates are page-based)
      * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
      * @return {Ext.Element} this
      */
-    setXY : function(pos, animate){
-           var me = this;
-        if(!animate || !me.anim){
-            D.setXY(me.dom, pos);
-        }else{
-            me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
+    setXY: function(pos, animate) {
+        var me = this;
+        if (!animate || !me.anim) {
+            ELEMENT.setXY(me.dom, pos);
+        }
+        else {
+            if (!Ext.isObject(animate)) {
+                animate = {};
+            }
+            me.animate(Ext.applyIf({ to: { x: pos[0], y: pos[1] } }, animate));
         }
         return me;
     },
 
-    <div id="method-Ext.Element-setLocation"></div>/**
-     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
+<span id='Ext-Element-method-setLocation'>    /**
+</span>     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
      * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
      * @param {Number} x X value for new position (coordinates are page-based)
      * @param {Number} y Y value for new position (coordinates are page-based)
@@ -149,11 +157,11 @@ Ext.Element.addMethods({
      * @return {Ext.Element} this
      */
     setLocation : function(x, y, animate){
-        return this.setXY([x, y], this.animTest(arguments, animate, 2));
+        return this.setXY([x, y], animate);
     },
 
-    <div id="method-Ext.Element-moveTo"></div>/**
-     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
+<span id='Ext-Element-method-moveTo'>    /**
+</span>     * Sets the position of the element in page coordinates, regardless of how the element is positioned.
      * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
      * @param {Number} x X value for new position (coordinates are page-based)
      * @param {Number} y Y value for new position (coordinates are page-based)
@@ -161,71 +169,73 @@ Ext.Element.addMethods({
      * @return {Ext.Element} this
      */
     moveTo : function(x, y, animate){
-        return this.setXY([x, y], this.animTest(arguments, animate, 2));        
-    },    
-    
-    <div id="method-Ext.Element-getLeft"></div>/**
-     * Gets the left X coordinate
+        return this.setXY([x, y], animate);
+    },
+
+<span id='Ext-Element-method-getLeft'>    /**
+</span>     * Gets the left X coordinate
      * @param {Boolean} local True to get the local css position instead of page coordinate
      * @return {Number}
      */
     getLeft : function(local){
-           return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
+        return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
     },
 
-    <div id="method-Ext.Element-getRight"></div>/**
-     * Gets the right X coordinate of the element (element X position + element width)
+<span id='Ext-Element-method-getRight'>    /**
+</span>     * Gets the right X coordinate of the element (element X position + element width)
      * @param {Boolean} local True to get the local css position instead of page coordinate
      * @return {Number}
      */
     getRight : function(local){
-           var me = this;
-           return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
+        var me = this;
+        return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
     },
 
-    <div id="method-Ext.Element-getTop"></div>/**
-     * Gets the top Y coordinate
+<span id='Ext-Element-method-getTop'>    /**
+</span>     * Gets the top Y coordinate
      * @param {Boolean} local True to get the local css position instead of page coordinate
      * @return {Number}
      */
     getTop : function(local) {
-           return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
+        return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
     },
 
-    <div id="method-Ext.Element-getBottom"></div>/**
-     * Gets the bottom Y coordinate of the element (element Y position + element height)
+<span id='Ext-Element-method-getBottom'>    /**
+</span>     * Gets the bottom Y coordinate of the element (element Y position + element height)
      * @param {Boolean} local True to get the local css position instead of page coordinate
      * @return {Number}
      */
     getBottom : function(local){
-           var me = this;
-           return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
+        var me = this;
+        return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
     },
 
-    <div id="method-Ext.Element-position"></div>/**
-    * Initializes positioning on this element. If a desired position is not passed, it will make the
+<span id='Ext-Element-method-position'>    /**
+</span>    * Initializes positioning on this element. If a desired position is not passed, it will make the
     * the element positioned relative IF it is not already positioned.
-    * @param {String} pos (optional) Positioning to use "relative", "absolute" or "fixed"
+    * @param {String} pos (optional) Positioning to use &quot;relative&quot;, &quot;absolute&quot; or &quot;fixed&quot;
     * @param {Number} zIndex (optional) The zIndex to apply
     * @param {Number} x (optional) Set the page X position
     * @param {Number} y (optional) Set the page Y position
     */
-    position : function(pos, zIndex, x, y){
-           var me = this;
-           
-        if(!pos && me.isStyle(POSITION, STATIC)){           
-            me.setStyle(POSITION, RELATIVE);           
+    position : function(pos, zIndex, x, y) {
+        var me = this;
+
+        if (!pos &amp;&amp; me.isStyle(POSITION, STATIC)){
+            me.setStyle(POSITION, RELATIVE);
         } else if(pos) {
             me.setStyle(POSITION, pos);
         }
-        if(zIndex){
+        if (zIndex){
             me.setStyle(ZINDEX, zIndex);
         }
-        if(x || y) me.setXY([x || false, y || false]);
+        if (x || y) {
+            me.setXY([x || false, y || false]);
+        }
     },
 
-    <div id="method-Ext.Element-clearPositioning"></div>/**
-    * Clear positioning back to the default when the document was loaded
+<span id='Ext-Element-method-clearPositioning'>    /**
+</span>    * Clear positioning back to the default when the document was loaded
     * @param {String} value (optional) The value to use for the left,right,top,bottom, defaults to '' (empty string). You could use 'auto'.
     * @return {Ext.Element} this
      */
@@ -236,14 +246,14 @@ Ext.Element.addMethods({
             right : value,
             top : value,
             bottom : value,
-            "z-index" : "",
+            &quot;z-index&quot; : &quot;&quot;,
             position : STATIC
         });
         return this;
     },
 
-    <div id="method-Ext.Element-getPositioning"></div>/**
-    * Gets an object with all CSS positioning properties. Useful along with setPostioning to get
+<span id='Ext-Element-method-getPositioning'>    /**
+</span>    * Gets an object with all CSS positioning properties. Useful along with setPostioning to get
     * snapshot before performing an update and then restoring the element.
     * @return {Object}
     */
@@ -251,61 +261,323 @@ Ext.Element.addMethods({
         var l = this.getStyle(LEFT);
         var t = this.getStyle(TOP);
         return {
-            "position" : this.getStyle(POSITION),
-            "left" : l,
-            "right" : l ? "" : this.getStyle(RIGHT),
-            "top" : t,
-            "bottom" : t ? "" : this.getStyle(BOTTOM),
-            "z-index" : this.getStyle(ZINDEX)
+            &quot;position&quot; : this.getStyle(POSITION),
+            &quot;left&quot; : l,
+            &quot;right&quot; : l ? &quot;&quot; : this.getStyle(RIGHT),
+            &quot;top&quot; : t,
+            &quot;bottom&quot; : t ? &quot;&quot; : this.getStyle(BOTTOM),
+            &quot;z-index&quot; : this.getStyle(ZINDEX)
         };
     },
-    
-    <div id="method-Ext.Element-setPositioning"></div>/**
-    * Set positioning with an object returned by getPositioning().
+
+<span id='Ext-Element-method-setPositioning'>    /**
+</span>    * Set positioning with an object returned by getPositioning().
     * @param {Object} posCfg
     * @return {Ext.Element} this
      */
     setPositioning : function(pc){
-           var me = this,
-               style = me.dom.style;
-               
+        var me = this,
+            style = me.dom.style;
+
         me.setStyle(pc);
-        
+
         if(pc.right == AUTO){
-            style.right = "";
+            style.right = &quot;&quot;;
         }
         if(pc.bottom == AUTO){
-            style.bottom = "";
+            style.bottom = &quot;&quot;;
         }
-        
+
         return me;
-    },    
-       
-    <div id="method-Ext.Element-translatePoints"></div>/**
-     * Translates the passed page coordinates into left/top css values for this element
-     * @param {Number/Array} x The page x or an array containing [x, y]
+    },
+
+<span id='Ext-Element-method-translatePoints'>    /**
+</span>     * Translates the passed page coordinates into left/top css values for this element
+     * @param {Number/Number[]} x The page x or an array containing [x, y]
      * @param {Number} y (optional) The page y, required if x is not an array
      * @return {Object} An object with left and top properties. e.g. {left: (value), top: (value)}
      */
-    translatePoints : function(x, y){               
-           y = isNaN(x[1]) ? y : x[1];
-        x = isNaN(x[0]) ? x : x[0];
+    translatePoints: function(x, y) {
+        if (Ext.isArray(x)) {
+             y = x[1];
+             x = x[0];
+        }
         var me = this,
-               relative = me.isStyle(POSITION, RELATIVE),
-               o = me.getXY(),
-               l = parseInt(me.getStyle(LEFT), 10),
-               t = parseInt(me.getStyle(TOP), 10);
-        
-        l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
-        t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);        
-
-        return {left: (x - o[0] + l), top: (y - o[1] + t)}; 
+            relative = me.isStyle(POSITION, RELATIVE),
+            o = me.getXY(),
+            left = parseInt(me.getStyle(LEFT), 10),
+            top = parseInt(me.getStyle(TOP), 10);
+
+        if (!Ext.isNumber(left)) {
+            left = relative ? 0 : me.dom.offsetLeft;
+        }
+        if (!Ext.isNumber(top)) {
+            top = relative ? 0 : me.dom.offsetTop;
+        }
+        left = (Ext.isNumber(x)) ? x - o[0] + left : undefined;
+        top = (Ext.isNumber(y)) ? y - o[1] + top : undefined;
+        return {
+            left: left,
+            top: top
+        };
+    },
+
+<span id='Ext-Element-method-setBox'>    /**
+</span>     * Sets the element's box. Use getBox() on another element to get a box obj. If animate is true then width, height, x and y will be animated concurrently.
+     * @param {Object} box The box to fill {x, y, width, height}
+     * @param {Boolean} adjust (optional) Whether to adjust for box-model issues automatically
+     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
+     * @return {Ext.Element} this
+     */
+    setBox: function(box, adjust, animate) {
+        var me = this,
+            w = box.width,
+            h = box.height;
+        if ((adjust &amp;&amp; !me.autoBoxAdjust) &amp;&amp; !me.isBorderBox()) {
+            w -= (me.getBorderWidth(&quot;lr&quot;) + me.getPadding(&quot;lr&quot;));
+            h -= (me.getBorderWidth(&quot;tb&quot;) + me.getPadding(&quot;tb&quot;));
+        }
+        me.setBounds(box.x, box.y, w, h, animate);
+        return me;
     },
-    
-    animTest : function(args, animate, i) {
-        return !!animate && this.preanim ? this.preanim(args, i) : false;
+
+<span id='Ext-Element-method-getBox'>    /**
+</span>     * Return an object defining the area of this Element which can be passed to {@link #setBox} to
+     * set another Element's size/location to match this element.
+     * @param {Boolean} contentBox (optional) If true a box for the content of the element is returned.
+     * @param {Boolean} local (optional) If true the element's left and top are returned instead of page x/y.
+     * @return {Object} box An object in the format&lt;pre&gt;&lt;code&gt;
+{
+    x: &amp;lt;Element's X position&gt;,
+    y: &amp;lt;Element's Y position&gt;,
+    width: &amp;lt;Element's width&gt;,
+    height: &amp;lt;Element's height&gt;,
+    bottom: &amp;lt;Element's lower bound&gt;,
+    right: &amp;lt;Element's rightmost bound&gt;
+}
+&lt;/code&gt;&lt;/pre&gt;
+     * The returned object may also be addressed as an Array where index 0 contains the X position
+     * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
+     */
+    getBox: function(contentBox, local) {
+        var me = this,
+            xy,
+            left,
+            top,
+            getBorderWidth = me.getBorderWidth,
+            getPadding = me.getPadding,
+            l, r, t, b, w, h, bx;
+        if (!local) {
+            xy = me.getXY();
+        } else {
+            left = parseInt(me.getStyle(&quot;left&quot;), 10) || 0;
+            top = parseInt(me.getStyle(&quot;top&quot;), 10) || 0;
+            xy = [left, top];
+        }
+        w = me.getWidth();
+        h = me.getHeight();
+        if (!contentBox) {
+            bx = {
+                x: xy[0],
+                y: xy[1],
+                0: xy[0],
+                1: xy[1],
+                width: w,
+                height: h
+            };
+        } else {
+            l = getBorderWidth.call(me, &quot;l&quot;) + getPadding.call(me, &quot;l&quot;);
+            r = getBorderWidth.call(me, &quot;r&quot;) + getPadding.call(me, &quot;r&quot;);
+            t = getBorderWidth.call(me, &quot;t&quot;) + getPadding.call(me, &quot;t&quot;);
+            b = getBorderWidth.call(me, &quot;b&quot;) + getPadding.call(me, &quot;b&quot;);
+            bx = {
+                x: xy[0] + l,
+                y: xy[1] + t,
+                0: xy[0] + l,
+                1: xy[1] + t,
+                width: w - (l + r),
+                height: h - (t + b)
+            };
+        }
+        bx.right = bx.x + bx.width;
+        bx.bottom = bx.y + bx.height;
+        return bx;
+    },
+
+<span id='Ext-Element-method-move'>    /**
+</span>     * Move this element relative to its current position.
+     * @param {String} direction Possible values are: &quot;l&quot; (or &quot;left&quot;), &quot;r&quot; (or &quot;right&quot;), &quot;t&quot; (or &quot;top&quot;, or &quot;up&quot;), &quot;b&quot; (or &quot;bottom&quot;, or &quot;down&quot;).
+     * @param {Number} distance How far to move the element in pixels
+     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
+     */
+    move: function(direction, distance, animate) {
+        var me = this,
+            xy = me.getXY(),
+            x = xy[0],
+            y = xy[1],
+            left = [x - distance, y],
+            right = [x + distance, y],
+            top = [x, y - distance],
+            bottom = [x, y + distance],
+            hash = {
+                l: left,
+                left: left,
+                r: right,
+                right: right,
+                t: top,
+                top: top,
+                up: top,
+                b: bottom,
+                bottom: bottom,
+                down: bottom
+            };
+
+        direction = direction.toLowerCase();
+        me.moveTo(hash[direction][0], hash[direction][1], animate);
+    },
+
+<span id='Ext-Element-method-setLeftTop'>    /**
+</span>     * Quick set left and top adding default units
+     * @param {String} left The left CSS property value
+     * @param {String} top The top CSS property value
+     * @return {Ext.Element} this
+     */
+    setLeftTop: function(left, top) {
+        var me = this,
+            style = me.dom.style;
+        style.left = me.addUnits(left);
+        style.top = me.addUnits(top);
+        return me;
+    },
+
+<span id='Ext-Element-method-getRegion'>    /**
+</span>     * Returns the region of this element.
+     * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+     * @return {Ext.util.Region} A Region containing &quot;top, left, bottom, right&quot; member data.
+     */
+    getRegion: function() {
+        return this.getPageBox(true);
+    },
+
+<span id='Ext-Element-method-getViewRegion'>    /**
+</span>     * Returns the &lt;b&gt;content&lt;/b&gt; region of this element. That is the region within the borders and padding.
+     * @return {Ext.util.Region} A Region containing &quot;top, left, bottom, right&quot; member data.
+     */
+    getViewRegion: function() {
+        var me = this,
+            isBody = me.dom === document.body,
+            scroll, pos, top, left, width, height;
+
+        // For the body we want to do some special logic
+        if (isBody) {
+            scroll = me.getScroll();
+            left = scroll.left;
+            top = scroll.top;
+            width = Ext.Element.getViewportWidth();
+            height = Ext.Element.getViewportHeight();
+        }
+        else {
+            pos = me.getXY();
+            left = pos[0] + me.getBorderWidth('l') + me.getPadding('l');
+            top = pos[1] + me.getBorderWidth('t') + me.getPadding('t');
+            width = me.getWidth(true);
+            height = me.getHeight(true);
+        }
+
+        return Ext.create('Ext.util.Region', top, left + width, top + height, left);
+    },
+
+<span id='Ext-Element-method-getPageBox'>    /**
+</span>     * Return an object defining the area of this Element which can be passed to {@link #setBox} to
+     * set another Element's size/location to match this element.
+     * @param {Boolean} asRegion(optional) If true an Ext.util.Region will be returned
+     * @return {Object} box An object in the format&lt;pre&gt;&lt;code&gt;
+{
+    x: &amp;lt;Element's X position&gt;,
+    y: &amp;lt;Element's Y position&gt;,
+    width: &amp;lt;Element's width&gt;,
+    height: &amp;lt;Element's height&gt;,
+    bottom: &amp;lt;Element's lower bound&gt;,
+    right: &amp;lt;Element's rightmost bound&gt;
+}
+&lt;/code&gt;&lt;/pre&gt;
+     * The returned object may also be addressed as an Array where index 0 contains the X position
+     * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
+     */
+    getPageBox : function(getRegion) {
+        var me = this,
+            el = me.dom,
+            isDoc = el === document.body,
+            w = isDoc ? Ext.Element.getViewWidth()  : el.offsetWidth,
+            h = isDoc ? Ext.Element.getViewHeight() : el.offsetHeight,
+            xy = me.getXY(),
+            t = xy[1],
+            r = xy[0] + w,
+            b = xy[1] + h,
+            l = xy[0];
+
+        if (getRegion) {
+            return Ext.create('Ext.util.Region', t, r, b, l);
+        }
+        else {
+            return {
+                left: l,
+                top: t,
+                width: w,
+                height: h,
+                right: r,
+                bottom: b
+            };
+        }
+    },
+
+<span id='Ext-Element-method-setBounds'>    /**
+</span>     * Sets the element's position and size in one shot. If animation is true then width, height, x and y will be animated concurrently.
+     * @param {Number} x X value for new position (coordinates are page-based)
+     * @param {Number} y Y value for new position (coordinates are page-based)
+     * @param {Number/String} width The new width. This may be one of:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+     * &lt;li&gt;A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)&lt;/li&gt;
+     * &lt;li&gt;A String used to set the CSS width style. Animation may &lt;b&gt;not&lt;/b&gt; be used.
+     * &lt;/ul&gt;&lt;/div&gt;
+     * @param {Number/String} height The new height. This may be one of:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+     * &lt;li&gt;A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)&lt;/li&gt;
+     * &lt;li&gt;A String used to set the CSS height style. Animation may &lt;b&gt;not&lt;/b&gt; be used.&lt;/li&gt;
+     * &lt;/ul&gt;&lt;/div&gt;
+     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
+     * @return {Ext.Element} this
+     */
+    setBounds: function(x, y, width, height, animate) {
+        var me = this;
+        if (!animate || !me.anim) {
+            me.setSize(width, height);
+            me.setLocation(x, y);
+        } else {
+            if (!Ext.isObject(animate)) {
+                animate = {};
+            }
+            me.animate(Ext.applyIf({
+                to: {
+                    x: x,
+                    y: y,
+                    width: me.adjustWidth(width),
+                    height: me.adjustHeight(height)
+                }
+            }, animate));
+        }
+        return me;
+    },
+
+<span id='Ext-Element-method-setRegion'>    /**
+</span>     * Sets the element's position and size the specified region. If animation is true then width, height, x and y will be animated concurrently.
+     * @param {Ext.util.Region} region The region to fill
+     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
+     * @return {Ext.Element} this
+     */
+    setRegion: function(region, animate) {
+        return this.setBounds(region.left, region.top, region.right - region.left, region.bottom - region.top, animate);
     }
 });
-})();</pre>    
+})();
+</pre>
 </body>
-</html>
\ No newline at end of file
+</html>