Web Interface For Lite Argus Control modules
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.

236 lines
8.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. /**
  16. * @class Ext.util.Observable
  17. */
  18. Ext.apply(Ext.util.Observable.prototype, function(){
  19. // this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)
  20. // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
  21. // private
  22. function getMethodEvent(method){
  23. var e = (this.methodEvents = this.methodEvents ||
  24. {})[method], returnValue, v, cancel, obj = this;
  25. if (!e) {
  26. this.methodEvents[method] = e = {};
  27. e.originalFn = this[method];
  28. e.methodName = method;
  29. e.before = [];
  30. e.after = [];
  31. var makeCall = function(fn, scope, args){
  32. if((v = fn.apply(scope || obj, args)) !== undefined){
  33. if (typeof v == 'object') {
  34. if(v.returnValue !== undefined){
  35. returnValue = v.returnValue;
  36. }else{
  37. returnValue = v;
  38. }
  39. cancel = !!v.cancel;
  40. }
  41. else
  42. if (v === false) {
  43. cancel = true;
  44. }
  45. else {
  46. returnValue = v;
  47. }
  48. }
  49. };
  50. this[method] = function(){
  51. var args = Array.prototype.slice.call(arguments, 0),
  52. b;
  53. returnValue = v = undefined;
  54. cancel = false;
  55. for(var i = 0, len = e.before.length; i < len; i++){
  56. b = e.before[i];
  57. makeCall(b.fn, b.scope, args);
  58. if (cancel) {
  59. return returnValue;
  60. }
  61. }
  62. if((v = e.originalFn.apply(obj, args)) !== undefined){
  63. returnValue = v;
  64. }
  65. for(var i = 0, len = e.after.length; i < len; i++){
  66. b = e.after[i];
  67. makeCall(b.fn, b.scope, args);
  68. if (cancel) {
  69. return returnValue;
  70. }
  71. }
  72. return returnValue;
  73. };
  74. }
  75. return e;
  76. }
  77. return {
  78. // these are considered experimental
  79. // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
  80. // adds an 'interceptor' called before the original method
  81. beforeMethod : function(method, fn, scope){
  82. getMethodEvent.call(this, method).before.push({
  83. fn: fn,
  84. scope: scope
  85. });
  86. },
  87. // adds a 'sequence' called after the original method
  88. afterMethod : function(method, fn, scope){
  89. getMethodEvent.call(this, method).after.push({
  90. fn: fn,
  91. scope: scope
  92. });
  93. },
  94. removeMethodListener: function(method, fn, scope){
  95. var e = this.getMethodEvent(method);
  96. for(var i = 0, len = e.before.length; i < len; i++){
  97. if(e.before[i].fn == fn && e.before[i].scope == scope){
  98. e.before.splice(i, 1);
  99. return;
  100. }
  101. }
  102. for(var i = 0, len = e.after.length; i < len; i++){
  103. if(e.after[i].fn == fn && e.after[i].scope == scope){
  104. e.after.splice(i, 1);
  105. return;
  106. }
  107. }
  108. },
  109. <div id="method-Ext.util.Observable-relayEvents"></div>/**
  110. * Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.
  111. * @param {Object} o The Observable whose events this object is to relay.
  112. * @param {Array} events Array of event names to relay.
  113. */
  114. relayEvents : function(o, events){
  115. var me = this;
  116. function createHandler(ename){
  117. return function(){
  118. return me.fireEvent.apply(me, [ename].concat(Array.prototype.slice.call(arguments, 0)));
  119. };
  120. }
  121. for(var i = 0, len = events.length; i < len; i++){
  122. var ename = events[i];
  123. me.events[ename] = me.events[ename] || true;
  124. o.on(ename, createHandler(ename), me);
  125. }
  126. },
  127. <div id="method-Ext.util.Observable-enableBubble"></div>/**
  128. * <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling
  129. * <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>
  130. * <p>This is commonly used by Ext.Components to bubble events to owner Containers. See {@link Ext.Component.getBubbleTarget}. The default
  131. * implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to
  132. * access the required target more quickly.</p>
  133. * <p>Example:</p><pre><code>
  134. Ext.override(Ext.form.Field, {
  135. // Add functionality to Field&#39;s initComponent to enable the change event to bubble
  136. initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
  137. this.enableBubble('change');
  138. }),
  139. // We know that we want Field&#39;s events to bubble directly to the FormPanel.
  140. getBubbleTarget : function() {
  141. if (!this.formPanel) {
  142. this.formPanel = this.findParentByType('form');
  143. }
  144. return this.formPanel;
  145. }
  146. });
  147. var myForm = new Ext.formPanel({
  148. title: 'User Details',
  149. items: [{
  150. ...
  151. }],
  152. listeners: {
  153. change: function() {
  154. // Title goes red if form has been modified.
  155. myForm.header.setStyle('color', 'red');
  156. }
  157. }
  158. });
  159. </code></pre>
  160. * @param {String/Array} events The event name to bubble, or an Array of event names.
  161. */
  162. enableBubble : function(events){
  163. var me = this;
  164. if(!Ext.isEmpty(events)){
  165. events = Ext.isArray(events) ? events : Array.prototype.slice.call(arguments, 0);
  166. for(var i = 0, len = events.length; i < len; i++){
  167. var ename = events[i];
  168. ename = ename.toLowerCase();
  169. var ce = me.events[ename] || true;
  170. if (typeof ce == 'boolean') {
  171. ce = new Ext.util.Event(me, ename);
  172. me.events[ename] = ce;
  173. }
  174. ce.bubble = true;
  175. }
  176. }
  177. }
  178. };
  179. }());
  180. <div id="method-Ext.util.Observable-Observable.capture"></div>/**
  181. * Starts capture on the specified Observable. All events will be passed
  182. * to the supplied function with the event name + standard signature of the event
  183. * <b>before</b> the event is fired. If the supplied function returns false,
  184. * the event will not fire.
  185. * @param {Observable} o The Observable to capture events from.
  186. * @param {Function} fn The function to call when an event is fired.
  187. * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the Observable firing the event.
  188. * @static
  189. */
  190. Ext.util.Observable.capture = function(o, fn, scope){
  191. o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
  192. };
  193. <div id="method-Ext.util.Observable-Observable.observeClass"></div>/**
  194. * Sets observability on the passed class constructor.<p>
  195. * <p>This makes any event fired on any instance of the passed class also fire a single event through
  196. * the <i>class</i> allowing for central handling of events on many instances at once.</p>
  197. * <p>Usage:</p><pre><code>
  198. Ext.util.Observable.observeClass(Ext.data.Connection);
  199. Ext.data.Connection.on('beforerequest', function(con, options) {
  200. console.log('Ajax request made to ' + options.url);
  201. });</code></pre>
  202. * @param {Function} c The class constructor to make observable.
  203. * @param {Object} listeners An object containing a series of listeners to add. See {@link #addListener}.
  204. * @static
  205. */
  206. Ext.util.Observable.observeClass = function(c, listeners){
  207. if(c){
  208. if(!c.fireEvent){
  209. Ext.apply(c, new Ext.util.Observable());
  210. Ext.util.Observable.capture(c.prototype, c.fireEvent, c);
  211. }
  212. if(typeof listeners == 'object'){
  213. c.on(listeners);
  214. }
  215. return c;
  216. }
  217. };
  218. </pre>
  219. </body>
  220. </html>