3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
18 Ext.Element.addMethods({
19 <div id="method-Ext.Element-setBox"></div>/**
20 * 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.
21 * @param {Object} box The box to fill {x, y, width, height}
22 * @param {Boolean} adjust (optional) Whether to adjust for box-model issues automatically
23 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
24 * @return {Ext.Element} this
26 setBox : function(box, adjust, animate){
30 if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
31 w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
32 h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
34 me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
38 <div id="method-Ext.Element-getBox"></div>/**
39 * Return an object defining the area of this Element which can be passed to {@link #setBox} to
40 * set another Element's size/location to match this element.
41 * @param {Boolean} contentBox (optional) If true a box for the content of the element is returned.
42 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page x/y.
43 * @return {Object} box An object in the format<pre><code>
45 x: <Element's X position>,
46 y: <Element's Y position>,
47 width: <Element's width>,
48 height: <Element's height>,
49 bottom: <Element's lower bound>,
50 right: <Element's rightmost bound>
53 * The returned object may also be addressed as an Array where index 0 contains the X position
54 * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
56 getBox : function(contentBox, local) {
61 getBorderWidth = me.getBorderWidth,
62 getPadding = me.getPadding,
70 left = parseInt(me.getStyle("left"), 10) || 0;
71 top = parseInt(me.getStyle("top"), 10) || 0;
74 var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
76 bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
78 l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
79 r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
80 t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
81 b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
82 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)};
84 bx.right = bx.x + bx.width;
85 bx.bottom = bx.y + bx.height;
89 <div id="method-Ext.Element-move"></div>/**
90 * Move this element relative to its current position.
91 * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").
92 * @param {Number} distance How far to move the element in pixels
93 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
94 * @return {Ext.Element} this
96 move : function(direction, distance, animate){
101 left = [x - distance, y],
102 right = [x + distance, y],
103 top = [x, y - distance],
104 bottom = [x, y + distance],
118 direction = direction.toLowerCase();
119 me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
122 <div id="method-Ext.Element-setLeftTop"></div>/**
123 * Quick set left and top adding default units
124 * @param {String} left The left CSS property value
125 * @param {String} top The top CSS property value
126 * @return {Ext.Element} this
128 setLeftTop : function(left, top){
130 style = me.dom.style;
131 style.left = me.addUnits(left);
132 style.top = me.addUnits(top);
136 <div id="method-Ext.Element-getRegion"></div>/**
137 * Returns the region of the given element.
138 * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
139 * @return {Region} A Ext.lib.Region containing "top, left, bottom, right" member data.
141 getRegion : function(){
142 return Ext.lib.Dom.getRegion(this.dom);
145 <div id="method-Ext.Element-setBounds"></div>/**
146 * Sets the element's position and size in one shot. If animation is true then width, height, x and y will be animated concurrently.
147 * @param {Number} x X value for new position (coordinates are page-based)
148 * @param {Number} y Y value for new position (coordinates are page-based)
149 * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>
150 * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)</li>
151 * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.
153 * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>
154 * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)</li>
155 * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
157 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
158 * @return {Ext.Element} this
160 setBounds : function(x, y, width, height, animate){
162 if (!animate || !me.anim) {
163 me.setSize(width, height);
164 me.setLocation(x, y);
166 me.anim({points: {to: [x, y]},
167 width: {to: me.adjustWidth(width)},
168 height: {to: me.adjustHeight(height)}},
169 me.preanim(arguments, 4),
175 <div id="method-Ext.Element-setRegion"></div>/**
176 * Sets the element's position and size the specified region. If animation is true then width, height, x and y will be animated concurrently.
177 * @param {Ext.lib.Region} region The region to fill
178 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
179 * @return {Ext.Element} this
181 setRegion : function(region, animate) {
182 return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));