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.

538 lines
18 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. (function(){
  16. var EXTUTIL = Ext.util,
  17. EACH = Ext.each,
  18. TRUE = true,
  19. FALSE = false;
  20. <div id="cls-Ext.util.Observable"></div>/**
  21. * @class Ext.util.Observable
  22. * Base class that provides a common interface for publishing events. Subclasses are expected to
  23. * to have a property "events" with all the events defined, and, optionally, a property "listeners"
  24. * with configured listeners defined.<br>
  25. * For example:
  26. * <pre><code>
  27. Employee = Ext.extend(Ext.util.Observable, {
  28. constructor: function(config){
  29. this.name = config.name;
  30. this.addEvents({
  31. "fired" : true,
  32. "quit" : true
  33. });
  34. // Copy configured listeners into *this* object so that the base class&#39;s
  35. // constructor will add them.
  36. this.listeners = config.listeners;
  37. // Call our superclass constructor to complete construction process.
  38. Employee.superclass.constructor.call(this, config)
  39. }
  40. });
  41. </code></pre>
  42. * This could then be used like this:<pre><code>
  43. var newEmployee = new Employee({
  44. name: employeeName,
  45. listeners: {
  46. quit: function() {
  47. // By default, "this" will be the object that fired the event.
  48. alert(this.name + " has quit!");
  49. }
  50. }
  51. });
  52. </code></pre>
  53. */
  54. EXTUTIL.Observable = function(){
  55. <div id="cfg-Ext.util.Observable-listeners"></div>/**
  56. * @cfg {Object} listeners (optional) <p>A config object containing one or more event handlers to be added to this
  57. * object during initialization. This should be a valid listeners config object as specified in the
  58. * {@link #addListener} example for attaching multiple handlers at once.</p>
  59. * <br><p><b><u>DOM events from ExtJs {@link Ext.Component Components}</u></b></p>
  60. * <br><p>While <i>some</i> ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
  61. * is usually only done when extra value can be added. For example the {@link Ext.DataView DataView}'s
  62. * <b><code>{@link Ext.DataView#click click}</code></b> event passing the node clicked on. To access DOM
  63. * events directly from a Component's HTMLElement, listeners must be added to the <i>{@link Ext.Component#getEl Element}</i> after the Component
  64. * has been rendered. A plugin can simplify this step:<pre><code>
  65. // Plugin is configured with a listeners config object.
  66. // The Component is appended to the argument list of all handler functions.
  67. Ext.DomObserver = Ext.extend(Object, {
  68. constructor: function(config) {
  69. this.listeners = config.listeners ? config.listeners : config;
  70. },
  71. // Component passes itself into plugin&#39;s init method
  72. init: function(c) {
  73. var p, l = this.listeners;
  74. for (p in l) {
  75. if (Ext.isFunction(l[p])) {
  76. l[p] = this.createHandler(l[p], c);
  77. } else {
  78. l[p].fn = this.createHandler(l[p].fn, c);
  79. }
  80. }
  81. // Add the listeners to the Element immediately following the render call
  82. c.render = c.render.{@link Function#createSequence createSequence}(function() {
  83. var e = c.getEl();
  84. if (e) {
  85. e.on(l);
  86. }
  87. });
  88. },
  89. createHandler: function(fn, c) {
  90. return function(e) {
  91. fn.call(this, e, c);
  92. };
  93. }
  94. });
  95. var combo = new Ext.form.ComboBox({
  96. // Collapse combo when its element is clicked on
  97. plugins: [ new Ext.DomObserver({
  98. click: function(evt, comp) {
  99. comp.collapse();
  100. }
  101. })],
  102. store: myStore,
  103. typeAhead: true,
  104. mode: 'local',
  105. triggerAction: 'all'
  106. });
  107. * </code></pre></p>
  108. */
  109. var me = this, e = me.events;
  110. if(me.listeners){
  111. me.on(me.listeners);
  112. delete me.listeners;
  113. }
  114. me.events = e || {};
  115. };
  116. EXTUTIL.Observable.prototype = {
  117. // private
  118. filterOptRe : /^(?:scope|delay|buffer|single)$/,
  119. <div id="method-Ext.util.Observable-fireEvent"></div>/**
  120. * <p>Fires the specified event with the passed parameters (minus the event name).</p>
  121. * <p>An event may be set to bubble up an Observable parent hierarchy (See {@link Ext.Component#getBubbleTarget})
  122. * by calling {@link #enableBubble}.</p>
  123. * @param {String} eventName The name of the event to fire.
  124. * @param {Object...} args Variable number of parameters are passed to handlers.
  125. * @return {Boolean} returns false if any of the handlers return false otherwise it returns true.
  126. */
  127. fireEvent : function(){
  128. var a = Array.prototype.slice.call(arguments, 0),
  129. ename = a[0].toLowerCase(),
  130. me = this,
  131. ret = TRUE,
  132. ce = me.events[ename],
  133. cc,
  134. q,
  135. c;
  136. if (me.eventsSuspended === TRUE) {
  137. if (q = me.eventQueue) {
  138. q.push(a);
  139. }
  140. }
  141. else if(typeof ce == 'object') {
  142. if (ce.bubble){
  143. if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
  144. return FALSE;
  145. }
  146. c = me.getBubbleTarget && me.getBubbleTarget();
  147. if(c && c.enableBubble) {
  148. cc = c.events[ename];
  149. if(!cc || typeof cc != 'object' || !cc.bubble) {
  150. c.enableBubble(ename);
  151. }
  152. return c.fireEvent.apply(c, a);
  153. }
  154. }
  155. else {
  156. a.shift();
  157. ret = ce.fire.apply(ce, a);
  158. }
  159. }
  160. return ret;
  161. },
  162. <div id="method-Ext.util.Observable-addListener"></div>/**
  163. * Appends an event handler to this object.
  164. * @param {String} eventName The name of the event to listen for.
  165. * @param {Function} handler The method the event invokes.
  166. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.
  167. * <b>If omitted, defaults to the object which fired the event.</b>
  168. * @param {Object} options (optional) An object containing handler configuration.
  169. * properties. This may contain any of the following properties:<ul>
  170. * <li><b>scope</b> : Object<div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the handler function is executed.
  171. * <b>If omitted, defaults to the object which fired the event.</b></div></li>
  172. * <li><b>delay</b> : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</div></li>
  173. * <li><b>single</b> : 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>
  174. * <li><b>buffer</b> : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
  175. * by the specified number of milliseconds. If the event fires again within that time, the original
  176. * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
  177. * <li><b>target</b> : Observable<div class="sub-desc">Only call the handler if the event was fired on the target Observable, <i>not</i>
  178. * if the event was bubbled up from a child Observable.</div></li>
  179. * </ul><br>
  180. * <p>
  181. * <b>Combining Options</b><br>
  182. * Using the options argument, it is possible to combine different types of listeners:<br>
  183. * <br>
  184. * A delayed, one-time listener.
  185. * <pre><code>
  186. myDataView.on('click', this.onClick, this, {
  187. single: true,
  188. delay: 100
  189. });</code></pre>
  190. * <p>
  191. * <b>Attaching multiple handlers in 1 call</b><br>
  192. * The method also allows for a single argument to be passed which is a config object containing properties
  193. * which specify multiple handlers.
  194. * <p>
  195. * <pre><code>
  196. myGridPanel.on({
  197. 'click' : {
  198. fn: this.onClick,
  199. scope: this,
  200. delay: 100
  201. },
  202. 'mouseover' : {
  203. fn: this.onMouseOver,
  204. scope: this
  205. },
  206. 'mouseout' : {
  207. fn: this.onMouseOut,
  208. scope: this
  209. }
  210. });</code></pre>
  211. * <p>
  212. * Or a shorthand syntax:<br>
  213. * <pre><code>
  214. myGridPanel.on({
  215. 'click' : this.onClick,
  216. 'mouseover' : this.onMouseOver,
  217. 'mouseout' : this.onMouseOut,
  218. scope: this
  219. });</code></pre>
  220. */
  221. addListener : function(eventName, fn, scope, o){
  222. var me = this,
  223. e,
  224. oe,
  225. ce;
  226. if (typeof eventName == 'object') {
  227. o = eventName;
  228. for (e in o) {
  229. oe = o[e];
  230. if (!me.filterOptRe.test(e)) {
  231. me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
  232. }
  233. }
  234. } else {
  235. eventName = eventName.toLowerCase();
  236. ce = me.events[eventName] || TRUE;
  237. if (typeof ce == 'boolean') {
  238. me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
  239. }
  240. ce.addListener(fn, scope, typeof o == 'object' ? o : {});
  241. }
  242. },
  243. <div id="method-Ext.util.Observable-removeListener"></div>/**
  244. * Removes an event handler.
  245. * @param {String} eventName The type of event the handler was associated with.
  246. * @param {Function} handler The handler to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
  247. * @param {Object} scope (optional) The scope originally specified for the handler.
  248. */
  249. removeListener : function(eventName, fn, scope){
  250. var ce = this.events[eventName.toLowerCase()];
  251. if (typeof ce == 'object') {
  252. ce.removeListener(fn, scope);
  253. }
  254. },
  255. <div id="method-Ext.util.Observable-purgeListeners"></div>/**
  256. * Removes all listeners for this object
  257. */
  258. purgeListeners : function(){
  259. var events = this.events,
  260. evt,
  261. key;
  262. for(key in events){
  263. evt = events[key];
  264. if(typeof evt == 'object'){
  265. evt.clearListeners();
  266. }
  267. }
  268. },
  269. <div id="method-Ext.util.Observable-addEvents"></div>/**
  270. * Adds the specified events to the list of events which this Observable may fire.
  271. * @param {Object|String} o Either an object with event names as properties with a value of <code>true</code>
  272. * or the first event name string if multiple event names are being passed as separate parameters.
  273. * @param {string} Optional. Event name if multiple event names are being passed as separate parameters.
  274. * Usage:<pre><code>
  275. this.addEvents('storeloaded', 'storecleared');
  276. </code></pre>
  277. */
  278. addEvents : function(o){
  279. var me = this;
  280. me.events = me.events || {};
  281. if (typeof o == 'string') {
  282. var a = arguments,
  283. i = a.length;
  284. while(i--) {
  285. me.events[a[i]] = me.events[a[i]] || TRUE;
  286. }
  287. } else {
  288. Ext.applyIf(me.events, o);
  289. }
  290. },
  291. <div id="method-Ext.util.Observable-hasListener"></div>/**
  292. * Checks to see if this object has any listeners for a specified event
  293. * @param {String} eventName The name of the event to check for
  294. * @return {Boolean} True if the event is being listened for, else false
  295. */
  296. hasListener : function(eventName){
  297. var e = this.events[eventName.toLowerCase()];
  298. return typeof e == 'object' && e.listeners.length > 0;
  299. },
  300. <div id="method-Ext.util.Observable-suspendEvents"></div>/**
  301. * Suspend the firing of all events. (see {@link #resumeEvents})
  302. * @param {Boolean} queueSuspended Pass as true to queue up suspended events to be fired
  303. * after the {@link #resumeEvents} call instead of discarding all suspended events;
  304. */
  305. suspendEvents : function(queueSuspended){
  306. this.eventsSuspended = TRUE;
  307. if(queueSuspended && !this.eventQueue){
  308. this.eventQueue = [];
  309. }
  310. },
  311. <div id="method-Ext.util.Observable-resumeEvents"></div>/**
  312. * Resume firing events. (see {@link #suspendEvents})
  313. * If events were suspended using the <tt><b>queueSuspended</b></tt> parameter, then all
  314. * events fired during event suspension will be sent to any listeners now.
  315. */
  316. resumeEvents : function(){
  317. var me = this,
  318. queued = me.eventQueue || [];
  319. me.eventsSuspended = FALSE;
  320. delete me.eventQueue;
  321. EACH(queued, function(e) {
  322. me.fireEvent.apply(me, e);
  323. });
  324. }
  325. };
  326. var OBSERVABLE = EXTUTIL.Observable.prototype;
  327. <div id="method-Ext.util.Observable-on"></div>/**
  328. * Appends an event handler to this object (shorthand for {@link #addListener}.)
  329. * @param {String} eventName The type of event to listen for
  330. * @param {Function} handler The method the event invokes
  331. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.
  332. * <b>If omitted, defaults to the object which fired the event.</b>
  333. * @param {Object} options (optional) An object containing handler configuration.
  334. * @method
  335. */
  336. OBSERVABLE.on = OBSERVABLE.addListener;
  337. <div id="method-Ext.util.Observable-un"></div>/**
  338. * Removes an event handler (shorthand for {@link #removeListener}.)
  339. * @param {String} eventName The type of event the handler was associated with.
  340. * @param {Function} handler The handler to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
  341. * @param {Object} scope (optional) The scope originally specified for the handler.
  342. * @method
  343. */
  344. OBSERVABLE.un = OBSERVABLE.removeListener;
  345. <div id="method-Ext.util.Observable-Observable.releaseCapture"></div>/**
  346. * Removes <b>all</b> added captures from the Observable.
  347. * @param {Observable} o The Observable to release
  348. * @static
  349. */
  350. EXTUTIL.Observable.releaseCapture = function(o){
  351. o.fireEvent = OBSERVABLE.fireEvent;
  352. };
  353. function createTargeted(h, o, scope){
  354. return function(){
  355. if(o.target == arguments[0]){
  356. h.apply(scope, Array.prototype.slice.call(arguments, 0));
  357. }
  358. };
  359. };
  360. function createBuffered(h, o, l, scope){
  361. l.task = new EXTUTIL.DelayedTask();
  362. return function(){
  363. l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
  364. };
  365. };
  366. function createSingle(h, e, fn, scope){
  367. return function(){
  368. e.removeListener(fn, scope);
  369. return h.apply(scope, arguments);
  370. };
  371. };
  372. function createDelayed(h, o, l, scope){
  373. return function(){
  374. var task = new EXTUTIL.DelayedTask(),
  375. args = Array.prototype.slice.call(arguments, 0);
  376. if(!l.tasks) {
  377. l.tasks = [];
  378. }
  379. l.tasks.push(task);
  380. task.delay(o.delay || 10, function(){
  381. l.tasks.remove(task);
  382. h.apply(scope, args);
  383. }, scope);
  384. };
  385. };
  386. EXTUTIL.Event = function(obj, name){
  387. this.name = name;
  388. this.obj = obj;
  389. this.listeners = [];
  390. };
  391. EXTUTIL.Event.prototype = {
  392. addListener : function(fn, scope, options){
  393. var me = this,
  394. l;
  395. scope = scope || me.obj;
  396. if(!me.isListening(fn, scope)){
  397. l = me.createListener(fn, scope, options);
  398. if(me.firing){ // if we are currently firing this event, don't disturb the listener loop
  399. me.listeners = me.listeners.slice(0);
  400. }
  401. me.listeners.push(l);
  402. }
  403. },
  404. createListener: function(fn, scope, o){
  405. o = o || {};
  406. scope = scope || this.obj;
  407. var l = {
  408. fn: fn,
  409. scope: scope,
  410. options: o
  411. }, h = fn;
  412. if(o.target){
  413. h = createTargeted(h, o, scope);
  414. }
  415. if(o.delay){
  416. h = createDelayed(h, o, l, scope);
  417. }
  418. if(o.single){
  419. h = createSingle(h, this, fn, scope);
  420. }
  421. if(o.buffer){
  422. h = createBuffered(h, o, l, scope);
  423. }
  424. l.fireFn = h;
  425. return l;
  426. },
  427. findListener : function(fn, scope){
  428. var list = this.listeners,
  429. i = list.length,
  430. l;
  431. scope = scope || this.obj;
  432. while(i--){
  433. l = list[i];
  434. if(l){
  435. if(l.fn == fn && l.scope == scope){
  436. return i;
  437. }
  438. }
  439. }
  440. return -1;
  441. },
  442. isListening : function(fn, scope){
  443. return this.findListener(fn, scope) != -1;
  444. },
  445. removeListener : function(fn, scope){
  446. var index,
  447. l,
  448. k,
  449. me = this,
  450. ret = FALSE;
  451. if((index = me.findListener(fn, scope)) != -1){
  452. if (me.firing) {
  453. me.listeners = me.listeners.slice(0);
  454. }
  455. l = me.listeners[index];
  456. if(l.task) {
  457. l.task.cancel();
  458. delete l.task;
  459. }
  460. k = l.tasks && l.tasks.length;
  461. if(k) {
  462. while(k--) {
  463. l.tasks[k].cancel();
  464. }
  465. delete l.tasks;
  466. }
  467. me.listeners.splice(index, 1);
  468. ret = TRUE;
  469. }
  470. return ret;
  471. },
  472. // Iterate to stop any buffered/delayed events
  473. clearListeners : function(){
  474. var me = this,
  475. l = me.listeners,
  476. i = l.length;
  477. while(i--) {
  478. me.removeListener(l[i].fn, l[i].scope);
  479. }
  480. },
  481. fire : function(){
  482. var me = this,
  483. listeners = me.listeners,
  484. len = listeners.length,
  485. i = 0,
  486. l;
  487. if(len > 0){
  488. me.firing = TRUE;
  489. var args = Array.prototype.slice.call(arguments, 0);
  490. for (; i < len; i++) {
  491. l = listeners[i];
  492. if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
  493. return (me.firing = FALSE);
  494. }
  495. }
  496. }
  497. me.firing = FALSE;
  498. return TRUE;
  499. }
  500. };
  501. })();
  502. </pre>
  503. </body>
  504. </html>