Web UI for ARGUS server
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.

943 lines
36 KiB

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