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.2.2
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
17 * <p>Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.</p>
18 * <p>All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.</p>
19 * <p>Note that the events documented in this class are not Ext events, they encapsulate browser events. To
20 * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older
21 * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.</p>
25 var el = Ext.get("my-div");
27 // by DOM element reference
28 var el = Ext.get(myDivElement);
30 * <b>Animations</b><br />
31 * <p>When an element is manipulated, by default there is no animation.</p>
33 var el = Ext.get("my-div");
38 * <p>Many of the functions for manipulating an element have an optional "animate" parameter. This
39 * parameter can be specified as boolean (<tt>true</tt>) for default animation effects.</p>
42 el.setWidth(100, true);
45 * <p>To configure the effects, an object literal with animation options to use as the Element animation
46 * configuration object can also be specified. Note that the supported Element animation configuration
47 * options are a subset of the {@link Ext.Fx} animation options specific to Fx effects. The supported
48 * Element animation configuration options are:</p>
50 Option Default Description
51 --------- -------- ---------------------------------------------
52 {@link Ext.Fx#duration duration} .35 The duration of the animation in seconds
53 {@link Ext.Fx#easing easing} easeOut The easing method
54 {@link Ext.Fx#callback callback} none A function to execute when the anim completes
55 {@link Ext.Fx#scope scope} this The scope (this) of the callback function
59 // Element animation options object
61 {@link Ext.Fx#duration duration}: 1,
62 {@link Ext.Fx#easing easing}: 'elasticIn',
63 {@link Ext.Fx#callback callback}: this.foo,
64 {@link Ext.Fx#scope scope}: this
66 // animation with some options set
67 el.setWidth(100, opt);
69 * <p>The Element animation object being used for the animation will be set on the options
70 * object as "anim", which allows you to stop or manipulate the animation. Here is an example:</p>
72 // using the "anim" property to get the Anim object
73 if(opt.anim.isAnimated()){
77 * <p>Also see the <tt>{@link #animate}</tt> method for another animation technique.</p>
78 * <p><b> Composite (Collections of) Elements</b></p>
79 * <p>For working with collections of Elements, see {@link Ext.CompositeElement}</p>
80 * @constructor Create a new Element directly.
81 * @param {String/HTMLElement} element
82 * @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).
87 Ext.Element = function(element, forceNew){
88 var dom = typeof element == "string" ?
89 DOC.getElementById(element) : element,
96 if(!forceNew && id && Ext.elCache[id]){ // element object already exists
97 return Ext.elCache[id].el;
100 <div id="prop-Ext.Element-dom"></div>/**
106 <div id="prop-Ext.Element-id"></div>/**
110 this.id = id || Ext.id(dom);
113 var DH = Ext.DomHelper,
118 <div id="method-Ext.Element-set"></div>/**
119 * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
120 * @param {Object} o The object with the attributes
121 * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.
122 * @return {Ext.Element} this
124 set : function(o, useSet){
128 useSet = (useSet !== false) && !!el.setAttribute;
131 if (o.hasOwnProperty(attr)) {
133 if (attr == 'style') {
134 DH.applyStyles(el, val);
135 } else if (attr == 'cls') {
138 el.setAttribute(attr, val);
148 <div id="event-Ext.Element-click"></div>/**
150 * Fires when a mouse click is detected within the element.
151 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
152 * @param {HtmlElement} t The target of the event.
153 * @param {Object} o The options configuration passed to the {@link #addListener} call.
155 <div id="event-Ext.Element-contextmenu"></div>/**
157 * Fires when a right click is detected within the element.
158 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
159 * @param {HtmlElement} t The target of the event.
160 * @param {Object} o The options configuration passed to the {@link #addListener} call.
162 <div id="event-Ext.Element-dblclick"></div>/**
164 * Fires when a mouse double click is detected within the element.
165 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
166 * @param {HtmlElement} t The target of the event.
167 * @param {Object} o The options configuration passed to the {@link #addListener} call.
169 <div id="event-Ext.Element-mousedown"></div>/**
171 * Fires when a mousedown is detected within the element.
172 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
173 * @param {HtmlElement} t The target of the event.
174 * @param {Object} o The options configuration passed to the {@link #addListener} call.
176 <div id="event-Ext.Element-mouseup"></div>/**
178 * Fires when a mouseup is detected within the element.
179 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
180 * @param {HtmlElement} t The target of the event.
181 * @param {Object} o The options configuration passed to the {@link #addListener} call.
183 <div id="event-Ext.Element-mouseover"></div>/**
185 * Fires when a mouseover is detected within the element.
186 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
187 * @param {HtmlElement} t The target of the event.
188 * @param {Object} o The options configuration passed to the {@link #addListener} call.
190 <div id="event-Ext.Element-mousemove"></div>/**
192 * Fires when a mousemove is detected with the element.
193 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
194 * @param {HtmlElement} t The target of the event.
195 * @param {Object} o The options configuration passed to the {@link #addListener} call.
197 <div id="event-Ext.Element-mouseout"></div>/**
199 * Fires when a mouseout is detected with the element.
200 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
201 * @param {HtmlElement} t The target of the event.
202 * @param {Object} o The options configuration passed to the {@link #addListener} call.
204 <div id="event-Ext.Element-mouseenter"></div>/**
206 * Fires when the mouse enters the element.
207 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
208 * @param {HtmlElement} t The target of the event.
209 * @param {Object} o The options configuration passed to the {@link #addListener} call.
211 <div id="event-Ext.Element-mouseleave"></div>/**
213 * Fires when the mouse leaves the element.
214 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
215 * @param {HtmlElement} t The target of the event.
216 * @param {Object} o The options configuration passed to the {@link #addListener} call.
220 <div id="event-Ext.Element-keypress"></div>/**
222 * Fires when a keypress is detected within the element.
223 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
224 * @param {HtmlElement} t The target of the event.
225 * @param {Object} o The options configuration passed to the {@link #addListener} call.
227 <div id="event-Ext.Element-keydown"></div>/**
229 * Fires when a keydown is detected within the element.
230 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
231 * @param {HtmlElement} t The target of the event.
232 * @param {Object} o The options configuration passed to the {@link #addListener} call.
234 <div id="event-Ext.Element-keyup"></div>/**
236 * Fires when a keyup is detected within the element.
237 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
238 * @param {HtmlElement} t The target of the event.
239 * @param {Object} o The options configuration passed to the {@link #addListener} call.
243 // HTML frame/object events
244 <div id="event-Ext.Element-load"></div>/**
246 * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.
247 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
248 * @param {HtmlElement} t The target of the event.
249 * @param {Object} o The options configuration passed to the {@link #addListener} call.
251 <div id="event-Ext.Element-unload"></div>/**
253 * 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.
254 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
255 * @param {HtmlElement} t The target of the event.
256 * @param {Object} o The options configuration passed to the {@link #addListener} call.
258 <div id="event-Ext.Element-abort"></div>/**
260 * Fires when an object/image is stopped from loading before completely loaded.
261 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
262 * @param {HtmlElement} t The target of the event.
263 * @param {Object} o The options configuration passed to the {@link #addListener} call.
265 <div id="event-Ext.Element-error"></div>/**
267 * Fires when an object/image/frame cannot be loaded properly.
268 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
269 * @param {HtmlElement} t The target of the event.
270 * @param {Object} o The options configuration passed to the {@link #addListener} call.
272 <div id="event-Ext.Element-resize"></div>/**
274 * Fires when a document view is resized.
275 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
276 * @param {HtmlElement} t The target of the event.
277 * @param {Object} o The options configuration passed to the {@link #addListener} call.
279 <div id="event-Ext.Element-scroll"></div>/**
281 * Fires when a document view is scrolled.
282 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
283 * @param {HtmlElement} t The target of the event.
284 * @param {Object} o The options configuration passed to the {@link #addListener} call.
288 <div id="event-Ext.Element-select"></div>/**
290 * Fires when a user selects some text in a text field, including input and textarea.
291 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
292 * @param {HtmlElement} t The target of the event.
293 * @param {Object} o The options configuration passed to the {@link #addListener} call.
295 <div id="event-Ext.Element-change"></div>/**
297 * Fires when a control loses the input focus and its value has been modified since gaining focus.
298 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
299 * @param {HtmlElement} t The target of the event.
300 * @param {Object} o The options configuration passed to the {@link #addListener} call.
302 <div id="event-Ext.Element-submit"></div>/**
304 * Fires when a form is submitted.
305 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
306 * @param {HtmlElement} t The target of the event.
307 * @param {Object} o The options configuration passed to the {@link #addListener} call.
309 <div id="event-Ext.Element-reset"></div>/**
311 * Fires when a form is reset.
312 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
313 * @param {HtmlElement} t The target of the event.
314 * @param {Object} o The options configuration passed to the {@link #addListener} call.
316 <div id="event-Ext.Element-focus"></div>/**
318 * Fires when an element receives focus either via the pointing device or by tab navigation.
319 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
320 * @param {HtmlElement} t The target of the event.
321 * @param {Object} o The options configuration passed to the {@link #addListener} call.
323 <div id="event-Ext.Element-blur"></div>/**
325 * Fires when an element loses focus either via the pointing device or by tabbing navigation.
326 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
327 * @param {HtmlElement} t The target of the event.
328 * @param {Object} o The options configuration passed to the {@link #addListener} call.
331 // User Interface events
332 <div id="event-Ext.Element-DOMFocusIn"></div>/**
334 * Where supported. Similar to HTML focus event, but can be applied to any focusable element.
335 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
336 * @param {HtmlElement} t The target of the event.
337 * @param {Object} o The options configuration passed to the {@link #addListener} call.
339 <div id="event-Ext.Element-DOMFocusOut"></div>/**
341 * Where supported. Similar to HTML blur event, but can be applied to any focusable element.
342 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
343 * @param {HtmlElement} t The target of the event.
344 * @param {Object} o The options configuration passed to the {@link #addListener} call.
346 <div id="event-Ext.Element-DOMActivate"></div>/**
348 * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
349 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
350 * @param {HtmlElement} t The target of the event.
351 * @param {Object} o The options configuration passed to the {@link #addListener} call.
354 // DOM Mutation events
355 <div id="event-Ext.Element-DOMSubtreeModified"></div>/**
356 * @event DOMSubtreeModified
357 * Where supported. Fires when the subtree is modified.
358 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
359 * @param {HtmlElement} t The target of the event.
360 * @param {Object} o The options configuration passed to the {@link #addListener} call.
362 <div id="event-Ext.Element-DOMNodeInserted"></div>/**
363 * @event DOMNodeInserted
364 * Where supported. Fires when a node has been added as a child of another node.
365 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
366 * @param {HtmlElement} t The target of the event.
367 * @param {Object} o The options configuration passed to the {@link #addListener} call.
369 <div id="event-Ext.Element-DOMNodeRemoved"></div>/**
370 * @event DOMNodeRemoved
371 * Where supported. Fires when a descendant node of the element is removed.
372 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
373 * @param {HtmlElement} t The target of the event.
374 * @param {Object} o The options configuration passed to the {@link #addListener} call.
376 <div id="event-Ext.Element-DOMNodeRemovedFromDocument"></div>/**
377 * @event DOMNodeRemovedFromDocument
378 * Where supported. Fires when a node is being removed from a document.
379 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
380 * @param {HtmlElement} t The target of the event.
381 * @param {Object} o The options configuration passed to the {@link #addListener} call.
383 <div id="event-Ext.Element-DOMNodeInsertedIntoDocument"></div>/**
384 * @event DOMNodeInsertedIntoDocument
385 * Where supported. Fires when a node is being inserted into a document.
386 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
387 * @param {HtmlElement} t The target of the event.
388 * @param {Object} o The options configuration passed to the {@link #addListener} call.
390 <div id="event-Ext.Element-DOMAttrModified"></div>/**
391 * @event DOMAttrModified
392 * Where supported. Fires when an attribute has been modified.
393 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
394 * @param {HtmlElement} t The target of the event.
395 * @param {Object} o The options configuration passed to the {@link #addListener} call.
397 <div id="event-Ext.Element-DOMCharacterDataModified"></div>/**
398 * @event DOMCharacterDataModified
399 * Where supported. Fires when the character data has been modified.
400 * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
401 * @param {HtmlElement} t The target of the event.
402 * @param {Object} o The options configuration passed to the {@link #addListener} call.
405 <div id="prop-Ext.Element-defaultUnit"></div>/**
406 * The default unit to append to CSS values where a unit isn't provided (defaults to px).
411 <div id="method-Ext.Element-is"></div>/**
412 * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
413 * @param {String} selector The simple selector to test
414 * @return {Boolean} True if this element matches the selector, else false
416 is : function(simpleSelector){
417 return Ext.DomQuery.is(this.dom, simpleSelector);
420 <div id="method-Ext.Element-focus"></div>/**
421 * Tries to focus the element. Any exceptions are caught and ignored.
422 * @param {Number} defer (optional) Milliseconds to defer the focus
423 * @return {Ext.Element} this
425 focus : function(defer, /* private */ dom) {
430 me.focus.defer(defer, null, [null, dom]);
438 <div id="method-Ext.Element-blur"></div>/**
439 * Tries to blur the element. Any exceptions are caught and ignored.
440 * @return {Ext.Element} this
449 <div id="method-Ext.Element-getValue"></div>/**
450 * Returns the value of the "value" attribute
451 * @param {Boolean} asNumber true to parse the value as a number
452 * @return {String/Number}
454 getValue : function(asNumber){
455 var val = this.dom.value;
456 return asNumber ? parseInt(val, 10) : val;
459 <div id="method-Ext.Element-addListener"></div>/**
460 * Appends an event handler to this element. The shorthand version {@link #on} is equivalent.
461 * @param {String} eventName The name of event to handle.
462 * @param {Function} fn The handler function the event invokes. This function is passed
463 * the following parameters:<ul>
464 * <li><b>evt</b> : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
465 * <li><b>el</b> : HtmlElement<div class="sub-desc">The DOM element which was the target of the event.
466 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
467 * <li><b>o</b> : Object<div class="sub-desc">The options object from the addListener call.</div></li>
469 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.
470 * <b>If omitted, defaults to this Element.</b>.
471 * @param {Object} options (optional) An object containing handler configuration properties.
472 * This may contain any of the following properties:<ul>
473 * <li><b>scope</b> Object : <div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the handler function is executed.
474 * <b>If omitted, defaults to this Element.</b></div></li>
475 * <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>
476 * <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>
477 * <li><b>preventDefault</b> Boolean: <div class="sub-desc">True to prevent the default action</div></li>
478 * <li><b>stopPropagation</b> Boolean: <div class="sub-desc">True to prevent event propagation</div></li>
479 * <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>
480 * <li><b>target</b> Ext.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>
481 * <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>
482 * <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>
483 * <li><b>buffer</b> Number: <div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
484 * by the specified number of milliseconds. If the event fires again within that time, the original
485 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
488 * <b>Combining Options</b><br>
489 * In the following examples, the shorthand form {@link #on} is used rather than the more verbose
490 * addListener. The two are equivalent. Using the options argument, it is possible to combine different
491 * types of listeners:<br>
493 * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
494 * options object. The options object is available as the third parameter in the handler function.<div style="margin: 5px 20px 20px;">
496 el.on('click', this.onClick, this, {
503 * <b>Attaching multiple handlers in 1 call</b><br>
504 * The method also allows for a single argument to be passed which is a config object containing properties
505 * which specify multiple handlers.</p>
515 fn: this.onMouseOver,
524 * Or a shorthand syntax:<br>
525 * Code:<pre><code></p>
527 'click' : this.onClick,
528 'mouseover' : this.onMouseOver,
529 'mouseout' : this.onMouseOut,
533 * <p><b>delegate</b></p>
534 * <p>This is a configuration option that you can pass along when registering a handler for
535 * an event to assist with event delegation. Event delegation is a technique that is used to
536 * reduce memory consumption and prevent exposure to memory-leaks. By registering an event
537 * for a container element as opposed to each element within a container. By setting this
538 * configuration option to a simple selector, the target element will be filtered to look for
539 * a descendant of the target.
540 * For example:<pre><code>
541 // using this markup:
543 <p id='p1'>paragraph one</p>
544 <p id='p2' class='clickable'>paragraph two</p>
545 <p id='p3'>paragraph three</p>
547 // utilize event delegation to registering just one handler on the container element:
548 el = Ext.get('elId');
553 console.info(t.id); // 'p2'
557 // filter the target element to be a descendant with the class 'clickable'
558 delegate: '.clickable'
562 * @return {Ext.Element} this
564 addListener : function(eventName, fn, scope, options){
565 Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
569 <div id="method-Ext.Element-removeListener"></div>/**
570 * Removes an event handler from this element. The shorthand version {@link #un} is equivalent.
571 * <b>Note</b>: if a <i>scope</i> was explicitly specified when {@link #addListener adding} the
572 * listener, the same scope must be specified here.
575 el.removeListener('click', this.handlerFn);
577 el.un('click', this.handlerFn);
579 * @param {String} eventName The name of the event from which to remove the handler.
580 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
581 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
582 * then this must refer to the same object.
583 * @return {Ext.Element} this
585 removeListener : function(eventName, fn, scope){
586 Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
590 <div id="method-Ext.Element-removeAllListeners"></div>/**
591 * Removes all previous added listeners from this element
592 * @return {Ext.Element} this
594 removeAllListeners : function(){
595 Ext.EventManager.removeAll(this.dom);
599 <div id="method-Ext.Element-purgeAllListeners"></div>/**
600 * Recursively removes all previous added listeners from this element and its children
601 * @return {Ext.Element} this
603 purgeAllListeners : function() {
604 Ext.EventManager.purgeElement(this, true);
608 * @private Test if size has a unit, otherwise appends the default
610 addUnits : function(size){
611 if(size === "" || size == "auto" || size === undefined){
613 } else if(!isNaN(size) || !unitPattern.test(size)){
614 size = size + (this.defaultUnit || 'px');
619 <div id="method-Ext.Element-load"></div>/**
620 * <p>Updates the <a href="http://developer.mozilla.org/en/DOM/element.innerHTML">innerHTML</a> of this Element
621 * from a specified URL. Note that this is subject to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same Origin Policy</a></p>
622 * <p>Updating innerHTML of an element will <b>not</b> execute embedded <tt><script></tt> elements. This is a browser restriction.</p>
623 * @param {Mixed} options. Either a sring containing the URL from which to load the HTML, or an {@link Ext.Ajax#request} options object specifying
624 * exactly how to request the HTML.
625 * @return {Ext.Element} this
627 load : function(url, params, cb){
628 Ext.Ajax.request(Ext.apply({
633 indicatorText: url.indicatorText || ''
634 }, Ext.isObject(url) ? url : {}));
638 <div id="method-Ext.Element-isBorderBox"></div>/**
639 * Tests various css rules/browsers to determine if this element uses a border box
642 isBorderBox : function(){
643 return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;
646 <div id="method-Ext.Element-remove"></div>/**
647 * <p>Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode}</p>
659 <div id="method-Ext.Element-hover"></div>/**
660 * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.
661 * @param {Function} overFn The function to call when the mouse enters the Element.
662 * @param {Function} outFn The function to call when the mouse leaves the Element.
663 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the functions are executed. Defaults to the Element's DOM element.
664 * @param {Object} options (optional) Options for the listener. See {@link Ext.util.Observable#addListener the <tt>options</tt> parameter}.
665 * @return {Ext.Element} this
667 hover : function(overFn, outFn, scope, options){
669 me.on('mouseenter', overFn, scope || me.dom, options);
670 me.on('mouseleave', outFn, scope || me.dom, options);
674 <div id="method-Ext.Element-contains"></div>/**
675 * Returns true if this element is an ancestor of the passed element
676 * @param {HTMLElement/String} el The element to check
677 * @return {Boolean} True if this element is an ancestor of el, else false
679 contains : function(el){
680 return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
683 <div id="method-Ext.Element-getAttributeNS"></div>/**
684 * Returns the value of a namespaced attribute from the element's underlying DOM node.
685 * @param {String} namespace The namespace in which to look for the attribute
686 * @param {String} name The attribute name
687 * @return {String} The attribute value
690 getAttributeNS : function(ns, name){
691 return this.getAttribute(name, ns);
694 <div id="method-Ext.Element-getAttribute"></div>/**
695 * Returns the value of an attribute from the element's underlying DOM node.
696 * @param {String} name The attribute name
697 * @param {String} namespace (optional) The namespace in which to look for the attribute
698 * @return {String} The attribute value
700 getAttribute : Ext.isIE ? function(name, ns){
702 type = typeof d[ns + ":" + name];
704 if(['undefined', 'unknown'].indexOf(type) == -1){
705 return d[ns + ":" + name];
708 } : function(name, ns){
710 return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
713 <div id="method-Ext.Element-update"></div>/**
714 * Update the innerHTML of this element
715 * @param {String} html The new HTML
716 * @return {Ext.Element} this
718 update : function(html) {
720 this.dom.innerHTML = html;
726 var ep = El.prototype;
728 El.addMethods = function(o){
732 <div id="method-Ext.Element-on"></div>/**
733 * 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.Element
741 ep.on = ep.addListener;
743 <div id="method-Ext.Element-un"></div>/**
744 * 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.Element} this
750 * @member Ext.Element
753 ep.un = ep.removeListener;
755 <div id="prop-Ext.Element-autoBoxAdjust"></div>/**
756 * true to automatically adjust width and height settings for box-model issues (default to true)
758 ep.autoBoxAdjust = true;
761 var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
768 <div id="method-Ext.Element-get"></div>/**
769 * Retrieves Ext.Element objects.
770 * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method
771 * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by
772 * its ID, use {@link Ext.ComponentMgr#get}.</p>
773 * <p>Uses simple caching to consistently return the same object. Automatically fixes if an
774 * object was recreated with the same id via AJAX or DOM.</p>
775 * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
776 * @return {Element} The Element object (or null if no matching element was found)
778 * @member Ext.Element
781 El.get = function(el){
785 if(!el){ return null; }
786 if (typeof el == "string") { // element id
787 if (!(elm = DOC.getElementById(el))) {
790 if (EC[el] && EC[el].el) {
794 ex = El.addToCache(new El(elm));
797 } else if (el.tagName) { // dom element
801 if (EC[id] && EC[id].el) {
805 ex = El.addToCache(new El(el));
808 } else if (el instanceof El) {
810 // refresh dom element in case no longer valid,
811 // catch case where it hasn't been appended
813 // If an el instance is passed, don't pass to getElementById without some kind of id
814 if (Ext.isIE && (el.id == undefined || el.id == '')) {
817 el.dom = DOC.getElementById(el.id) || el.dom;
821 } else if(el.isComposite) {
823 } else if(Ext.isArray(el)) {
824 return El.select(el);
825 } else if(el == DOC) {
826 // create a bogus element object representing the document object
828 var f = function(){};
829 f.prototype = El.prototype;
838 El.addToCache = function(el, id){
848 // private method for getting and setting element data
849 El.data = function(el, key, value){
854 var c = EC[el.id].data;
855 if(arguments.length == 2){
858 return (c[key] = value);
863 // Garbage collection - uncache elements/purge listeners on orphaned elements
864 // so we don't hold a reference and cause the browser to retain them
865 function garbageCollect(){
866 if(!Ext.enableGarbageCollector){
867 clearInterval(El.collectorThreadId);
881 // -------------------------------------------------------
882 // Determining what is garbage:
883 // -------------------------------------------------------
885 // dom node is null, definitely garbage
886 // -------------------------------------------------------
888 // no parentNode == direct orphan, definitely garbage
889 // -------------------------------------------------------
890 // !d.offsetParent && !document.getElementById(eid)
891 // display none elements have no offsetParent so we will
892 // also try to look it up by it's id. However, check
893 // offsetParent first so we don't do unneeded lookups.
894 // This enables collection of elements that are not orphans
895 // directly, but somewhere up the line they have an orphan
897 // -------------------------------------------------------
898 if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){
899 if(Ext.enableListenerCollection){
900 Ext.EventManager.removeAll(d);
905 // Cleanup IE Object leaks
911 EC = Ext.elCache = t;
915 El.collectorThreadId = setInterval(garbageCollect, 30000);
917 var flyFn = function(){};
918 flyFn.prototype = El.prototype;
921 El.Flyweight = function(dom){
925 El.Flyweight.prototype = new flyFn();
926 El.Flyweight.prototype.isFlyweight = true;
929 <div id="method-Ext.Element-fly"></div>/**
930 * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
931 * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}</p>
932 * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by
933 * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}
934 * will be more appropriate to take advantage of the caching provided by the Ext.Element class.</p>
935 * @param {String/HTMLElement} el The dom node or id
936 * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
937 * (e.g. internally Ext uses "_global")
938 * @return {Element} The shared Element object (or null if no matching element was found)
939 * @member Ext.Element
942 El.fly = function(el, named){
944 named = named || '_global';
946 if (el = Ext.getDom(el)) {
947 (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
948 ret = El._flyweights[named];
953 <div id="method-Ext-get"></div>/**
954 * Retrieves Ext.Element objects.
955 * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method
956 * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by
957 * its ID, use {@link Ext.ComponentMgr#get}.</p>
958 * <p>Uses simple caching to consistently return the same object. Automatically fixes if an
959 * object was recreated with the same id via AJAX or DOM.</p>
960 * Shorthand of {@link Ext.Element#get}
961 * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
962 * @return {Element} The Element object (or null if no matching element was found)
968 <div id="method-Ext-fly"></div>/**
969 * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
970 * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}</p>
971 * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by
972 * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}
973 * will be more appropriate to take advantage of the caching provided by the Ext.Element class.</p>
974 * @param {String/HTMLElement} el The dom node or id
975 * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
976 * (e.g. internally Ext uses "_global")
977 * @return {Element} The shared Element object (or null if no matching element was found)
983 // speedy lookup for elements never to box adjust
984 var noBoxAdjust = Ext.isStrict ? {
987 input:1, select:1, textarea:1
989 if(Ext.isIE || Ext.isGecko){
990 noBoxAdjust['button'] = 1;