/* This file is part of Ext JS 4.2 Copyright (c) 2011-2013 Sencha Inc Contact: http://www.sencha.com/contact GNU General Public License Usage This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. Build date: 2013-05-16 14:36:50 (f9be68accb407158ba2b1be2c226a6ce1f649314) */ // @tag dom,core /** * @class Ext.dom.Element * @alternateClassName Ext.Element * @alternateClassName Ext.core.Element * @extends Ext.dom.AbstractElement * * Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences. * * All instances of this class inherit the methods of {@link Ext.fx.Anim} making visual effects easily available to all * DOM elements. * * Note that the events documented in this class are not Ext events, they encapsulate browser events. Some older browsers * may not support the full range of events. Which events are supported is beyond the control of Ext JS. * * Usage: * * // by id * var el = Ext.get("my-div"); * * // by DOM element reference * var el = Ext.get(myDivElement); * * # Animations * * When an element is manipulated, by default there is no animation. * * var el = Ext.get("my-div"); * * // no animation * el.setWidth(100); * * Many of the functions for manipulating an element have an optional "animate" parameter. This parameter can be * specified as boolean (true) for default animation effects. * * // default animation * el.setWidth(100, true); * * To configure the effects, an object literal with animation options to use as the Element animation configuration * object can also be specified. Note that the supported Element animation configuration options are a subset of the * {@link Ext.fx.Anim} animation options specific to Fx effects. The supported Element animation configuration options * are: * * Option Default Description * --------- -------- --------------------------------------------- * {@link Ext.fx.Anim#duration duration} 350 The duration of the animation in milliseconds * {@link Ext.fx.Anim#easing easing} easeOut The easing method * {@link Ext.fx.Anim#callback callback} none A function to execute when the anim completes * {@link Ext.fx.Anim#scope scope} this The scope (this) of the callback function * * Usage: * * // Element animation options object * var opt = { * {@link Ext.fx.Anim#duration duration}: 1000, * {@link Ext.fx.Anim#easing easing}: 'elasticIn', * {@link Ext.fx.Anim#callback callback}: this.foo, * {@link Ext.fx.Anim#scope scope}: this * }; * // animation with some options set * el.setWidth(100, opt); * * The Element animation object being used for the animation will be set on the options object as "anim", which allows * you to stop or manipulate the animation. Here is an example: * * // using the "anim" property to get the Anim object * if(opt.anim.isAnimated()){ * opt.anim.stop(); * } * * # Composite (Collections of) Elements * * For working with collections of Elements, see {@link Ext.CompositeElement} * * @constructor * Creates new Element directly. * @param {String/HTMLElement} element * @param {Boolean} [forceNew] 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). * @return {Object} */ Ext.define('Ext.dom.Element', function(Element) { var HIDDEN = 'hidden', DOC = document, VISIBILITY = "visibility", DISPLAY = "display", NONE = "none", XMASKED = Ext.baseCSSPrefix + "masked", XMASKEDRELATIVE = Ext.baseCSSPrefix + "masked-relative", EXTELMASKMSG = Ext.baseCSSPrefix + "mask-msg", bodyRe = /^body/i, visFly, // speedy lookup for elements never to box adjust noBoxAdjust = Ext.isStrict ? { select: 1 }: { input: 1, select: 1, textarea: 1 }, // Pseudo for use by cacheScrollValues isScrolled = function(c) { var r = [], ri = -1, i, ci; for (i = 0; ci = c[i]; i++) { if (ci.scrollTop > 0 || ci.scrollLeft > 0) { r[++ri] = ci; } } return r; }; return { extend: 'Ext.dom.AbstractElement', alternateClassName: ['Ext.Element', 'Ext.core.Element'], requires: [ 'Ext.dom.Query', 'Ext.dom.Element_anim', 'Ext.dom.Element_dd', 'Ext.dom.Element_fx', 'Ext.dom.Element_position', 'Ext.dom.Element_scroll', 'Ext.dom.Element_style' ], tableTagRe: /^(?:tr|td|table|tbody)$/i, mixins: [ 'Ext.util.Positionable' ], addUnits: function() { return Element.addUnits.apply(Element, arguments); }, /** * Tries to focus the element. Any exceptions are caught and ignored. * @param {Number} [defer] Milliseconds to defer the focus * @return {Ext.dom.Element} this */ focus: function(defer, /* private */ dom) { var me = this; dom = dom || me.dom; try { if (Number(defer)) { Ext.defer(me.focus, defer, me, [null, dom]); } else { dom.focus(); } } catch(e) { } return me; }, /** * Tries to blur the element. Any exceptions are caught and ignored. * @return {Ext.dom.Element} this */ blur: function() { var me = this, dom = me.dom; // In IE, blurring the body can cause the browser window to hide. // Blurring the body is redundant, so instead we just focus it if (dom !== document.body) { try { dom.blur(); } catch(e) { } return me; } else { return me.focus(undefined, dom); } }, /** * Tests various css rules/browsers to determine if this element uses a border box * @return {Boolean} */ isBorderBox: function() { var box = Ext.isBorderBox; // IE6/7 force input elements to content-box even if border-box is set explicitly if (box && Ext.isIE7m) { box = !((this.dom.tagName || "").toLowerCase() in noBoxAdjust); } return box; }, /** * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element. * @param {Function} overFn The function to call when the mouse enters the Element. * @param {Function} outFn The function to call when the mouse leaves the Element. * @param {Object} [scope] The scope (`this` reference) in which the functions are executed. Defaults * to the Element's DOM element. * @param {Object} [options] Options for the listener. See {@link Ext.util.Observable#addListener the * options parameter}. * @return {Ext.dom.Element} this */ hover: function(overFn, outFn, scope, options) { var me = this; me.on('mouseenter', overFn, scope || me.dom, options); me.on('mouseleave', outFn, scope || me.dom, options); return me; }, /** * Returns the value of a namespaced attribute from the element's underlying DOM node. * @param {String} namespace The namespace in which to look for the attribute * @param {String} name The attribute name * @return {String} The attribute value */ getAttributeNS: function(ns, name) { return this.getAttribute(name, ns); }, getAttribute: (Ext.isIE && !(Ext.isIE9p && DOC.documentMode >= 9)) ? // Essentially all web browsers (Firefox, Internet Explorer, recent versions of Opera, Safari, Konqueror, and iCab, // as a non-exhaustive list) return null when the specified attribute does not exist on the specified element. // The DOM specification says that the correct return value in this case is actually the empty string, and some // DOM implementations implement this behavior. The implementation of getAttribute in XUL (Gecko) actually follows // the specification and returns an empty string. Consequently, you should use hasAttribute to check for an attribute's // existence prior to calling getAttribute() if it is possible that the requested attribute does not exist on the specified element. // // https://developer.mozilla.org/en-US/docs/DOM/element.getAttribute // http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614 function(name, ns) { var d = this.dom, type; if (ns) { type = typeof d[ns + ":" + name]; if (type != 'undefined' && type != 'unknown') { return d[ns + ":" + name] || null; } return null; } if (name === "for") { name = "htmlFor"; } return d[name] || null; } : function(name, ns) { var d = this.dom; if (ns) { return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name); } return d.getAttribute(name) || d[name] || null; }, /** * When an element is moved around in the DOM, or is hidden using `display:none`, it loses layout, and therefore * all scroll positions of all descendant elements are lost. * * This function caches them, and returns a function, which when run will restore the cached positions. * In the following example, the Panel is moved from one Container to another which will cause it to lose all scroll positions: * * var restoreScroll = myPanel.el.cacheScrollValues(); * myOtherContainer.add(myPanel); * restoreScroll(); * * @return {Function} A function which will restore all descentant elements of this Element to their scroll * positions recorded when this function was executed. Be aware that the returned function is a closure which has * captured the scope of `cacheScrollValues`, so take care to derefence it as soon as not needed - if is it is a `var` * it will drop out of scope, and the reference will be freed. */ cacheScrollValues: function() { var me = this, scrolledDescendants, el, i, scrollValues = [], result = function() { for (i = 0; i < scrolledDescendants.length; i++) { el = scrolledDescendants[i]; el.scrollLeft = scrollValues[i][0]; el.scrollTop = scrollValues[i][1]; } }; if (!Ext.DomQuery.pseudos.isScrolled) { Ext.DomQuery.pseudos.isScrolled = isScrolled; } scrolledDescendants = me.query(':isScrolled'); for (i = 0; i < scrolledDescendants.length; i++) { el = scrolledDescendants[i]; scrollValues[i] = [el.scrollLeft, el.scrollTop]; } return result; }, /** * @property {Boolean} autoBoxAdjust * True to automatically adjust width and height settings for box-model issues. */ autoBoxAdjust: true, /** * Checks whether the element is currently visible using both visibility and display properties. * @param {Boolean} [deep=false] True to walk the dom and see if parent elements are hidden. * If false, the function only checks the visibility of the element itself and it may return * `true` even though a parent is not visible. * @return {Boolean} `true` if the element is currently visible, else `false` */ isVisible : function(deep) { var me = this, dom = me.dom, stopNode = dom.ownerDocument.documentElement; if (!visFly) { visFly = new Element.Fly(); } while (dom !== stopNode) { // We're invisible if we hit a nonexistent parentNode or a document // fragment or computed style visibility:hidden or display:none if (!dom || dom.nodeType === 11 || (visFly.attach(dom)).isStyle(VISIBILITY, HIDDEN) || visFly.isStyle(DISPLAY, NONE)) { return false; } // Quit now unless we are being asked to check parent nodes. if (!deep) { break; } dom = dom.parentNode; } return true; }, /** * Returns true if display is not "none" * @return {Boolean} */ isDisplayed : function() { return !this.isStyle(DISPLAY, NONE); }, /** * Convenience method for setVisibilityMode(Element.DISPLAY) * @param {String} [display] What to set display to when visible * @return {Ext.dom.Element} this */ enableDisplayMode : function(display) { var me = this; me.setVisibilityMode(Element.DISPLAY); if (!Ext.isEmpty(display)) { (me.$cache || me.getCache()).data.originalDisplay = display; } return me; }, /** * Puts a mask over this element to disable user interaction. Requires core.css. * This method can only be applied to elements which accept child nodes. * @param {String} [msg] A message to display in the mask * @param {String} [msgCls] A css class to apply to the msg element * @return {Ext.dom.Element} The mask element */ mask : function(msg, msgCls /* private - passed by AbstractComponent.mask to avoid the need to interrogate the DOM to get the height*/, elHeight) { var me = this, dom = me.dom, // In some cases, setExpression will exist but not be of a function type, // so we check it explicitly here to stop IE throwing errors setExpression = dom.style.setExpression, data = (me.$cache || me.getCache()).data, maskShimEl = data.maskShimEl, maskEl = data.maskEl, maskMsg = data.maskMsg, widthExpression, heightExpression; if (!(bodyRe.test(dom.tagName) && me.getStyle('position') == 'static')) { me.addCls(XMASKEDRELATIVE); } // We always needs to recreate the mask since the DOM element may have been re-created if (maskEl) { maskEl.remove(); } if (maskMsg) { maskMsg.remove(); } if (maskShimEl) { maskShimEl.remove(); } if (Ext.isIE6) { maskShimEl = Ext.DomHelper.append(dom, { tag: 'iframe', cls : Ext.baseCSSPrefix + 'shim ' + Ext.baseCSSPrefix + 'mask-shim' }, true); data.maskShimEl = maskShimEl; maskShimEl.setDisplayed(true); } Ext.DomHelper.append(dom, [{ cls : Ext.baseCSSPrefix + "mask", style: 'top:0;left:0;' }, { cls : msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG, cn : { tag: 'div', cls: Ext.baseCSSPrefix + 'mask-msg-inner', cn: { tag: 'div', cls: Ext.baseCSSPrefix + 'mask-msg-text', html: msg || '' } } }]); maskMsg = Ext.get(dom.lastChild); maskEl = Ext.get(maskMsg.dom.previousSibling); data.maskMsg = maskMsg; data.maskEl = maskEl; me.addCls(XMASKED); maskEl.setDisplayed(true); if (typeof msg == 'string') { maskMsg.setDisplayed(true); maskMsg.center(me); } else { maskMsg.setDisplayed(false); } // NOTE: CSS expressions are resource intensive and to be used only as a last resort // These expressions are removed as soon as they are no longer necessary - in the unmask method. // In normal use cases an element will be masked for a limited period of time. // Fix for https://sencha.jira.com/browse/EXTJSIV-19. // IE6 strict mode and IE6-9 quirks mode takes off left+right padding when calculating width! if (!Ext.supports.IncludePaddingInWidthCalculation && setExpression) { // In an occasional case setExpression will throw an exception try { maskEl.dom.style.setExpression('width', 'this.parentNode.clientWidth + "px"'); widthExpression = 'this.parentNode.clientWidth + "px"'; if (maskShimEl) { maskShimEl.dom.style.setExpression('width', widthExpression); } maskEl.dom.style.setExpression('width', widthExpression); } catch (e) {} } // Some versions and modes of IE subtract top+bottom padding when calculating height. // Different versions from those which make the same error for width! if (!Ext.supports.IncludePaddingInHeightCalculation && setExpression) { // In an occasional case setExpression will throw an exception try { heightExpression = 'this.parentNode.' + (dom == DOC.body ? 'scrollHeight' : 'offsetHeight') + ' + "px"'; if (maskShimEl) { maskShimEl.dom.style.setExpression('height', heightExpression); } maskEl.dom.style.setExpression('height', heightExpression); } catch (e) {} } // ie will not expand full height automatically else if (Ext.isIE9m && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') { if (maskShimEl) { maskShimEl.setSize(undefined, elHeight || me.getHeight()); } maskEl.setSize(undefined, elHeight || me.getHeight()); } return maskEl; }, /** * Hides a previously applied mask. */ unmask : function() { var me = this, data = (me.$cache || me.getCache()).data, maskEl = data.maskEl, maskShimEl = data.maskShimEl, maskMsg = data.maskMsg, style; if (maskEl) { style = maskEl.dom.style; // Remove resource-intensive CSS expressions as soon as they are not required. if (style.clearExpression) { style.clearExpression('width'); style.clearExpression('height'); } if (maskEl) { maskEl.remove(); delete data.maskEl; } if (maskMsg) { maskMsg.remove(); delete data.maskMsg; } me.removeCls([XMASKED, XMASKEDRELATIVE]); if (maskShimEl) { style = maskShimEl.dom.style; // Remove resource-intensive CSS expressions as soon as they are not required. if (style.clearExpression) { style.clearExpression('width'); style.clearExpression('height'); } maskShimEl.remove(); delete data.maskShimEl; } } }, /** * Returns true if this element is masked. Also re-centers any displayed message within the mask. * @return {Boolean} */ isMasked : function() { var me = this, data = (me.$cache || me.getCache()).data, maskEl = data.maskEl, maskMsg = data.maskMsg, hasMask = false; if (maskEl && maskEl.isVisible()) { if (maskMsg) { maskMsg.center(me); } hasMask = true; } return hasMask; }, /** * Creates an iframe shim for this element to keep selects and other windowed objects from * showing through. * @return {Ext.dom.Element} The new shim element */ createShim : function() { var el = DOC.createElement('iframe'), shim; el.frameBorder = '0'; el.className = Ext.baseCSSPrefix + 'shim'; el.src = Ext.SSL_SECURE_URL; shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom)); shim.autoBoxAdjust = false; return shim; }, /** * Convenience method for constructing a KeyMap * @param {String/Number/Number[]/Object} key Either a string with the keys to listen for, the numeric key code, * array of key codes or an object with the following options: * @param {Number/Array} key.key * @param {Boolean} key.shift * @param {Boolean} key.ctrl * @param {Boolean} key.alt * @param {Function} fn The function to call * @param {Object} [scope] The scope (`this` reference) in which the specified function is executed. Defaults to this Element. * @return {Ext.util.KeyMap} The KeyMap created */ addKeyListener : function(key, fn, scope){ var config; if(typeof key != 'object' || Ext.isArray(key)){ config = { target: this, key: key, fn: fn, scope: scope }; }else{ config = { target: this, key : key.key, shift : key.shift, ctrl : key.ctrl, alt : key.alt, fn: fn, scope: scope }; } return new Ext.util.KeyMap(config); }, /** * Creates a KeyMap for this element * @param {Object} config The KeyMap config. See {@link Ext.util.KeyMap} for more details * @return {Ext.util.KeyMap} The KeyMap created */ addKeyMap : function(config) { return new Ext.util.KeyMap(Ext.apply({ target: this }, config)); }, // Mouse events /** * @event click * Fires when a mouse click is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event contextmenu * Fires when a right click is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event dblclick * Fires when a mouse double click is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mousedown * Fires when a mousedown is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mouseup * Fires when a mouseup is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mouseover * Fires when a mouseover is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mousemove * Fires when a mousemove is detected with the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mouseout * Fires when a mouseout is detected with the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mouseenter * Fires when the mouse enters the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event mouseleave * Fires when the mouse leaves the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ // Keyboard events /** * @event keypress * Fires when a keypress is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event keydown * Fires when a keydown is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event keyup * Fires when a keyup is detected within the element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ // HTML frame/object events /** * @event load * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, * objects and images. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event unload * 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. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event abort * Fires when an object/image is stopped from loading before completely loaded. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event error * Fires when an object/image/frame cannot be loaded properly. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event resize * Fires when a document view is resized. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event scroll * Fires when a document view is scrolled. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ // Form events /** * @event select * Fires when a user selects some text in a text field, including input and textarea. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event change * Fires when a control loses the input focus and its value has been modified since gaining focus. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event submit * Fires when a form is submitted. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event reset * Fires when a form is reset. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event focus * Fires when an element receives focus either via the pointing device or by tab navigation. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event blur * Fires when an element loses focus either via the pointing device or by tabbing navigation. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ // User Interface events /** * @event DOMFocusIn * Where supported. Similar to HTML focus event, but can be applied to any focusable element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMFocusOut * Where supported. Similar to HTML blur event, but can be applied to any focusable element. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMActivate * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ // DOM Mutation events /** * @event DOMSubtreeModified * Where supported. Fires when the subtree is modified. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMNodeInserted * Where supported. Fires when a node has been added as a child of another node. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMNodeRemoved * Where supported. Fires when a descendant node of the element is removed. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMNodeRemovedFromDocument * Where supported. Fires when a node is being removed from a document. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMNodeInsertedIntoDocument * Where supported. Fires when a node is being inserted into a document. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMAttrModified * Where supported. Fires when an attribute has been modified. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * @event DOMCharacterDataModified * Where supported. Fires when the character data has been modified. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. * @param {HTMLElement} t The target of the event. */ /** * Appends an event handler to this element. * * @param {String} eventName The name of event to handle. * * @param {Function} fn The handler function the event invokes. This function is passed the following parameters: * * - **evt** : EventObject * * The {@link Ext.EventObject EventObject} describing the event. * * - **el** : HtmlElement * * The DOM element which was the target of the event. Note that this may be filtered by using the delegate option. * * - **o** : Object * * The options object from the call that setup the listener. * * @param {Object} scope (optional) The scope (**this** reference) in which the handler function is executed. **If * omitted, defaults to this Element.** * * @param {Object} options (optional) An object containing handler configuration properties. This may contain any of * the following properties: * * - **scope** Object : * * The scope (**this** reference) in which the handler function is executed. **If omitted, defaults to this * Element.** * * - **delegate** String: * * A simple selector to filter the target or look for a descendant of the target. See below for additional details. * * - **stopEvent** Boolean: * * True to stop the event. That is stop propagation, and prevent the default action. * * - **preventDefault** Boolean: * * True to prevent the default action * * - **stopPropagation** Boolean: * * True to prevent event propagation * * - **normalized** Boolean: * * False to pass a browser event to the handler function instead of an Ext.EventObject * * - **target** Ext.dom.Element: * * Only call the handler if the event was fired on the target Element, _not_ if the event was bubbled up from a * child node. * * - **delay** Number: * * The number of milliseconds to delay the invocation of the handler after the event fires. * * - **single** Boolean: * * True to add a handler to handle just the next firing of the event, and then remove itself. * * - **buffer** Number: * * Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed by the specified number of * milliseconds. If the event fires again within that time, the original handler is _not_ invoked, but the new * handler is scheduled in its place. * * **Combining Options** * * Using the options argument, it is possible to combine different types of listeners: * * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the options * object. The options object is available as the third parameter in the handler function. * * Code: * * el.on('click', this.onClick, this, { * single: true, * delay: 100, * stopEvent : true, * forumId: 4 * }); * * **Attaching multiple handlers in 1 call** * * The method also allows for a single argument to be passed which is a config object containing properties which * specify multiple handlers. * * Code: * * el.on({ * 'click' : { * fn: this.onClick, * scope: this, * delay: 100 * }, * 'mouseover' : { * fn: this.onMouseOver, * scope: this * }, * 'mouseout' : { * fn: this.onMouseOut, * scope: this * } * }); * * Or a shorthand syntax: * * Code: * * el.on({ * 'click' : this.onClick, * 'mouseover' : this.onMouseOver, * 'mouseout' : this.onMouseOut, * scope: this * }); * * **delegate** * * This is a configuration option that you can pass along when registering a handler for an event to assist with * event delegation. Event delegation is a technique that is used to reduce memory consumption and prevent exposure * to memory-leaks. By registering an event for a container element as opposed to each element within a container. * By setting this configuration option to a simple selector, the target element will be filtered to look for a * descendant of the target. For example: * * // using this markup: *
paragraph one
*paragraph two
*paragraph three
*