3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.EventManager"></div>/**
\r
10 * @class Ext.EventManager
\r
11 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
\r
12 * several useful events directly.
\r
13 * See {@link Ext.EventObject} for more details on normalized event objects.
\r
16 Ext.EventManager = function(){
\r
19 docReadyState = false,
\r
24 IEDEFERED = "ie-deferred-loader",
\r
25 DOMCONTENTLOADED = "DOMContentLoaded",
\r
26 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
\r
28 * This cache is used to hold special js objects, the document and window, that don't have an id. We need to keep
\r
29 * a reference to them so we can look them up at a later point.
\r
31 specialElCache = [];
\r
36 len = specialElCache.length,
\r
41 if(el.getElementById || el.navigator){
\r
43 for(; i < len; ++i){
\r
44 o = specialElCache[i];
\r
51 // for browsers that support it, ensure that give the el the same id
\r
53 specialElCache.push({
\r
62 if(!Ext.elCache[id]){
\r
63 Ext.Element.addToCache(new Ext.Element(el), id);
\r
65 Ext.elCache[id].skipGC = true;
\r
72 /// There is some jquery work around stuff here that isn't needed in Ext Core.
\r
73 function addListener(el, ename, fn, wrap, scope){
\r
74 el = Ext.getDom(el);
\r
76 es = Ext.elCache[id].events,
\r
79 wfn = E.on(el, ename, wrap);
\r
80 es[ename] = es[ename] || [];
\r
81 es[ename].push([fn, wrap, scope, wfn]);
\r
83 // this is a workaround for jQuery and should somehow be removed from Ext Core in the future
\r
84 // without breaking ExtJS.
\r
85 if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery
\r
86 var args = ["DOMMouseScroll", wrap, false];
\r
87 el.addEventListener.apply(el, args);
\r
88 Ext.EventManager.addListener(WINDOW, 'unload', function(){
\r
89 el.removeEventListener.apply(el, args);
\r
92 if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
\r
93 Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
\r
97 function fireDocReady(){
\r
99 Ext.isReady = docReadyState = true;
\r
100 if(docReadyProcId){
\r
101 clearInterval(docReadyProcId);
\r
103 if(Ext.isGecko || Ext.isOpera) {
\r
104 DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
107 var defer = DOC.getElementById(IEDEFERED);
\r
109 defer.onreadystatechange = null;
\r
110 defer.parentNode.removeChild(defer);
\r
114 docReadyEvent.fire();
\r
115 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
120 function initDocReady(){
\r
121 var COMPLETE = "complete";
\r
123 docReadyEvent = new Ext.util.Event();
\r
124 if (Ext.isGecko || Ext.isOpera) {
\r
125 DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
126 } else if (Ext.isIE){
\r
127 DOC.write("<s"+'cript id=' + IEDEFERED + ' defer="defer" src="/'+'/:"></s'+"cript>");
\r
128 DOC.getElementById(IEDEFERED).onreadystatechange = function(){
\r
129 if(this.readyState == COMPLETE){
\r
133 } else if (Ext.isWebKit){
\r
134 docReadyProcId = setInterval(function(){
\r
135 if(DOC.readyState == COMPLETE) {
\r
140 // no matter what, make sure it fires on load
\r
141 E.on(WINDOW, "load", fireDocReady);
\r
144 function createTargeted(h, o){
\r
146 var args = Ext.toArray(arguments);
\r
147 if(o.target == Ext.EventObject.setEvent(args[0]).target){
\r
148 h.apply(this, args);
\r
153 function createBuffered(h, o, fn){
\r
154 fn.task = new Ext.util.DelayedTask(h);
\r
155 var w = function(e){
\r
156 // create new event object impl so new events don't wipe out properties
\r
157 fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
\r
162 function createSingle(h, el, ename, fn, scope){
\r
163 return function(e){
\r
164 Ext.EventManager.removeListener(el, ename, fn, scope);
\r
169 function createDelayed(h, o, fn){
\r
170 return function(e){
\r
171 var task = new Ext.util.DelayedTask(h);
\r
175 fn.tasks.push(task);
\r
176 task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
\r
180 function listen(element, ename, opt, fn, scope){
\r
181 var o = !Ext.isObject(opt) ? {} : opt,
\r
182 el = Ext.getDom(element);
\r
185 scope = scope || o.scope;
\r
188 throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
\r
191 // prevent errors while unload occurring
\r
192 if(!Ext){// !window[xname]){ ==> can't we do this?
\r
195 e = Ext.EventObject.setEvent(e);
\r
198 if(!(t = e.getTarget(o.delegate, el))){
\r
207 if (o.preventDefault) {
\r
208 e.preventDefault();
\r
210 if (o.stopPropagation) {
\r
211 e.stopPropagation();
\r
213 if (o.normalized) {
\r
214 e = e.browserEvent;
\r
217 fn.call(scope || el, e, t, o);
\r
220 h = createTargeted(h, o);
\r
223 h = createDelayed(h, o, fn);
\r
226 h = createSingle(h, el, ename, fn, scope);
\r
229 h = createBuffered(h, o, fn);
\r
232 addListener(el, ename, fn, h, scope);
\r
237 <div id="method-Ext.EventManager-addListener"></div>/**
\r
238 * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
\r
239 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
\r
240 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
\r
241 * @param {String} eventName The name of the event to listen for.
\r
242 * @param {Function} handler The handler function the event invokes. This function is passed
\r
243 * the following parameters:<ul>
\r
244 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
\r
245 * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
\r
246 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
\r
247 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
\r
249 * @param {Object} scope (optional) The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.
\r
250 * @param {Object} options (optional) An object containing handler configuration properties.
\r
251 * This may contain any of the following properties:<ul>
\r
252 * <li>scope : Object<div class="sub-desc">The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.</div></li>
\r
253 * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
\r
254 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
\r
255 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
\r
256 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
\r
257 * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
\r
258 * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
\r
259 * <li>single : 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>
\r
260 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
\r
261 * by the specified number of milliseconds. If the event fires again within that time, the original
\r
262 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
\r
263 * <li>target : 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>
\r
265 * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
\r
267 addListener : function(element, eventName, fn, scope, options){
\r
268 if(Ext.isObject(eventName)){
\r
269 var o = eventName, e, val;
\r
272 if(!propRe.test(e)){
\r
273 if(Ext.isFunction(val)){
\r
275 listen(element, e, o, val, o.scope);
\r
277 // individual options
\r
278 listen(element, e, val);
\r
283 listen(element, eventName, options, fn, scope);
\r
287 <div id="method-Ext.EventManager-removeListener"></div>/**
\r
288 * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
\r
289 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
\r
290 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
291 * @param {String} eventName The name of the event.
\r
292 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
\r
293 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
294 * then this must refer to the same object.
\r
296 removeListener : function(el, eventName, fn, scope){
\r
297 el = Ext.getDom(el);
\r
298 var id = getId(el),
\r
299 f = el && (Ext.elCache[id].events)[eventName] || [],
\r
302 for (i = 0, len = f.length; i < len; i++) {
\r
303 if (Ext.isArray(f[i]) && f[i][0] == fn && (!scope || f[i][2] == scope)) {
\r
308 k = fn.tasks && fn.tasks.length;
\r
311 fn.tasks[k].cancel();
\r
315 wf = wrap = f[i][1];
\r
316 if (E.extAdapter) {
\r
319 E.un(el, eventName, wf);
\r
321 if (f.length === 0) {
\r
322 delete Ext.elCache[id].events[eventName];
\r
324 for (k in Ext.elCache[id].events) {
\r
327 Ext.elCache[id].events = {};
\r
332 // jQuery workaround that should be removed from Ext Core
\r
333 if(eventName == "mousewheel" && el.addEventListener && wrap){
\r
334 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
337 if(eventName == "mousedown" && el == DOC && wrap){ // fix stopped mousedowns on the document
\r
338 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
342 <div id="method-Ext.EventManager-removeAll"></div>/**
\r
343 * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
\r
344 * directly on an Element in favor of calling this version.
\r
345 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
\r
347 removeAll : function(el){
\r
348 el = Ext.getDom(el);
\r
349 var id = getId(el),
\r
350 ec = Ext.elCache[id] || {},
\r
351 es = ec.events || {},
\r
352 f, i, len, ename, fn, k;
\r
355 if(es.hasOwnProperty(ename)){
\r
357 for (i = 0, len = f.length; i < len; i++) {
\r
363 if(fn.tasks && (k = fn.tasks.length)) {
\r
365 fn.tasks[k].cancel();
\r
369 E.un(el, ename, E.extAdapter ? f[i][3] : f[i][1]);
\r
373 if (Ext.elCache[id]) {
\r
374 Ext.elCache[id].events = {};
\r
378 getListeners : function(el, eventName) {
\r
379 el = Ext.getDom(el);
\r
380 var id = getId(el),
\r
381 ec = Ext.elCache[id] || {},
\r
382 es = ec.events || {},
\r
384 if (es && es[eventName]) {
\r
385 return es[eventName];
\r
391 purgeElement : function(el, recurse, eventName) {
\r
392 el = Ext.getDom(el);
\r
393 var id = getId(el),
\r
394 ec = Ext.elCache[id] || {},
\r
395 es = ec.events || {},
\r
398 if (es && es.hasOwnProperty(eventName)) {
\r
400 for (i = 0, len = f.length; i < len; i++) {
\r
401 Ext.EventManager.removeListener(el, eventName, f[i][0]);
\r
405 Ext.EventManager.removeAll(el);
\r
407 if (recurse && el && el.childNodes) {
\r
408 for (i = 0, len = el.childNodes.length; i < len; i++) {
\r
409 Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
\r
414 _unload : function() {
\r
416 for (el in Ext.elCache) {
\r
417 Ext.EventManager.removeAll(el);
\r
420 <div id="method-Ext.EventManager-onDocumentReady"></div>/**
\r
421 * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
\r
422 * accessed shorthanded as Ext.onReady().
\r
423 * @param {Function} fn The method the event invokes.
\r
424 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
425 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
426 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
428 onDocumentReady : function(fn, scope, options){
\r
429 if(docReadyState){ // if it already fired
\r
430 docReadyEvent.addListener(fn, scope, options);
\r
431 docReadyEvent.fire();
\r
432 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
434 if(!docReadyEvent) initDocReady();
\r
435 options = options || {};
\r
436 options.delay = options.delay || 1;
\r
437 docReadyEvent.addListener(fn, scope, options);
\r
441 <div id="method-Ext.EventManager-on"></div>/**
\r
442 * Appends an event handler to an element. Shorthand for {@link #addListener}.
\r
443 * @param {String/HTMLElement} el The html element or id to assign the event handler to
\r
444 * @param {String} eventName The name of the event to listen for.
\r
445 * @param {Function} handler The handler function the event invokes.
\r
446 * @param {Object} scope (optional) (<code>this</code> reference) in which the handler function executes. <b>Defaults to the Element</b>.
\r
447 * @param {Object} options (optional) An object containing standard {@link #addListener} options
\r
448 * @member Ext.EventManager
\r
451 pub.on = pub.addListener;
\r
452 <div id="method-Ext.EventManager-un"></div>/**
\r
453 * Removes an event handler from an element. Shorthand for {@link #removeListener}.
\r
454 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
455 * @param {String} eventName The name of the event.
\r
456 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #on} call.</b>
\r
457 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
458 * then this must refer to the same object.
\r
459 * @member Ext.EventManager
\r
462 pub.un = pub.removeListener;
\r
464 pub.stoppedMouseDownEvent = new Ext.util.Event();
\r
467 <div id="method-Ext-onReady"></div>/**
\r
468 * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Shorthand of {@link Ext.EventManager#onDocumentReady}.
\r
469 * @param {Function} fn The method the event invokes.
\r
470 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
471 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
472 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
476 Ext.onReady = Ext.EventManager.onDocumentReady;
\r
479 //Initialize doc classes
\r
482 var initExtCss = function(){
\r
483 // find the body element
\r
484 var bd = document.body || document.getElementsByTagName('body')[0];
\r
485 if(!bd){ return false; }
\r
487 Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
\r
488 : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
\r
489 : Ext.isOpera ? "ext-opera"
\r
490 : Ext.isWebKit ? "ext-webkit" : ""];
\r
493 cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
\r
494 }else if(Ext.isChrome){
\r
495 cls.push("ext-chrome");
\r
499 cls.push("ext-mac");
\r
502 cls.push("ext-linux");
\r
505 if(Ext.isStrict || Ext.isBorderBox){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
\r
506 var p = bd.parentNode;
\r
508 p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
\r
511 bd.className += cls.join(' ');
\r
516 Ext.onReady(initExtCss);
\r
521 <div id="cls-Ext.EventObject"></div>/**
\r
522 * @class Ext.EventObject
\r
523 * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
\r
524 * wraps the browser's native event-object normalizing cross-browser differences,
\r
525 * such as which mouse button is clicked, keys pressed, mechanisms to stop
\r
526 * event-propagation along with a method to prevent default actions from taking place.
\r
527 * <p>For example:</p>
\r
529 function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
\r
530 e.preventDefault();
\r
531 var target = e.getTarget(); // same as t (the target HTMLElement)
\r
534 var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}
\r
535 myDiv.on( // 'on' is shorthand for addListener
\r
536 "click", // perform an action on click of myDiv
\r
537 handleClick // reference to the action handler
\r
539 // other methods to do the same:
\r
540 Ext.EventManager.on("myDiv", 'click', handleClick);
\r
541 Ext.EventManager.addListener("myDiv", 'click', handleClick);
\r
545 Ext.EventObject = function(){
\r
546 var E = Ext.lib.Event,
\r
547 // safari keypress events for special keys return bad keycodes
\r
550 63234 : 37, // left
\r
551 63235 : 39, // right
\r
553 63233 : 40, // down
\r
554 63276 : 33, // page up
\r
555 63277 : 34, // page down
\r
556 63272 : 46, // delete
\r
557 63273 : 36, // home
\r
560 // normalize button clicks
\r
561 btnMap = Ext.isIE ? {1:0,4:1,2:2} :
\r
562 (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
\r
564 Ext.EventObjectImpl = function(e){
\r
566 this.setEvent(e.browserEvent || e);
\r
570 Ext.EventObjectImpl.prototype = {
\r
572 setEvent : function(e){
\r
574 if(e == me || (e && e.browserEvent)){ // already wrapped
\r
577 me.browserEvent = e;
\r
579 // normalize buttons
\r
580 me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
\r
581 if(e.type == 'click' && me.button == -1){
\r
585 me.shiftKey = e.shiftKey;
\r
586 // mac metaKey behaves like ctrlKey
\r
587 me.ctrlKey = e.ctrlKey || e.metaKey || false;
\r
588 me.altKey = e.altKey;
\r
589 // in getKey these will be normalized for the mac
\r
590 me.keyCode = e.keyCode;
\r
591 me.charCode = e.charCode;
\r
592 // cache the target for the delayed and or buffered events
\r
593 me.target = E.getTarget(e);
\r
595 me.xy = E.getXY(e);
\r
598 me.shiftKey = false;
\r
599 me.ctrlKey = false;
\r
609 <div id="method-Ext.EventObject-stopEvent"></div>/**
\r
610 * Stop the event (preventDefault and stopPropagation)
\r
612 stopEvent : function(){
\r
614 if(me.browserEvent){
\r
615 if(me.browserEvent.type == 'mousedown'){
\r
616 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
618 E.stopEvent(me.browserEvent);
\r
622 <div id="method-Ext.EventObject-preventDefault"></div>/**
\r
623 * Prevents the browsers default handling of the event.
\r
625 preventDefault : function(){
\r
626 if(this.browserEvent){
\r
627 E.preventDefault(this.browserEvent);
\r
631 <div id="method-Ext.EventObject-stopPropagation"></div>/**
\r
632 * Cancels bubbling of the event.
\r
634 stopPropagation : function(){
\r
636 if(me.browserEvent){
\r
637 if(me.browserEvent.type == 'mousedown'){
\r
638 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
640 E.stopPropagation(me.browserEvent);
\r
644 <div id="method-Ext.EventObject-getCharCode"></div>/**
\r
645 * Gets the character code for the event.
\r
648 getCharCode : function(){
\r
649 return this.charCode || this.keyCode;
\r
652 <div id="method-Ext.EventObject-getKey"></div>/**
\r
653 * Returns a normalized keyCode for the event.
\r
654 * @return {Number} The key code
\r
656 getKey : function(){
\r
657 return this.normalizeKey(this.keyCode || this.charCode)
\r
661 normalizeKey: function(k){
\r
662 return Ext.isSafari ? (safariKeys[k] || k) : k;
\r
665 <div id="method-Ext.EventObject-getPageX"></div>/**
\r
666 * Gets the x coordinate of the event.
\r
669 getPageX : function(){
\r
673 <div id="method-Ext.EventObject-getPageY"></div>/**
\r
674 * Gets the y coordinate of the event.
\r
677 getPageY : function(){
\r
681 <div id="method-Ext.EventObject-getXY"></div>/**
\r
682 * Gets the page coordinates of the event.
\r
683 * @return {Array} The xy values like [x, y]
\r
685 getXY : function(){
\r
689 <div id="method-Ext.EventObject-getTarget"></div>/**
\r
690 * Gets the target for the event.
\r
691 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
\r
692 * @param {Number/Mixed} maxDepth (optional) The max depth to
\r
693 search as a number or element (defaults to 10 || document.body)
\r
694 * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
\r
695 * @return {HTMLelement}
\r
697 getTarget : function(selector, maxDepth, returnEl){
\r
698 return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
\r
701 <div id="method-Ext.EventObject-getRelatedTarget"></div>/**
\r
702 * Gets the related target.
\r
703 * @return {HTMLElement}
\r
705 getRelatedTarget : function(){
\r
706 return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
\r
709 <div id="method-Ext.EventObject-getWheelDelta"></div>/**
\r
710 * Normalizes mouse wheel delta across browsers
\r
711 * @return {Number} The delta
\r
713 getWheelDelta : function(){
\r
714 var e = this.browserEvent;
\r
716 if(e.wheelDelta){ /* IE/Opera. */
\r
717 delta = e.wheelDelta/120;
\r
718 }else if(e.detail){ /* Mozilla case. */
\r
719 delta = -e.detail/3;
\r
724 <div id="method-Ext.EventObject-within"></div>/**
\r
725 * Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false if if the target is el.
\r
726 * Example usage:<pre><code>
\r
727 // Handle click on any child of an element
\r
728 Ext.getBody().on('click', function(e){
\r
729 if(e.within('some-el')){
\r
730 alert('Clicked on a child of some-el!');
\r
734 // Handle click directly on an element, ignoring clicks on child nodes
\r
735 Ext.getBody().on('click', function(e,t){
\r
736 if((t.id == 'some-el') && !e.within(t, true)){
\r
737 alert('Clicked directly on some-el!');
\r
741 * @param {Mixed} el The id, DOM element or Ext.Element to check
\r
742 * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
\r
743 * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
\r
744 * @return {Boolean}
\r
746 within : function(el, related, allowEl){
\r
748 var t = this[related ? "getRelatedTarget" : "getTarget"]();
\r
749 return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
\r
755 return new Ext.EventObjectImpl();
\r