3 * Copyright(c) 2006-2010 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.EventManager
\r
9 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
\r
10 * several useful events directly.
\r
11 * See {@link Ext.EventObject} for more details on normalized event objects.
\r
14 Ext.EventManager = function(){
\r
17 docReadyState = false,
\r
22 IEDEFERED = "ie-deferred-loader",
\r
23 DOMCONTENTLOADED = "DOMContentLoaded",
\r
24 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
\r
26 * This cache is used to hold special js objects, the document and window, that don't have an id. We need to keep
\r
27 * a reference to them so we can look them up at a later point.
\r
29 specialElCache = [];
\r
34 len = specialElCache.length,
\r
39 if(el.getElementById || el.navigator){
\r
41 for(; i < len; ++i){
\r
42 o = specialElCache[i];
\r
49 // for browsers that support it, ensure that give the el the same id
\r
51 specialElCache.push({
\r
60 if(!Ext.elCache[id]){
\r
61 Ext.Element.addToCache(new Ext.Element(el), id);
\r
63 Ext.elCache[id].skipGC = true;
\r
70 /// There is some jquery work around stuff here that isn't needed in Ext Core.
\r
71 function addListener(el, ename, fn, task, wrap, scope){
\r
72 el = Ext.getDom(el);
\r
74 es = Ext.elCache[id].events,
\r
77 wfn = E.on(el, ename, wrap);
\r
78 es[ename] = es[ename] || [];
\r
80 /* 0 = Original Function,
\r
81 1 = Event Manager Wrapped Function,
\r
83 3 = Adapter Wrapped Function,
\r
86 es[ename].push([fn, wrap, scope, wfn, task]);
\r
88 // this is a workaround for jQuery and should somehow be removed from Ext Core in the future
\r
89 // without breaking ExtJS.
\r
91 // workaround for jQuery
\r
92 if(el.addEventListener && ename == "mousewheel"){
\r
93 var args = ["DOMMouseScroll", wrap, false];
\r
94 el.addEventListener.apply(el, args);
\r
95 Ext.EventManager.addListener(WINDOW, 'unload', function(){
\r
96 el.removeEventListener.apply(el, args);
\r
100 // fix stopped mousedowns on the document
\r
101 if(el == DOC && ename == "mousedown"){
\r
102 Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
\r
106 function fireDocReady(){
\r
107 if(!docReadyState){
\r
108 Ext.isReady = docReadyState = true;
\r
109 if(docReadyProcId){
\r
110 clearInterval(docReadyProcId);
\r
112 if(Ext.isGecko || Ext.isOpera) {
\r
113 DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
116 var defer = DOC.getElementById(IEDEFERED);
\r
118 defer.onreadystatechange = null;
\r
119 defer.parentNode.removeChild(defer);
\r
123 docReadyEvent.fire();
\r
124 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
129 function initDocReady(){
\r
130 var COMPLETE = "complete";
\r
132 docReadyEvent = new Ext.util.Event();
\r
133 if (Ext.isGecko || Ext.isOpera) {
\r
134 DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
135 } else if (Ext.isIE){
\r
136 DOC.write("<s"+'cript id=' + IEDEFERED + ' defer="defer" src="/'+'/:"></s'+"cript>");
\r
137 DOC.getElementById(IEDEFERED).onreadystatechange = function(){
\r
138 if(this.readyState == COMPLETE){
\r
142 } else if (Ext.isWebKit){
\r
143 docReadyProcId = setInterval(function(){
\r
144 if(DOC.readyState == COMPLETE) {
\r
149 // no matter what, make sure it fires on load
\r
150 E.on(WINDOW, "load", fireDocReady);
\r
153 function createTargeted(h, o){
\r
155 var args = Ext.toArray(arguments);
\r
156 if(o.target == Ext.EventObject.setEvent(args[0]).target){
\r
157 h.apply(this, args);
\r
162 function createBuffered(h, o, task){
\r
163 return function(e){
\r
164 // create new event object impl so new events don't wipe out properties
\r
165 task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
\r
169 function createSingle(h, el, ename, fn, scope){
\r
170 return function(e){
\r
171 Ext.EventManager.removeListener(el, ename, fn, scope);
\r
176 function createDelayed(h, o, fn){
\r
177 return function(e){
\r
178 var task = new Ext.util.DelayedTask(h);
\r
182 fn.tasks.push(task);
\r
183 task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
\r
187 function listen(element, ename, opt, fn, scope){
\r
188 var o = !Ext.isObject(opt) ? {} : opt,
\r
189 el = Ext.getDom(element), task;
\r
192 scope = scope || o.scope;
\r
195 throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
\r
198 // prevent errors while unload occurring
\r
199 if(!Ext){// !window[xname]){ ==> can't we do this?
\r
202 e = Ext.EventObject.setEvent(e);
\r
205 if(!(t = e.getTarget(o.delegate, el))){
\r
214 if (o.preventDefault) {
\r
215 e.preventDefault();
\r
217 if (o.stopPropagation) {
\r
218 e.stopPropagation();
\r
220 if (o.normalized) {
\r
221 e = e.browserEvent;
\r
224 fn.call(scope || el, e, t, o);
\r
227 h = createTargeted(h, o);
\r
230 h = createDelayed(h, o, fn);
\r
233 h = createSingle(h, el, ename, fn, scope);
\r
236 task = new Ext.util.DelayedTask(h);
\r
237 h = createBuffered(h, o, task);
\r
240 addListener(el, ename, fn, task, h, scope);
\r
246 * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
\r
247 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
\r
248 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
\r
249 * @param {String} eventName The name of the event to listen for.
\r
250 * @param {Function} handler The handler function the event invokes. This function is passed
\r
251 * the following parameters:<ul>
\r
252 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
\r
253 * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
\r
254 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
\r
255 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
\r
257 * @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
258 * @param {Object} options (optional) An object containing handler configuration properties.
\r
259 * This may contain any of the following properties:<ul>
\r
260 * <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
261 * <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
262 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
\r
263 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
\r
264 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
\r
265 * <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
266 * <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
267 * <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
268 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
\r
269 * by the specified number of milliseconds. If the event fires again within that time, the original
\r
270 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
\r
271 * <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
273 * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
\r
275 addListener : function(element, eventName, fn, scope, options){
\r
276 if(Ext.isObject(eventName)){
\r
277 var o = eventName, e, val;
\r
280 if(!propRe.test(e)){
\r
281 if(Ext.isFunction(val)){
\r
283 listen(element, e, o, val, o.scope);
\r
285 // individual options
\r
286 listen(element, e, val);
\r
291 listen(element, eventName, options, fn, scope);
\r
296 * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
\r
297 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
\r
298 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
299 * @param {String} eventName The name of the event.
\r
300 * @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
301 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
302 * then this must refer to the same object.
\r
304 removeListener : function(el, eventName, fn, scope){
\r
305 el = Ext.getDom(el);
\r
306 var id = getId(el),
\r
307 f = el && (Ext.elCache[id].events)[eventName] || [],
\r
308 wrap, i, l, k, len, fnc;
\r
310 for (i = 0, len = f.length; i < len; i++) {
\r
312 /* 0 = Original Function,
\r
313 1 = Event Manager Wrapped Function,
\r
315 3 = Adapter Wrapped Function,
\r
318 if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
\r
322 k = fn.tasks && fn.tasks.length;
\r
325 fn.tasks[k].cancel();
\r
330 E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
\r
332 // jQuery workaround that should be removed from Ext Core
\r
333 if(wrap && el.addEventListener && eventName == "mousewheel"){
\r
334 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
337 // fix stopped mousedowns on the document
\r
338 if(wrap && el == DOC && eventName == "mousedown"){
\r
339 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
343 if (f.length === 0) {
\r
344 delete Ext.elCache[id].events[eventName];
\r
346 for (k in Ext.elCache[id].events) {
\r
349 Ext.elCache[id].events = {};
\r
356 * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
\r
357 * directly on an Element in favor of calling this version.
\r
358 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
\r
360 removeAll : function(el){
\r
361 el = Ext.getDom(el);
\r
362 var id = getId(el),
\r
363 ec = Ext.elCache[id] || {},
\r
364 es = ec.events || {},
\r
365 f, i, len, ename, fn, k, wrap;
\r
368 if(es.hasOwnProperty(ename)){
\r
370 /* 0 = Original Function,
\r
371 1 = Event Manager Wrapped Function,
\r
373 3 = Adapter Wrapped Function,
\r
376 for (i = 0, len = f.length; i < len; i++) {
\r
381 if(fn[0].tasks && (k = fn[0].tasks.length)) {
\r
383 fn[0].tasks[k].cancel();
\r
388 E.un(el, ename, E.extAdapter ? fn[3] : wrap);
\r
390 // jQuery workaround that should be removed from Ext Core
\r
391 if(el.addEventListener && wrap && ename == "mousewheel"){
\r
392 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
395 // fix stopped mousedowns on the document
\r
396 if(wrap && el == DOC && ename == "mousedown"){
\r
397 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
402 if (Ext.elCache[id]) {
\r
403 Ext.elCache[id].events = {};
\r
407 getListeners : function(el, eventName) {
\r
408 el = Ext.getDom(el);
\r
409 var id = getId(el),
\r
410 ec = Ext.elCache[id] || {},
\r
411 es = ec.events || {},
\r
413 if (es && es[eventName]) {
\r
414 return es[eventName];
\r
420 purgeElement : function(el, recurse, eventName) {
\r
421 el = Ext.getDom(el);
\r
422 var id = getId(el),
\r
423 ec = Ext.elCache[id] || {},
\r
424 es = ec.events || {},
\r
427 if (es && es.hasOwnProperty(eventName)) {
\r
429 for (i = 0, len = f.length; i < len; i++) {
\r
430 Ext.EventManager.removeListener(el, eventName, f[i][0]);
\r
434 Ext.EventManager.removeAll(el);
\r
436 if (recurse && el && el.childNodes) {
\r
437 for (i = 0, len = el.childNodes.length; i < len; i++) {
\r
438 Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
\r
443 _unload : function() {
\r
445 for (el in Ext.elCache) {
\r
446 Ext.EventManager.removeAll(el);
\r
448 delete Ext.elCache;
\r
449 delete Ext.Element._flyweights;
\r
452 * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
\r
453 * accessed shorthanded as Ext.onReady().
\r
454 * @param {Function} fn The method the event invokes.
\r
455 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
456 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
457 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
459 onDocumentReady : function(fn, scope, options){
\r
460 if(docReadyState){ // if it already fired
\r
461 docReadyEvent.addListener(fn, scope, options);
\r
462 docReadyEvent.fire();
\r
463 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
465 if(!docReadyEvent) initDocReady();
\r
466 options = options || {};
\r
467 options.delay = options.delay || 1;
\r
468 docReadyEvent.addListener(fn, scope, options);
\r
473 * Appends an event handler to an element. Shorthand for {@link #addListener}.
\r
474 * @param {String/HTMLElement} el The html element or id to assign the event handler to
\r
475 * @param {String} eventName The name of the event to listen for.
\r
476 * @param {Function} handler The handler function the event invokes.
\r
477 * @param {Object} scope (optional) (<code>this</code> reference) in which the handler function executes. <b>Defaults to the Element</b>.
\r
478 * @param {Object} options (optional) An object containing standard {@link #addListener} options
\r
479 * @member Ext.EventManager
\r
482 pub.on = pub.addListener;
\r
484 * Removes an event handler from an element. Shorthand for {@link #removeListener}.
\r
485 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
486 * @param {String} eventName The name of the event.
\r
487 * @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
488 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
489 * then this must refer to the same object.
\r
490 * @member Ext.EventManager
\r
493 pub.un = pub.removeListener;
\r
495 pub.stoppedMouseDownEvent = new Ext.util.Event();
\r
499 * 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
500 * @param {Function} fn The method the event invokes.
\r
501 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
502 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
503 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
507 Ext.onReady = Ext.EventManager.onDocumentReady;
\r
510 //Initialize doc classes
\r
513 var initExtCss = function(){
\r
514 // find the body element
\r
515 var bd = document.body || document.getElementsByTagName('body')[0];
\r
516 if(!bd){ return false; }
\r
518 Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
\r
519 : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
\r
520 : Ext.isOpera ? "ext-opera"
\r
521 : Ext.isWebKit ? "ext-webkit" : ""];
\r
524 cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
\r
525 }else if(Ext.isChrome){
\r
526 cls.push("ext-chrome");
\r
530 cls.push("ext-mac");
\r
533 cls.push("ext-linux");
\r
536 if(Ext.isStrict || Ext.isBorderBox){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
\r
537 var p = bd.parentNode;
\r
539 p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
\r
542 bd.className += cls.join(' ');
\r
547 Ext.onReady(initExtCss);
\r
553 * @class Ext.EventObject
\r
554 * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
\r
555 * wraps the browser's native event-object normalizing cross-browser differences,
\r
556 * such as which mouse button is clicked, keys pressed, mechanisms to stop
\r
557 * event-propagation along with a method to prevent default actions from taking place.
\r
558 * <p>For example:</p>
\r
560 function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
\r
561 e.preventDefault();
\r
562 var target = e.getTarget(); // same as t (the target HTMLElement)
\r
565 var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}
\r
566 myDiv.on( // 'on' is shorthand for addListener
\r
567 "click", // perform an action on click of myDiv
\r
568 handleClick // reference to the action handler
\r
570 // other methods to do the same:
\r
571 Ext.EventManager.on("myDiv", 'click', handleClick);
\r
572 Ext.EventManager.addListener("myDiv", 'click', handleClick);
\r
576 Ext.EventObject = function(){
\r
577 var E = Ext.lib.Event,
\r
578 // safari keypress events for special keys return bad keycodes
\r
581 63234 : 37, // left
\r
582 63235 : 39, // right
\r
584 63233 : 40, // down
\r
585 63276 : 33, // page up
\r
586 63277 : 34, // page down
\r
587 63272 : 46, // delete
\r
588 63273 : 36, // home
\r
591 // normalize button clicks
\r
592 btnMap = Ext.isIE ? {1:0,4:1,2:2} :
\r
593 (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
\r
595 Ext.EventObjectImpl = function(e){
\r
597 this.setEvent(e.browserEvent || e);
\r
601 Ext.EventObjectImpl.prototype = {
\r
603 setEvent : function(e){
\r
605 if(e == me || (e && e.browserEvent)){ // already wrapped
\r
608 me.browserEvent = e;
\r
610 // normalize buttons
\r
611 me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
\r
612 if(e.type == 'click' && me.button == -1){
\r
616 me.shiftKey = e.shiftKey;
\r
617 // mac metaKey behaves like ctrlKey
\r
618 me.ctrlKey = e.ctrlKey || e.metaKey || false;
\r
619 me.altKey = e.altKey;
\r
620 // in getKey these will be normalized for the mac
\r
621 me.keyCode = e.keyCode;
\r
622 me.charCode = e.charCode;
\r
623 // cache the target for the delayed and or buffered events
\r
624 me.target = E.getTarget(e);
\r
626 me.xy = E.getXY(e);
\r
629 me.shiftKey = false;
\r
630 me.ctrlKey = false;
\r
641 * Stop the event (preventDefault and stopPropagation)
\r
643 stopEvent : function(){
\r
645 if(me.browserEvent){
\r
646 if(me.browserEvent.type == 'mousedown'){
\r
647 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
649 E.stopEvent(me.browserEvent);
\r
654 * Prevents the browsers default handling of the event.
\r
656 preventDefault : function(){
\r
657 if(this.browserEvent){
\r
658 E.preventDefault(this.browserEvent);
\r
663 * Cancels bubbling of the event.
\r
665 stopPropagation : function(){
\r
667 if(me.browserEvent){
\r
668 if(me.browserEvent.type == 'mousedown'){
\r
669 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
671 E.stopPropagation(me.browserEvent);
\r
676 * Gets the character code for the event.
\r
679 getCharCode : function(){
\r
680 return this.charCode || this.keyCode;
\r
684 * Returns a normalized keyCode for the event.
\r
685 * @return {Number} The key code
\r
687 getKey : function(){
\r
688 return this.normalizeKey(this.keyCode || this.charCode)
\r
692 normalizeKey: function(k){
\r
693 return Ext.isSafari ? (safariKeys[k] || k) : k;
\r
697 * Gets the x coordinate of the event.
\r
700 getPageX : function(){
\r
705 * Gets the y coordinate of the event.
\r
708 getPageY : function(){
\r
713 * Gets the page coordinates of the event.
\r
714 * @return {Array} The xy values like [x, y]
\r
716 getXY : function(){
\r
721 * Gets the target for the event.
\r
722 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
\r
723 * @param {Number/Mixed} maxDepth (optional) The max depth to
\r
724 search as a number or element (defaults to 10 || document.body)
\r
725 * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
\r
726 * @return {HTMLelement}
\r
728 getTarget : function(selector, maxDepth, returnEl){
\r
729 return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
\r
733 * Gets the related target.
\r
734 * @return {HTMLElement}
\r
736 getRelatedTarget : function(){
\r
737 return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
\r
741 * Normalizes mouse wheel delta across browsers
\r
742 * @return {Number} The delta
\r
744 getWheelDelta : function(){
\r
745 var e = this.browserEvent;
\r
747 if(e.wheelDelta){ /* IE/Opera. */
\r
748 delta = e.wheelDelta/120;
\r
749 }else if(e.detail){ /* Mozilla case. */
\r
750 delta = -e.detail/3;
\r
756 * 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
757 * Example usage:<pre><code>
\r
758 // Handle click on any child of an element
\r
759 Ext.getBody().on('click', function(e){
\r
760 if(e.within('some-el')){
\r
761 alert('Clicked on a child of some-el!');
\r
765 // Handle click directly on an element, ignoring clicks on child nodes
\r
766 Ext.getBody().on('click', function(e,t){
\r
767 if((t.id == 'some-el') && !e.within(t, true)){
\r
768 alert('Clicked directly on some-el!');
\r
772 * @param {Mixed} el The id, DOM element or Ext.Element to check
\r
773 * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
\r
774 * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
\r
775 * @return {Boolean}
\r
777 within : function(el, related, allowEl){
\r
779 var t = this[related ? "getRelatedTarget" : "getTarget"]();
\r
780 return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
\r
786 return new Ext.EventObjectImpl();
\r