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, task, 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
82 /* 0 = Original Function,
\r
83 1 = Event Manager Wrapped Function,
\r
85 3 = Adapter Wrapped Function,
\r
88 es[ename].push([fn, wrap, scope, wfn, task]);
\r
90 // this is a workaround for jQuery and should somehow be removed from Ext Core in the future
\r
91 // without breaking ExtJS.
\r
93 // workaround for jQuery
\r
94 if(el.addEventListener && ename == "mousewheel"){
\r
95 var args = ["DOMMouseScroll", wrap, false];
\r
96 el.addEventListener.apply(el, args);
\r
97 Ext.EventManager.addListener(WINDOW, 'unload', function(){
\r
98 el.removeEventListener.apply(el, args);
\r
102 // fix stopped mousedowns on the document
\r
103 if(el == DOC && ename == "mousedown"){
\r
104 Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
\r
108 function fireDocReady(){
\r
109 if(!docReadyState){
\r
110 Ext.isReady = docReadyState = true;
\r
111 if(docReadyProcId){
\r
112 clearInterval(docReadyProcId);
\r
114 if(Ext.isGecko || Ext.isOpera) {
\r
115 DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
118 var defer = DOC.getElementById(IEDEFERED);
\r
120 defer.onreadystatechange = null;
\r
121 defer.parentNode.removeChild(defer);
\r
125 docReadyEvent.fire();
\r
126 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
131 function initDocReady(){
\r
132 var COMPLETE = "complete";
\r
134 docReadyEvent = new Ext.util.Event();
\r
135 if (Ext.isGecko || Ext.isOpera) {
\r
136 DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
\r
137 } else if (Ext.isIE){
\r
138 DOC.write("<s"+'cript id=' + IEDEFERED + ' defer="defer" src="/'+'/:"></s'+"cript>");
\r
139 DOC.getElementById(IEDEFERED).onreadystatechange = function(){
\r
140 if(this.readyState == COMPLETE){
\r
144 } else if (Ext.isWebKit){
\r
145 docReadyProcId = setInterval(function(){
\r
146 if(DOC.readyState == COMPLETE) {
\r
151 // no matter what, make sure it fires on load
\r
152 E.on(WINDOW, "load", fireDocReady);
\r
155 function createTargeted(h, o){
\r
157 var args = Ext.toArray(arguments);
\r
158 if(o.target == Ext.EventObject.setEvent(args[0]).target){
\r
159 h.apply(this, args);
\r
164 function createBuffered(h, o, task){
\r
165 return function(e){
\r
166 // create new event object impl so new events don't wipe out properties
\r
167 task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
\r
171 function createSingle(h, el, ename, fn, scope){
\r
172 return function(e){
\r
173 Ext.EventManager.removeListener(el, ename, fn, scope);
\r
178 function createDelayed(h, o, fn){
\r
179 return function(e){
\r
180 var task = new Ext.util.DelayedTask(h);
\r
184 fn.tasks.push(task);
\r
185 task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
\r
189 function listen(element, ename, opt, fn, scope){
\r
190 var o = !Ext.isObject(opt) ? {} : opt,
\r
191 el = Ext.getDom(element), task;
\r
194 scope = scope || o.scope;
\r
197 throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
\r
200 // prevent errors while unload occurring
\r
201 if(!Ext){// !window[xname]){ ==> can't we do this?
\r
204 e = Ext.EventObject.setEvent(e);
\r
207 if(!(t = e.getTarget(o.delegate, el))){
\r
216 if (o.preventDefault) {
\r
217 e.preventDefault();
\r
219 if (o.stopPropagation) {
\r
220 e.stopPropagation();
\r
222 if (o.normalized) {
\r
223 e = e.browserEvent;
\r
226 fn.call(scope || el, e, t, o);
\r
229 h = createTargeted(h, o);
\r
232 h = createDelayed(h, o, fn);
\r
235 h = createSingle(h, el, ename, fn, scope);
\r
238 task = new Ext.util.DelayedTask(h);
\r
239 h = createBuffered(h, o, task);
\r
242 addListener(el, ename, fn, task, h, scope);
\r
247 <div id="method-Ext.EventManager-addListener"></div>/**
\r
248 * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
\r
249 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
\r
250 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
\r
251 * @param {String} eventName The name of the event to listen for.
\r
252 * @param {Function} handler The handler function the event invokes. This function is passed
\r
253 * the following parameters:<ul>
\r
254 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
\r
255 * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
\r
256 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
\r
257 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
\r
259 * @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
260 * @param {Object} options (optional) An object containing handler configuration properties.
\r
261 * This may contain any of the following properties:<ul>
\r
262 * <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
263 * <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
264 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
\r
265 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
\r
266 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
\r
267 * <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
268 * <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
269 * <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
270 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
\r
271 * by the specified number of milliseconds. If the event fires again within that time, the original
\r
272 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
\r
273 * <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
275 * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
\r
277 addListener : function(element, eventName, fn, scope, options){
\r
278 if(Ext.isObject(eventName)){
\r
279 var o = eventName, e, val;
\r
282 if(!propRe.test(e)){
\r
283 if(Ext.isFunction(val)){
\r
285 listen(element, e, o, val, o.scope);
\r
287 // individual options
\r
288 listen(element, e, val);
\r
293 listen(element, eventName, options, fn, scope);
\r
297 <div id="method-Ext.EventManager-removeListener"></div>/**
\r
298 * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
\r
299 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
\r
300 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
301 * @param {String} eventName The name of the event.
\r
302 * @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
303 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
304 * then this must refer to the same object.
\r
306 removeListener : function(el, eventName, fn, scope){
\r
307 el = Ext.getDom(el);
\r
308 var id = getId(el),
\r
309 f = el && (Ext.elCache[id].events)[eventName] || [],
\r
310 wrap, i, l, k, len, fnc;
\r
312 for (i = 0, len = f.length; i < len; i++) {
\r
314 /* 0 = Original Function,
\r
315 1 = Event Manager Wrapped Function,
\r
317 3 = Adapter Wrapped Function,
\r
320 if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
\r
324 k = fn.tasks && fn.tasks.length;
\r
327 fn.tasks[k].cancel();
\r
332 E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
\r
334 // jQuery workaround that should be removed from Ext Core
\r
335 if(wrap && el.addEventListener && eventName == "mousewheel"){
\r
336 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
339 // fix stopped mousedowns on the document
\r
340 if(wrap && el == DOC && eventName == "mousedown"){
\r
341 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
345 if (f.length === 0) {
\r
346 delete Ext.elCache[id].events[eventName];
\r
348 for (k in Ext.elCache[id].events) {
\r
351 Ext.elCache[id].events = {};
\r
357 <div id="method-Ext.EventManager-removeAll"></div>/**
\r
358 * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
\r
359 * directly on an Element in favor of calling this version.
\r
360 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
\r
362 removeAll : function(el){
\r
363 el = Ext.getDom(el);
\r
364 var id = getId(el),
\r
365 ec = Ext.elCache[id] || {},
\r
366 es = ec.events || {},
\r
367 f, i, len, ename, fn, k, wrap;
\r
370 if(es.hasOwnProperty(ename)){
\r
372 /* 0 = Original Function,
\r
373 1 = Event Manager Wrapped Function,
\r
375 3 = Adapter Wrapped Function,
\r
378 for (i = 0, len = f.length; i < len; i++) {
\r
383 if(fn[0].tasks && (k = fn[0].tasks.length)) {
\r
385 fn[0].tasks[k].cancel();
\r
390 E.un(el, ename, E.extAdapter ? fn[3] : wrap);
\r
392 // jQuery workaround that should be removed from Ext Core
\r
393 if(el.addEventListener && wrap && ename == "mousewheel"){
\r
394 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
397 // fix stopped mousedowns on the document
\r
398 if(wrap && el == DOC && ename == "mousedown"){
\r
399 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
404 if (Ext.elCache[id]) {
\r
405 Ext.elCache[id].events = {};
\r
409 getListeners : function(el, eventName) {
\r
410 el = Ext.getDom(el);
\r
411 var id = getId(el),
\r
412 ec = Ext.elCache[id] || {},
\r
413 es = ec.events || {},
\r
415 if (es && es[eventName]) {
\r
416 return es[eventName];
\r
422 purgeElement : function(el, recurse, eventName) {
\r
423 el = Ext.getDom(el);
\r
424 var id = getId(el),
\r
425 ec = Ext.elCache[id] || {},
\r
426 es = ec.events || {},
\r
429 if (es && es.hasOwnProperty(eventName)) {
\r
431 for (i = 0, len = f.length; i < len; i++) {
\r
432 Ext.EventManager.removeListener(el, eventName, f[i][0]);
\r
436 Ext.EventManager.removeAll(el);
\r
438 if (recurse && el && el.childNodes) {
\r
439 for (i = 0, len = el.childNodes.length; i < len; i++) {
\r
440 Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
\r
445 _unload : function() {
\r
447 for (el in Ext.elCache) {
\r
448 Ext.EventManager.removeAll(el);
\r
450 delete Ext.elCache;
\r
451 delete Ext.Element._flyweights;
\r
453 <div id="method-Ext.EventManager-onDocumentReady"></div>/**
\r
454 * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
\r
455 * accessed shorthanded as Ext.onReady().
\r
456 * @param {Function} fn The method the event invokes.
\r
457 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
458 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
459 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
461 onDocumentReady : function(fn, scope, options){
\r
462 if(docReadyState){ // if it already fired
\r
463 docReadyEvent.addListener(fn, scope, options);
\r
464 docReadyEvent.fire();
\r
465 docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?
\r
467 if(!docReadyEvent) initDocReady();
\r
468 options = options || {};
\r
469 options.delay = options.delay || 1;
\r
470 docReadyEvent.addListener(fn, scope, options);
\r
474 <div id="method-Ext.EventManager-on"></div>/**
\r
475 * Appends an event handler to an element. Shorthand for {@link #addListener}.
\r
476 * @param {String/HTMLElement} el The html element or id to assign the event handler to
\r
477 * @param {String} eventName The name of the event to listen for.
\r
478 * @param {Function} handler The handler function the event invokes.
\r
479 * @param {Object} scope (optional) (<code>this</code> reference) in which the handler function executes. <b>Defaults to the Element</b>.
\r
480 * @param {Object} options (optional) An object containing standard {@link #addListener} options
\r
481 * @member Ext.EventManager
\r
484 pub.on = pub.addListener;
\r
485 <div id="method-Ext.EventManager-un"></div>/**
\r
486 * Removes an event handler from an element. Shorthand for {@link #removeListener}.
\r
487 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
\r
488 * @param {String} eventName The name of the event.
\r
489 * @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
490 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
\r
491 * then this must refer to the same object.
\r
492 * @member Ext.EventManager
\r
495 pub.un = pub.removeListener;
\r
497 pub.stoppedMouseDownEvent = new Ext.util.Event();
\r
500 <div id="method-Ext-onReady"></div>/**
\r
501 * 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
502 * @param {Function} fn The method the event invokes.
\r
503 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
\r
504 * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
\r
505 * <code>{single: true}</code> be used so that the handler is removed on first invocation.
\r
509 Ext.onReady = Ext.EventManager.onDocumentReady;
\r
512 //Initialize doc classes
\r
515 var initExtCss = function(){
\r
516 // find the body element
\r
517 var bd = document.body || document.getElementsByTagName('body')[0];
\r
518 if(!bd){ return false; }
\r
520 Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
\r
521 : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
\r
522 : Ext.isOpera ? "ext-opera"
\r
523 : Ext.isWebKit ? "ext-webkit" : ""];
\r
526 cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
\r
527 }else if(Ext.isChrome){
\r
528 cls.push("ext-chrome");
\r
532 cls.push("ext-mac");
\r
535 cls.push("ext-linux");
\r
538 if(Ext.isStrict || Ext.isBorderBox){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
\r
539 var p = bd.parentNode;
\r
541 p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
\r
544 bd.className += cls.join(' ');
\r
549 Ext.onReady(initExtCss);
\r
554 <div id="cls-Ext.EventObject"></div>/**
\r
555 * @class Ext.EventObject
\r
556 * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
\r
557 * wraps the browser's native event-object normalizing cross-browser differences,
\r
558 * such as which mouse button is clicked, keys pressed, mechanisms to stop
\r
559 * event-propagation along with a method to prevent default actions from taking place.
\r
560 * <p>For example:</p>
\r
562 function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
\r
563 e.preventDefault();
\r
564 var target = e.getTarget(); // same as t (the target HTMLElement)
\r
567 var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}
\r
568 myDiv.on( // 'on' is shorthand for addListener
\r
569 "click", // perform an action on click of myDiv
\r
570 handleClick // reference to the action handler
\r
572 // other methods to do the same:
\r
573 Ext.EventManager.on("myDiv", 'click', handleClick);
\r
574 Ext.EventManager.addListener("myDiv", 'click', handleClick);
\r
578 Ext.EventObject = function(){
\r
579 var E = Ext.lib.Event,
\r
580 // safari keypress events for special keys return bad keycodes
\r
583 63234 : 37, // left
\r
584 63235 : 39, // right
\r
586 63233 : 40, // down
\r
587 63276 : 33, // page up
\r
588 63277 : 34, // page down
\r
589 63272 : 46, // delete
\r
590 63273 : 36, // home
\r
593 // normalize button clicks
\r
594 btnMap = Ext.isIE ? {1:0,4:1,2:2} :
\r
595 (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
\r
597 Ext.EventObjectImpl = function(e){
\r
599 this.setEvent(e.browserEvent || e);
\r
603 Ext.EventObjectImpl.prototype = {
\r
605 setEvent : function(e){
\r
607 if(e == me || (e && e.browserEvent)){ // already wrapped
\r
610 me.browserEvent = e;
\r
612 // normalize buttons
\r
613 me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
\r
614 if(e.type == 'click' && me.button == -1){
\r
618 me.shiftKey = e.shiftKey;
\r
619 // mac metaKey behaves like ctrlKey
\r
620 me.ctrlKey = e.ctrlKey || e.metaKey || false;
\r
621 me.altKey = e.altKey;
\r
622 // in getKey these will be normalized for the mac
\r
623 me.keyCode = e.keyCode;
\r
624 me.charCode = e.charCode;
\r
625 // cache the target for the delayed and or buffered events
\r
626 me.target = E.getTarget(e);
\r
628 me.xy = E.getXY(e);
\r
631 me.shiftKey = false;
\r
632 me.ctrlKey = false;
\r
642 <div id="method-Ext.EventObject-stopEvent"></div>/**
\r
643 * Stop the event (preventDefault and stopPropagation)
\r
645 stopEvent : function(){
\r
647 if(me.browserEvent){
\r
648 if(me.browserEvent.type == 'mousedown'){
\r
649 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
651 E.stopEvent(me.browserEvent);
\r
655 <div id="method-Ext.EventObject-preventDefault"></div>/**
\r
656 * Prevents the browsers default handling of the event.
\r
658 preventDefault : function(){
\r
659 if(this.browserEvent){
\r
660 E.preventDefault(this.browserEvent);
\r
664 <div id="method-Ext.EventObject-stopPropagation"></div>/**
\r
665 * Cancels bubbling of the event.
\r
667 stopPropagation : function(){
\r
669 if(me.browserEvent){
\r
670 if(me.browserEvent.type == 'mousedown'){
\r
671 Ext.EventManager.stoppedMouseDownEvent.fire(me);
\r
673 E.stopPropagation(me.browserEvent);
\r
677 <div id="method-Ext.EventObject-getCharCode"></div>/**
\r
678 * Gets the character code for the event.
\r
681 getCharCode : function(){
\r
682 return this.charCode || this.keyCode;
\r
685 <div id="method-Ext.EventObject-getKey"></div>/**
\r
686 * Returns a normalized keyCode for the event.
\r
687 * @return {Number} The key code
\r
689 getKey : function(){
\r
690 return this.normalizeKey(this.keyCode || this.charCode)
\r
694 normalizeKey: function(k){
\r
695 return Ext.isSafari ? (safariKeys[k] || k) : k;
\r
698 <div id="method-Ext.EventObject-getPageX"></div>/**
\r
699 * Gets the x coordinate of the event.
\r
702 getPageX : function(){
\r
706 <div id="method-Ext.EventObject-getPageY"></div>/**
\r
707 * Gets the y coordinate of the event.
\r
710 getPageY : function(){
\r
714 <div id="method-Ext.EventObject-getXY"></div>/**
\r
715 * Gets the page coordinates of the event.
\r
716 * @return {Array} The xy values like [x, y]
\r
718 getXY : function(){
\r
722 <div id="method-Ext.EventObject-getTarget"></div>/**
\r
723 * Gets the target for the event.
\r
724 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
\r
725 * @param {Number/Mixed} maxDepth (optional) The max depth to
\r
726 search as a number or element (defaults to 10 || document.body)
\r
727 * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
\r
728 * @return {HTMLelement}
\r
730 getTarget : function(selector, maxDepth, returnEl){
\r
731 return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
\r
734 <div id="method-Ext.EventObject-getRelatedTarget"></div>/**
\r
735 * Gets the related target.
\r
736 * @return {HTMLElement}
\r
738 getRelatedTarget : function(){
\r
739 return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
\r
742 <div id="method-Ext.EventObject-getWheelDelta"></div>/**
\r
743 * Normalizes mouse wheel delta across browsers
\r
744 * @return {Number} The delta
\r
746 getWheelDelta : function(){
\r
747 var e = this.browserEvent;
\r
749 if(e.wheelDelta){ /* IE/Opera. */
\r
750 delta = e.wheelDelta/120;
\r
751 }else if(e.detail){ /* Mozilla case. */
\r
752 delta = -e.detail/3;
\r
757 <div id="method-Ext.EventObject-within"></div>/**
\r
758 * 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
759 * Example usage:<pre><code>
\r
760 // Handle click on any child of an element
\r
761 Ext.getBody().on('click', function(e){
\r
762 if(e.within('some-el')){
\r
763 alert('Clicked on a child of some-el!');
\r
767 // Handle click directly on an element, ignoring clicks on child nodes
\r
768 Ext.getBody().on('click', function(e,t){
\r
769 if((t.id == 'some-el') && !e.within(t, true)){
\r
770 alert('Clicked directly on some-el!');
\r
774 * @param {Mixed} el The id, DOM element or Ext.Element to check
\r
775 * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
\r
776 * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
\r
777 * @return {Boolean}
\r
779 within : function(el, related, allowEl){
\r
781 var t = this[related ? "getRelatedTarget" : "getTarget"]();
\r
782 return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
\r
788 return new Ext.EventObjectImpl();
\r