Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / source / Element2.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-core-Element-method-constructor'><span id='Ext-core-Element'>/**
19 </span></span> * @class Ext.core.Element
20  * &lt;p&gt;Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.&lt;/p&gt;
21  * &lt;p&gt;All instances of this class inherit the methods of {@link Ext.fx.Anim} making visual effects easily available to all DOM elements.&lt;/p&gt;
22  * &lt;p&gt;Note that the events documented in this class are not Ext events, they encapsulate browser events. To
23  * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older
24  * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.&lt;/p&gt;
25  * Usage:&lt;br&gt;
26 &lt;pre&gt;&lt;code&gt;
27 // by id
28 var el = Ext.get(&quot;my-div&quot;);
29
30 // by DOM element reference
31 var el = Ext.get(myDivElement);
32 &lt;/code&gt;&lt;/pre&gt;
33  * &lt;b&gt;Animations&lt;/b&gt;&lt;br /&gt;
34  * &lt;p&gt;When an element is manipulated, by default there is no animation.&lt;/p&gt;
35  * &lt;pre&gt;&lt;code&gt;
36 var el = Ext.get(&quot;my-div&quot;);
37
38 // no animation
39 el.setWidth(100);
40  * &lt;/code&gt;&lt;/pre&gt;
41  * &lt;p&gt;Many of the functions for manipulating an element have an optional &quot;animate&quot; parameter.  This
42  * parameter can be specified as boolean (&lt;tt&gt;true&lt;/tt&gt;) for default animation effects.&lt;/p&gt;
43  * &lt;pre&gt;&lt;code&gt;
44 // default animation
45 el.setWidth(100, true);
46  * &lt;/code&gt;&lt;/pre&gt;
47  *
48  * &lt;p&gt;To configure the effects, an object literal with animation options to use as the Element animation
49  * configuration object can also be specified. Note that the supported Element animation configuration
50  * options are a subset of the {@link Ext.fx.Anim} animation options specific to Fx effects.  The supported
51  * Element animation configuration options are:&lt;/p&gt;
52 &lt;pre&gt;
53 Option    Default   Description
54 --------- --------  ---------------------------------------------
55 {@link Ext.fx.Anim#duration duration}  .35       The duration of the animation in seconds
56 {@link Ext.fx.Anim#easing easing}    easeOut   The easing method
57 {@link Ext.fx.Anim#callback callback}  none      A function to execute when the anim completes
58 {@link Ext.fx.Anim#scope scope}     this      The scope (this) of the callback function
59 &lt;/pre&gt;
60  *
61  * &lt;pre&gt;&lt;code&gt;
62 // Element animation options object
63 var opt = {
64     {@link Ext.fx.Anim#duration duration}: 1,
65     {@link Ext.fx.Anim#easing easing}: 'elasticIn',
66     {@link Ext.fx.Anim#callback callback}: this.foo,
67     {@link Ext.fx.Anim#scope scope}: this
68 };
69 // animation with some options set
70 el.setWidth(100, opt);
71  * &lt;/code&gt;&lt;/pre&gt;
72  * &lt;p&gt;The Element animation object being used for the animation will be set on the options
73  * object as &quot;anim&quot;, which allows you to stop or manipulate the animation. Here is an example:&lt;/p&gt;
74  * &lt;pre&gt;&lt;code&gt;
75 // using the &quot;anim&quot; property to get the Anim object
76 if(opt.anim.isAnimated()){
77     opt.anim.stop();
78 }
79  * &lt;/code&gt;&lt;/pre&gt;
80  * &lt;p&gt;Also see the &lt;tt&gt;{@link #animate}&lt;/tt&gt; method for another animation technique.&lt;/p&gt;
81  * &lt;p&gt;&lt;b&gt; Composite (Collections of) Elements&lt;/b&gt;&lt;/p&gt;
82  * &lt;p&gt;For working with collections of Elements, see {@link Ext.CompositeElement}&lt;/p&gt;
83  * @constructor Create a new Element directly.
84  * @param {String/HTMLElement} element
85  * @param {Boolean} forceNew (optional) By default the constructor checks to see if there is already an instance of this element in the cache and if there is it returns the same instance. This will skip that check (useful for extending this class).
86  */
87  (function() {
88     var DOC = document,
89         EC = Ext.cache;
90
91     Ext.Element = Ext.core.Element = function(element, forceNew) {
92         var dom = typeof element == &quot;string&quot; ? DOC.getElementById(element) : element,
93         id;
94
95         if (!dom) {
96             return null;
97         }
98
99         id = dom.id;
100
101         if (!forceNew &amp;&amp; id &amp;&amp; EC[id]) {
102             // element object already exists
103             return EC[id].el;
104         }
105
106 <span id='Ext-core-Element-property-dom'>        /**
107 </span>     * The DOM element
108      * @type HTMLElement
109      */
110         this.dom = dom;
111
112 <span id='Ext-core-Element-property-id'>        /**
113 </span>     * The DOM element ID
114      * @type String
115      */
116         this.id = id || Ext.id(dom);
117     };
118
119     var DH = Ext.core.DomHelper,
120     El = Ext.core.Element;
121
122
123     El.prototype = {
124 <span id='Ext-core-Element-method-set'>        /**
125 </span>     * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
126      * @param {Object} o The object with the attributes
127      * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.
128      * @return {Ext.core.Element} this
129      */
130         set: function(o, useSet) {
131             var el = this.dom,
132                 attr,
133                 val;
134             useSet = (useSet !== false) &amp;&amp; !!el.setAttribute;
135
136             for (attr in o) {
137                 if (o.hasOwnProperty(attr)) {
138                     val = o[attr];
139                     if (attr == 'style') {
140                         DH.applyStyles(el, val);
141                     } else if (attr == 'cls') {
142                         el.className = val;
143                     } else if (useSet) {
144                         el.setAttribute(attr, val);
145                     } else {
146                         el[attr] = val;
147                     }
148                 }
149             }
150             return this;
151         },
152
153         //  Mouse events
154 <span id='Ext-core-Element-event-click'>        /**
155 </span>     * @event click
156      * Fires when a mouse click is detected within the element.
157      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
158      * @param {HtmlElement} t The target of the event.
159      * @param {Object} o The options configuration passed to the {@link #addListener} call.
160      */
161 <span id='Ext-core-Element-event-contextmenu'>        /**
162 </span>     * @event contextmenu
163      * Fires when a right click is detected within the element.
164      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
165      * @param {HtmlElement} t The target of the event.
166      * @param {Object} o The options configuration passed to the {@link #addListener} call.
167      */
168 <span id='Ext-core-Element-event-dblclick'>        /**
169 </span>     * @event dblclick
170      * Fires when a mouse double click is detected within the element.
171      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
172      * @param {HtmlElement} t The target of the event.
173      * @param {Object} o The options configuration passed to the {@link #addListener} call.
174      */
175 <span id='Ext-core-Element-event-mousedown'>        /**
176 </span>     * @event mousedown
177      * Fires when a mousedown is detected within the element.
178      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
179      * @param {HtmlElement} t The target of the event.
180      * @param {Object} o The options configuration passed to the {@link #addListener} call.
181      */
182 <span id='Ext-core-Element-event-mouseup'>        /**
183 </span>     * @event mouseup
184      * Fires when a mouseup is detected within the element.
185      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
186      * @param {HtmlElement} t The target of the event.
187      * @param {Object} o The options configuration passed to the {@link #addListener} call.
188      */
189 <span id='Ext-core-Element-event-mouseover'>        /**
190 </span>     * @event mouseover
191      * Fires when a mouseover is detected within the element.
192      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
193      * @param {HtmlElement} t The target of the event.
194      * @param {Object} o The options configuration passed to the {@link #addListener} call.
195      */
196 <span id='Ext-core-Element-event-mousemove'>        /**
197 </span>     * @event mousemove
198      * Fires when a mousemove is detected with the element.
199      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
200      * @param {HtmlElement} t The target of the event.
201      * @param {Object} o The options configuration passed to the {@link #addListener} call.
202      */
203 <span id='Ext-core-Element-event-mouseout'>        /**
204 </span>     * @event mouseout
205      * Fires when a mouseout is detected with the element.
206      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
207      * @param {HtmlElement} t The target of the event.
208      * @param {Object} o The options configuration passed to the {@link #addListener} call.
209      */
210 <span id='Ext-core-Element-event-mouseenter'>        /**
211 </span>     * @event mouseenter
212      * Fires when the mouse enters the element.
213      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
214      * @param {HtmlElement} t The target of the event.
215      * @param {Object} o The options configuration passed to the {@link #addListener} call.
216      */
217 <span id='Ext-core-Element-event-mouseleave'>        /**
218 </span>     * @event mouseleave
219      * Fires when the mouse leaves the element.
220      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
221      * @param {HtmlElement} t The target of the event.
222      * @param {Object} o The options configuration passed to the {@link #addListener} call.
223      */
224
225         //  Keyboard events
226 <span id='Ext-core-Element-event-keypress'>        /**
227 </span>     * @event keypress
228      * Fires when a keypress is detected within the element.
229      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
230      * @param {HtmlElement} t The target of the event.
231      * @param {Object} o The options configuration passed to the {@link #addListener} call.
232      */
233 <span id='Ext-core-Element-event-keydown'>        /**
234 </span>     * @event keydown
235      * Fires when a keydown is detected within the element.
236      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
237      * @param {HtmlElement} t The target of the event.
238      * @param {Object} o The options configuration passed to the {@link #addListener} call.
239      */
240 <span id='Ext-core-Element-event-keyup'>        /**
241 </span>     * @event keyup
242      * Fires when a keyup is detected within the element.
243      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
244      * @param {HtmlElement} t The target of the event.
245      * @param {Object} o The options configuration passed to the {@link #addListener} call.
246      */
247
248
249         //  HTML frame/object events
250 <span id='Ext-core-Element-event-load'>        /**
251 </span>     * @event load
252      * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.
253      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
254      * @param {HtmlElement} t The target of the event.
255      * @param {Object} o The options configuration passed to the {@link #addListener} call.
256      */
257 <span id='Ext-core-Element-event-unload'>        /**
258 </span>     * @event unload
259      * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target element or any of its content has been removed.
260      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
261      * @param {HtmlElement} t The target of the event.
262      * @param {Object} o The options configuration passed to the {@link #addListener} call.
263      */
264 <span id='Ext-core-Element-event-abort'>        /**
265 </span>     * @event abort
266      * Fires when an object/image is stopped from loading before completely loaded.
267      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
268      * @param {HtmlElement} t The target of the event.
269      * @param {Object} o The options configuration passed to the {@link #addListener} call.
270      */
271 <span id='Ext-core-Element-event-error'>        /**
272 </span>     * @event error
273      * Fires when an object/image/frame cannot be loaded properly.
274      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
275      * @param {HtmlElement} t The target of the event.
276      * @param {Object} o The options configuration passed to the {@link #addListener} call.
277      */
278 <span id='Ext-core-Element-event-resize'>        /**
279 </span>     * @event resize
280      * Fires when a document view is resized.
281      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
282      * @param {HtmlElement} t The target of the event.
283      * @param {Object} o The options configuration passed to the {@link #addListener} call.
284      */
285 <span id='Ext-core-Element-event-scroll'>        /**
286 </span>     * @event scroll
287      * Fires when a document view is scrolled.
288      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
289      * @param {HtmlElement} t The target of the event.
290      * @param {Object} o The options configuration passed to the {@link #addListener} call.
291      */
292
293         //  Form events
294 <span id='Ext-core-Element-event-select'>        /**
295 </span>     * @event select
296      * Fires when a user selects some text in a text field, including input and textarea.
297      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
298      * @param {HtmlElement} t The target of the event.
299      * @param {Object} o The options configuration passed to the {@link #addListener} call.
300      */
301 <span id='Ext-core-Element-event-change'>        /**
302 </span>     * @event change
303      * Fires when a control loses the input focus and its value has been modified since gaining focus.
304      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
305      * @param {HtmlElement} t The target of the event.
306      * @param {Object} o The options configuration passed to the {@link #addListener} call.
307      */
308 <span id='Ext-core-Element-event-submit'>        /**
309 </span>     * @event submit
310      * Fires when a form is submitted.
311      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
312      * @param {HtmlElement} t The target of the event.
313      * @param {Object} o The options configuration passed to the {@link #addListener} call.
314      */
315 <span id='Ext-core-Element-event-reset'>        /**
316 </span>     * @event reset
317      * Fires when a form is reset.
318      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
319      * @param {HtmlElement} t The target of the event.
320      * @param {Object} o The options configuration passed to the {@link #addListener} call.
321      */
322 <span id='Ext-core-Element-event-focus'>        /**
323 </span>     * @event focus
324      * Fires when an element receives focus either via the pointing device or by tab navigation.
325      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
326      * @param {HtmlElement} t The target of the event.
327      * @param {Object} o The options configuration passed to the {@link #addListener} call.
328      */
329 <span id='Ext-core-Element-event-blur'>        /**
330 </span>     * @event blur
331      * Fires when an element loses focus either via the pointing device or by tabbing navigation.
332      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
333      * @param {HtmlElement} t The target of the event.
334      * @param {Object} o The options configuration passed to the {@link #addListener} call.
335      */
336
337         //  User Interface events
338 <span id='Ext-core-Element-event-DOMFocusIn'>        /**
339 </span>     * @event DOMFocusIn
340      * Where supported. Similar to HTML focus event, but can be applied to any focusable element.
341      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
342      * @param {HtmlElement} t The target of the event.
343      * @param {Object} o The options configuration passed to the {@link #addListener} call.
344      */
345 <span id='Ext-core-Element-event-DOMFocusOut'>        /**
346 </span>     * @event DOMFocusOut
347      * Where supported. Similar to HTML blur event, but can be applied to any focusable element.
348      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
349      * @param {HtmlElement} t The target of the event.
350      * @param {Object} o The options configuration passed to the {@link #addListener} call.
351      */
352 <span id='Ext-core-Element-event-DOMActivate'>        /**
353 </span>     * @event DOMActivate
354      * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
355      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
356      * @param {HtmlElement} t The target of the event.
357      * @param {Object} o The options configuration passed to the {@link #addListener} call.
358      */
359
360         //  DOM Mutation events
361 <span id='Ext-core-Element-event-DOMSubtreeModified'>        /**
362 </span>     * @event DOMSubtreeModified
363      * Where supported. Fires when the subtree is modified.
364      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
365      * @param {HtmlElement} t The target of the event.
366      * @param {Object} o The options configuration passed to the {@link #addListener} call.
367      */
368 <span id='Ext-core-Element-event-DOMNodeInserted'>        /**
369 </span>     * @event DOMNodeInserted
370      * Where supported. Fires when a node has been added as a child of another node.
371      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
372      * @param {HtmlElement} t The target of the event.
373      * @param {Object} o The options configuration passed to the {@link #addListener} call.
374      */
375 <span id='Ext-core-Element-event-DOMNodeRemoved'>        /**
376 </span>     * @event DOMNodeRemoved
377      * Where supported. Fires when a descendant node of the element is removed.
378      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
379      * @param {HtmlElement} t The target of the event.
380      * @param {Object} o The options configuration passed to the {@link #addListener} call.
381      */
382 <span id='Ext-core-Element-event-DOMNodeRemovedFromDocument'>        /**
383 </span>     * @event DOMNodeRemovedFromDocument
384      * Where supported. Fires when a node is being removed from a document.
385      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
386      * @param {HtmlElement} t The target of the event.
387      * @param {Object} o The options configuration passed to the {@link #addListener} call.
388      */
389 <span id='Ext-core-Element-event-DOMNodeInsertedIntoDocument'>        /**
390 </span>     * @event DOMNodeInsertedIntoDocument
391      * Where supported. Fires when a node is being inserted into a document.
392      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
393      * @param {HtmlElement} t The target of the event.
394      * @param {Object} o The options configuration passed to the {@link #addListener} call.
395      */
396 <span id='Ext-core-Element-event-DOMAttrModified'>        /**
397 </span>     * @event DOMAttrModified
398      * Where supported. Fires when an attribute has been modified.
399      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
400      * @param {HtmlElement} t The target of the event.
401      * @param {Object} o The options configuration passed to the {@link #addListener} call.
402      */
403 <span id='Ext-core-Element-event-DOMCharacterDataModified'>        /**
404 </span>     * @event DOMCharacterDataModified
405      * Where supported. Fires when the character data has been modified.
406      * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
407      * @param {HtmlElement} t The target of the event.
408      * @param {Object} o The options configuration passed to the {@link #addListener} call.
409      */
410
411 <span id='Ext-core-Element-property-defaultUnit'>        /**
412 </span>     * The default unit to append to CSS values where a unit isn't provided (defaults to px).
413      * @type String
414      */
415         defaultUnit: &quot;px&quot;,
416
417 <span id='Ext-core-Element-method-is'>        /**
418 </span>     * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
419      * @param {String} selector The simple selector to test
420      * @return {Boolean} True if this element matches the selector, else false
421      */
422         is: function(simpleSelector) {
423             return Ext.DomQuery.is(this.dom, simpleSelector);
424         },
425
426 <span id='Ext-core-Element-method-focus'>        /**
427 </span>     * Tries to focus the element. Any exceptions are caught and ignored.
428      * @param {Number} defer (optional) Milliseconds to defer the focus
429      * @return {Ext.core.Element} this
430      */
431         focus: function(defer,
432                         /* private */
433                         dom) {
434             var me = this;
435             dom = dom || me.dom;
436             try {
437                 if (Number(defer)) {
438                     Ext.defer(me.focus, defer, null, [null, dom]);
439                 } else {
440                     dom.focus();
441                 }
442             } catch(e) {}
443             return me;
444         },
445
446 <span id='Ext-core-Element-method-blur'>        /**
447 </span>     * Tries to blur the element. Any exceptions are caught and ignored.
448      * @return {Ext.core.Element} this
449      */
450         blur: function() {
451             try {
452                 this.dom.blur();
453             } catch(e) {}
454             return this;
455         },
456
457 <span id='Ext-core-Element-method-getValue'>        /**
458 </span>     * Returns the value of the &quot;value&quot; attribute
459      * @param {Boolean} asNumber true to parse the value as a number
460      * @return {String/Number}
461      */
462         getValue: function(asNumber) {
463             var val = this.dom.value;
464             return asNumber ? parseInt(val, 10) : val;
465         },
466
467 <span id='Ext-core-Element-method-addListener'>        /**
468 </span>     * Appends an event handler to this element.  The shorthand version {@link #on} is equivalent.
469      * @param {String} eventName The name of event to handle.
470      * @param {Function} fn The handler function the event invokes. This function is passed
471      * the following parameters:&lt;ul&gt;
472      * &lt;li&gt;&lt;b&gt;evt&lt;/b&gt; : EventObject&lt;div class=&quot;sub-desc&quot;&gt;The {@link Ext.EventObject EventObject} describing the event.&lt;/div&gt;&lt;/li&gt;
473      * &lt;li&gt;&lt;b&gt;el&lt;/b&gt; : HtmlElement&lt;div class=&quot;sub-desc&quot;&gt;The DOM element which was the target of the event.
474      * Note that this may be filtered by using the &lt;tt&gt;delegate&lt;/tt&gt; option.&lt;/div&gt;&lt;/li&gt;
475      * &lt;li&gt;&lt;b&gt;o&lt;/b&gt; : Object&lt;div class=&quot;sub-desc&quot;&gt;The options object from the addListener call.&lt;/div&gt;&lt;/li&gt;
476      * &lt;/ul&gt;
477      * @param {Object} scope (optional) The scope (&lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the handler function is executed.
478      * &lt;b&gt;If omitted, defaults to this Element.&lt;/b&gt;.
479      * @param {Object} options (optional) An object containing handler configuration properties.
480      * This may contain any of the following properties:&lt;ul&gt;
481      * &lt;li&gt;&lt;b&gt;scope&lt;/b&gt; Object : &lt;div class=&quot;sub-desc&quot;&gt;The scope (&lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the handler function is executed.
482      * &lt;b&gt;If omitted, defaults to this Element.&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;
483      * &lt;li&gt;&lt;b&gt;delegate&lt;/b&gt; String: &lt;div class=&quot;sub-desc&quot;&gt;A simple selector to filter the target or look for a descendant of the target. See below for additional details.&lt;/div&gt;&lt;/li&gt;
484      * &lt;li&gt;&lt;b&gt;stopEvent&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to stop the event. That is stop propagation, and prevent the default action.&lt;/div&gt;&lt;/li&gt;
485      * &lt;li&gt;&lt;b&gt;preventDefault&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to prevent the default action&lt;/div&gt;&lt;/li&gt;
486      * &lt;li&gt;&lt;b&gt;stopPropagation&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to prevent event propagation&lt;/div&gt;&lt;/li&gt;
487      * &lt;li&gt;&lt;b&gt;normalized&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;False to pass a browser event to the handler function instead of an Ext.EventObject&lt;/div&gt;&lt;/li&gt;
488      * &lt;li&gt;&lt;b&gt;target&lt;/b&gt; Ext.core.Element: &lt;div class=&quot;sub-desc&quot;&gt;Only call the handler if the event was fired on the target Element, &lt;i&gt;not&lt;/i&gt; if the event was bubbled up from a child node.&lt;/div&gt;&lt;/li&gt;
489      * &lt;li&gt;&lt;b&gt;delay&lt;/b&gt; Number: &lt;div class=&quot;sub-desc&quot;&gt;The number of milliseconds to delay the invocation of the handler after the event fires.&lt;/div&gt;&lt;/li&gt;
490      * &lt;li&gt;&lt;b&gt;single&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to add a handler to handle just the next firing of the event, and then remove itself.&lt;/div&gt;&lt;/li&gt;
491      * &lt;li&gt;&lt;b&gt;buffer&lt;/b&gt; Number: &lt;div class=&quot;sub-desc&quot;&gt;Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
492      * by the specified number of milliseconds. If the event fires again within that time, the original
493      * handler is &lt;em&gt;not&lt;/em&gt; invoked, but the new handler is scheduled in its place.&lt;/div&gt;&lt;/li&gt;
494      * &lt;/ul&gt;&lt;br&gt;
495      * &lt;p&gt;
496      * &lt;b&gt;Combining Options&lt;/b&gt;&lt;br&gt;
497      * In the following examples, the shorthand form {@link #on} is used rather than the more verbose
498      * addListener.  The two are equivalent.  Using the options argument, it is possible to combine different
499      * types of listeners:&lt;br&gt;
500      * &lt;br&gt;
501      * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
502      * options object. The options object is available as the third parameter in the handler function.&lt;div style=&quot;margin: 5px 20px 20px;&quot;&gt;
503      * Code:&lt;pre&gt;&lt;code&gt;
504 el.on('click', this.onClick, this, {
505     single: true,
506     delay: 100,
507     stopEvent : true,
508     forumId: 4
509 });&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
510      * &lt;p&gt;
511      * &lt;b&gt;Attaching multiple handlers in 1 call&lt;/b&gt;&lt;br&gt;
512      * The method also allows for a single argument to be passed which is a config object containing properties
513      * which specify multiple handlers.&lt;/p&gt;
514      * &lt;p&gt;
515      * Code:&lt;pre&gt;&lt;code&gt;
516 el.on({
517     'click' : {
518         fn: this.onClick,
519         scope: this,
520         delay: 100
521     },
522     'mouseover' : {
523         fn: this.onMouseOver,
524         scope: this
525     },
526     'mouseout' : {
527         fn: this.onMouseOut,
528         scope: this
529     }
530 });&lt;/code&gt;&lt;/pre&gt;
531      * &lt;p&gt;
532      * Or a shorthand syntax:&lt;br&gt;
533      * Code:&lt;pre&gt;&lt;code&gt;&lt;/p&gt;
534 el.on({
535     'click' : this.onClick,
536     'mouseover' : this.onMouseOver,
537     'mouseout' : this.onMouseOut,
538     scope: this
539 });
540      * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
541      * &lt;p&gt;&lt;b&gt;delegate&lt;/b&gt;&lt;/p&gt;
542      * &lt;p&gt;This is a configuration option that you can pass along when registering a handler for
543      * an event to assist with event delegation. Event delegation is a technique that is used to
544      * reduce memory consumption and prevent exposure to memory-leaks. By registering an event
545      * for a container element as opposed to each element within a container. By setting this
546      * configuration option to a simple selector, the target element will be filtered to look for
547      * a descendant of the target.
548      * For example:&lt;pre&gt;&lt;code&gt;
549 // using this markup:
550 &amp;lt;div id='elId'&gt;
551     &amp;lt;p id='p1'&gt;paragraph one&amp;lt;/p&gt;
552     &amp;lt;p id='p2' class='clickable'&gt;paragraph two&amp;lt;/p&gt;
553     &amp;lt;p id='p3'&gt;paragraph three&amp;lt;/p&gt;
554 &amp;lt;/div&gt;
555 // utilize event delegation to registering just one handler on the container element:
556 el = Ext.get('elId');
557 el.on(
558     'click',
559     function(e,t) {
560         // handle click
561         console.info(t.id); // 'p2'
562     },
563     this,
564     {
565         // filter the target element to be a descendant with the class 'clickable'
566         delegate: '.clickable'
567     }
568 );
569      * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
570      * @return {Ext.core.Element} this
571      */
572         addListener: function(eventName, fn, scope, options) {
573             Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
574             return this;
575         },
576
577 <span id='Ext-core-Element-method-removeListener'>        /**
578 </span>     * Removes an event handler from this element.  The shorthand version {@link #un} is equivalent.
579      * &lt;b&gt;Note&lt;/b&gt;: if a &lt;i&gt;scope&lt;/i&gt; was explicitly specified when {@link #addListener adding} the
580      * listener, the same scope must be specified here.
581      * Example:
582      * &lt;pre&gt;&lt;code&gt;
583 el.removeListener('click', this.handlerFn);
584 // or
585 el.un('click', this.handlerFn);
586 &lt;/code&gt;&lt;/pre&gt;
587      * @param {String} eventName The name of the event from which to remove the handler.
588      * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #addListener} call.&lt;/b&gt;
589      * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
590      * then this must refer to the same object.
591      * @return {Ext.core.Element} this
592      */
593         removeListener: function(eventName, fn, scope) {
594             Ext.EventManager.un(this.dom, eventName, fn, scope || this);
595             return this;
596         },
597
598 <span id='Ext-core-Element-method-removeAllListeners'>        /**
599 </span>     * Removes all previous added listeners from this element
600      * @return {Ext.core.Element} this
601      */
602         removeAllListeners: function() {
603             Ext.EventManager.removeAll(this.dom);
604             return this;
605         },
606
607 <span id='Ext-core-Element-method-purgeAllListeners'>        /**
608 </span>         * Recursively removes all previous added listeners from this element and its children
609          * @return {Ext.core.Element} this
610          */
611         purgeAllListeners: function() {
612             Ext.EventManager.purgeElement(this);
613             return this;
614         },
615
616 <span id='Ext-core-Element-method-addUnits'>        /**
617 </span>         * @private Test if size has a unit, otherwise appends the passed unit string, or the default for this Element.
618          * @param size {Mixed} The size to set
619          * @param units {String} The units to append to a numeric size value
620          */
621         addUnits: function(size, units) {
622
623             // Most common case first: Size is set to a number
624             if (Ext.isNumber(size)) {
625                 return size + (units || this.defaultUnit || 'px');
626             }
627
628             // Size set to a value which means &quot;auto&quot;
629             if (size === &quot;&quot; || size == &quot;auto&quot; || size === undefined || size === null) {
630                 return size || '';
631             }
632
633             // Otherwise, warn if it's not a valid CSS measurement
634             if (!unitPattern.test(size)) {
635                 //&lt;debug&gt;
636                 if (Ext.isDefined(Ext.global.console)) {
637                     Ext.global.console.warn(&quot;Warning, size detected as NaN on Element.addUnits.&quot;);
638                 }
639                 //&lt;/debug&gt;
640                 return size || '';
641             }
642             return size;
643         },
644
645 <span id='Ext-core-Element-method-isBorderBox'>        /**
646 </span>         * Tests various css rules/browsers to determine if this element uses a border box
647          * @return {Boolean}
648          */
649         isBorderBox: function() {
650             return Ext.isBorderBox || noBoxAdjust[(this.dom.tagName || &quot;&quot;).toLowerCase()];
651         },
652
653 <span id='Ext-core-Element-method-remove'>        /**
654 </span>         * &lt;p&gt;Removes this element's dom reference.  Note that event and cache removal is handled at {@link Ext#removeNode Ext.removeNode}&lt;/p&gt;
655          */
656         remove: function() {
657             var me = this,
658             dom = me.dom;
659
660             if (dom) {
661                 delete me.dom;
662                 Ext.removeNode(dom);
663             }
664         },
665
666 <span id='Ext-core-Element-method-hover'>        /**
667 </span>         * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.
668          * @param {Function} overFn The function to call when the mouse enters the Element.
669          * @param {Function} outFn The function to call when the mouse leaves the Element.
670          * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the functions are executed. Defaults to the Element's DOM element.
671          * @param {Object} options (optional) Options for the listener. See {@link Ext.util.Observable#addListener the &lt;tt&gt;options&lt;/tt&gt; parameter}.
672          * @return {Ext.core.Element} this
673          */
674         hover: function(overFn, outFn, scope, options) {
675             var me = this;
676             me.on('mouseenter', overFn, scope || me.dom, options);
677             me.on('mouseleave', outFn, scope || me.dom, options);
678             return me;
679         },
680
681 <span id='Ext-core-Element-method-contains'>        /**
682 </span>         * Returns true if this element is an ancestor of the passed element
683          * @param {HTMLElement/String} el The element to check
684          * @return {Boolean} True if this element is an ancestor of el, else false
685          */
686         contains: function(el) {
687             return ! el ? false: Ext.core.Element.isAncestor(this.dom, el.dom ? el.dom: el);
688         },
689
690 <span id='Ext-core-Element-method-getAttributeNS'>        /**
691 </span>         * Returns the value of a namespaced attribute from the element's underlying DOM node.
692          * @param {String} namespace The namespace in which to look for the attribute
693          * @param {String} name The attribute name
694          * @return {String} The attribute value
695          * @deprecated
696          */
697         getAttributeNS: function(ns, name) {
698             return this.getAttribute(name, ns);
699         },
700
701 <span id='Ext-core-Element-method-getAttribute'>        /**
702 </span>         * Returns the value of an attribute from the element's underlying DOM node.
703          * @param {String} name The attribute name
704          * @param {String} namespace (optional) The namespace in which to look for the attribute
705          * @return {String} The attribute value
706          * @method
707          */
708         getAttribute: (Ext.isIE &amp;&amp; !(Ext.isIE9 &amp;&amp; document.documentMode === 9)) ?
709         function(name, ns) {
710             var d = this.dom,
711             type;
712             if(ns) {
713                 type = typeof d[ns + &quot;:&quot; + name];
714                 if (type != 'undefined' &amp;&amp; type != 'unknown') {
715                     return d[ns + &quot;:&quot; + name] || null;
716                 }
717                 return null;
718             }
719             if (name === &quot;for&quot;) {
720                 name = &quot;htmlFor&quot;;
721             }
722             return d[name] || null;
723         }: function(name, ns) {
724             var d = this.dom;
725             if (ns) {
726                return d.getAttributeNS(ns, name) || d.getAttribute(ns + &quot;:&quot; + name);
727             }
728             return  d.getAttribute(name) || d[name] || null;
729         },
730
731 <span id='Ext-core-Element-method-update'>        /**
732 </span>         * Update the innerHTML of this element
733          * @param {String} html The new HTML
734          * @return {Ext.core.Element} this
735          */
736         update: function(html) {
737             if (this.dom) {
738                 this.dom.innerHTML = html;
739             }
740             return this;
741         }
742     };
743
744     var ep = El.prototype;
745
746     El.addMethods = function(o) {
747         Ext.apply(ep, o);
748     };
749
750 <span id='Ext-core-Element-method-on'>    /**
751 </span>     * Appends an event handler (shorthand for {@link #addListener}).
752      * @param {String} eventName The name of event to handle.
753      * @param {Function} fn The handler function the event invokes.
754      * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function is executed.
755      * @param {Object} options (optional) An object containing standard {@link #addListener} options
756      * @member Ext.core.Element
757      * @method on
758      */
759     ep.on = ep.addListener;
760
761 <span id='Ext-core-Element-method-un'>    /**
762 </span>     * Removes an event handler from this element (see {@link #removeListener} for additional notes).
763      * @param {String} eventName The name of the event from which to remove the handler.
764      * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #addListener} call.&lt;/b&gt;
765      * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
766      * then this must refer to the same object.
767      * @return {Ext.core.Element} this
768      * @member Ext.core.Element
769      * @method un
770      */
771     ep.un = ep.removeListener;
772
773 <span id='Ext-core-Element-method-clearListeners'>    /**
774 </span>     * Removes all previous added listeners from this element
775      * @return {Ext.core.Element} this
776      * @member Ext.core.Element
777      * @method clearListeners
778      */
779     ep.clearListeners = ep.removeAllListeners;
780
781 <span id='Ext-core-Element-method-destroy'>    /**
782 </span>     * Removes this element's dom reference.  Note that event and cache removal is handled at {@link Ext#removeNode Ext.removeNode}.
783      * Alias to {@link #remove}.
784      * @member Ext.core.Element
785      * @method destroy
786      */
787     ep.destroy = ep.remove;
788
789 <span id='Ext-core-Element-property-autoBoxAdjust'>    /**
790 </span>     * true to automatically adjust width and height settings for box-model issues (default to true)
791      */
792     ep.autoBoxAdjust = true;
793
794     // private
795     var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
796     docEl;
797
798 <span id='Ext-core-Element-method-get'>    /**
799 </span>     * Retrieves Ext.core.Element objects.
800      * &lt;p&gt;&lt;b&gt;This method does not retrieve {@link Ext.Component Component}s.&lt;/b&gt; This method
801      * retrieves Ext.core.Element objects which encapsulate DOM elements. To retrieve a Component by
802      * its ID, use {@link Ext.ComponentManager#get}.&lt;/p&gt;
803      * &lt;p&gt;Uses simple caching to consistently return the same object. Automatically fixes if an
804      * object was recreated with the same id via AJAX or DOM.&lt;/p&gt;
805      * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
806      * @return {Element} The Element object (or null if no matching element was found)
807      * @static
808      * @member Ext.core.Element
809      * @method get
810      */
811     El.get = function(el) {
812         var ex,
813         elm,
814         id;
815         if (!el) {
816             return null;
817         }
818         if (typeof el == &quot;string&quot;) {
819             // element id
820             if (! (elm = DOC.getElementById(el))) {
821                 return null;
822             }
823             if (EC[el] &amp;&amp; EC[el].el) {
824                 ex = EC[el].el;
825                 ex.dom = elm;
826             } else {
827                 ex = El.addToCache(new El(elm));
828             }
829             return ex;
830         } else if (el.tagName) {
831             // dom element
832             if (! (id = el.id)) {
833                 id = Ext.id(el);
834             }
835             if (EC[id] &amp;&amp; EC[id].el) {
836                 ex = EC[id].el;
837                 ex.dom = el;
838             } else {
839                 ex = El.addToCache(new El(el));
840             }
841             return ex;
842         } else if (el instanceof El) {
843             if (el != docEl) {
844                 // refresh dom element in case no longer valid,
845                 // catch case where it hasn't been appended
846                 // If an el instance is passed, don't pass to getElementById without some kind of id
847                 if (Ext.isIE &amp;&amp; (el.id == undefined || el.id == '')) {
848                     el.dom = el.dom;
849                 } else {
850                     el.dom = DOC.getElementById(el.id) || el.dom;
851                 }
852             }
853             return el;
854         } else if (el.isComposite) {
855             return el;
856         } else if (Ext.isArray(el)) {
857             return El.select(el);
858         } else if (el == DOC) {
859             // create a bogus element object representing the document object
860             if (!docEl) {
861                 var f = function() {};
862                 f.prototype = El.prototype;
863                 docEl = new f();
864                 docEl.dom = DOC;
865             }
866             return docEl;
867         }
868         return null;
869     };
870
871     El.addToCache = function(el, id) {
872         if (el) {
873             id = id || el.id;
874             EC[id] = {
875                 el: el,
876                 data: {},
877                 events: {}
878             };
879         }
880         return el;
881     };
882
883     // private method for getting and setting element data
884     El.data = function(el, key, value) {
885         el = El.get(el);
886         if (!el) {
887             return null;
888         }
889         var c = EC[el.id].data;
890         if (arguments.length == 2) {
891             return c[key];
892         } else {
893             return (c[key] = value);
894         }
895     };
896
897     // private
898     // Garbage collection - uncache elements/purge listeners on orphaned elements
899     // so we don't hold a reference and cause the browser to retain them
900     function garbageCollect() {
901         if (!Ext.enableGarbageCollector) {
902             clearInterval(El.collectorThreadId);
903         } else {
904             var eid,
905             el,
906             d,
907             o;
908
909             for (eid in EC) {
910                 if (!EC.hasOwnProperty(eid)) {
911                     continue;
912                 }
913                 o = EC[eid];
914                 if (o.skipGarbageCollection) {
915                     continue;
916                 }
917                 el = o.el;
918                 d = el.dom;
919                 // -------------------------------------------------------
920                 // Determining what is garbage:
921                 // -------------------------------------------------------
922                 // !d
923                 // dom node is null, definitely garbage
924                 // -------------------------------------------------------
925                 // !d.parentNode
926                 // no parentNode == direct orphan, definitely garbage
927                 // -------------------------------------------------------
928                 // !d.offsetParent &amp;&amp; !document.getElementById(eid)
929                 // display none elements have no offsetParent so we will
930                 // also try to look it up by it's id. However, check
931                 // offsetParent first so we don't do unneeded lookups.
932                 // This enables collection of elements that are not orphans
933                 // directly, but somewhere up the line they have an orphan
934                 // parent.
935                 // -------------------------------------------------------
936                 if (!d || !d.parentNode || (!d.offsetParent &amp;&amp; !DOC.getElementById(eid))) {
937                     if (d &amp;&amp; Ext.enableListenerCollection) {
938                         Ext.EventManager.removeAll(d);
939                     }
940                     delete EC[eid];
941                 }
942             }
943             // Cleanup IE Object leaks
944             if (Ext.isIE) {
945                 var t = {};
946                 for (eid in EC) {
947                     if (!EC.hasOwnProperty(eid)) {
948                         continue;
949                     }
950                     t[eid] = EC[eid];
951                 }
952                 EC = Ext.cache = t;
953             }
954         }
955     }
956     El.collectorThreadId = setInterval(garbageCollect, 30000);
957
958     var flyFn = function() {};
959     flyFn.prototype = El.prototype;
960
961     // dom is optional
962     El.Flyweight = function(dom) {
963         this.dom = dom;
964     };
965
966     El.Flyweight.prototype = new flyFn();
967     El.Flyweight.prototype.isFlyweight = true;
968     El._flyweights = {};
969
970 <span id='Ext-core-Element-method-fly'>    /**
971 </span>     * &lt;p&gt;Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
972      * the dom node can be overwritten by other code. Shorthand of {@link Ext.core.Element#fly}&lt;/p&gt;
973      * &lt;p&gt;Use this to make one-time references to DOM elements which are not going to be accessed again either by
974      * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get Ext.get}
975      * will be more appropriate to take advantage of the caching provided by the Ext.core.Element class.&lt;/p&gt;
976      * @param {String/HTMLElement} el The dom node or id
977      * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
978      * (e.g. internally Ext uses &quot;_global&quot;)
979      * @return {Element} The shared Element object (or null if no matching element was found)
980      * @member Ext.core.Element
981      * @method fly
982      */
983     El.fly = function(el, named) {
984         var ret = null;
985         named = named || '_global';
986         el = Ext.getDom(el);
987         if (el) {
988             (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
989             ret = El._flyweights[named];
990         }
991         return ret;
992     };
993
994 <span id='Ext-method-get'>    /**
995 </span>     * Retrieves Ext.core.Element objects.
996      * &lt;p&gt;&lt;b&gt;This method does not retrieve {@link Ext.Component Component}s.&lt;/b&gt; This method
997      * retrieves Ext.core.Element objects which encapsulate DOM elements. To retrieve a Component by
998      * its ID, use {@link Ext.ComponentManager#get}.&lt;/p&gt;
999      * &lt;p&gt;Uses simple caching to consistently return the same object. Automatically fixes if an
1000      * object was recreated with the same id via AJAX or DOM.&lt;/p&gt;
1001      * Shorthand of {@link Ext.core.Element#get}
1002      * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
1003      * @return {Element} The Element object (or null if no matching element was found)
1004      * @member Ext
1005      * @method get
1006      */
1007     Ext.get = El.get;
1008
1009 <span id='Ext-method-fly'>    /**
1010 </span>     * &lt;p&gt;Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
1011      * the dom node can be overwritten by other code. Shorthand of {@link Ext.core.Element#fly}&lt;/p&gt;
1012      * &lt;p&gt;Use this to make one-time references to DOM elements which are not going to be accessed again either by
1013      * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get Ext.get}
1014      * will be more appropriate to take advantage of the caching provided by the Ext.core.Element class.&lt;/p&gt;
1015      * @param {String/HTMLElement} el The dom node or id
1016      * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
1017      * (e.g. internally Ext uses &quot;_global&quot;)
1018      * @return {Element} The shared Element object (or null if no matching element was found)
1019      * @member Ext
1020      * @method fly
1021      */
1022     Ext.fly = El.fly;
1023
1024     // speedy lookup for elements never to box adjust
1025     var noBoxAdjust = Ext.isStrict ? {
1026         select: 1
1027     }: {
1028         input: 1,
1029         select: 1,
1030         textarea: 1
1031     };
1032     if (Ext.isIE || Ext.isGecko) {
1033         noBoxAdjust['button'] = 1;
1034     }
1035 })();
1036 </pre>
1037 </body>
1038 </html>