-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.EventManager"></div>/**\r
- * @class Ext.EventManager\r
- * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides\r
- * several useful events directly.\r
- * See {@link Ext.EventObject} for more details on normalized event objects.\r
- * @singleton\r
- */\r
-Ext.EventManager = function(){\r
- var docReadyEvent,\r
- docReadyProcId,\r
- docReadyState = false,\r
- E = Ext.lib.Event,\r
- D = Ext.lib.Dom,\r
- DOC = document,\r
- WINDOW = window,\r
- IEDEFERED = "ie-deferred-loader",\r
- DOMCONTENTLOADED = "DOMContentLoaded",\r
- propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,\r
- /*\r
- * This cache is used to hold special js objects, the document and window, that don't have an id. We need to keep\r
- * a reference to them so we can look them up at a later point.\r
- */\r
- specialElCache = [];\r
-\r
- function getId(el){\r
- var id = false,\r
- i = 0,\r
- len = specialElCache.length,\r
- id = false,\r
- skip = false,\r
- o;\r
- if(el){\r
- if(el.getElementById || el.navigator){\r
- // look up the id\r
- for(; i < len; ++i){\r
- o = specialElCache[i];\r
- if(o.el === el){\r
- id = o.id;\r
- break;\r
- }\r
- }\r
- if(!id){\r
- // for browsers that support it, ensure that give the el the same id\r
- id = Ext.id(el);\r
- specialElCache.push({\r
- id: id,\r
- el: el\r
- });\r
- skip = true;\r
- }\r
- }else{\r
- id = Ext.id(el);\r
- }\r
- if(!Ext.elCache[id]){\r
- Ext.Element.addToCache(new Ext.Element(el), id);\r
- if(skip){\r
- Ext.elCache[id].skipGC = true;\r
- }\r
- }\r
- }\r
- return id;\r
- };\r
-\r
- /// There is some jquery work around stuff here that isn't needed in Ext Core.\r
- function addListener(el, ename, fn, task, wrap, scope){\r
- el = Ext.getDom(el);\r
- var id = getId(el),\r
- es = Ext.elCache[id].events,\r
- wfn;\r
-\r
- wfn = E.on(el, ename, wrap);\r
- es[ename] = es[ename] || [];\r
-\r
- /* 0 = Original Function,\r
- 1 = Event Manager Wrapped Function,\r
- 2 = Scope,\r
- 3 = Adapter Wrapped Function,\r
- 4 = Buffered Task\r
- */\r
- es[ename].push([fn, wrap, scope, wfn, task]);\r
-\r
- // this is a workaround for jQuery and should somehow be removed from Ext Core in the future\r
- // without breaking ExtJS.\r
-\r
- // workaround for jQuery\r
- if(el.addEventListener && ename == "mousewheel"){\r
- var args = ["DOMMouseScroll", wrap, false];\r
- el.addEventListener.apply(el, args);\r
- Ext.EventManager.addListener(WINDOW, 'unload', function(){\r
- el.removeEventListener.apply(el, args);\r
- });\r
- }\r
-\r
- // fix stopped mousedowns on the document\r
- if(el == DOC && ename == "mousedown"){\r
- Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);\r
- }\r
- };\r
-\r
- function fireDocReady(){\r
- if(!docReadyState){\r
- Ext.isReady = docReadyState = true;\r
- if(docReadyProcId){\r
- clearInterval(docReadyProcId);\r
- }\r
- if(Ext.isGecko || Ext.isOpera) {\r
- DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);\r
- }\r
- if(Ext.isIE){\r
- var defer = DOC.getElementById(IEDEFERED);\r
- if(defer){\r
- defer.onreadystatechange = null;\r
- defer.parentNode.removeChild(defer);\r
- }\r
- }\r
- if(docReadyEvent){\r
- docReadyEvent.fire();\r
- docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?\r
- }\r
- }\r
- };\r
-\r
- function initDocReady(){\r
- var COMPLETE = "complete";\r
-\r
- docReadyEvent = new Ext.util.Event();\r
- if (Ext.isGecko || Ext.isOpera) {\r
- DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);\r
- } else if (Ext.isIE){\r
- DOC.write("<s"+'cript id=' + IEDEFERED + ' defer="defer" src="/'+'/:"></s'+"cript>");\r
- DOC.getElementById(IEDEFERED).onreadystatechange = function(){\r
- if(this.readyState == COMPLETE){\r
- fireDocReady();\r
- }\r
- };\r
- } else if (Ext.isWebKit){\r
- docReadyProcId = setInterval(function(){\r
- if(DOC.readyState == COMPLETE) {\r
- fireDocReady();\r
- }\r
- }, 10);\r
- }\r
- // no matter what, make sure it fires on load\r
- E.on(WINDOW, "load", fireDocReady);\r
- };\r
-\r
- function createTargeted(h, o){\r
- return function(){\r
- var args = Ext.toArray(arguments);\r
- if(o.target == Ext.EventObject.setEvent(args[0]).target){\r
- h.apply(this, args);\r
- }\r
- };\r
- };\r
-\r
- function createBuffered(h, o, task){\r
- return function(e){\r
- // create new event object impl so new events don't wipe out properties\r
- task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);\r
- };\r
- };\r
-\r
- function createSingle(h, el, ename, fn, scope){\r
- return function(e){\r
- Ext.EventManager.removeListener(el, ename, fn, scope);\r
- h(e);\r
- };\r
- };\r
-\r
- function createDelayed(h, o, fn){\r
- return function(e){\r
- var task = new Ext.util.DelayedTask(h);\r
- if(!fn.tasks) {\r
- fn.tasks = [];\r
- }\r
- fn.tasks.push(task);\r
- task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);\r
- };\r
- };\r
-\r
- function listen(element, ename, opt, fn, scope){\r
- var o = !Ext.isObject(opt) ? {} : opt,\r
- el = Ext.getDom(element), task;\r
-\r
- fn = fn || o.fn;\r
- scope = scope || o.scope;\r
-\r
- if(!el){\r
- throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';\r
- }\r
- function h(e){\r
- // prevent errors while unload occurring\r
- if(!Ext){// !window[xname]){ ==> can't we do this?\r
- return;\r
- }\r
- e = Ext.EventObject.setEvent(e);\r
- var t;\r
- if (o.delegate) {\r
- if(!(t = e.getTarget(o.delegate, el))){\r
- return;\r
- }\r
- } else {\r
- t = e.target;\r
- }\r
- if (o.stopEvent) {\r
- e.stopEvent();\r
- }\r
- if (o.preventDefault) {\r
- e.preventDefault();\r
- }\r
- if (o.stopPropagation) {\r
- e.stopPropagation();\r
- }\r
- if (o.normalized) {\r
- e = e.browserEvent;\r
- }\r
-\r
- fn.call(scope || el, e, t, o);\r
- };\r
- if(o.target){\r
- h = createTargeted(h, o);\r
- }\r
- if(o.delay){\r
- h = createDelayed(h, o, fn);\r
- }\r
- if(o.single){\r
- h = createSingle(h, el, ename, fn, scope);\r
- }\r
- if(o.buffer){\r
- task = new Ext.util.DelayedTask(h);\r
- h = createBuffered(h, o, task);\r
- }\r
-\r
- addListener(el, ename, fn, task, h, scope);\r
- return h;\r
- };\r
-\r
- var pub = {\r
- <div id="method-Ext.EventManager-addListener"></div>/**\r
- * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will\r
- * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.\r
- * @param {String/HTMLElement} el The html element or id to assign the event handler to.\r
- * @param {String} eventName The name of the event to listen for.\r
- * @param {Function} handler The handler function the event invokes. This function is passed\r
- * the following parameters:<ul>\r
- * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>\r
- * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.\r
- * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>\r
- * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>\r
- * </ul>\r
- * @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
- * @param {Object} options (optional) An object containing handler configuration properties.\r
- * This may contain any of the following properties:<ul>\r
- * <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
- * <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
- * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>\r
- * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>\r
- * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>\r
- * <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
- * <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
- * <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
- * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed\r
- * by the specified number of milliseconds. If the event fires again within that time, the original\r
- * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>\r
- * <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
- * </ul><br>\r
- * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>\r
- */\r
- addListener : function(element, eventName, fn, scope, options){\r
- if(Ext.isObject(eventName)){\r
- var o = eventName, e, val;\r
- for(e in o){\r
- val = o[e];\r
- if(!propRe.test(e)){\r
- if(Ext.isFunction(val)){\r
- // shared options\r
- listen(element, e, o, val, o.scope);\r
- }else{\r
- // individual options\r
- listen(element, e, val);\r
- }\r
- }\r
- }\r
- } else {\r
- listen(element, eventName, options, fn, scope);\r
- }\r
- },\r
-\r
- <div id="method-Ext.EventManager-removeListener"></div>/**\r
- * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically\r
- * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.\r
- * @param {String/HTMLElement} el The id or html element from which to remove the listener.\r
- * @param {String} eventName The name of the event.\r
- * @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
- * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,\r
- * then this must refer to the same object.\r
- */\r
- removeListener : function(el, eventName, fn, scope){\r
- el = Ext.getDom(el);\r
- var id = getId(el),\r
- f = el && (Ext.elCache[id].events)[eventName] || [],\r
- wrap, i, l, k, len, fnc;\r
-\r
- for (i = 0, len = f.length; i < len; i++) {\r
-\r
- /* 0 = Original Function,\r
- 1 = Event Manager Wrapped Function,\r
- 2 = Scope,\r
- 3 = Adapter Wrapped Function,\r
- 4 = Buffered Task\r
- */\r
- if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {\r
- if(fnc[4]) {\r
- fnc[4].cancel();\r
- }\r
- k = fn.tasks && fn.tasks.length;\r
- if(k) {\r
- while(k--) {\r
- fn.tasks[k].cancel();\r
- }\r
- delete fn.tasks;\r
- }\r
- wrap = fnc[1];\r
- E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);\r
-\r
- // jQuery workaround that should be removed from Ext Core\r
- if(wrap && el.addEventListener && eventName == "mousewheel"){\r
- el.removeEventListener("DOMMouseScroll", wrap, false);\r
- }\r
-\r
- // fix stopped mousedowns on the document\r
- if(wrap && el == DOC && eventName == "mousedown"){\r
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);\r
- }\r
-\r
- f.splice(i, 1);\r
- if (f.length === 0) {\r
- delete Ext.elCache[id].events[eventName];\r
- }\r
- for (k in Ext.elCache[id].events) {\r
- return false;\r
- }\r
- Ext.elCache[id].events = {};\r
- return false;\r
- }\r
- }\r
- },\r
-\r
- <div id="method-Ext.EventManager-removeAll"></div>/**\r
- * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}\r
- * directly on an Element in favor of calling this version.\r
- * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.\r
- */\r
- removeAll : function(el){\r
- el = Ext.getDom(el);\r
- var id = getId(el),\r
- ec = Ext.elCache[id] || {},\r
- es = ec.events || {},\r
- f, i, len, ename, fn, k, wrap;\r
-\r
- for(ename in es){\r
- if(es.hasOwnProperty(ename)){\r
- f = es[ename];\r
- /* 0 = Original Function,\r
- 1 = Event Manager Wrapped Function,\r
- 2 = Scope,\r
- 3 = Adapter Wrapped Function,\r
- 4 = Buffered Task\r
- */\r
- for (i = 0, len = f.length; i < len; i++) {\r
- fn = f[i];\r
- if(fn[4]) {\r
- fn[4].cancel();\r
- }\r
- if(fn[0].tasks && (k = fn[0].tasks.length)) {\r
- while(k--) {\r
- fn[0].tasks[k].cancel();\r
- }\r
- delete fn.tasks;\r
- }\r
- wrap = fn[1];\r
- E.un(el, ename, E.extAdapter ? fn[3] : wrap);\r
-\r
- // jQuery workaround that should be removed from Ext Core\r
- if(el.addEventListener && wrap && ename == "mousewheel"){\r
- el.removeEventListener("DOMMouseScroll", wrap, false);\r
- }\r
-\r
- // fix stopped mousedowns on the document\r
- if(wrap && el == DOC && ename == "mousedown"){\r
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);\r
- }\r
- }\r
- }\r
- }\r
- if (Ext.elCache[id]) {\r
- Ext.elCache[id].events = {};\r
- }\r
- },\r
-\r
- getListeners : function(el, eventName) {\r
- el = Ext.getDom(el);\r
- var id = getId(el),\r
- ec = Ext.elCache[id] || {},\r
- es = ec.events || {},\r
- results = [];\r
- if (es && es[eventName]) {\r
- return es[eventName];\r
- } else {\r
- return null;\r
- }\r
- },\r
-\r
- purgeElement : function(el, recurse, eventName) {\r
- el = Ext.getDom(el);\r
- var id = getId(el),\r
- ec = Ext.elCache[id] || {},\r
- es = ec.events || {},\r
- i, f, len;\r
- if (eventName) {\r
- if (es && es.hasOwnProperty(eventName)) {\r
- f = es[eventName];\r
- for (i = 0, len = f.length; i < len; i++) {\r
- Ext.EventManager.removeListener(el, eventName, f[i][0]);\r
- }\r
- }\r
- } else {\r
- Ext.EventManager.removeAll(el);\r
- }\r
- if (recurse && el && el.childNodes) {\r
- for (i = 0, len = el.childNodes.length; i < len; i++) {\r
- Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);\r
- }\r
- }\r
- },\r
-\r
- _unload : function() {\r
- var el;\r
- for (el in Ext.elCache) {\r
- Ext.EventManager.removeAll(el);\r
- }\r
- delete Ext.elCache;\r
- delete Ext.Element._flyweights;\r
- },\r
- <div id="method-Ext.EventManager-onDocumentReady"></div>/**\r
- * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be\r
- * accessed shorthanded as Ext.onReady().\r
- * @param {Function} fn The method the event invokes.\r
- * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.\r
- * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options\r
- * <code>{single: true}</code> be used so that the handler is removed on first invocation.\r
- */\r
- onDocumentReady : function(fn, scope, options){\r
- if(docReadyState){ // if it already fired\r
- docReadyEvent.addListener(fn, scope, options);\r
- docReadyEvent.fire();\r
- docReadyEvent.listeners = []; // clearListeners no longer compatible. Force single: true?\r
- } else {\r
- if(!docReadyEvent) initDocReady();\r
- options = options || {};\r
- options.delay = options.delay || 1;\r
- docReadyEvent.addListener(fn, scope, options);\r
- }\r
- }\r
- };\r
- <div id="method-Ext.EventManager-on"></div>/**\r
- * Appends an event handler to an element. Shorthand for {@link #addListener}.\r
- * @param {String/HTMLElement} el The html element or id to assign the event handler to\r
- * @param {String} eventName The name of the event to listen for.\r
- * @param {Function} handler The handler function the event invokes.\r
- * @param {Object} scope (optional) (<code>this</code> reference) in which the handler function executes. <b>Defaults to the Element</b>.\r
- * @param {Object} options (optional) An object containing standard {@link #addListener} options\r
- * @member Ext.EventManager\r
- * @method on\r
- */\r
- pub.on = pub.addListener;\r
- <div id="method-Ext.EventManager-un"></div>/**\r
- * Removes an event handler from an element. Shorthand for {@link #removeListener}.\r
- * @param {String/HTMLElement} el The id or html element from which to remove the listener.\r
- * @param {String} eventName The name of the event.\r
- * @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
- * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,\r
- * then this must refer to the same object.\r
- * @member Ext.EventManager\r
- * @method un\r
- */\r
- pub.un = pub.removeListener;\r
-\r
- pub.stoppedMouseDownEvent = new Ext.util.Event();\r
- return pub;\r
-}();\r
-<div id="method-Ext-onReady"></div>/**\r
- * 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
- * @param {Function} fn The method the event invokes.\r
- * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.\r
- * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options\r
- * <code>{single: true}</code> be used so that the handler is removed on first invocation.\r
- * @member Ext\r
- * @method onReady\r
- */\r
-Ext.onReady = Ext.EventManager.onDocumentReady;\r
-\r
-\r
-//Initialize doc classes\r
-(function(){\r
-\r
- var initExtCss = function(){\r
- // find the body element\r
- var bd = document.body || document.getElementsByTagName('body')[0];\r
- if(!bd){ return false; }\r
- var cls = [' ',\r
- Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))\r
- : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')\r
- : Ext.isOpera ? "ext-opera"\r
- : Ext.isWebKit ? "ext-webkit" : ""];\r
-\r
- if(Ext.isSafari){\r
- cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));\r
- }else if(Ext.isChrome){\r
- cls.push("ext-chrome");\r
- }\r
-\r
- if(Ext.isMac){\r
- cls.push("ext-mac");\r
- }\r
- if(Ext.isLinux){\r
- cls.push("ext-linux");\r
- }\r
-\r
- if(Ext.isStrict || Ext.isBorderBox){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"\r
- var p = bd.parentNode;\r
- if(p){\r
- p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';\r
- }\r
- }\r
- bd.className += cls.join(' ');\r
- return true;\r
- }\r
-\r
- if(!initExtCss()){\r
- Ext.onReady(initExtCss);\r
- }\r
-})();\r
-\r
-\r
-<div id="cls-Ext.EventObject"></div>/**\r
- * @class Ext.EventObject\r
- * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject\r
- * wraps the browser's native event-object normalizing cross-browser differences,\r
- * such as which mouse button is clicked, keys pressed, mechanisms to stop\r
- * event-propagation along with a method to prevent default actions from taking place.\r
- * <p>For example:</p>\r
- * <pre><code>\r
-function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject\r
- e.preventDefault();\r
- var target = e.getTarget(); // same as t (the target HTMLElement)\r
- ...\r
-}\r
-var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}\r
-myDiv.on( // 'on' is shorthand for addListener\r
- "click", // perform an action on click of myDiv\r
- handleClick // reference to the action handler\r
-);\r
-// other methods to do the same:\r
-Ext.EventManager.on("myDiv", 'click', handleClick);\r
-Ext.EventManager.addListener("myDiv", 'click', handleClick);\r
- </code></pre>\r
- * @singleton\r
- */\r
-Ext.EventObject = function(){\r
- var E = Ext.lib.Event,\r
- // safari keypress events for special keys return bad keycodes\r
- safariKeys = {\r
- 3 : 13, // enter\r
- 63234 : 37, // left\r
- 63235 : 39, // right\r
- 63232 : 38, // up\r
- 63233 : 40, // down\r
- 63276 : 33, // page up\r
- 63277 : 34, // page down\r
- 63272 : 46, // delete\r
- 63273 : 36, // home\r
- 63275 : 35 // end\r
- },\r
- // normalize button clicks\r
- btnMap = Ext.isIE ? {1:0,4:1,2:2} :\r
- (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});\r
-\r
- Ext.EventObjectImpl = function(e){\r
- if(e){\r
- this.setEvent(e.browserEvent || e);\r
- }\r
- };\r
-\r
- Ext.EventObjectImpl.prototype = {\r
- /** @private */\r
- setEvent : function(e){\r
- var me = this;\r
- if(e == me || (e && e.browserEvent)){ // already wrapped\r
- return e;\r
- }\r
- me.browserEvent = e;\r
- if(e){\r
- // normalize buttons\r
- me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);\r
- if(e.type == 'click' && me.button == -1){\r
- me.button = 0;\r
- }\r
- me.type = e.type;\r
- me.shiftKey = e.shiftKey;\r
- // mac metaKey behaves like ctrlKey\r
- me.ctrlKey = e.ctrlKey || e.metaKey || false;\r
- me.altKey = e.altKey;\r
- // in getKey these will be normalized for the mac\r
- me.keyCode = e.keyCode;\r
- me.charCode = e.charCode;\r
- // cache the target for the delayed and or buffered events\r
- me.target = E.getTarget(e);\r
- // same for XY\r
- me.xy = E.getXY(e);\r
- }else{\r
- me.button = -1;\r
- me.shiftKey = false;\r
- me.ctrlKey = false;\r
- me.altKey = false;\r
- me.keyCode = 0;\r
- me.charCode = 0;\r
- me.target = null;\r
- me.xy = [0, 0];\r
- }\r
- return me;\r
- },\r
-\r
- <div id="method-Ext.EventObject-stopEvent"></div>/**\r
- * Stop the event (preventDefault and stopPropagation)\r
- */\r
- stopEvent : function(){\r
- var me = this;\r
- if(me.browserEvent){\r
- if(me.browserEvent.type == 'mousedown'){\r
- Ext.EventManager.stoppedMouseDownEvent.fire(me);\r
- }\r
- E.stopEvent(me.browserEvent);\r
- }\r
- },\r
-\r
- <div id="method-Ext.EventObject-preventDefault"></div>/**\r
- * Prevents the browsers default handling of the event.\r
- */\r
- preventDefault : function(){\r
- if(this.browserEvent){\r
- E.preventDefault(this.browserEvent);\r
- }\r
- },\r
-\r
- <div id="method-Ext.EventObject-stopPropagation"></div>/**\r
- * Cancels bubbling of the event.\r
- */\r
- stopPropagation : function(){\r
- var me = this;\r
- if(me.browserEvent){\r
- if(me.browserEvent.type == 'mousedown'){\r
- Ext.EventManager.stoppedMouseDownEvent.fire(me);\r
- }\r
- E.stopPropagation(me.browserEvent);\r
- }\r
- },\r
-\r
- <div id="method-Ext.EventObject-getCharCode"></div>/**\r
- * Gets the character code for the event.\r
- * @return {Number}\r
- */\r
- getCharCode : function(){\r
- return this.charCode || this.keyCode;\r
- },\r
-\r
- <div id="method-Ext.EventObject-getKey"></div>/**\r
- * Returns a normalized keyCode for the event.\r
- * @return {Number} The key code\r
- */\r
- getKey : function(){\r
- return this.normalizeKey(this.keyCode || this.charCode)\r
- },\r
-\r
- // private\r
- normalizeKey: function(k){\r
- return Ext.isSafari ? (safariKeys[k] || k) : k;\r
- },\r
-\r
- <div id="method-Ext.EventObject-getPageX"></div>/**\r
- * Gets the x coordinate of the event.\r
- * @return {Number}\r
- */\r
- getPageX : function(){\r
- return this.xy[0];\r
- },\r
-\r
- <div id="method-Ext.EventObject-getPageY"></div>/**\r
- * Gets the y coordinate of the event.\r
- * @return {Number}\r
- */\r
- getPageY : function(){\r
- return this.xy[1];\r
- },\r
-\r
- <div id="method-Ext.EventObject-getXY"></div>/**\r
- * Gets the page coordinates of the event.\r
- * @return {Array} The xy values like [x, y]\r
- */\r
- getXY : function(){\r
- return this.xy;\r
- },\r
-\r
- <div id="method-Ext.EventObject-getTarget"></div>/**\r
- * Gets the target for the event.\r
- * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target\r
- * @param {Number/Mixed} maxDepth (optional) The max depth to\r
- search as a number or element (defaults to 10 || document.body)\r
- * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node\r
- * @return {HTMLelement}\r
- */\r
- getTarget : function(selector, maxDepth, returnEl){\r
- return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);\r
- },\r
-\r
- <div id="method-Ext.EventObject-getRelatedTarget"></div>/**\r
- * Gets the related target.\r
- * @return {HTMLElement}\r
- */\r
- getRelatedTarget : function(){\r
- return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;\r
- },\r
-\r
- <div id="method-Ext.EventObject-getWheelDelta"></div>/**\r
- * Normalizes mouse wheel delta across browsers\r
- * @return {Number} The delta\r
- */\r
- getWheelDelta : function(){\r
- var e = this.browserEvent;\r
- var delta = 0;\r
- if(e.wheelDelta){ /* IE/Opera. */\r
- delta = e.wheelDelta/120;\r
- }else if(e.detail){ /* Mozilla case. */\r
- delta = -e.detail/3;\r
- }\r
- return delta;\r
- },\r
-\r
- <div id="method-Ext.EventObject-within"></div>/**\r
- * 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
- * Example usage:<pre><code>\r
- // Handle click on any child of an element\r
- Ext.getBody().on('click', function(e){\r
- if(e.within('some-el')){\r
- alert('Clicked on a child of some-el!');\r
- }\r
- });\r
-\r
- // Handle click directly on an element, ignoring clicks on child nodes\r
- Ext.getBody().on('click', function(e,t){\r
- if((t.id == 'some-el') && !e.within(t, true)){\r
- alert('Clicked directly on some-el!');\r
- }\r
- });\r
- </code></pre>\r
- * @param {Mixed} el The id, DOM element or Ext.Element to check\r
- * @param {Boolean} related (optional) true to test if the related target is within el instead of the target\r
- * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target\r
- * @return {Boolean}\r
- */\r
- within : function(el, related, allowEl){\r
- if(el){\r
- var t = this[related ? "getRelatedTarget" : "getTarget"]();\r
- return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));\r
- }\r
- return false;\r
- }\r
- };\r
-\r
- return new Ext.EventObjectImpl();\r
-}();\r
-</pre> \r
-</body>\r
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.EventManager"></div>/**
+ * @class Ext.EventManager
+ * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
+ * several useful events directly.
+ * See {@link Ext.EventObject} for more details on normalized event objects.
+ * @singleton
+ */
+
+Ext.EventManager = function(){
+ var docReadyEvent,
+ docReadyProcId,
+ docReadyState = false,
+ DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari,
+ E = Ext.lib.Event,
+ D = Ext.lib.Dom,
+ DOC = document,
+ WINDOW = window,
+ DOMCONTENTLOADED = "DOMContentLoaded",
+ COMPLETE = 'complete',
+ propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
+ /*
+ * This cache is used to hold special js objects, the document and window, that don't have an id. We need to keep
+ * a reference to them so we can look them up at a later point.
+ */
+ specialElCache = [];
+
+ function getId(el){
+ var id = false,
+ i = 0,
+ len = specialElCache.length,
+ id = false,
+ skip = false,
+ o;
+ if(el){
+ if(el.getElementById || el.navigator){
+ // look up the id
+ for(; i < len; ++i){
+ o = specialElCache[i];
+ if(o.el === el){
+ id = o.id;
+ break;
+ }
+ }
+ if(!id){
+ // for browsers that support it, ensure that give the el the same id
+ id = Ext.id(el);
+ specialElCache.push({
+ id: id,
+ el: el
+ });
+ skip = true;
+ }
+ }else{
+ id = Ext.id(el);
+ }
+ if(!Ext.elCache[id]){
+ Ext.Element.addToCache(new Ext.Element(el), id);
+ if(skip){
+ Ext.elCache[id].skipGC = true;
+ }
+ }
+ }
+ return id;
+ };
+
+ /// There is some jquery work around stuff here that isn't needed in Ext Core.
+ function addListener(el, ename, fn, task, wrap, scope){
+ el = Ext.getDom(el);
+ var id = getId(el),
+ es = Ext.elCache[id].events,
+ wfn;
+
+ wfn = E.on(el, ename, wrap);
+ es[ename] = es[ename] || [];
+
+ /* 0 = Original Function,
+ 1 = Event Manager Wrapped Function,
+ 2 = Scope,
+ 3 = Adapter Wrapped Function,
+ 4 = Buffered Task
+ */
+ es[ename].push([fn, wrap, scope, wfn, task]);
+
+ // this is a workaround for jQuery and should somehow be removed from Ext Core in the future
+ // without breaking ExtJS.
+
+ // workaround for jQuery
+ if(el.addEventListener && ename == "mousewheel"){
+ var args = ["DOMMouseScroll", wrap, false];
+ el.addEventListener.apply(el, args);
+ Ext.EventManager.addListener(WINDOW, 'unload', function(){
+ el.removeEventListener.apply(el, args);
+ });
+ }
+
+ // fix stopped mousedowns on the document
+ if(el == DOC && ename == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
+ }
+ };
+
+ function doScrollChk(){
+ /* Notes:
+ 'doScroll' will NOT work in a IFRAME/FRAMESET.
+ The method succeeds but, a DOM query done immediately after -- FAILS.
+ */
+ if(window != top){
+ return false;
+ }
+
+ try{
+ DOC.documentElement.doScroll('left');
+ }catch(e){
+ return false;
+ }
+
+ fireDocReady();
+ return true;
+ }
+ <div id="method-Ext.EventManager-function"></div>/**
+ * @return {Boolean} True if the document is in a 'complete' state (or was determined to
+ * be true by other means). If false, the state is evaluated again until canceled.
+ */
+ function checkReadyState(e){
+
+ if(Ext.isIE && doScrollChk()){
+ return true;
+ }
+ if(DOC.readyState == COMPLETE){
+ fireDocReady();
+ return true;
+ }
+ docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
+ return false;
+ }
+
+ var styles;
+ function checkStyleSheets(e){
+ styles || (styles = Ext.query('style, link[rel=stylesheet]'));
+ if(styles.length == DOC.styleSheets.length){
+ fireDocReady();
+ return true;
+ }
+ docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
+ return false;
+ }
+
+ function OperaDOMContentLoaded(e){
+ DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false);
+ checkStyleSheets();
+ }
+
+ function fireDocReady(e){
+ if(!docReadyState){
+ docReadyState = true; //only attempt listener removal once
+
+ if(docReadyProcId){
+ clearTimeout(docReadyProcId);
+ }
+ if(DETECT_NATIVE) {
+ DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
+ }
+ if(Ext.isIE && checkReadyState.bindIE){ //was this was actually set ??
+ DOC.detachEvent('onreadystatechange', checkReadyState);
+ }
+ E.un(WINDOW, "load", arguments.callee);
+ }
+ if(docReadyEvent && !Ext.isReady){
+ Ext.isReady = true;
+ docReadyEvent.fire();
+ docReadyEvent.listeners = [];
+ }
+
+ };
+
+ function initDocReady(){
+ docReadyEvent || (docReadyEvent = new Ext.util.Event());
+ if (DETECT_NATIVE) {
+ DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
+ }
+ /*
+ * Handle additional (exceptional) detection strategies here
+ */
+ if (Ext.isIE){
+ //Use readystatechange as a backup AND primary detection mechanism for a FRAME/IFRAME
+ //See if page is already loaded
+ if(!checkReadyState()){
+ checkReadyState.bindIE = true;
+ DOC.attachEvent('onreadystatechange', checkReadyState);
+ }
+
+ }else if(Ext.isOpera ){
+ /* Notes:
+ Opera needs special treatment needed here because CSS rules are NOT QUITE
+ available after DOMContentLoaded is raised.
+ */
+
+ //See if page is already loaded and all styleSheets are in place
+ (DOC.readyState == COMPLETE && checkStyleSheets()) ||
+ DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false);
+
+ }else if (Ext.isWebKit){
+ //Fallback for older Webkits without DOMCONTENTLOADED support
+ checkReadyState();
+ }
+ // no matter what, make sure it fires on load
+ E.on(WINDOW, "load", fireDocReady);
+ };
+
+ function createTargeted(h, o){
+ return function(){
+ var args = Ext.toArray(arguments);
+ if(o.target == Ext.EventObject.setEvent(args[0]).target){
+ h.apply(this, args);
+ }
+ };
+ };
+
+ function createBuffered(h, o, task){
+ return function(e){
+ // create new event object impl so new events don't wipe out properties
+ task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
+ };
+ };
+
+ function createSingle(h, el, ename, fn, scope){
+ return function(e){
+ Ext.EventManager.removeListener(el, ename, fn, scope);
+ h(e);
+ };
+ };
+
+ function createDelayed(h, o, fn){
+ return function(e){
+ var task = new Ext.util.DelayedTask(h);
+ if(!fn.tasks) {
+ fn.tasks = [];
+ }
+ fn.tasks.push(task);
+ task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
+ };
+ };
+
+ function listen(element, ename, opt, fn, scope){
+ var o = (!opt || typeof opt == "boolean") ? {} : opt,
+ el = Ext.getDom(element), task;
+
+ fn = fn || o.fn;
+ scope = scope || o.scope;
+
+ if(!el){
+ throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
+ }
+ function h(e){
+ // prevent errors while unload occurring
+ if(!Ext){// !window[xname]){ ==> can't we do this?
+ return;
+ }
+ e = Ext.EventObject.setEvent(e);
+ var t;
+ if (o.delegate) {
+ if(!(t = e.getTarget(o.delegate, el))){
+ return;
+ }
+ } else {
+ t = e.target;
+ }
+ if (o.stopEvent) {
+ e.stopEvent();
+ }
+ if (o.preventDefault) {
+ e.preventDefault();
+ }
+ if (o.stopPropagation) {
+ e.stopPropagation();
+ }
+ if (o.normalized) {
+ e = e.browserEvent;
+ }
+
+ fn.call(scope || el, e, t, o);
+ };
+ if(o.target){
+ h = createTargeted(h, o);
+ }
+ if(o.delay){
+ h = createDelayed(h, o, fn);
+ }
+ if(o.single){
+ h = createSingle(h, el, ename, fn, scope);
+ }
+ if(o.buffer){
+ task = new Ext.util.DelayedTask(h);
+ h = createBuffered(h, o, task);
+ }
+
+ addListener(el, ename, fn, task, h, scope);
+ return h;
+ };
+
+ var pub = {
+ <div id="method-Ext.EventManager-addListener"></div>/**
+ * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
+ * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
+ * @param {String/HTMLElement} el The html element or id to assign the event handler to.
+ * @param {String} eventName The name of the event to listen for.
+ * @param {Function} handler The handler function the event invokes. This function is passed
+ * the following parameters:<ul>
+ * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
+ * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
+ * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
+ * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
+ * </ul>
+ * @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>.
+ * @param {Object} options (optional) An object containing handler configuration properties.
+ * This may contain any of the following properties:<ul>
+ * <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>
+ * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
+ * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
+ * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
+ * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
+ * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
+ * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
+ * <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>
+ * <li>buffer : Number<div class="sub-desc">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 <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
+ * <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>
+ * </ul><br>
+ * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
+ */
+ addListener : function(element, eventName, fn, scope, options){
+ if(typeof eventName == 'object'){
+ var o = eventName, e, val;
+ for(e in o){
+ val = o[e];
+ if(!propRe.test(e)){
+ if(Ext.isFunction(val)){
+ // shared options
+ listen(element, e, o, val, o.scope);
+ }else{
+ // individual options
+ listen(element, e, val);
+ }
+ }
+ }
+ } else {
+ listen(element, eventName, options, fn, scope);
+ }
+ },
+
+ <div id="method-Ext.EventManager-removeListener"></div>/**
+ * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
+ * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
+ * @param {String/HTMLElement} el The id or html element from which to remove the listener.
+ * @param {String} eventName The name of the event.
+ * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
+ * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
+ * then this must refer to the same object.
+ */
+ removeListener : function(el, eventName, fn, scope){
+ el = Ext.getDom(el);
+ var id = getId(el),
+ f = el && (Ext.elCache[id].events)[eventName] || [],
+ wrap, i, l, k, len, fnc;
+
+ for (i = 0, len = f.length; i < len; i++) {
+
+ /* 0 = Original Function,
+ 1 = Event Manager Wrapped Function,
+ 2 = Scope,
+ 3 = Adapter Wrapped Function,
+ 4 = Buffered Task
+ */
+ if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
+ if(fnc[4]) {
+ fnc[4].cancel();
+ }
+ k = fn.tasks && fn.tasks.length;
+ if(k) {
+ while(k--) {
+ fn.tasks[k].cancel();
+ }
+ delete fn.tasks;
+ }
+ wrap = fnc[1];
+ E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
+
+ // jQuery workaround that should be removed from Ext Core
+ if(wrap && el.addEventListener && eventName == "mousewheel"){
+ el.removeEventListener("DOMMouseScroll", wrap, false);
+ }
+
+ // fix stopped mousedowns on the document
+ if(wrap && el == DOC && eventName == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
+ }
+
+ f.splice(i, 1);
+ if (f.length === 0) {
+ delete Ext.elCache[id].events[eventName];
+ }
+ for (k in Ext.elCache[id].events) {
+ return false;
+ }
+ Ext.elCache[id].events = {};
+ return false;
+ }
+ }
+ },
+
+ <div id="method-Ext.EventManager-removeAll"></div>/**
+ * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
+ * directly on an Element in favor of calling this version.
+ * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
+ */
+ removeAll : function(el){
+ el = Ext.getDom(el);
+ var id = getId(el),
+ ec = Ext.elCache[id] || {},
+ es = ec.events || {},
+ f, i, len, ename, fn, k, wrap;
+
+ for(ename in es){
+ if(es.hasOwnProperty(ename)){
+ f = es[ename];
+ /* 0 = Original Function,
+ 1 = Event Manager Wrapped Function,
+ 2 = Scope,
+ 3 = Adapter Wrapped Function,
+ 4 = Buffered Task
+ */
+ for (i = 0, len = f.length; i < len; i++) {
+ fn = f[i];
+ if(fn[4]) {
+ fn[4].cancel();
+ }
+ if(fn[0].tasks && (k = fn[0].tasks.length)) {
+ while(k--) {
+ fn[0].tasks[k].cancel();
+ }
+ delete fn.tasks;
+ }
+ wrap = fn[1];
+ E.un(el, ename, E.extAdapter ? fn[3] : wrap);
+
+ // jQuery workaround that should be removed from Ext Core
+ if(el.addEventListener && wrap && ename == "mousewheel"){
+ el.removeEventListener("DOMMouseScroll", wrap, false);
+ }
+
+ // fix stopped mousedowns on the document
+ if(wrap && el == DOC && ename == "mousedown"){
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
+ }
+ }
+ }
+ }
+ if (Ext.elCache[id]) {
+ Ext.elCache[id].events = {};
+ }
+ },
+
+ getListeners : function(el, eventName) {
+ el = Ext.getDom(el);
+ var id = getId(el),
+ ec = Ext.elCache[id] || {},
+ es = ec.events || {},
+ results = [];
+ if (es && es[eventName]) {
+ return es[eventName];
+ } else {
+ return null;
+ }
+ },
+
+ purgeElement : function(el, recurse, eventName) {
+ el = Ext.getDom(el);
+ var id = getId(el),
+ ec = Ext.elCache[id] || {},
+ es = ec.events || {},
+ i, f, len;
+ if (eventName) {
+ if (es && es.hasOwnProperty(eventName)) {
+ f = es[eventName];
+ for (i = 0, len = f.length; i < len; i++) {
+ Ext.EventManager.removeListener(el, eventName, f[i][0]);
+ }
+ }
+ } else {
+ Ext.EventManager.removeAll(el);
+ }
+ if (recurse && el && el.childNodes) {
+ for (i = 0, len = el.childNodes.length; i < len; i++) {
+ Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
+ }
+ }
+ },
+
+ _unload : function() {
+ var el;
+ for (el in Ext.elCache) {
+ Ext.EventManager.removeAll(el);
+ }
+ delete Ext.elCache;
+ delete Ext.Element._flyweights;
+
+ // Abort any outstanding Ajax requests
+ var c,
+ conn,
+ tid,
+ ajax = Ext.lib.Ajax;
+ (typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {};
+ for (tid in conn) {
+ c = conn[tid];
+ if (c) {
+ ajax.abort({conn: c, tId: tid});
+ }
+ }
+ },
+ <div id="method-Ext.EventManager-onDocumentReady"></div>/**
+ * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
+ * accessed shorthanded as Ext.onReady().
+ * @param {Function} fn The method the event invokes.
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
+ * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
+ * <code>{single: true}</code> be used so that the handler is removed on first invocation.
+ */
+ onDocumentReady : function(fn, scope, options){
+ if(Ext.isReady){ // if it already fired or document.body is present
+ docReadyEvent || (docReadyEvent = new Ext.util.Event());
+ docReadyEvent.addListener(fn, scope, options);
+ docReadyEvent.fire();
+ docReadyEvent.listeners = [];
+ }else{
+ if(!docReadyEvent){
+ initDocReady();
+ }
+ options = options || {};
+ options.delay = options.delay || 1;
+ docReadyEvent.addListener(fn, scope, options);
+ }
+ },
+
+ <div id="prop-Ext.EventManager-fireDocReady"></div>/**
+ * Forces a document ready state transition for the framework. Used when Ext is loaded
+ * into a DOM structure AFTER initial page load (Google API or other dynamic load scenario.
+ * Any pending 'onDocumentReady' handlers will be fired (if not already handled).
+ */
+ fireDocReady : fireDocReady
+ };
+ <div id="method-Ext.EventManager-on"></div>/**
+ * Appends an event handler to an element. Shorthand for {@link #addListener}.
+ * @param {String/HTMLElement} el The html element or id to assign the event handler to
+ * @param {String} eventName The name of the event to listen for.
+ * @param {Function} handler The handler function the event invokes.
+ * @param {Object} scope (optional) (<code>this</code> reference) in which the handler function executes. <b>Defaults to the Element</b>.
+ * @param {Object} options (optional) An object containing standard {@link #addListener} options
+ * @member Ext.EventManager
+ * @method on
+ */
+ pub.on = pub.addListener;
+ <div id="method-Ext.EventManager-un"></div>/**
+ * Removes an event handler from an element. Shorthand for {@link #removeListener}.
+ * @param {String/HTMLElement} el The id or html element from which to remove the listener.
+ * @param {String} eventName The name of the event.
+ * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #on} call.</b>
+ * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
+ * then this must refer to the same object.
+ * @member Ext.EventManager
+ * @method un
+ */
+ pub.un = pub.removeListener;
+
+ pub.stoppedMouseDownEvent = new Ext.util.Event();
+ return pub;
+}();
+<div id="method-Ext-onReady"></div>/**
+ * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Shorthand of {@link Ext.EventManager#onDocumentReady}.
+ * @param {Function} fn The method the event invokes.
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
+ * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
+ * <code>{single: true}</code> be used so that the handler is removed on first invocation.
+ * @member Ext
+ * @method onReady
+ */
+Ext.onReady = Ext.EventManager.onDocumentReady;
+
+
+//Initialize doc classes
+(function(){
+
+ var initExtCss = function(){
+ // find the body element
+ var bd = document.body || document.getElementsByTagName('body')[0];
+ if(!bd){ return false; }
+ var cls = [' ',
+ Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
+ : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
+ : Ext.isOpera ? "ext-opera"
+ : Ext.isWebKit ? "ext-webkit" : ""];
+
+ if(Ext.isSafari){
+ cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
+ }else if(Ext.isChrome){
+ cls.push("ext-chrome");
+ }
+
+ if(Ext.isMac){
+ cls.push("ext-mac");
+ }
+ if(Ext.isLinux){
+ cls.push("ext-linux");
+ }
+
+ if(Ext.isStrict || Ext.isBorderBox){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
+ var p = bd.parentNode;
+ if(p){
+ p.className += Ext.isStrict ? ' ext-strict' : ' ext-border-box';
+ }
+ }
+ bd.className += cls.join(' ');
+ return true;
+ }
+
+ if(!initExtCss()){
+ Ext.onReady(initExtCss);
+ }
+})();
+
+
+<div id="cls-Ext.EventObject"></div>/**
+ * @class Ext.EventObject
+ * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
+ * wraps the browser's native event-object normalizing cross-browser differences,
+ * such as which mouse button is clicked, keys pressed, mechanisms to stop
+ * event-propagation along with a method to prevent default actions from taking place.
+ * <p>For example:</p>
+ * <pre><code>
+function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
+ e.preventDefault();
+ var target = e.getTarget(); // same as t (the target HTMLElement)
+ ...
+}
+var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}
+myDiv.on( // 'on' is shorthand for addListener
+ "click", // perform an action on click of myDiv
+ handleClick // reference to the action handler
+);
+// other methods to do the same:
+Ext.EventManager.on("myDiv", 'click', handleClick);
+Ext.EventManager.addListener("myDiv", 'click', handleClick);
+ </code></pre>
+ * @singleton
+ */
+Ext.EventObject = function(){
+ var E = Ext.lib.Event,
+ // safari keypress events for special keys return bad keycodes
+ safariKeys = {
+ 3 : 13, // enter
+ 63234 : 37, // left
+ 63235 : 39, // right
+ 63232 : 38, // up
+ 63233 : 40, // down
+ 63276 : 33, // page up
+ 63277 : 34, // page down
+ 63272 : 46, // delete
+ 63273 : 36, // home
+ 63275 : 35 // end
+ },
+ // normalize button clicks
+ btnMap = Ext.isIE ? {1:0,4:1,2:2} :
+ (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
+
+ Ext.EventObjectImpl = function(e){
+ if(e){
+ this.setEvent(e.browserEvent || e);
+ }
+ };
+
+ Ext.EventObjectImpl.prototype = {
+ /** @private */
+ setEvent : function(e){
+ var me = this;
+ if(e == me || (e && e.browserEvent)){ // already wrapped
+ return e;
+ }
+ me.browserEvent = e;
+ if(e){
+ // normalize buttons
+ me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
+ if(e.type == 'click' && me.button == -1){
+ me.button = 0;
+ }
+ me.type = e.type;
+ me.shiftKey = e.shiftKey;
+ // mac metaKey behaves like ctrlKey
+ me.ctrlKey = e.ctrlKey || e.metaKey || false;
+ me.altKey = e.altKey;
+ // in getKey these will be normalized for the mac
+ me.keyCode = e.keyCode;
+ me.charCode = e.charCode;
+ // cache the target for the delayed and or buffered events
+ me.target = E.getTarget(e);
+ // same for XY
+ me.xy = E.getXY(e);
+ }else{
+ me.button = -1;
+ me.shiftKey = false;
+ me.ctrlKey = false;
+ me.altKey = false;
+ me.keyCode = 0;
+ me.charCode = 0;
+ me.target = null;
+ me.xy = [0, 0];
+ }
+ return me;
+ },
+
+ <div id="method-Ext.EventObject-stopEvent"></div>/**
+ * Stop the event (preventDefault and stopPropagation)
+ */
+ stopEvent : function(){
+ var me = this;
+ if(me.browserEvent){
+ if(me.browserEvent.type == 'mousedown'){
+ Ext.EventManager.stoppedMouseDownEvent.fire(me);
+ }
+ E.stopEvent(me.browserEvent);
+ }
+ },
+
+ <div id="method-Ext.EventObject-preventDefault"></div>/**
+ * Prevents the browsers default handling of the event.
+ */
+ preventDefault : function(){
+ if(this.browserEvent){
+ E.preventDefault(this.browserEvent);
+ }
+ },
+
+ <div id="method-Ext.EventObject-stopPropagation"></div>/**
+ * Cancels bubbling of the event.
+ */
+ stopPropagation : function(){
+ var me = this;
+ if(me.browserEvent){
+ if(me.browserEvent.type == 'mousedown'){
+ Ext.EventManager.stoppedMouseDownEvent.fire(me);
+ }
+ E.stopPropagation(me.browserEvent);
+ }
+ },
+
+ <div id="method-Ext.EventObject-getCharCode"></div>/**
+ * Gets the character code for the event.
+ * @return {Number}
+ */
+ getCharCode : function(){
+ return this.charCode || this.keyCode;
+ },
+
+ <div id="method-Ext.EventObject-getKey"></div>/**
+ * Returns a normalized keyCode for the event.
+ * @return {Number} The key code
+ */
+ getKey : function(){
+ return this.normalizeKey(this.keyCode || this.charCode)
+ },
+
+ // private
+ normalizeKey: function(k){
+ return Ext.isSafari ? (safariKeys[k] || k) : k;
+ },
+
+ <div id="method-Ext.EventObject-getPageX"></div>/**
+ * Gets the x coordinate of the event.
+ * @return {Number}
+ */
+ getPageX : function(){
+ return this.xy[0];
+ },
+
+ <div id="method-Ext.EventObject-getPageY"></div>/**
+ * Gets the y coordinate of the event.
+ * @return {Number}
+ */
+ getPageY : function(){
+ return this.xy[1];
+ },
+
+ <div id="method-Ext.EventObject-getXY"></div>/**
+ * Gets the page coordinates of the event.
+ * @return {Array} The xy values like [x, y]
+ */
+ getXY : function(){
+ return this.xy;
+ },
+
+ <div id="method-Ext.EventObject-getTarget"></div>/**
+ * Gets the target for the event.
+ * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
+ * @param {Number/Mixed} maxDepth (optional) The max depth to
+ search as a number or element (defaults to 10 || document.body)
+ * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
+ * @return {HTMLelement}
+ */
+ getTarget : function(selector, maxDepth, returnEl){
+ return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
+ },
+
+ <div id="method-Ext.EventObject-getRelatedTarget"></div>/**
+ * Gets the related target.
+ * @return {HTMLElement}
+ */
+ getRelatedTarget : function(){
+ return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
+ },
+
+ <div id="method-Ext.EventObject-getWheelDelta"></div>/**
+ * Normalizes mouse wheel delta across browsers
+ * @return {Number} The delta
+ */
+ getWheelDelta : function(){
+ var e = this.browserEvent;
+ var delta = 0;
+ if(e.wheelDelta){ /* IE/Opera. */
+ delta = e.wheelDelta/120;
+ }else if(e.detail){ /* Mozilla case. */
+ delta = -e.detail/3;
+ }
+ return delta;
+ },
+
+ <div id="method-Ext.EventObject-within"></div>/**
+ * 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.
+ * Example usage:<pre><code>
+ // Handle click on any child of an element
+ Ext.getBody().on('click', function(e){
+ if(e.within('some-el')){
+ alert('Clicked on a child of some-el!');
+ }
+ });
+
+ // Handle click directly on an element, ignoring clicks on child nodes
+ Ext.getBody().on('click', function(e,t){
+ if((t.id == 'some-el') && !e.within(t, true)){
+ alert('Clicked directly on some-el!');
+ }
+ });
+ </code></pre>
+ * @param {Mixed} el The id, DOM element or Ext.Element to check
+ * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
+ * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
+ * @return {Boolean}
+ */
+ within : function(el, related, allowEl){
+ if(el){
+ var t = this[related ? "getRelatedTarget" : "getTarget"]();
+ return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
+ }
+ return false;
+ }
+ };
+
+ return new Ext.EventObjectImpl();
+}();
+</pre>
+</body>
</html>
\ No newline at end of file