3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">/**
\r
10 * @class Ext.Element
\r
12 Ext.Element.addMethods({
\r
13 <div id="method-Ext.Element-setBox"></div>/**
\r
14 * 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.
\r
15 * @param {Object} box The box to fill {x, y, width, height}
\r
16 * @param {Boolean} adjust (optional) Whether to adjust for box-model issues automatically
\r
17 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
\r
18 * @return {Ext.Element} this
\r
20 setBox : function(box, adjust, animate){
\r
24 if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
\r
25 w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
\r
26 h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
\r
28 me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
\r
32 <div id="method-Ext.Element-getBox"></div>/**
\r
33 * Return an object defining the area of this Element which can be passed to {@link #setBox} to
\r
34 * set another Element's size/location to match this element.
\r
35 * @param {Boolean} contentBox (optional) If true a box for the content of the element is returned.
\r
36 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page x/y.
\r
37 * @return {Object} box An object in the format<pre><code>
\r
39 x: <Element's X position>,
\r
40 y: <Element's Y position>,
\r
41 width: <Element's width>,
\r
42 height: <Element's height>,
\r
43 bottom: <Element's lower bound>,
\r
44 right: <Element's rightmost bound>
\r
47 * The returned object may also be addressed as an Array where index 0 contains the X position
\r
48 * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
\r
50 getBox : function(contentBox, local) {
\r
55 getBorderWidth = me.getBorderWidth,
\r
56 getPadding = me.getPadding,
\r
64 left = parseInt(me.getStyle("left"), 10) || 0;
\r
65 top = parseInt(me.getStyle("top"), 10) || 0;
\r
68 var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
\r
70 bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
\r
72 l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
\r
73 r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
\r
74 t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
\r
75 b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
\r
76 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)};
\r
78 bx.right = bx.x + bx.width;
\r
79 bx.bottom = bx.y + bx.height;
\r
83 <div id="method-Ext.Element-move"></div>/**
\r
84 * Move this element relative to its current position.
\r
85 * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").
\r
86 * @param {Number} distance How far to move the element in pixels
\r
87 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
\r
88 * @return {Ext.Element} this
\r
90 move : function(direction, distance, animate){
\r
95 left = [x - distance, y],
\r
96 right = [x + distance, y],
\r
97 top = [x, y - distance],
\r
98 bottom = [x, y + distance],
\r
112 direction = direction.toLowerCase();
\r
113 me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
\r
116 <div id="method-Ext.Element-setLeftTop"></div>/**
\r
117 * Quick set left and top adding default units
\r
118 * @param {String} left The left CSS property value
\r
119 * @param {String} top The top CSS property value
\r
120 * @return {Ext.Element} this
\r
122 setLeftTop : function(left, top){
\r
124 style = me.dom.style;
\r
125 style.left = me.addUnits(left);
\r
126 style.top = me.addUnits(top);
\r
130 <div id="method-Ext.Element-getRegion"></div>/**
\r
131 * Returns the region of the given element.
\r
132 * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
\r
133 * @return {Region} A Ext.lib.Region containing "top, left, bottom, right" member data.
\r
135 getRegion : function(){
\r
136 return Ext.lib.Dom.getRegion(this.dom);
\r
139 <div id="method-Ext.Element-setBounds"></div>/**
\r
140 * Sets the element's position and size in one shot. If animation is true then width, height, x and y will be animated concurrently.
\r
141 * @param {Number} x X value for new position (coordinates are page-based)
\r
142 * @param {Number} y Y value for new position (coordinates are page-based)
\r
143 * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>
\r
144 * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)</li>
\r
145 * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.
\r
147 * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>
\r
148 * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)</li>
\r
149 * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
\r
151 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
\r
152 * @return {Ext.Element} this
\r
154 setBounds : function(x, y, width, height, animate){
\r
156 if (!animate || !me.anim) {
\r
157 me.setSize(width, height);
\r
158 me.setLocation(x, y);
\r
160 me.anim({points: {to: [x, y]},
\r
161 width: {to: me.adjustWidth(width)},
\r
162 height: {to: me.adjustHeight(height)}},
\r
163 me.preanim(arguments, 4),
\r
169 <div id="method-Ext.Element-setRegion"></div>/**
\r
170 * Sets the element's position and size the specified region. If animation is true then width, height, x and y will be animated concurrently.
\r
171 * @param {Ext.lib.Region} region The region to fill
\r
172 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
\r
173 * @return {Ext.Element} this
\r
175 setRegion : function(region, animate) {
\r
176 return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
\r