You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

995 lines
39 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-EventManager'>/**
  19. </span> * @class Ext.EventManager
  20. * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
  21. * several useful events directly.
  22. * See {@link Ext.EventObject} for more details on normalized event objects.
  23. * @singleton
  24. */
  25. Ext.EventManager = function(){
  26. var docReadyEvent,
  27. docReadyProcId,
  28. docReadyState = false,
  29. DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari || Ext.isIE10p,
  30. E = Ext.lib.Event,
  31. D = Ext.lib.Dom,
  32. DOC = document,
  33. WINDOW = window,
  34. DOMCONTENTLOADED = &quot;DOMContentLoaded&quot;,
  35. COMPLETE = 'complete',
  36. propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
  37. /*
  38. * This cache is used to hold special js objects, the document and window, that don't have an id. We need to keep
  39. * a reference to them so we can look them up at a later point.
  40. */
  41. specialElCache = [];
  42. function getId(el){
  43. var id = false,
  44. i = 0,
  45. len = specialElCache.length,
  46. skip = false,
  47. o;
  48. if (el) {
  49. if (el.getElementById || el.navigator) {
  50. // look up the id
  51. for(; i &lt; len; ++i){
  52. o = specialElCache[i];
  53. if(o.el === el){
  54. id = o.id;
  55. break;
  56. }
  57. }
  58. if(!id){
  59. // for browsers that support it, ensure that give the el the same id
  60. id = Ext.id(el);
  61. specialElCache.push({
  62. id: id,
  63. el: el
  64. });
  65. skip = true;
  66. }
  67. }else{
  68. id = Ext.id(el);
  69. }
  70. if(!Ext.elCache[id]){
  71. Ext.Element.addToCache(new Ext.Element(el), id);
  72. if(skip){
  73. Ext.elCache[id].skipGC = true;
  74. }
  75. }
  76. }
  77. return id;
  78. }
  79. /// There is some jquery work around stuff here that isn't needed in Ext Core.
  80. function addListener(el, ename, fn, task, wrap, scope){
  81. el = Ext.getDom(el);
  82. var id = getId(el),
  83. es = Ext.elCache[id].events,
  84. wfn;
  85. wfn = E.on(el, ename, wrap);
  86. es[ename] = es[ename] || [];
  87. /* 0 = Original Function,
  88. 1 = Event Manager Wrapped Function,
  89. 2 = Scope,
  90. 3 = Adapter Wrapped Function,
  91. 4 = Buffered Task
  92. */
  93. es[ename].push([fn, wrap, scope, wfn, task]);
  94. // this is a workaround for jQuery and should somehow be removed from Ext Core in the future
  95. // without breaking ExtJS.
  96. // workaround for jQuery
  97. if(el.addEventListener &amp;&amp; ename == &quot;mousewheel&quot;){
  98. var args = [&quot;DOMMouseScroll&quot;, wrap, false];
  99. el.addEventListener.apply(el, args);
  100. Ext.EventManager.addListener(WINDOW, 'unload', function(){
  101. el.removeEventListener.apply(el, args);
  102. });
  103. }
  104. // fix stopped mousedowns on the document
  105. if(el == DOC &amp;&amp; ename == &quot;mousedown&quot;){
  106. Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
  107. }
  108. }
  109. function doScrollChk(){
  110. /* Notes:
  111. 'doScroll' will NOT work in a IFRAME/FRAMESET.
  112. The method succeeds but, a DOM query done immediately after -- FAILS.
  113. */
  114. if(window != top){
  115. return false;
  116. }
  117. try{
  118. DOC.documentElement.doScroll('left');
  119. }catch(e){
  120. return false;
  121. }
  122. fireDocReady();
  123. return true;
  124. }
  125. <span id='Ext-EventManager-method-checkReadyState'> /**
  126. </span> * @return {Boolean} True if the document is in a 'complete' state (or was determined to
  127. * be true by other means). If false, the state is evaluated again until canceled.
  128. */
  129. function checkReadyState(e){
  130. if(Ext.isIE9m &amp;&amp; doScrollChk()){
  131. return true;
  132. }
  133. if(DOC.readyState == COMPLETE){
  134. fireDocReady();
  135. return true;
  136. }
  137. docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
  138. return false;
  139. }
  140. var styles;
  141. function checkStyleSheets(e){
  142. styles || (styles = Ext.query('style, link[rel=stylesheet]'));
  143. if(styles.length == DOC.styleSheets.length){
  144. fireDocReady();
  145. return true;
  146. }
  147. docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
  148. return false;
  149. }
  150. function OperaDOMContentLoaded(e){
  151. DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false);
  152. checkStyleSheets();
  153. }
  154. function fireDocReady(e){
  155. if(!docReadyState){
  156. docReadyState = true; //only attempt listener removal once
  157. if(docReadyProcId){
  158. clearTimeout(docReadyProcId);
  159. }
  160. if(DETECT_NATIVE) {
  161. DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
  162. }
  163. if(Ext.isIE9m &amp;&amp; checkReadyState.bindIE){ //was this was actually set ??
  164. DOC.detachEvent('onreadystatechange', checkReadyState);
  165. }
  166. E.un(WINDOW, &quot;load&quot;, arguments.callee);
  167. }
  168. if(docReadyEvent &amp;&amp; !Ext.isReady){
  169. Ext.isReady = true;
  170. docReadyEvent.fire();
  171. docReadyEvent.listeners = [];
  172. }
  173. }
  174. function initDocReady(){
  175. docReadyEvent || (docReadyEvent = new Ext.util.Event());
  176. if (DETECT_NATIVE) {
  177. DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
  178. }
  179. /*
  180. * Handle additional (exceptional) detection strategies here
  181. */
  182. if (Ext.isIE9m){
  183. //Use readystatechange as a backup AND primary detection mechanism for a FRAME/IFRAME
  184. //See if page is already loaded
  185. if(!checkReadyState()){
  186. checkReadyState.bindIE = true;
  187. DOC.attachEvent('onreadystatechange', checkReadyState);
  188. }
  189. }else if(Ext.isOpera ){
  190. /* Notes:
  191. Opera needs special treatment needed here because CSS rules are NOT QUITE
  192. available after DOMContentLoaded is raised.
  193. */
  194. //See if page is already loaded and all styleSheets are in place
  195. (DOC.readyState == COMPLETE &amp;&amp; checkStyleSheets()) ||
  196. DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false);
  197. }else if (Ext.isWebKit){
  198. //Fallback for older Webkits without DOMCONTENTLOADED support
  199. checkReadyState();
  200. }
  201. // no matter what, make sure it fires on load
  202. E.on(WINDOW, &quot;load&quot;, fireDocReady);
  203. }
  204. function createTargeted(h, o){
  205. return function(){
  206. var args = Ext.toArray(arguments);
  207. if(o.target == Ext.EventObject.setEvent(args[0]).target){
  208. h.apply(this, args);
  209. }
  210. };
  211. }
  212. function createBuffered(h, o, task){
  213. return function(e){
  214. // create new event object impl so new events don't wipe out properties
  215. task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
  216. };
  217. }
  218. function createSingle(h, el, ename, fn, scope){
  219. return function(e){
  220. Ext.EventManager.removeListener(el, ename, fn, scope);
  221. h(e);
  222. };
  223. }
  224. function createDelayed(h, o, fn){
  225. return function(e){
  226. var task = new Ext.util.DelayedTask(h);
  227. if(!fn.tasks) {
  228. fn.tasks = [];
  229. }
  230. fn.tasks.push(task);
  231. task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
  232. };
  233. }
  234. function listen(element, ename, opt, fn, scope){
  235. var o = (!opt || typeof opt == &quot;boolean&quot;) ? {} : opt,
  236. el = Ext.getDom(element), task;
  237. fn = fn || o.fn;
  238. scope = scope || o.scope;
  239. if(!el){
  240. throw &quot;Error listening for \&quot;&quot; + ename + '\&quot;. Element &quot;' + element + '&quot; doesn\'t exist.';
  241. }
  242. function h(e){
  243. // prevent errors while unload occurring
  244. if(!Ext){// !window[xname]){ ==&gt; can't we do this?
  245. return;
  246. }
  247. e = Ext.EventObject.setEvent(e);
  248. var t;
  249. if (o.delegate) {
  250. if(!(t = e.getTarget(o.delegate, el))){
  251. return;
  252. }
  253. } else {
  254. t = e.target;
  255. }
  256. if (o.stopEvent) {
  257. e.stopEvent();
  258. }
  259. if (o.preventDefault) {
  260. e.preventDefault();
  261. }
  262. if (o.stopPropagation) {
  263. e.stopPropagation();
  264. }
  265. if (o.normalized === false) {
  266. e = e.browserEvent;
  267. }
  268. fn.call(scope || el, e, t, o);
  269. }
  270. if(o.target){
  271. h = createTargeted(h, o);
  272. }
  273. if(o.delay){
  274. h = createDelayed(h, o, fn);
  275. }
  276. if(o.single){
  277. h = createSingle(h, el, ename, fn, scope);
  278. }
  279. if(o.buffer){
  280. task = new Ext.util.DelayedTask(h);
  281. h = createBuffered(h, o, task);
  282. }
  283. addListener(el, ename, fn, task, h, scope);
  284. return h;
  285. }
  286. var pub = {
  287. <span id='Ext-EventManager-method-addListener'> /**
  288. </span> * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
  289. * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
  290. * @param {String/HTMLElement} el The html element or id to assign the event handler to.
  291. * @param {String} eventName The name of the event to listen for.
  292. * @param {Function} handler The handler function the event invokes. This function is passed
  293. * the following parameters:&lt;ul&gt;
  294. * &lt;li&gt;evt : EventObject&lt;div class=&quot;sub-desc&quot;&gt;The {@link Ext.EventObject EventObject} describing the event.&lt;/div&gt;&lt;/li&gt;
  295. * &lt;li&gt;t : Element&lt;div class=&quot;sub-desc&quot;&gt;The {@link Ext.Element Element} which was the target of the event.
  296. * Note that this may be filtered by using the &lt;tt&gt;delegate&lt;/tt&gt; option.&lt;/div&gt;&lt;/li&gt;
  297. * &lt;li&gt;o : Object&lt;div class=&quot;sub-desc&quot;&gt;The options object from the addListener call.&lt;/div&gt;&lt;/li&gt;
  298. * &lt;/ul&gt;
  299. * @param {Object} scope (optional) The scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) in which the handler function is executed. &lt;b&gt;Defaults to the Element&lt;/b&gt;.
  300. * @param {Object} options (optional) An object containing handler configuration properties.
  301. * This may contain any of the following properties:&lt;ul&gt;
  302. * &lt;li&gt;scope : Object&lt;div class=&quot;sub-desc&quot;&gt;The scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) in which the handler function is executed. &lt;b&gt;Defaults to the Element&lt;/b&gt;.&lt;/div&gt;&lt;/li&gt;
  303. * &lt;li&gt;delegate : String&lt;div class=&quot;sub-desc&quot;&gt;A simple selector to filter the target or look for a descendant of the target&lt;/div&gt;&lt;/li&gt;
  304. * &lt;li&gt;stopEvent : Boolean&lt;div class=&quot;sub-desc&quot;&gt;True to stop the event. That is stop propagation, and prevent the default action.&lt;/div&gt;&lt;/li&gt;
  305. * &lt;li&gt;preventDefault : Boolean&lt;div class=&quot;sub-desc&quot;&gt;True to prevent the default action&lt;/div&gt;&lt;/li&gt;
  306. * &lt;li&gt;stopPropagation : Boolean&lt;div class=&quot;sub-desc&quot;&gt;True to prevent event propagation&lt;/div&gt;&lt;/li&gt;
  307. * &lt;li&gt;normalized : Boolean&lt;div class=&quot;sub-desc&quot;&gt;False to pass a browser event to the handler function instead of an Ext.EventObject&lt;/div&gt;&lt;/li&gt;
  308. * &lt;li&gt;delay : Number&lt;div class=&quot;sub-desc&quot;&gt;The number of milliseconds to delay the invocation of the handler after te event fires.&lt;/div&gt;&lt;/li&gt;
  309. * &lt;li&gt;single : Boolean&lt;div class=&quot;sub-desc&quot;&gt;True to add a handler to handle just the next firing of the event, and then remove itself.&lt;/div&gt;&lt;/li&gt;
  310. * &lt;li&gt;buffer : Number&lt;div class=&quot;sub-desc&quot;&gt;Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
  311. * by the specified number of milliseconds. If the event fires again within that time, the original
  312. * handler is &lt;em&gt;not&lt;/em&gt; invoked, but the new handler is scheduled in its place.&lt;/div&gt;&lt;/li&gt;
  313. * &lt;li&gt;target : Element&lt;div class=&quot;sub-desc&quot;&gt;Only call the handler if the event was fired on the target Element, &lt;i&gt;not&lt;/i&gt; if the event was bubbled up from a child node.&lt;/div&gt;&lt;/li&gt;
  314. * &lt;/ul&gt;&lt;br&gt;
  315. * &lt;p&gt;See {@link Ext.Element#addListener} for examples of how to use these options.&lt;/p&gt;
  316. */
  317. addListener : function(element, eventName, fn, scope, options){
  318. if(typeof eventName == 'object'){
  319. var o = eventName, e, val;
  320. for(e in o){
  321. val = o[e];
  322. if(!propRe.test(e)){
  323. if(Ext.isFunction(val)){
  324. // shared options
  325. listen(element, e, o, val, o.scope);
  326. }else{
  327. // individual options
  328. listen(element, e, val);
  329. }
  330. }
  331. }
  332. } else {
  333. listen(element, eventName, options, fn, scope);
  334. }
  335. },
  336. <span id='Ext-EventManager-method-removeListener'> /**
  337. </span> * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
  338. * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
  339. * @param {String/HTMLElement} el The id or html element from which to remove the listener.
  340. * @param {String} eventName The name of the event.
  341. * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #addListener} call.&lt;/b&gt;
  342. * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
  343. * then this must refer to the same object.
  344. */
  345. removeListener : function(el, eventName, fn, scope){
  346. el = Ext.getDom(el);
  347. var id = getId(el),
  348. f = el &amp;&amp; (Ext.elCache[id].events)[eventName] || [],
  349. wrap, i, l, k, len, fnc;
  350. for (i = 0, len = f.length; i &lt; len; i++) {
  351. /* 0 = Original Function,
  352. 1 = Event Manager Wrapped Function,
  353. 2 = Scope,
  354. 3 = Adapter Wrapped Function,
  355. 4 = Buffered Task
  356. */
  357. if (Ext.isArray(fnc = f[i]) &amp;&amp; fnc[0] == fn &amp;&amp; (!scope || fnc[2] == scope)) {
  358. if(fnc[4]) {
  359. fnc[4].cancel();
  360. }
  361. k = fn.tasks &amp;&amp; fn.tasks.length;
  362. if(k) {
  363. while(k--) {
  364. fn.tasks[k].cancel();
  365. }
  366. delete fn.tasks;
  367. }
  368. wrap = fnc[1];
  369. E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
  370. // jQuery workaround that should be removed from Ext Core
  371. if(wrap &amp;&amp; el.addEventListener &amp;&amp; eventName == &quot;mousewheel&quot;){
  372. el.removeEventListener(&quot;DOMMouseScroll&quot;, wrap, false);
  373. }
  374. // fix stopped mousedowns on the document
  375. if(wrap &amp;&amp; el == DOC &amp;&amp; eventName == &quot;mousedown&quot;){
  376. Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
  377. }
  378. f.splice(i, 1);
  379. if (f.length === 0) {
  380. delete Ext.elCache[id].events[eventName];
  381. }
  382. for (k in Ext.elCache[id].events) {
  383. return false;
  384. }
  385. Ext.elCache[id].events = {};
  386. return false;
  387. }
  388. }
  389. },
  390. <span id='Ext-EventManager-method-removeAll'> /**
  391. </span> * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
  392. * directly on an Element in favor of calling this version.
  393. * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
  394. */
  395. removeAll : function(el){
  396. el = Ext.getDom(el);
  397. var id = getId(el),
  398. ec = Ext.elCache[id] || {},
  399. es = ec.events || {},
  400. f, i, len, ename, fn, k, wrap;
  401. for(ename in es){
  402. if(es.hasOwnProperty(ename)){
  403. f = es[ename];
  404. /* 0 = Original Function,
  405. 1 = Event Manager Wrapped Function,
  406. 2 = Scope,
  407. 3 = Adapter Wrapped Function,
  408. 4 = Buffered Task
  409. */
  410. for (i = 0, len = f.length; i &lt; len; i++) {
  411. fn = f[i];
  412. if(fn[4]) {
  413. fn[4].cancel();
  414. }
  415. if(fn[0].tasks &amp;&amp; (k = fn[0].tasks.length)) {
  416. while(k--) {
  417. fn[0].tasks[k].cancel();
  418. }
  419. delete fn.tasks;
  420. }
  421. wrap = fn[1];
  422. E.un(el, ename, E.extAdapter ? fn[3] : wrap);
  423. // jQuery workaround that should be removed from Ext Core
  424. if(el.addEventListener &amp;&amp; wrap &amp;&amp; ename == &quot;mousewheel&quot;){
  425. el.removeEventListener(&quot;DOMMouseScroll&quot;, wrap, false);
  426. }
  427. // fix stopped mousedowns on the document
  428. if(wrap &amp;&amp; el == DOC &amp;&amp; ename == &quot;mousedown&quot;){
  429. Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
  430. }
  431. }
  432. }
  433. }
  434. if (Ext.elCache[id]) {
  435. Ext.elCache[id].events = {};
  436. }
  437. },
  438. getListeners : function(el, eventName) {
  439. el = Ext.getDom(el);
  440. var id = getId(el),
  441. ec = Ext.elCache[id] || {},
  442. es = ec.events || {},
  443. results = [];
  444. if (es &amp;&amp; es[eventName]) {
  445. return es[eventName];
  446. } else {
  447. return null;
  448. }
  449. },
  450. removeFromSpecialCache: function(o) {
  451. var i = 0,
  452. len = specialElCache.length;
  453. for (; i &lt; len; ++i) {
  454. if (specialElCache[i].el == o) {
  455. specialElCache.splice(i, 1);
  456. }
  457. }
  458. },
  459. purgeElement : function(el, recurse, eventName) {
  460. el = Ext.getDom(el);
  461. var id = getId(el),
  462. ec = Ext.elCache[id] || {},
  463. es = ec.events || {},
  464. i, f, len;
  465. if (eventName) {
  466. if (es &amp;&amp; es.hasOwnProperty(eventName)) {
  467. f = es[eventName];
  468. for (i = 0, len = f.length; i &lt; len; i++) {
  469. Ext.EventManager.removeListener(el, eventName, f[i][0]);
  470. }
  471. }
  472. } else {
  473. Ext.EventManager.removeAll(el);
  474. }
  475. if (recurse &amp;&amp; el &amp;&amp; el.childNodes) {
  476. for (i = 0, len = el.childNodes.length; i &lt; len; i++) {
  477. Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
  478. }
  479. }
  480. },
  481. _unload : function() {
  482. var el;
  483. for (el in Ext.elCache) {
  484. Ext.EventManager.removeAll(el);
  485. }
  486. delete Ext.elCache;
  487. delete Ext.Element._flyweights;
  488. // Abort any outstanding Ajax requests
  489. var c,
  490. conn,
  491. tid,
  492. ajax = Ext.lib.Ajax;
  493. (typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {};
  494. for (tid in conn) {
  495. c = conn[tid];
  496. if (c) {
  497. ajax.abort({conn: c, tId: tid});
  498. }
  499. }
  500. },
  501. <span id='Ext-EventManager-method-onDocumentReady'> /**
  502. </span> * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
  503. * accessed shorthanded as Ext.onReady().
  504. * @param {Function} fn The method the event invokes.
  505. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function executes. Defaults to the browser window.
  506. * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
  507. * &lt;code&gt;{single: true}&lt;/code&gt; be used so that the handler is removed on first invocation.
  508. */
  509. onDocumentReady : function(fn, scope, options){
  510. if (Ext.isReady) { // if it already fired or document.body is present
  511. docReadyEvent || (docReadyEvent = new Ext.util.Event());
  512. docReadyEvent.addListener(fn, scope, options);
  513. docReadyEvent.fire();
  514. docReadyEvent.listeners = [];
  515. } else {
  516. if (!docReadyEvent) {
  517. initDocReady();
  518. }
  519. options = options || {};
  520. options.delay = options.delay || 1;
  521. docReadyEvent.addListener(fn, scope, options);
  522. }
  523. },
  524. <span id='Ext-EventManager-property-fireDocReady'> /**
  525. </span> * Forces a document ready state transition for the framework. Used when Ext is loaded
  526. * into a DOM structure AFTER initial page load (Google API or other dynamic load scenario.
  527. * Any pending 'onDocumentReady' handlers will be fired (if not already handled).
  528. */
  529. fireDocReady : fireDocReady
  530. };
  531. <span id='Ext-EventManager-method-on'> /**
  532. </span> * Appends an event handler to an element. Shorthand for {@link #addListener}.
  533. * @param {String/HTMLElement} el The html element or id to assign the event handler to
  534. * @param {String} eventName The name of the event to listen for.
  535. * @param {Function} handler The handler function the event invokes.
  536. * @param {Object} scope (optional) (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function executes. &lt;b&gt;Defaults to the Element&lt;/b&gt;.
  537. * @param {Object} options (optional) An object containing standard {@link #addListener} options
  538. * @member Ext.EventManager
  539. * @method on
  540. */
  541. pub.on = pub.addListener;
  542. <span id='Ext-EventManager-method-un'> /**
  543. </span> * Removes an event handler from an element. Shorthand for {@link #removeListener}.
  544. * @param {String/HTMLElement} el The id or html element from which to remove the listener.
  545. * @param {String} eventName The name of the event.
  546. * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #on} call.&lt;/b&gt;
  547. * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
  548. * then this must refer to the same object.
  549. * @member Ext.EventManager
  550. * @method un
  551. */
  552. pub.un = pub.removeListener;
  553. pub.stoppedMouseDownEvent = new Ext.util.Event();
  554. return pub;
  555. }();
  556. <span id='Ext-method-onReady'>/**
  557. </span> * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Shorthand of {@link Ext.EventManager#onDocumentReady}.
  558. * @param {Function} fn The method the event invokes.
  559. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function executes. Defaults to the browser window.
  560. * @param {boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options
  561. * &lt;code&gt;{single: true}&lt;/code&gt; be used so that the handler is removed on first invocation.
  562. * @member Ext
  563. * @method onReady
  564. */
  565. Ext.onReady = Ext.EventManager.onDocumentReady;
  566. //Initialize doc classes
  567. (function(){
  568. var initExtCss = function() {
  569. // find the body element
  570. var bd = document.body || document.getElementsByTagName('body')[0];
  571. if (!bd) {
  572. return false;
  573. }
  574. var cls = [];
  575. if (Ext.isIE) {
  576. // Only treat IE9 and less like IE in the css
  577. if (!Ext.isIE10p) {
  578. cls.push('ext-ie');
  579. }
  580. if (Ext.isIE6) {
  581. cls.push('ext-ie6');
  582. } else if (Ext.isIE7) {
  583. cls.push('ext-ie7', 'ext-ie7m');
  584. } else if (Ext.isIE8) {
  585. cls.push('ext-ie8', 'ext-ie8m');
  586. } else if (Ext.isIE9) {
  587. cls.push('ext-ie9', 'ext-ie9m');
  588. } else if (Ext.isIE10) {
  589. cls.push('ext-ie10');
  590. }
  591. }
  592. if (Ext.isGecko) {
  593. if (Ext.isGecko2) {
  594. cls.push('ext-gecko2');
  595. } else {
  596. cls.push('ext-gecko3');
  597. }
  598. }
  599. if (Ext.isOpera) {
  600. cls.push('ext-opera');
  601. }
  602. if (Ext.isWebKit) {
  603. cls.push('ext-webkit');
  604. }
  605. if (Ext.isSafari) {
  606. cls.push(&quot;ext-safari &quot; + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
  607. } else if(Ext.isChrome) {
  608. cls.push(&quot;ext-chrome&quot;);
  609. }
  610. if (Ext.isMac) {
  611. cls.push(&quot;ext-mac&quot;);
  612. }
  613. if (Ext.isLinux) {
  614. cls.push(&quot;ext-linux&quot;);
  615. }
  616. // add to the parent to allow for selectors like &quot;.ext-strict .ext-ie&quot;
  617. if (Ext.isStrict || Ext.isBorderBox) {
  618. var p = bd.parentNode;
  619. if (p) {
  620. if (!Ext.isStrict) {
  621. Ext.fly(p, '_internal').addClass('x-quirks');
  622. if (Ext.isIE9m &amp;&amp; !Ext.isStrict) {
  623. Ext.isIEQuirks = true;
  624. }
  625. }
  626. Ext.fly(p, '_internal').addClass(((Ext.isStrict &amp;&amp; Ext.isIE ) || (!Ext.enableForcedBoxModel &amp;&amp; !Ext.isIE)) ? ' ext-strict' : ' ext-border-box');
  627. }
  628. }
  629. // Forced border box model class applied to all elements. Bypassing javascript based box model adjustments
  630. // in favor of css. This is for non-IE browsers.
  631. if (Ext.enableForcedBoxModel &amp;&amp; !Ext.isIE) {
  632. Ext.isForcedBorderBox = true;
  633. cls.push(&quot;ext-forced-border-box&quot;);
  634. }
  635. Ext.fly(bd, '_internal').addClass(cls);
  636. return true;
  637. };
  638. if (!initExtCss()) {
  639. Ext.onReady(initExtCss);
  640. }
  641. })();
  642. // Code used to detect certain browser feature/quirks/bugs at startup.
  643. (function(){
  644. <span id='Ext-supports'> /**
  645. </span> * @class Ext.supports
  646. * @ignore
  647. */
  648. var supports = Ext.apply(Ext.supports, {
  649. <span id='Ext-supports-property-correctRightMargin'> /**
  650. </span> * In Webkit, there is an issue with getting the margin right property, see
  651. * https://bugs.webkit.org/show_bug.cgi?id=13343
  652. */
  653. correctRightMargin: true,
  654. <span id='Ext-supports-property-correctTransparentColor'> /**
  655. </span> * Webkit browsers return rgba(0, 0, 0) when a transparent color is used
  656. */
  657. correctTransparentColor: true,
  658. <span id='Ext-supports-property-cssFloat'> /**
  659. </span> * IE uses styleFloat, not cssFloat for the float property.
  660. */
  661. cssFloat: true
  662. });
  663. var supportTests = function(){
  664. var div = document.createElement('div'),
  665. doc = document,
  666. view,
  667. last;
  668. div.innerHTML = '&lt;div style=&quot;height:30px;width:50px;&quot;&gt;&lt;div style=&quot;height:20px;width:20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;float:left;background-color:transparent;&quot;&gt;';
  669. doc.body.appendChild(div);
  670. last = div.lastChild;
  671. if((view = doc.defaultView)){
  672. if(view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px'){
  673. supports.correctRightMargin = false;
  674. }
  675. if(view.getComputedStyle(last, null).backgroundColor != 'transparent'){
  676. supports.correctTransparentColor = false;
  677. }
  678. }
  679. supports.cssFloat = !!last.style.cssFloat;
  680. doc.body.removeChild(div);
  681. };
  682. if (Ext.isReady) {
  683. supportTests();
  684. } else {
  685. Ext.onReady(supportTests);
  686. }
  687. })();
  688. <span id='Ext-EventObject'>/**
  689. </span> * @class Ext.EventObject
  690. * Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
  691. * wraps the browser's native event-object normalizing cross-browser differences,
  692. * such as which mouse button is clicked, keys pressed, mechanisms to stop
  693. * event-propagation along with a method to prevent default actions from taking place.
  694. * &lt;p&gt;For example:&lt;/p&gt;
  695. * &lt;pre&gt;&lt;code&gt;
  696. function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
  697. e.preventDefault();
  698. var target = e.getTarget(); // same as t (the target HTMLElement)
  699. ...
  700. }
  701. var myDiv = {@link Ext#get Ext.get}(&quot;myDiv&quot;); // get reference to an {@link Ext.Element}
  702. myDiv.on( // 'on' is shorthand for addListener
  703. &quot;click&quot;, // perform an action on click of myDiv
  704. handleClick // reference to the action handler
  705. );
  706. // other methods to do the same:
  707. Ext.EventManager.on(&quot;myDiv&quot;, 'click', handleClick);
  708. Ext.EventManager.addListener(&quot;myDiv&quot;, 'click', handleClick);
  709. &lt;/code&gt;&lt;/pre&gt;
  710. * @singleton
  711. */
  712. Ext.EventObject = function(){
  713. var E = Ext.lib.Event,
  714. clickRe = /(dbl)?click/,
  715. // safari keypress events for special keys return bad keycodes
  716. safariKeys = {
  717. 3 : 13, // enter
  718. 63234 : 37, // left
  719. 63235 : 39, // right
  720. 63232 : 38, // up
  721. 63233 : 40, // down
  722. 63276 : 33, // page up
  723. 63277 : 34, // page down
  724. 63272 : 46, // delete
  725. 63273 : 36, // home
  726. 63275 : 35 // end
  727. },
  728. // normalize button clicks
  729. btnMap = Ext.isIE ? {1:0,4:1,2:2} : {0:0,1:1,2:2};
  730. Ext.EventObjectImpl = function(e){
  731. if(e){
  732. this.setEvent(e.browserEvent || e);
  733. }
  734. };
  735. Ext.EventObjectImpl.prototype = {
  736. <span id='Ext-EventObject-method-setEvent'> /** @private */
  737. </span> setEvent : function(e){
  738. var me = this;
  739. if(e == me || (e &amp;&amp; e.browserEvent)){ // already wrapped
  740. return e;
  741. }
  742. me.browserEvent = e;
  743. if(e){
  744. // normalize buttons
  745. me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
  746. if(clickRe.test(e.type) &amp;&amp; me.button == -1){
  747. me.button = 0;
  748. }
  749. me.type = e.type;
  750. me.shiftKey = e.shiftKey;
  751. // mac metaKey behaves like ctrlKey
  752. me.ctrlKey = e.ctrlKey || e.metaKey || false;
  753. me.altKey = e.altKey;
  754. // in getKey these will be normalized for the mac
  755. me.keyCode = e.keyCode;
  756. me.charCode = e.charCode;
  757. // cache the target for the delayed and or buffered events
  758. me.target = E.getTarget(e);
  759. // same for XY
  760. me.xy = E.getXY(e);
  761. }else{
  762. me.button = -1;
  763. me.shiftKey = false;
  764. me.ctrlKey = false;
  765. me.altKey = false;
  766. me.keyCode = 0;
  767. me.charCode = 0;
  768. me.target = null;
  769. me.xy = [0, 0];
  770. }
  771. return me;
  772. },
  773. <span id='Ext-EventObject-method-stopEvent'> /**
  774. </span> * Stop the event (preventDefault and stopPropagation)
  775. */
  776. stopEvent : function(){
  777. var me = this;
  778. if(me.browserEvent){
  779. if(me.browserEvent.type == 'mousedown'){
  780. Ext.EventManager.stoppedMouseDownEvent.fire(me);
  781. }
  782. E.stopEvent(me.browserEvent);
  783. }
  784. },
  785. <span id='Ext-EventObject-method-preventDefault'> /**
  786. </span> * Prevents the browsers default handling of the event.
  787. */
  788. preventDefault : function(){
  789. if(this.browserEvent){
  790. E.preventDefault(this.browserEvent);
  791. }
  792. },
  793. <span id='Ext-EventObject-method-stopPropagation'> /**
  794. </span> * Cancels bubbling of the event.
  795. */
  796. stopPropagation : function(){
  797. var me = this;
  798. if(me.browserEvent){
  799. if(me.browserEvent.type == 'mousedown'){
  800. Ext.EventManager.stoppedMouseDownEvent.fire(me);
  801. }
  802. E.stopPropagation(me.browserEvent);
  803. }
  804. },
  805. <span id='Ext-EventObject-method-getCharCode'> /**
  806. </span> * Gets the character code for the event.
  807. * @return {Number}
  808. */
  809. getCharCode : function(){
  810. return this.charCode || this.keyCode;
  811. },
  812. <span id='Ext-EventObject-method-getKey'> /**
  813. </span> * Returns a normalized keyCode for the event.
  814. * @return {Number} The key code
  815. */
  816. getKey : function(){
  817. return this.normalizeKey(this.keyCode || this.charCode);
  818. },
  819. // private
  820. normalizeKey: function(k){
  821. return Ext.isSafari ? (safariKeys[k] || k) : k;
  822. },
  823. <span id='Ext-EventObject-method-getPageX'> /**
  824. </span> * Gets the x coordinate of the event.
  825. * @return {Number}
  826. */
  827. getPageX : function(){
  828. return this.xy[0];
  829. },
  830. <span id='Ext-EventObject-method-getPageY'> /**
  831. </span> * Gets the y coordinate of the event.
  832. * @return {Number}
  833. */
  834. getPageY : function(){
  835. return this.xy[1];
  836. },
  837. <span id='Ext-EventObject-method-getXY'> /**
  838. </span> * Gets the page coordinates of the event.
  839. * @return {Array} The xy values like [x, y]
  840. */
  841. getXY : function(){
  842. return this.xy;
  843. },
  844. <span id='Ext-EventObject-method-getTarget'> /**
  845. </span> * Gets the target for the event.
  846. * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
  847. * @param {Number/Mixed} maxDepth (optional) The max depth to
  848. search as a number or element (defaults to 10 || document.body)
  849. * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
  850. * @return {HTMLelement}
  851. */
  852. getTarget : function(selector, maxDepth, returnEl){
  853. return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
  854. },
  855. <span id='Ext-EventObject-method-getRelatedTarget'> /**
  856. </span> * Gets the related target.
  857. * @return {HTMLElement}
  858. */
  859. getRelatedTarget : function(){
  860. return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
  861. },
  862. <span id='Ext-EventObject-method-getWheelDelta'> /**
  863. </span> * Normalizes mouse wheel delta across browsers
  864. * @return {Number} The delta
  865. */
  866. getWheelDelta : function(){
  867. var e = this.browserEvent;
  868. var delta = 0;
  869. if(e.wheelDelta){ /* IE/Opera. */
  870. delta = e.wheelDelta/120;
  871. }else if(e.detail){ /* Mozilla case. */
  872. delta = -e.detail/3;
  873. }
  874. return delta;
  875. },
  876. <span id='Ext-EventObject-method-within'> /**
  877. </span> * 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.
  878. * Example usage:&lt;pre&gt;&lt;code&gt;
  879. // Handle click on any child of an element
  880. Ext.getBody().on('click', function(e){
  881. if(e.within('some-el')){
  882. alert('Clicked on a child of some-el!');
  883. }
  884. });
  885. // Handle click directly on an element, ignoring clicks on child nodes
  886. Ext.getBody().on('click', function(e,t){
  887. if((t.id == 'some-el') &amp;&amp; !e.within(t, true)){
  888. alert('Clicked directly on some-el!');
  889. }
  890. });
  891. &lt;/code&gt;&lt;/pre&gt;
  892. * @param {Mixed} el The id, DOM element or Ext.Element to check
  893. * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
  894. * @param {Boolean} allowEl (optional) true to also check if the passed element is the target or related target
  895. * @return {Boolean}
  896. */
  897. within : function(el, related, allowEl){
  898. if(el){
  899. var t = this[related ? &quot;getRelatedTarget&quot; : &quot;getTarget&quot;]();
  900. return t &amp;&amp; ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
  901. }
  902. return false;
  903. }
  904. };
  905. return new Ext.EventObjectImpl();
  906. }();</pre>
  907. </body>
  908. </html>