1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-core.Element-method-constructor'><span id='Ext-core.Element'>/**
2 </span></span> * @class Ext.core.Element
3 * <p>Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.</p>
4 * <p>All instances of this class inherit the methods of {@link Ext.fx.Anim} making visual effects easily available to all DOM elements.</p>
5 * <p>Note that the events documented in this class are not Ext events, they encapsulate browser events. To
6 * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older
7 * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.</p>
9 <pre><code>
11 var el = Ext.get("my-div");
13 // by DOM element reference
14 var el = Ext.get(myDivElement);
15 </code></pre>
16 * <b>Animations</b><br />
17 * <p>When an element is manipulated, by default there is no animation.</p>
18 * <pre><code>
19 var el = Ext.get("my-div");
23 * </code></pre>
24 * <p>Many of the functions for manipulating an element have an optional "animate" parameter. This
25 * parameter can be specified as boolean (<tt>true</tt>) for default animation effects.</p>
26 * <pre><code>
28 el.setWidth(100, true);
29 * </code></pre>
31 * <p>To configure the effects, an object literal with animation options to use as the Element animation
32 * configuration object can also be specified. Note that the supported Element animation configuration
33 * options are a subset of the {@link Ext.fx.Anim} animation options specific to Fx effects. The supported
34 * Element animation configuration options are:</p>
36 Option Default Description
37 --------- -------- ---------------------------------------------
38 {@link Ext.fx.Anim#duration duration} .35 The duration of the animation in seconds
39 {@link Ext.fx.Anim#easing easing} easeOut The easing method
40 {@link Ext.fx.Anim#callback callback} none A function to execute when the anim completes
41 {@link Ext.fx.Anim#scope scope} this The scope (this) of the callback function
44 * <pre><code>
45 // Element animation options object
47 {@link Ext.fx.Anim#duration duration}: 1,
48 {@link Ext.fx.Anim#easing easing}: 'elasticIn',
49 {@link Ext.fx.Anim#callback callback}: this.foo,
50 {@link Ext.fx.Anim#scope scope}: this
52 // animation with some options set
53 el.setWidth(100, opt);
54 * </code></pre>
55 * <p>The Element animation object being used for the animation will be set on the options
56 * object as "anim", which allows you to stop or manipulate the animation. Here is an example:</p>
57 * <pre><code>
58 // using the "anim" property to get the Anim object
59 if(opt.anim.isAnimated()){
62 * </code></pre>
63 * <p>Also see the <tt>{@link #animate}</tt> method for another animation technique.</p>
64 * <p><b> Composite (Collections of) Elements</b></p>
65 * <p>For working with collections of Elements, see {@link Ext.CompositeElement}</p>
66 * @constructor Create a new Element directly.
67 * @param {String/HTMLElement} element
68 * @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).
74 Ext.Element = Ext.core.Element = function(element, forceNew) {
75 var dom = typeof element == "string" ? DOC.getElementById(element) : element,
84 if (!forceNew && id && EC[id]) {
85 // element object already exists
89 <span id='Ext-core.Element-property-dom'> /**
90 </span> * The DOM element
95 <span id='Ext-core.Element-property-id'> /**
96 </span> * The DOM element ID
99 this.id = id || Ext.id(dom);
102 var DH = Ext.core.DomHelper,
103 El = Ext.core.Element;
107 <span id='Ext-core.Element-method-set'> /**
108 </span> * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
109 * @param {Object} o The object with the attributes
110 * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.
111 * @return {Ext.core.Element} this
113 set: function(o, useSet) {
117 useSet = (useSet !== false) && !!el.setAttribute;
120 if (o.hasOwnProperty(attr)) {
122 if (attr == 'style') {
123 DH.applyStyles(el, val);
124 } else if (attr == 'cls') {
127 el.setAttribute(attr, val);
137 <span id='Ext-core.Element-event-click'> /**
138 </span> * @event click
139 * Fires when a mouse click is detected within the element.
140 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
141 * @param {HtmlElement} t The target of the event.
142 * @param {Object} o The options configuration passed to the {@link #addListener} call.
144 <span id='Ext-core.Element-event-contextmenu'> /**
145 </span> * @event contextmenu
146 * Fires when a right click is detected within the element.
147 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
148 * @param {HtmlElement} t The target of the event.
149 * @param {Object} o The options configuration passed to the {@link #addListener} call.
151 <span id='Ext-core.Element-event-dblclick'> /**
152 </span> * @event dblclick
153 * Fires when a mouse double click is detected within the element.
154 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
155 * @param {HtmlElement} t The target of the event.
156 * @param {Object} o The options configuration passed to the {@link #addListener} call.
158 <span id='Ext-core.Element-event-mousedown'> /**
159 </span> * @event mousedown
160 * Fires when a mousedown is detected within the element.
161 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
162 * @param {HtmlElement} t The target of the event.
163 * @param {Object} o The options configuration passed to the {@link #addListener} call.
165 <span id='Ext-core.Element-event-mouseup'> /**
166 </span> * @event mouseup
167 * Fires when a mouseup is detected within the element.
168 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
169 * @param {HtmlElement} t The target of the event.
170 * @param {Object} o The options configuration passed to the {@link #addListener} call.
172 <span id='Ext-core.Element-event-mouseover'> /**
173 </span> * @event mouseover
174 * Fires when a mouseover is detected within the element.
175 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
176 * @param {HtmlElement} t The target of the event.
177 * @param {Object} o The options configuration passed to the {@link #addListener} call.
179 <span id='Ext-core.Element-event-mousemove'> /**
180 </span> * @event mousemove
181 * Fires when a mousemove is detected with the element.
182 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
183 * @param {HtmlElement} t The target of the event.
184 * @param {Object} o The options configuration passed to the {@link #addListener} call.
186 <span id='Ext-core.Element-event-mouseout'> /**
187 </span> * @event mouseout
188 * Fires when a mouseout is detected with the element.
189 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
190 * @param {HtmlElement} t The target of the event.
191 * @param {Object} o The options configuration passed to the {@link #addListener} call.
193 <span id='Ext-core.Element-event-mouseenter'> /**
194 </span> * @event mouseenter
195 * Fires when the mouse enters the element.
196 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
197 * @param {HtmlElement} t The target of the event.
198 * @param {Object} o The options configuration passed to the {@link #addListener} call.
200 <span id='Ext-core.Element-event-mouseleave'> /**
201 </span> * @event mouseleave
202 * Fires when the mouse leaves the element.
203 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
204 * @param {HtmlElement} t The target of the event.
205 * @param {Object} o The options configuration passed to the {@link #addListener} call.
209 <span id='Ext-core.Element-event-keypress'> /**
210 </span> * @event keypress
211 * Fires when a keypress is detected within the element.
212 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
213 * @param {HtmlElement} t The target of the event.
214 * @param {Object} o The options configuration passed to the {@link #addListener} call.
216 <span id='Ext-core.Element-event-keydown'> /**
217 </span> * @event keydown
218 * Fires when a keydown is detected within the element.
219 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
220 * @param {HtmlElement} t The target of the event.
221 * @param {Object} o The options configuration passed to the {@link #addListener} call.
223 <span id='Ext-core.Element-event-keyup'> /**
224 </span> * @event keyup
225 * Fires when a keyup is detected within the element.
226 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
227 * @param {HtmlElement} t The target of the event.
228 * @param {Object} o The options configuration passed to the {@link #addListener} call.
232 // HTML frame/object events
233 <span id='Ext-core.Element-event-load'> /**
234 </span> * @event load
235 * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.
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.
240 <span id='Ext-core.Element-event-unload'> /**
241 </span> * @event unload
242 * 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.
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.
247 <span id='Ext-core.Element-event-abort'> /**
248 </span> * @event abort
249 * Fires when an object/image is stopped from loading before completely loaded.
250 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
251 * @param {HtmlElement} t The target of the event.
252 * @param {Object} o The options configuration passed to the {@link #addListener} call.
254 <span id='Ext-core.Element-event-error'> /**
255 </span> * @event error
256 * Fires when an object/image/frame cannot be loaded properly.
257 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
258 * @param {HtmlElement} t The target of the event.
259 * @param {Object} o The options configuration passed to the {@link #addListener} call.
261 <span id='Ext-core.Element-event-resize'> /**
262 </span> * @event resize
263 * Fires when a document view is resized.
264 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
265 * @param {HtmlElement} t The target of the event.
266 * @param {Object} o The options configuration passed to the {@link #addListener} call.
268 <span id='Ext-core.Element-event-scroll'> /**
269 </span> * @event scroll
270 * Fires when a document view is scrolled.
271 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
272 * @param {HtmlElement} t The target of the event.
273 * @param {Object} o The options configuration passed to the {@link #addListener} call.
277 <span id='Ext-core.Element-event-select'> /**
278 </span> * @event select
279 * Fires when a user selects some text in a text field, including input and textarea.
280 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
281 * @param {HtmlElement} t The target of the event.
282 * @param {Object} o The options configuration passed to the {@link #addListener} call.
284 <span id='Ext-core.Element-event-change'> /**
285 </span> * @event change
286 * Fires when a control loses the input focus and its value has been modified since gaining focus.
287 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
288 * @param {HtmlElement} t The target of the event.
289 * @param {Object} o The options configuration passed to the {@link #addListener} call.
291 <span id='Ext-core.Element-event-submit'> /**
292 </span> * @event submit
293 * Fires when a form is submitted.
294 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
295 * @param {HtmlElement} t The target of the event.
296 * @param {Object} o The options configuration passed to the {@link #addListener} call.
298 <span id='Ext-core.Element-event-reset'> /**
299 </span> * @event reset
300 * Fires when a form is reset.
301 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
302 * @param {HtmlElement} t The target of the event.
303 * @param {Object} o The options configuration passed to the {@link #addListener} call.
305 <span id='Ext-core.Element-event-focus'> /**
306 </span> * @event focus
307 * Fires when an element receives focus either via the pointing device or by tab navigation.
308 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
309 * @param {HtmlElement} t The target of the event.
310 * @param {Object} o The options configuration passed to the {@link #addListener} call.
312 <span id='Ext-core.Element-event-blur'> /**
313 </span> * @event blur
314 * Fires when an element loses focus either via the pointing device or by tabbing navigation.
315 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
316 * @param {HtmlElement} t The target of the event.
317 * @param {Object} o The options configuration passed to the {@link #addListener} call.
320 // User Interface events
321 <span id='Ext-core.Element-event-DOMFocusIn'> /**
322 </span> * @event DOMFocusIn
323 * Where supported. Similar to HTML focus event, but can be applied to any focusable element.
324 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
325 * @param {HtmlElement} t The target of the event.
326 * @param {Object} o The options configuration passed to the {@link #addListener} call.
328 <span id='Ext-core.Element-event-DOMFocusOut'> /**
329 </span> * @event DOMFocusOut
330 * Where supported. Similar to HTML blur event, but can be applied to any focusable element.
331 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
332 * @param {HtmlElement} t The target of the event.
333 * @param {Object} o The options configuration passed to the {@link #addListener} call.
335 <span id='Ext-core.Element-event-DOMActivate'> /**
336 </span> * @event DOMActivate
337 * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
338 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
339 * @param {HtmlElement} t The target of the event.
340 * @param {Object} o The options configuration passed to the {@link #addListener} call.
343 // DOM Mutation events
344 <span id='Ext-core.Element-event-DOMSubtreeModified'> /**
345 </span> * @event DOMSubtreeModified
346 * Where supported. Fires when the subtree is modified.
347 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
348 * @param {HtmlElement} t The target of the event.
349 * @param {Object} o The options configuration passed to the {@link #addListener} call.
351 <span id='Ext-core.Element-event-DOMNodeInserted'> /**
352 </span> * @event DOMNodeInserted
353 * Where supported. Fires when a node has been added as a child of another node.
354 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
355 * @param {HtmlElement} t The target of the event.
356 * @param {Object} o The options configuration passed to the {@link #addListener} call.
358 <span id='Ext-core.Element-event-DOMNodeRemoved'> /**
359 </span> * @event DOMNodeRemoved
360 * Where supported. Fires when a descendant node of the element is removed.
361 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
362 * @param {HtmlElement} t The target of the event.
363 * @param {Object} o The options configuration passed to the {@link #addListener} call.
365 <span id='Ext-core.Element-event-DOMNodeRemovedFromDocument'> /**
366 </span> * @event DOMNodeRemovedFromDocument
367 * Where supported. Fires when a node is being removed from a document.
368 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
369 * @param {HtmlElement} t The target of the event.
370 * @param {Object} o The options configuration passed to the {@link #addListener} call.
372 <span id='Ext-core.Element-event-DOMNodeInsertedIntoDocument'> /**
373 </span> * @event DOMNodeInsertedIntoDocument
374 * Where supported. Fires when a node is being inserted into a document.
375 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
376 * @param {HtmlElement} t The target of the event.
377 * @param {Object} o The options configuration passed to the {@link #addListener} call.
379 <span id='Ext-core.Element-event-DOMAttrModified'> /**
380 </span> * @event DOMAttrModified
381 * Where supported. Fires when an attribute has been modified.
382 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
383 * @param {HtmlElement} t The target of the event.
384 * @param {Object} o The options configuration passed to the {@link #addListener} call.
386 <span id='Ext-core.Element-event-DOMCharacterDataModified'> /**
387 </span> * @event DOMCharacterDataModified
388 * Where supported. Fires when the character data has been modified.
389 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
390 * @param {HtmlElement} t The target of the event.
391 * @param {Object} o The options configuration passed to the {@link #addListener} call.
394 <span id='Ext-core.Element-property-defaultUnit'> /**
395 </span> * The default unit to append to CSS values where a unit isn't provided (defaults to px).
398 defaultUnit: "px",
400 <span id='Ext-core.Element-method-is'> /**
401 </span> * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
402 * @param {String} selector The simple selector to test
403 * @return {Boolean} True if this element matches the selector, else false
405 is: function(simpleSelector) {
406 return Ext.DomQuery.is(this.dom, simpleSelector);
409 <span id='Ext-core.Element-method-focus'> /**
410 </span> * Tries to focus the element. Any exceptions are caught and ignored.
411 * @param {Number} defer (optional) Milliseconds to defer the focus
412 * @return {Ext.core.Element} this
414 focus: function(defer,
421 Ext.defer(me.focus, defer, null, [null, dom]);
429 <span id='Ext-core.Element-method-blur'> /**
430 </span> * Tries to blur the element. Any exceptions are caught and ignored.
431 * @return {Ext.core.Element} this
440 <span id='Ext-core.Element-method-getValue'> /**
441 </span> * Returns the value of the "value" attribute
442 * @param {Boolean} asNumber true to parse the value as a number
443 * @return {String/Number}
445 getValue: function(asNumber) {
446 var val = this.dom.value;
447 return asNumber ? parseInt(val, 10) : val;
450 <span id='Ext-core.Element-method-addListener'> /**
451 </span> * Appends an event handler to this element. The shorthand version {@link #on} is equivalent.
452 * @param {String} eventName The name of event to handle.
453 * @param {Function} fn The handler function the event invokes. This function is passed
454 * the following parameters:<ul>
455 * <li><b>evt</b> : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
456 * <li><b>el</b> : HtmlElement<div class="sub-desc">The DOM element which was the target of the event.
457 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
458 * <li><b>o</b> : Object<div class="sub-desc">The options object from the addListener call.</div></li>
460 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.
461 * <b>If omitted, defaults to this Element.</b>.
462 * @param {Object} options (optional) An object containing handler configuration properties.
463 * This may contain any of the following properties:<ul>
464 * <li><b>scope</b> Object : <div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the handler function is executed.
465 * <b>If omitted, defaults to this Element.</b></div></li>
466 * <li><b>delegate</b> String: <div class="sub-desc">A simple selector to filter the target or look for a descendant of the target. See below for additional details.</div></li>
467 * <li><b>stopEvent</b> Boolean: <div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
468 * <li><b>preventDefault</b> Boolean: <div class="sub-desc">True to prevent the default action</div></li>
469 * <li><b>stopPropagation</b> Boolean: <div class="sub-desc">True to prevent event propagation</div></li>
470 * <li><b>normalized</b> Boolean: <div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
471 * <li><b>target</b> Ext.core.Element: <div class="sub-desc">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>
472 * <li><b>delay</b> Number: <div class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</div></li>
473 * <li><b>single</b> Boolean: <div class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>
474 * <li><b>buffer</b> Number: <div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
475 * by the specified number of milliseconds. If the event fires again within that time, the original
476 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
477 * </ul><br>
479 * <b>Combining Options</b><br>
480 * In the following examples, the shorthand form {@link #on} is used rather than the more verbose
481 * addListener. The two are equivalent. Using the options argument, it is possible to combine different
482 * types of listeners:<br>
484 * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
485 * options object. The options object is available as the third parameter in the handler function.<div style="margin: 5px 20px 20px;">
486 * Code:<pre><code>
487 el.on('click', this.onClick, this, {
492 });</code></pre></p>
494 * <b>Attaching multiple handlers in 1 call</b><br>
495 * The method also allows for a single argument to be passed which is a config object containing properties
496 * which specify multiple handlers.</p>
498 * Code:<pre><code>
506 fn: this.onMouseOver,
513 });</code></pre>
515 * Or a shorthand syntax:<br>
516 * Code:<pre><code></p>
518 'click' : this.onClick,
519 'mouseover' : this.onMouseOver,
520 'mouseout' : this.onMouseOut,
523 * </code></pre></p>
524 * <p><b>delegate</b></p>
525 * <p>This is a configuration option that you can pass along when registering a handler for
526 * an event to assist with event delegation. Event delegation is a technique that is used to
527 * reduce memory consumption and prevent exposure to memory-leaks. By registering an event
528 * for a container element as opposed to each element within a container. By setting this
529 * configuration option to a simple selector, the target element will be filtered to look for
530 * a descendant of the target.
531 * For example:<pre><code>
532 // using this markup:
533 &lt;div id='elId'>
534 &lt;p id='p1'>paragraph one&lt;/p>
535 &lt;p id='p2' class='clickable'>paragraph two&lt;/p>
536 &lt;p id='p3'>paragraph three&lt;/p>
538 // utilize event delegation to registering just one handler on the container element:
539 el = Ext.get('elId');
544 console.info(t.id); // 'p2'
548 // filter the target element to be a descendant with the class 'clickable'
549 delegate: '.clickable'
552 * </code></pre></p>
553 * @return {Ext.core.Element} this
555 addListener: function(eventName, fn, scope, options) {
556 Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
560 <span id='Ext-core.Element-method-removeListener'> /**
561 </span> * Removes an event handler from this element. The shorthand version {@link #un} is equivalent.
562 * <b>Note</b>: if a <i>scope</i> was explicitly specified when {@link #addListener adding} the
563 * listener, the same scope must be specified here.
565 * <pre><code>
566 el.removeListener('click', this.handlerFn);
568 el.un('click', this.handlerFn);
569 </code></pre>
570 * @param {String} eventName The name of the event from which to remove the handler.
571 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
572 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
573 * then this must refer to the same object.
574 * @return {Ext.core.Element} this
576 removeListener: function(eventName, fn, scope) {
577 Ext.EventManager.un(this.dom, eventName, fn, scope || this);
581 <span id='Ext-core.Element-method-removeAllListeners'> /**
582 </span> * Removes all previous added listeners from this element
583 * @return {Ext.core.Element} this
585 removeAllListeners: function() {
586 Ext.EventManager.removeAll(this.dom);
590 <span id='Ext-core.Element-method-purgeAllListeners'> /**
591 </span> * Recursively removes all previous added listeners from this element and its children
592 * @return {Ext.core.Element} this
594 purgeAllListeners: function() {
595 Ext.EventManager.purgeElement(this);
599 <span id='Ext-core.Element-method-addUnits'> /**
600 </span> * @private Test if size has a unit, otherwise appends the passed unit string, or the default for this Element.
601 * @param size {Mixed} The size to set
602 * @param units {String} The units to append to a numeric size value
604 addUnits: function(size, units) {
606 // Most common case first: Size is set to a number
607 if (Ext.isNumber(size)) {
608 return size + (units || this.defaultUnit || 'px');
611 // Size set to a value which means "auto"
612 if (size === "" || size == "auto" || size === undefined || size === null) {
616 // Otherwise, warn if it's not a valid CSS measurement
617 if (!unitPattern.test(size)) {
619 if (Ext.isDefined(Ext.global.console)) {
620 Ext.global.console.warn("Warning, size detected as NaN on Element.addUnits.");
628 <span id='Ext-core.Element-method-isBorderBox'> /**
629 </span> * Tests various css rules/browsers to determine if this element uses a border box
632 isBorderBox: function() {
633 return Ext.isBorderBox || noBoxAdjust[(this.dom.tagName || "").toLowerCase()];
636 <span id='Ext-core.Element-method-remove'> /**
637 </span> * <p>Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode Ext.removeNode}</p>
649 <span id='Ext-core.Element-method-hover'> /**
650 </span> * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.
651 * @param {Function} overFn The function to call when the mouse enters the Element.
652 * @param {Function} outFn The function to call when the mouse leaves the Element.
653 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the functions are executed. Defaults to the Element's DOM element.
654 * @param {Object} options (optional) Options for the listener. See {@link Ext.util.Observable#addListener the <tt>options</tt> parameter}.
655 * @return {Ext.core.Element} this
657 hover: function(overFn, outFn, scope, options) {
659 me.on('mouseenter', overFn, scope || me.dom, options);
660 me.on('mouseleave', outFn, scope || me.dom, options);
664 <span id='Ext-core.Element-method-contains'> /**
665 </span> * Returns true if this element is an ancestor of the passed element
666 * @param {HTMLElement/String} el The element to check
667 * @return {Boolean} True if this element is an ancestor of el, else false
669 contains: function(el) {
670 return ! el ? false: Ext.core.Element.isAncestor(this.dom, el.dom ? el.dom: el);
673 <span id='Ext-core.Element-method-getAttributeNS'> /**
674 </span> * Returns the value of a namespaced attribute from the element's underlying DOM node.
675 * @param {String} namespace The namespace in which to look for the attribute
676 * @param {String} name The attribute name
677 * @return {String} The attribute value
680 getAttributeNS: function(ns, name) {
681 return this.getAttribute(name, ns);
684 <span id='Ext-core.Element-property-getAttribute'> /**
685 </span> * Returns the value of an attribute from the element's underlying DOM node.
686 * @param {String} name The attribute name
687 * @param {String} namespace (optional) The namespace in which to look for the attribute
688 * @return {String} The attribute value
690 getAttribute: (Ext.isIE && !(Ext.isIE9 && document.documentMode === 9)) ?
695 type = typeof d[ns + ":" + name];
696 if (type != 'undefined' && type != 'unknown') {
697 return d[ns + ":" + name] || null;
701 if (name === "for") {
702 name = "htmlFor";
704 return d[name] || null;
705 }: function(name, ns) {
708 return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name);
710 return d.getAttribute(name) || d[name] || null;
713 <span id='Ext-core.Element-method-update'> /**
714 </span> * Update the innerHTML of this element
715 * @param {String} html The new HTML
716 * @return {Ext.core.Element} this
718 update: function(html) {
720 this.dom.innerHTML = html;
726 var ep = El.prototype;
728 El.addMethods = function(o) {
732 <span id='Ext-core.Element-method-on'> /**
733 </span> * Appends an event handler (shorthand for {@link #addListener}).
734 * @param {String} eventName The name of event to handle.
735 * @param {Function} fn The handler function the event invokes.
736 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function is executed.
737 * @param {Object} options (optional) An object containing standard {@link #addListener} options
738 * @member Ext.core.Element
741 ep.on = ep.addListener;
743 <span id='Ext-core.Element-method-un'> /**
744 </span> * Removes an event handler from this element (see {@link #removeListener} for additional notes).
745 * @param {String} eventName The name of the event from which to remove the handler.
746 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
747 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
748 * then this must refer to the same object.
749 * @return {Ext.core.Element} this
750 * @member Ext.core.Element
753 ep.un = ep.removeListener;
755 <span id='Ext-core.Element-method-clearListeners'> /**
756 </span> * Removes all previous added listeners from this element
757 * @return {Ext.core.Element} this
758 * @member Ext.core.Element
759 * @method clearListeners
761 ep.clearListeners = ep.removeAllListeners;
763 <span id='Ext-core.Element-method-destroy'> /**
764 </span> * Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode Ext.removeNode}.
765 * Alias to {@link #remove}.
766 * @member Ext.core.Element
769 ep.destroy = ep.remove;
771 <span id='Ext-core.Element-property-autoBoxAdjust'> /**
772 </span> * true to automatically adjust width and height settings for box-model issues (default to true)
774 ep.autoBoxAdjust = true;
777 var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
780 <span id='Ext-core.Element-method-get'> /**
781 </span> * Retrieves Ext.core.Element objects.
782 * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method
783 * retrieves Ext.core.Element objects which encapsulate DOM elements. To retrieve a Component by
784 * its ID, use {@link Ext.ComponentManager#get}.</p>
785 * <p>Uses simple caching to consistently return the same object. Automatically fixes if an
786 * object was recreated with the same id via AJAX or DOM.</p>
787 * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
788 * @return {Element} The Element object (or null if no matching element was found)
790 * @member Ext.core.Element
793 El.get = function(el) {
800 if (typeof el == "string") {
802 if (! (elm = DOC.getElementById(el))) {
805 if (EC[el] && EC[el].el) {
809 ex = El.addToCache(new El(elm));
812 } else if (el.tagName) {
814 if (! (id = el.id)) {
817 if (EC[id] && EC[id].el) {
821 ex = El.addToCache(new El(el));
824 } else if (el instanceof El) {
826 // refresh dom element in case no longer valid,
827 // catch case where it hasn't been appended
828 // If an el instance is passed, don't pass to getElementById without some kind of id
829 if (Ext.isIE && (el.id == undefined || el.id == '')) {
832 el.dom = DOC.getElementById(el.id) || el.dom;
836 } else if (el.isComposite) {
838 } else if (Ext.isArray(el)) {
839 return El.select(el);
840 } else if (el == DOC) {
841 // create a bogus element object representing the document object
843 var f = function() {};
844 f.prototype = El.prototype;
853 El.addToCache = function(el, id) {
865 // private method for getting and setting element data
866 El.data = function(el, key, value) {
871 var c = EC[el.id].data;
872 if (arguments.length == 2) {
875 return (c[key] = value);
880 // Garbage collection - uncache elements/purge listeners on orphaned elements
881 // so we don't hold a reference and cause the browser to retain them
882 function garbageCollect() {
883 if (!Ext.enableGarbageCollector) {
884 clearInterval(El.collectorThreadId);
892 if (!EC.hasOwnProperty(eid)) {
896 if (o.skipGarbageCollection) {
901 // -------------------------------------------------------
902 // Determining what is garbage:
903 // -------------------------------------------------------
905 // dom node is null, definitely garbage
906 // -------------------------------------------------------
908 // no parentNode == direct orphan, definitely garbage
909 // -------------------------------------------------------
910 // !d.offsetParent && !document.getElementById(eid)
911 // display none elements have no offsetParent so we will
912 // also try to look it up by it's id. However, check
913 // offsetParent first so we don't do unneeded lookups.
914 // This enables collection of elements that are not orphans
915 // directly, but somewhere up the line they have an orphan
917 // -------------------------------------------------------
918 if (!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))) {
919 if (d && Ext.enableListenerCollection) {
920 Ext.EventManager.removeAll(d);
925 // Cleanup IE Object leaks
929 if (!EC.hasOwnProperty(eid)) {
938 El.collectorThreadId = setInterval(garbageCollect, 30000);
940 var flyFn = function() {};
941 flyFn.prototype = El.prototype;
944 El.Flyweight = function(dom) {
948 El.Flyweight.prototype = new flyFn();
949 El.Flyweight.prototype.isFlyweight = true;
952 <span id='Ext-core.Element-method-fly'> /**
953 </span> * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
954 * the dom node can be overwritten by other code. Shorthand of {@link Ext.core.Element#fly}</p>
955 * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by
956 * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get Ext.get}
957 * will be more appropriate to take advantage of the caching provided by the Ext.core.Element class.</p>
958 * @param {String/HTMLElement} el The dom node or id
959 * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
960 * (e.g. internally Ext uses "_global")
961 * @return {Element} The shared Element object (or null if no matching element was found)
962 * @member Ext.core.Element
965 El.fly = function(el, named) {
967 named = named || '_global';
970 (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
971 ret = El._flyweights[named];
976 <span id='Ext-method-get'> /**
977 </span> * Retrieves Ext.core.Element objects.
978 * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method
979 * retrieves Ext.core.Element objects which encapsulate DOM elements. To retrieve a Component by
980 * its ID, use {@link Ext.ComponentManager#get}.</p>
981 * <p>Uses simple caching to consistently return the same object. Automatically fixes if an
982 * object was recreated with the same id via AJAX or DOM.</p>
983 * Shorthand of {@link Ext.core.Element#get}
984 * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
985 * @return {Element} The Element object (or null if no matching element was found)
991 <span id='Ext-method-fly'> /**
992 </span> * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
993 * the dom node can be overwritten by other code. Shorthand of {@link Ext.core.Element#fly}</p>
994 * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by
995 * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get Ext.get}
996 * will be more appropriate to take advantage of the caching provided by the Ext.core.Element class.</p>
997 * @param {String/HTMLElement} el The dom node or id
998 * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
999 * (e.g. internally Ext uses "_global")
1000 * @return {Element} The shared Element object (or null if no matching element was found)
1006 // speedy lookup for elements never to box adjust
1007 var noBoxAdjust = Ext.isStrict ? {
1014 if (Ext.isIE || Ext.isGecko) {
1015 noBoxAdjust['button'] = 1;
1018 </pre></pre></body></html>