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.

1796 lines
61 KiB

6 years ago
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. // for old browsers
  8. window.undefined = window.undefined;
  9. /**
  10. * @class Ext
  11. * Ext core utilities and functions.
  12. * @singleton
  13. */
  14. Ext = {
  15. /**
  16. * The version of the framework
  17. * @type String
  18. */
  19. version : '3.3.1',
  20. versionDetail : {
  21. major : 3,
  22. minor : 3,
  23. patch : 1
  24. }
  25. };
  26. /**
  27. * Copies all the properties of config to obj.
  28. * @param {Object} obj The receiver of the properties
  29. * @param {Object} config The source of the properties
  30. * @param {Object} defaults A different object that will also be applied for default values
  31. * @return {Object} returns obj
  32. * @member Ext apply
  33. */
  34. Ext.apply = function(o, c, defaults){
  35. // no "this" reference for friendly out of scope calls
  36. if(defaults){
  37. Ext.apply(o, defaults);
  38. }
  39. if(o && c && typeof c == 'object'){
  40. for(var p in c){
  41. o[p] = c[p];
  42. }
  43. }
  44. return o;
  45. };
  46. (function(){
  47. var idSeed = 0,
  48. toString = Object.prototype.toString,
  49. ua = navigator.userAgent.toLowerCase(),
  50. check = function(r){
  51. return r.test(ua);
  52. },
  53. DOC = document,
  54. docMode = DOC.documentMode,
  55. isStrict = DOC.compatMode == "CSS1Compat",
  56. isOpera = check(/opera/),
  57. isChrome = check(/\bchrome\b/),
  58. isWebKit = check(/webkit/),
  59. isSafari = !isChrome && check(/safari/),
  60. isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
  61. isSafari3 = isSafari && check(/version\/3/),
  62. isSafari4 = isSafari && check(/version\/4/),
  63. isIE = !isOpera && check(/msie/),
  64. isIE7 = isIE && (check(/msie 7/) || docMode == 7),
  65. isIE8 = isIE && (check(/msie 8/) && docMode != 7),
  66. isIE6 = isIE && !isIE7 && !isIE8,
  67. isGecko = !isWebKit && check(/gecko/),
  68. isGecko2 = isGecko && check(/rv:1\.8/),
  69. isGecko3 = isGecko && check(/rv:1\.9/),
  70. isBorderBox = isIE && !isStrict,
  71. isWindows = check(/windows|win32/),
  72. isMac = check(/macintosh|mac os x/),
  73. isAir = check(/adobeair/),
  74. isLinux = check(/linux/),
  75. isSecure = /^https/i.test(window.location.protocol);
  76. // remove css image flicker
  77. if(isIE6){
  78. try{
  79. DOC.execCommand("BackgroundImageCache", false, true);
  80. }catch(e){}
  81. }
  82. Ext.apply(Ext, {
  83. /**
  84. * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
  85. * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
  86. * @type String
  87. */
  88. SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
  89. /**
  90. * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
  91. * @type Boolean
  92. */
  93. isStrict : isStrict,
  94. /**
  95. * True if the page is running over SSL
  96. * @type Boolean
  97. */
  98. isSecure : isSecure,
  99. /**
  100. * True when the document is fully initialized and ready for action
  101. * @type Boolean
  102. */
  103. isReady : false,
  104. /**
  105. * True if the {@link Ext.Fx} Class is available
  106. * @type Boolean
  107. * @property enableFx
  108. */
  109. /**
  110. * HIGHLY EXPERIMENTAL
  111. * True to force css based border-box model override and turning off javascript based adjustments. This is a
  112. * runtime configuration and must be set before onReady.
  113. * @type Boolean
  114. */
  115. enableForcedBoxModel : false,
  116. /**
  117. * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
  118. * @type Boolean
  119. */
  120. enableGarbageCollector : true,
  121. /**
  122. * True to automatically purge event listeners during garbageCollection (defaults to false).
  123. * @type Boolean
  124. */
  125. enableListenerCollection : false,
  126. /**
  127. * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
  128. * Currently not optimized for performance.
  129. * @type Boolean
  130. */
  131. enableNestedListenerRemoval : false,
  132. /**
  133. * Indicates whether to use native browser parsing for JSON methods.
  134. * This option is ignored if the browser does not support native JSON methods.
  135. * <b>Note: Native JSON methods will not work with objects that have functions.
  136. * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
  137. * @type Boolean
  138. */
  139. USE_NATIVE_JSON : false,
  140. /**
  141. * Copies all the properties of config to obj if they don't already exist.
  142. * @param {Object} obj The receiver of the properties
  143. * @param {Object} config The source of the properties
  144. * @return {Object} returns obj
  145. */
  146. applyIf : function(o, c){
  147. if(o){
  148. for(var p in c){
  149. if(!Ext.isDefined(o[p])){
  150. o[p] = c[p];
  151. }
  152. }
  153. }
  154. return o;
  155. },
  156. /**
  157. * Generates unique ids. If the element already has an id, it is unchanged
  158. * @param {Mixed} el (optional) The element to generate an id for
  159. * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
  160. * @return {String} The generated Id.
  161. */
  162. id : function(el, prefix){
  163. el = Ext.getDom(el, true) || {};
  164. if (!el.id) {
  165. el.id = (prefix || "ext-gen") + (++idSeed);
  166. }
  167. return el.id;
  168. },
  169. /**
  170. * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
  171. * also adds the function "override()" to the subclass that can be used to override members of the class.</p>
  172. * For example, to create a subclass of Ext GridPanel:
  173. * <pre><code>
  174. MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
  175. constructor: function(config) {
  176. // Create configuration for this Grid.
  177. var store = new Ext.data.Store({...});
  178. var colModel = new Ext.grid.ColumnModel({...});
  179. // Create a new config object containing our computed properties
  180. // *plus* whatever was in the config parameter.
  181. config = Ext.apply({
  182. store: store,
  183. colModel: colModel
  184. }, config);
  185. MyGridPanel.superclass.constructor.call(this, config);
  186. // Your postprocessing here
  187. },
  188. yourMethod: function() {
  189. // etc.
  190. }
  191. });
  192. </code></pre>
  193. *
  194. * <p>This function also supports a 3-argument call in which the subclass's constructor is
  195. * passed as an argument. In this form, the parameters are as follows:</p>
  196. * <div class="mdetail-params"><ul>
  197. * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
  198. * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
  199. * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
  200. * prototype, and are therefore shared among all instances of the new class.</div></li>
  201. * </ul></div>
  202. *
  203. * @param {Function} superclass The constructor of class being extended.
  204. * @param {Object} overrides <p>A literal with members which are copied into the subclass's
  205. * prototype, and are therefore shared between all instances of the new class.</p>
  206. * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
  207. * to define the constructor of the new class, and is returned. If this property is
  208. * <i>not</i> specified, a constructor is generated and returned which just calls the
  209. * superclass's constructor passing on its parameters.</p>
  210. * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
  211. * @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
  212. */
  213. extend : function(){
  214. // inline overrides
  215. var io = function(o){
  216. for(var m in o){
  217. this[m] = o[m];
  218. }
  219. };
  220. var oc = Object.prototype.constructor;
  221. return function(sb, sp, overrides){
  222. if(typeof sp == 'object'){
  223. overrides = sp;
  224. sp = sb;
  225. sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
  226. }
  227. var F = function(){},
  228. sbp,
  229. spp = sp.prototype;
  230. F.prototype = spp;
  231. sbp = sb.prototype = new F();
  232. sbp.constructor=sb;
  233. sb.superclass=spp;
  234. if(spp.constructor == oc){
  235. spp.constructor=sp;
  236. }
  237. sb.override = function(o){
  238. Ext.override(sb, o);
  239. };
  240. sbp.superclass = sbp.supr = (function(){
  241. return spp;
  242. });
  243. sbp.override = io;
  244. Ext.override(sb, overrides);
  245. sb.extend = function(o){return Ext.extend(sb, o);};
  246. return sb;
  247. };
  248. }(),
  249. /**
  250. * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
  251. * Usage:<pre><code>
  252. Ext.override(MyClass, {
  253. newMethod1: function(){
  254. // etc.
  255. },
  256. newMethod2: function(foo){
  257. // etc.
  258. }
  259. });
  260. </code></pre>
  261. * @param {Object} origclass The class to override
  262. * @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
  263. * containing one or more methods.
  264. * @method override
  265. */
  266. override : function(origclass, overrides){
  267. if(overrides){
  268. var p = origclass.prototype;
  269. Ext.apply(p, overrides);
  270. if(Ext.isIE && overrides.hasOwnProperty('toString')){
  271. p.toString = overrides.toString;
  272. }
  273. }
  274. },
  275. /**
  276. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  277. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  278. * <pre><code>
  279. Ext.namespace('Company', 'Company.data');
  280. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  281. Company.Widget = function() { ... }
  282. Company.data.CustomStore = function(config) { ... }
  283. </code></pre>
  284. * @param {String} namespace1
  285. * @param {String} namespace2
  286. * @param {String} etc
  287. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  288. * @method namespace
  289. */
  290. namespace : function(){
  291. var o, d;
  292. Ext.each(arguments, function(v) {
  293. d = v.split(".");
  294. o = window[d[0]] = window[d[0]] || {};
  295. Ext.each(d.slice(1), function(v2){
  296. o = o[v2] = o[v2] || {};
  297. });
  298. });
  299. return o;
  300. },
  301. /**
  302. * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
  303. * @param {Object} o
  304. * @param {String} pre (optional) A prefix to add to the url encoded string
  305. * @return {String}
  306. */
  307. urlEncode : function(o, pre){
  308. var empty,
  309. buf = [],
  310. e = encodeURIComponent;
  311. Ext.iterate(o, function(key, item){
  312. empty = Ext.isEmpty(item);
  313. Ext.each(empty ? key : item, function(val){
  314. buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
  315. });
  316. });
  317. if(!pre){
  318. buf.shift();
  319. pre = '';
  320. }
  321. return pre + buf.join('');
  322. },
  323. /**
  324. * Takes an encoded URL and and converts it to an object. Example: <pre><code>
  325. Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
  326. Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
  327. </code></pre>
  328. * @param {String} string
  329. * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
  330. * @return {Object} A literal with members
  331. */
  332. urlDecode : function(string, overwrite){
  333. if(Ext.isEmpty(string)){
  334. return {};
  335. }
  336. var obj = {},
  337. pairs = string.split('&'),
  338. d = decodeURIComponent,
  339. name,
  340. value;
  341. Ext.each(pairs, function(pair) {
  342. pair = pair.split('=');
  343. name = d(pair[0]);
  344. value = d(pair[1]);
  345. obj[name] = overwrite || !obj[name] ? value :
  346. [].concat(obj[name]).concat(value);
  347. });
  348. return obj;
  349. },
  350. /**
  351. * Appends content to the query string of a URL, handling logic for whether to place
  352. * a question mark or ampersand.
  353. * @param {String} url The URL to append to.
  354. * @param {String} s The content to append to the URL.
  355. * @return (String) The resulting URL
  356. */
  357. urlAppend : function(url, s){
  358. if(!Ext.isEmpty(s)){
  359. return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
  360. }
  361. return url;
  362. },
  363. /**
  364. * Converts any iterable (numeric indices and a length property) into a true array
  365. * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
  366. * For strings, use this instead: "abc".match(/./g) => [a,b,c];
  367. * @param {Iterable} the iterable object to be turned into a true Array.
  368. * @return (Array) array
  369. */
  370. toArray : function(){
  371. return isIE ?
  372. function(a, i, j, res){
  373. res = [];
  374. for(var x = 0, len = a.length; x < len; x++) {
  375. res.push(a[x]);
  376. }
  377. return res.slice(i || 0, j || res.length);
  378. } :
  379. function(a, i, j){
  380. return Array.prototype.slice.call(a, i || 0, j || a.length);
  381. };
  382. }(),
  383. isIterable : function(v){
  384. //check for array or arguments
  385. if(Ext.isArray(v) || v.callee){
  386. return true;
  387. }
  388. //check for node list type
  389. if(/NodeList|HTMLCollection/.test(toString.call(v))){
  390. return true;
  391. }
  392. //NodeList has an item and length property
  393. //IXMLDOMNodeList has nextNode method, needs to be checked first.
  394. return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
  395. },
  396. /**
  397. * Iterates an array calling the supplied function.
  398. * @param {Array/NodeList/Mixed} array The array to be iterated. If this
  399. * argument is not really an array, the supplied function is called once.
  400. * @param {Function} fn The function to be called with each item. If the
  401. * supplied function returns false, iteration stops and this method returns
  402. * the current <code>index</code>. This function is called with
  403. * the following arguments:
  404. * <div class="mdetail-params"><ul>
  405. * <li><code>item</code> : <i>Mixed</i>
  406. * <div class="sub-desc">The item at the current <code>index</code>
  407. * in the passed <code>array</code></div></li>
  408. * <li><code>index</code> : <i>Number</i>
  409. * <div class="sub-desc">The current index within the array</div></li>
  410. * <li><code>allItems</code> : <i>Array</i>
  411. * <div class="sub-desc">The <code>array</code> passed as the first
  412. * argument to <code>Ext.each</code>.</div></li>
  413. * </ul></div>
  414. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
  415. * Defaults to the <code>item</code> at the current <code>index</code>
  416. * within the passed <code>array</code>.
  417. * @return See description for the fn parameter.
  418. */
  419. each : function(array, fn, scope){
  420. if(Ext.isEmpty(array, true)){
  421. return;
  422. }
  423. if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
  424. array = [array];
  425. }
  426. for(var i = 0, len = array.length; i < len; i++){
  427. if(fn.call(scope || array[i], array[i], i, array) === false){
  428. return i;
  429. };
  430. }
  431. },
  432. /**
  433. * Iterates either the elements in an array, or each of the properties in an object.
  434. * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
  435. * @param {Object/Array} object The object or array to be iterated
  436. * @param {Function} fn The function to be called for each iteration.
  437. * The iteration will stop if the supplied function returns false, or
  438. * all array elements / object properties have been covered. The signature
  439. * varies depending on the type of object being interated:
  440. * <div class="mdetail-params"><ul>
  441. * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
  442. * <div class="sub-desc">
  443. * When iterating an array, the supplied function is called with each item.</div></li>
  444. * <li>Objects : <tt>(String key, Object value, Object)</tt>
  445. * <div class="sub-desc">
  446. * When iterating an object, the supplied function is called with each key-value pair in
  447. * the object, and the iterated object</div></li>
  448. * </ul></div>
  449. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
  450. * the <code>object</code> being iterated.
  451. */
  452. iterate : function(obj, fn, scope){
  453. if(Ext.isEmpty(obj)){
  454. return;
  455. }
  456. if(Ext.isIterable(obj)){
  457. Ext.each(obj, fn, scope);
  458. return;
  459. }else if(typeof obj == 'object'){
  460. for(var prop in obj){
  461. if(obj.hasOwnProperty(prop)){
  462. if(fn.call(scope || obj, prop, obj[prop], obj) === false){
  463. return;
  464. };
  465. }
  466. }
  467. }
  468. },
  469. /**
  470. * Return the dom node for the passed String (id), dom node, or Ext.Element.
  471. * Optional 'strict' flag is needed for IE since it can return 'name' and
  472. * 'id' elements by using getElementById.
  473. * Here are some examples:
  474. * <pre><code>
  475. // gets dom node based on id
  476. var elDom = Ext.getDom('elId');
  477. // gets dom node based on the dom node
  478. var elDom1 = Ext.getDom(elDom);
  479. // If we don&#39;t know if we are working with an
  480. // Ext.Element or a dom node use Ext.getDom
  481. function(el){
  482. var dom = Ext.getDom(el);
  483. // do something with the dom node
  484. }
  485. * </code></pre>
  486. * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
  487. * when this method is called to be successful.
  488. * @param {Mixed} el
  489. * @return HTMLElement
  490. */
  491. getDom : function(el, strict){
  492. if(!el || !DOC){
  493. return null;
  494. }
  495. if (el.dom){
  496. return el.dom;
  497. } else {
  498. if (typeof el == 'string') {
  499. var e = DOC.getElementById(el);
  500. // IE returns elements with the 'name' and 'id' attribute.
  501. // we do a strict check to return the element with only the id attribute
  502. if (e && isIE && strict) {
  503. if (el == e.getAttribute('id')) {
  504. return e;
  505. } else {
  506. return null;
  507. }
  508. }
  509. return e;
  510. } else {
  511. return el;
  512. }
  513. }
  514. },
  515. /**
  516. * Returns the current document body as an {@link Ext.Element}.
  517. * @return Ext.Element The document body
  518. */
  519. getBody : function(){
  520. return Ext.get(DOC.body || DOC.documentElement);
  521. },
  522. /**
  523. * Returns the current document body as an {@link Ext.Element}.
  524. * @return Ext.Element The document body
  525. */
  526. getHead : function() {
  527. var head;
  528. return function() {
  529. if (head == undefined) {
  530. head = Ext.get(DOC.getElementsByTagName("head")[0]);
  531. }
  532. return head;
  533. };
  534. }(),
  535. /**
  536. * Removes a DOM node from the document.
  537. */
  538. /**
  539. * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
  540. * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
  541. * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
  542. * will be ignored if passed in.</p>
  543. * @param {HTMLElement} node The node to remove
  544. */
  545. removeNode : isIE && !isIE8 ? function(){
  546. var d;
  547. return function(n){
  548. if(n && n.tagName != 'BODY'){
  549. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  550. d = d || DOC.createElement('div');
  551. d.appendChild(n);
  552. d.innerHTML = '';
  553. delete Ext.elCache[n.id];
  554. }
  555. };
  556. }() : function(n){
  557. if(n && n.parentNode && n.tagName != 'BODY'){
  558. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  559. n.parentNode.removeChild(n);
  560. delete Ext.elCache[n.id];
  561. }
  562. },
  563. /**
  564. * <p>Returns true if the passed value is empty.</p>
  565. * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
  566. * <li>null</li>
  567. * <li>undefined</li>
  568. * <li>an empty array</li>
  569. * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
  570. * </ul></div>
  571. * @param {Mixed} value The value to test
  572. * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
  573. * @return {Boolean}
  574. */
  575. isEmpty : function(v, allowBlank){
  576. return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
  577. },
  578. /**
  579. * Returns true if the passed value is a JavaScript array, otherwise false.
  580. * @param {Mixed} value The value to test
  581. * @return {Boolean}
  582. */
  583. isArray : function(v){
  584. return toString.apply(v) === '[object Array]';
  585. },
  586. /**
  587. * Returns true if the passed object is a JavaScript date object, otherwise false.
  588. * @param {Object} object The object to test
  589. * @return {Boolean}
  590. */
  591. isDate : function(v){
  592. return toString.apply(v) === '[object Date]';
  593. },
  594. /**
  595. * Returns true if the passed value is a JavaScript Object, otherwise false.
  596. * @param {Mixed} value The value to test
  597. * @return {Boolean}
  598. */
  599. isObject : function(v){
  600. return !!v && Object.prototype.toString.call(v) === '[object Object]';
  601. },
  602. /**
  603. * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
  604. * @param {Mixed} value The value to test
  605. * @return {Boolean}
  606. */
  607. isPrimitive : function(v){
  608. return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
  609. },
  610. /**
  611. * Returns true if the passed value is a JavaScript Function, otherwise false.
  612. * @param {Mixed} value The value to test
  613. * @return {Boolean}
  614. */
  615. isFunction : function(v){
  616. return toString.apply(v) === '[object Function]';
  617. },
  618. /**
  619. * Returns true if the passed value is a number. Returns false for non-finite numbers.
  620. * @param {Mixed} value The value to test
  621. * @return {Boolean}
  622. */
  623. isNumber : function(v){
  624. return typeof v === 'number' && isFinite(v);
  625. },
  626. /**
  627. * Returns true if the passed value is a string.
  628. * @param {Mixed} value The value to test
  629. * @return {Boolean}
  630. */
  631. isString : function(v){
  632. return typeof v === 'string';
  633. },
  634. /**
  635. * Returns true if the passed value is a boolean.
  636. * @param {Mixed} value The value to test
  637. * @return {Boolean}
  638. */
  639. isBoolean : function(v){
  640. return typeof v === 'boolean';
  641. },
  642. /**
  643. * Returns true if the passed value is an HTMLElement
  644. * @param {Mixed} value The value to test
  645. * @return {Boolean}
  646. */
  647. isElement : function(v) {
  648. return v ? !!v.tagName : false;
  649. },
  650. /**
  651. * Returns true if the passed value is not undefined.
  652. * @param {Mixed} value The value to test
  653. * @return {Boolean}
  654. */
  655. isDefined : function(v){
  656. return typeof v !== 'undefined';
  657. },
  658. /**
  659. * True if the detected browser is Opera.
  660. * @type Boolean
  661. */
  662. isOpera : isOpera,
  663. /**
  664. * True if the detected browser uses WebKit.
  665. * @type Boolean
  666. */
  667. isWebKit : isWebKit,
  668. /**
  669. * True if the detected browser is Chrome.
  670. * @type Boolean
  671. */
  672. isChrome : isChrome,
  673. /**
  674. * True if the detected browser is Safari.
  675. * @type Boolean
  676. */
  677. isSafari : isSafari,
  678. /**
  679. * True if the detected browser is Safari 3.x.
  680. * @type Boolean
  681. */
  682. isSafari3 : isSafari3,
  683. /**
  684. * True if the detected browser is Safari 4.x.
  685. * @type Boolean
  686. */
  687. isSafari4 : isSafari4,
  688. /**
  689. * True if the detected browser is Safari 2.x.
  690. * @type Boolean
  691. */
  692. isSafari2 : isSafari2,
  693. /**
  694. * True if the detected browser is Internet Explorer.
  695. * @type Boolean
  696. */
  697. isIE : isIE,
  698. /**
  699. * True if the detected browser is Internet Explorer 6.x.
  700. * @type Boolean
  701. */
  702. isIE6 : isIE6,
  703. /**
  704. * True if the detected browser is Internet Explorer 7.x.
  705. * @type Boolean
  706. */
  707. isIE7 : isIE7,
  708. /**
  709. * True if the detected browser is Internet Explorer 8.x.
  710. * @type Boolean
  711. */
  712. isIE8 : isIE8,
  713. /**
  714. * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
  715. * @type Boolean
  716. */
  717. isGecko : isGecko,
  718. /**
  719. * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
  720. * @type Boolean
  721. */
  722. isGecko2 : isGecko2,
  723. /**
  724. * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
  725. * @type Boolean
  726. */
  727. isGecko3 : isGecko3,
  728. /**
  729. * True if the detected browser is Internet Explorer running in non-strict mode.
  730. * @type Boolean
  731. */
  732. isBorderBox : isBorderBox,
  733. /**
  734. * True if the detected platform is Linux.
  735. * @type Boolean
  736. */
  737. isLinux : isLinux,
  738. /**
  739. * True if the detected platform is Windows.
  740. * @type Boolean
  741. */
  742. isWindows : isWindows,
  743. /**
  744. * True if the detected platform is Mac OS.
  745. * @type Boolean
  746. */
  747. isMac : isMac,
  748. /**
  749. * True if the detected platform is Adobe Air.
  750. * @type Boolean
  751. */
  752. isAir : isAir
  753. });
  754. /**
  755. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  756. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  757. * <pre><code>
  758. Ext.namespace('Company', 'Company.data');
  759. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  760. Company.Widget = function() { ... }
  761. Company.data.CustomStore = function(config) { ... }
  762. </code></pre>
  763. * @param {String} namespace1
  764. * @param {String} namespace2
  765. * @param {String} etc
  766. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  767. * @method ns
  768. */
  769. Ext.ns = Ext.namespace;
  770. })();
  771. Ext.ns('Ext.util', 'Ext.lib', 'Ext.data', 'Ext.supports');
  772. Ext.elCache = {};
  773. /**
  774. * @class Function
  775. * These functions are available on every Function object (any JavaScript function).
  776. */
  777. Ext.apply(Function.prototype, {
  778. /**
  779. * Creates an interceptor function. The passed function is called before the original one. If it returns false,
  780. * the original one is not called. The resulting function returns the results of the original function.
  781. * The passed function is called with the parameters of the original function. Example usage:
  782. * <pre><code>
  783. var sayHi = function(name){
  784. alert('Hi, ' + name);
  785. }
  786. sayHi('Fred'); // alerts "Hi, Fred"
  787. // create a new function that validates input without
  788. // directly modifying the original function:
  789. var sayHiToFriend = sayHi.createInterceptor(function(name){
  790. return name == 'Brian';
  791. });
  792. sayHiToFriend('Fred'); // no alert
  793. sayHiToFriend('Brian'); // alerts "Hi, Brian"
  794. </code></pre>
  795. * @param {Function} fcn The function to call before the original
  796. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  797. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  798. * @return {Function} The new function
  799. */
  800. createInterceptor : function(fcn, scope){
  801. var method = this;
  802. return !Ext.isFunction(fcn) ?
  803. this :
  804. function() {
  805. var me = this,
  806. args = arguments;
  807. fcn.target = me;
  808. fcn.method = method;
  809. return (fcn.apply(scope || me || window, args) !== false) ?
  810. method.apply(me || window, args) :
  811. null;
  812. };
  813. },
  814. /**
  815. * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
  816. * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
  817. * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
  818. * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
  819. * executes in the window scope.
  820. * <p>This method is required when you want to pass arguments to a callback function. If no arguments
  821. * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
  822. * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
  823. * would simply execute immediately when the code is parsed. Example usage:
  824. * <pre><code>
  825. var sayHi = function(name){
  826. alert('Hi, ' + name);
  827. }
  828. // clicking the button alerts "Hi, Fred"
  829. new Ext.Button({
  830. text: 'Say Hi',
  831. renderTo: Ext.getBody(),
  832. handler: sayHi.createCallback('Fred')
  833. });
  834. </code></pre>
  835. * @return {Function} The new function
  836. */
  837. createCallback : function(/*args...*/){
  838. // make args available, in function below
  839. var args = arguments,
  840. method = this;
  841. return function() {
  842. return method.apply(window, args);
  843. };
  844. },
  845. /**
  846. * Creates a delegate (callback) that sets the scope to obj.
  847. * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
  848. * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
  849. * callback points to obj. Example usage:
  850. * <pre><code>
  851. var sayHi = function(name){
  852. // Note this use of "this.text" here. This function expects to
  853. // execute within a scope that contains a text property. In this
  854. // example, the "this" variable is pointing to the btn object that
  855. // was passed in createDelegate below.
  856. alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
  857. }
  858. var btn = new Ext.Button({
  859. text: 'Say Hi',
  860. renderTo: Ext.getBody()
  861. });
  862. // This callback will execute in the scope of the
  863. // button instance. Clicking the button alerts
  864. // "Hi, Fred. You clicked the "Say Hi" button."
  865. btn.on('click', sayHi.createDelegate(btn, ['Fred']));
  866. </code></pre>
  867. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  868. * <b>If omitted, defaults to the browser window.</b>
  869. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  870. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  871. * if a number the args are inserted at the specified position
  872. * @return {Function} The new function
  873. */
  874. createDelegate : function(obj, args, appendArgs){
  875. var method = this;
  876. return function() {
  877. var callArgs = args || arguments;
  878. if (appendArgs === true){
  879. callArgs = Array.prototype.slice.call(arguments, 0);
  880. callArgs = callArgs.concat(args);
  881. }else if (Ext.isNumber(appendArgs)){
  882. callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
  883. var applyArgs = [appendArgs, 0].concat(args); // create method call params
  884. Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
  885. }
  886. return method.apply(obj || window, callArgs);
  887. };
  888. },
  889. /**
  890. * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
  891. * <pre><code>
  892. var sayHi = function(name){
  893. alert('Hi, ' + name);
  894. }
  895. // executes immediately:
  896. sayHi('Fred');
  897. // executes after 2 seconds:
  898. sayHi.defer(2000, this, ['Fred']);
  899. // this syntax is sometimes useful for deferring
  900. // execution of an anonymous function:
  901. (function(){
  902. alert('Anonymous');
  903. }).defer(100);
  904. </code></pre>
  905. * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
  906. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  907. * <b>If omitted, defaults to the browser window.</b>
  908. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  909. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  910. * if a number the args are inserted at the specified position
  911. * @return {Number} The timeout id that can be used with clearTimeout
  912. */
  913. defer : function(millis, obj, args, appendArgs){
  914. var fn = this.createDelegate(obj, args, appendArgs);
  915. if(millis > 0){
  916. return setTimeout(fn, millis);
  917. }
  918. fn();
  919. return 0;
  920. }
  921. });
  922. /**
  923. * @class String
  924. * These functions are available on every String object.
  925. */
  926. Ext.applyIf(String, {
  927. /**
  928. * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
  929. * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
  930. * <pre><code>
  931. var cls = 'my-class', text = 'Some text';
  932. var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
  933. // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
  934. * </code></pre>
  935. * @param {String} string The tokenized string to be formatted
  936. * @param {String} value1 The value to replace token {0}
  937. * @param {String} value2 Etc...
  938. * @return {String} The formatted string
  939. * @static
  940. */
  941. format : function(format){
  942. var args = Ext.toArray(arguments, 1);
  943. return format.replace(/\{(\d+)\}/g, function(m, i){
  944. return args[i];
  945. });
  946. }
  947. });
  948. /**
  949. * @class Array
  950. */
  951. Ext.applyIf(Array.prototype, {
  952. /**
  953. * Checks whether or not the specified object exists in the array.
  954. * @param {Object} o The object to check for
  955. * @param {Number} from (Optional) The index at which to begin the search
  956. * @return {Number} The index of o in the array (or -1 if it is not found)
  957. */
  958. indexOf : function(o, from){
  959. var len = this.length;
  960. from = from || 0;
  961. from += (from < 0) ? len : 0;
  962. for (; from < len; ++from){
  963. if(this[from] === o){
  964. return from;
  965. }
  966. }
  967. return -1;
  968. },
  969. /**
  970. * Removes the specified object from the array. If the object is not found nothing happens.
  971. * @param {Object} o The object to remove
  972. * @return {Array} this array
  973. */
  974. remove : function(o){
  975. var index = this.indexOf(o);
  976. if(index != -1){
  977. this.splice(index, 1);
  978. }
  979. return this;
  980. }
  981. });
  982. /**
  983. * @class Ext.util.TaskRunner
  984. * Provides the ability to execute one or more arbitrary tasks in a multithreaded
  985. * manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
  986. * if needed, you can create separate instances of TaskRunner. Any number of
  987. * separate tasks can be started at any time and will run independently of each
  988. * other. Example usage:
  989. * <pre><code>
  990. // Start a simple clock task that updates a div once per second
  991. var updateClock = function(){
  992. Ext.fly('clock').update(new Date().format('g:i:s A'));
  993. }
  994. var task = {
  995. run: updateClock,
  996. interval: 1000 //1 second
  997. }
  998. var runner = new Ext.util.TaskRunner();
  999. runner.start(task);
  1000. // equivalent using TaskMgr
  1001. Ext.TaskMgr.start({
  1002. run: updateClock,
  1003. interval: 1000
  1004. });
  1005. * </code></pre>
  1006. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1007. * Also see {@link Ext.util.DelayedTask}.
  1008. *
  1009. * @constructor
  1010. * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
  1011. * (defaults to 10)
  1012. */
  1013. Ext.util.TaskRunner = function(interval){
  1014. interval = interval || 10;
  1015. var tasks = [],
  1016. removeQueue = [],
  1017. id = 0,
  1018. running = false,
  1019. // private
  1020. stopThread = function(){
  1021. running = false;
  1022. clearInterval(id);
  1023. id = 0;
  1024. },
  1025. // private
  1026. startThread = function(){
  1027. if(!running){
  1028. running = true;
  1029. id = setInterval(runTasks, interval);
  1030. }
  1031. },
  1032. // private
  1033. removeTask = function(t){
  1034. removeQueue.push(t);
  1035. if(t.onStop){
  1036. t.onStop.apply(t.scope || t);
  1037. }
  1038. },
  1039. // private
  1040. runTasks = function(){
  1041. var rqLen = removeQueue.length,
  1042. now = new Date().getTime();
  1043. if(rqLen > 0){
  1044. for(var i = 0; i < rqLen; i++){
  1045. tasks.remove(removeQueue[i]);
  1046. }
  1047. removeQueue = [];
  1048. if(tasks.length < 1){
  1049. stopThread();
  1050. return;
  1051. }
  1052. }
  1053. for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){
  1054. t = tasks[i];
  1055. itime = now - t.taskRunTime;
  1056. if(t.interval <= itime){
  1057. rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
  1058. t.taskRunTime = now;
  1059. if(rt === false || t.taskRunCount === t.repeat){
  1060. removeTask(t);
  1061. return;
  1062. }
  1063. }
  1064. if(t.duration && t.duration <= (now - t.taskStartTime)){
  1065. removeTask(t);
  1066. }
  1067. }
  1068. };
  1069. /**
  1070. * Starts a new task.
  1071. * @method start
  1072. * @param {Object} task <p>A config object that supports the following properties:<ul>
  1073. * <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
  1074. * function will be called at each interval and passed the <code>args</code> argument if specified, and the
  1075. * current invocation count if not.</p>
  1076. * <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
  1077. * <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
  1078. * <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
  1079. * should be invoked.</div></li>
  1080. * <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
  1081. * specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
  1082. * <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
  1083. * <code>run</code> function. Defaults to the task config object.</div></li>
  1084. * <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
  1085. * the task before stopping automatically (defaults to indefinite).</div></li>
  1086. * <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
  1087. * stopping automatically (defaults to indefinite).</div></li>
  1088. * </ul></p>
  1089. * <p>Before each invocation, Ext injects the property <code>taskRunCount</code> into the task object so
  1090. * that calculations based on the repeat count can be performed.</p>
  1091. * @return {Object} The task
  1092. */
  1093. this.start = function(task){
  1094. tasks.push(task);
  1095. task.taskStartTime = new Date().getTime();
  1096. task.taskRunTime = 0;
  1097. task.taskRunCount = 0;
  1098. startThread();
  1099. return task;
  1100. };
  1101. /**
  1102. * Stops an existing running task.
  1103. * @method stop
  1104. * @param {Object} task The task to stop
  1105. * @return {Object} The task
  1106. */
  1107. this.stop = function(task){
  1108. removeTask(task);
  1109. return task;
  1110. };
  1111. /**
  1112. * Stops all tasks that are currently running.
  1113. * @method stopAll
  1114. */
  1115. this.stopAll = function(){
  1116. stopThread();
  1117. for(var i = 0, len = tasks.length; i < len; i++){
  1118. if(tasks[i].onStop){
  1119. tasks[i].onStop();
  1120. }
  1121. }
  1122. tasks = [];
  1123. removeQueue = [];
  1124. };
  1125. };
  1126. /**
  1127. * @class Ext.TaskMgr
  1128. * @extends Ext.util.TaskRunner
  1129. * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop arbitrary tasks. See
  1130. * {@link Ext.util.TaskRunner} for supported methods and task config properties.
  1131. * <pre><code>
  1132. // Start a simple clock task that updates a div once per second
  1133. var task = {
  1134. run: function(){
  1135. Ext.fly('clock').update(new Date().format('g:i:s A'));
  1136. },
  1137. interval: 1000 //1 second
  1138. }
  1139. Ext.TaskMgr.start(task);
  1140. </code></pre>
  1141. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1142. * @singleton
  1143. */
  1144. Ext.TaskMgr = new Ext.util.TaskRunner();if(typeof jQuery == "undefined"){
  1145. throw "Unable to load Ext, jQuery not found.";
  1146. }
  1147. (function(){
  1148. var libFlyweight;
  1149. Ext.lib.Dom = {
  1150. getViewWidth : function(full){
  1151. // jQuery doesn't report full window size on document query, so max both
  1152. return full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
  1153. },
  1154. getViewHeight : function(full){
  1155. // jQuery doesn't report full window size on document query, so max both
  1156. return full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
  1157. },
  1158. isAncestor : function(p, c){
  1159. var ret = false;
  1160. p = Ext.getDom(p);
  1161. c = Ext.getDom(c);
  1162. if (p && c) {
  1163. if (p.contains) {
  1164. return p.contains(c);
  1165. } else if (p.compareDocumentPosition) {
  1166. return !!(p.compareDocumentPosition(c) & 16);
  1167. } else {
  1168. while (c = c.parentNode) {
  1169. ret = c == p || ret;
  1170. }
  1171. }
  1172. }
  1173. return ret;
  1174. },
  1175. getRegion : function(el){
  1176. return Ext.lib.Region.getRegion(el);
  1177. },
  1178. //////////////////////////////////////////////////////////////////////////////////////
  1179. // Use of jQuery.offset() removed to promote consistent behavior across libs.
  1180. // JVS 05/23/07
  1181. //////////////////////////////////////////////////////////////////////////////////////
  1182. getY : function(el){
  1183. return this.getXY(el)[1];
  1184. },
  1185. getX : function(el){
  1186. return this.getXY(el)[0];
  1187. },
  1188. getXY : function(el) {
  1189. var p, pe, b, scroll, bd = (document.body || document.documentElement);
  1190. el = Ext.getDom(el);
  1191. if(el == bd){
  1192. return [0, 0];
  1193. }
  1194. if (el.getBoundingClientRect) {
  1195. b = el.getBoundingClientRect();
  1196. scroll = fly(document).getScroll();
  1197. return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
  1198. }
  1199. var x = 0, y = 0;
  1200. p = el;
  1201. var hasAbsolute = fly(el).getStyle("position") == "absolute";
  1202. while (p) {
  1203. x += p.offsetLeft;
  1204. y += p.offsetTop;
  1205. if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
  1206. hasAbsolute = true;
  1207. }
  1208. if (Ext.isGecko) {
  1209. pe = fly(p);
  1210. var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
  1211. var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
  1212. x += bl;
  1213. y += bt;
  1214. if (p != el && pe.getStyle('overflow') != 'visible') {
  1215. x += bl;
  1216. y += bt;
  1217. }
  1218. }
  1219. p = p.offsetParent;
  1220. }
  1221. if (Ext.isSafari && hasAbsolute) {
  1222. x -= bd.offsetLeft;
  1223. y -= bd.offsetTop;
  1224. }
  1225. if (Ext.isGecko && !hasAbsolute) {
  1226. var dbd = fly(bd);
  1227. x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
  1228. y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
  1229. }
  1230. p = el.parentNode;
  1231. while (p && p != bd) {
  1232. if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
  1233. x -= p.scrollLeft;
  1234. y -= p.scrollTop;
  1235. }
  1236. p = p.parentNode;
  1237. }
  1238. return [x, y];
  1239. },
  1240. setXY : function(el, xy){
  1241. el = Ext.fly(el, '_setXY');
  1242. el.position();
  1243. var pts = el.translatePoints(xy);
  1244. if(xy[0] !== false){
  1245. el.dom.style.left = pts.left + "px";
  1246. }
  1247. if(xy[1] !== false){
  1248. el.dom.style.top = pts.top + "px";
  1249. }
  1250. },
  1251. setX : function(el, x){
  1252. this.setXY(el, [x, false]);
  1253. },
  1254. setY : function(el, y){
  1255. this.setXY(el, [false, y]);
  1256. }
  1257. };
  1258. // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
  1259. function fly(el){
  1260. if(!libFlyweight){
  1261. libFlyweight = new Ext.Element.Flyweight();
  1262. }
  1263. libFlyweight.dom = el;
  1264. return libFlyweight;
  1265. }
  1266. Ext.lib.Event = {
  1267. getPageX : function(e){
  1268. e = e.browserEvent || e;
  1269. return e.pageX;
  1270. },
  1271. getPageY : function(e){
  1272. e = e.browserEvent || e;
  1273. return e.pageY;
  1274. },
  1275. getXY : function(e){
  1276. e = e.browserEvent || e;
  1277. return [e.pageX, e.pageY];
  1278. },
  1279. getTarget : function(e){
  1280. return e.target;
  1281. },
  1282. // all Ext events will go through event manager which provides scoping
  1283. on : function(el, eventName, fn, scope, override){
  1284. jQuery(el).bind(eventName, fn);
  1285. },
  1286. un : function(el, eventName, fn){
  1287. jQuery(el).unbind(eventName, fn);
  1288. },
  1289. purgeElement : function(el){
  1290. jQuery(el).unbind();
  1291. },
  1292. preventDefault : function(e){
  1293. e = e.browserEvent || e;
  1294. if(e.preventDefault){
  1295. e.preventDefault();
  1296. }else{
  1297. e.returnValue = false;
  1298. }
  1299. },
  1300. stopPropagation : function(e){
  1301. e = e.browserEvent || e;
  1302. if(e.stopPropagation){
  1303. e.stopPropagation();
  1304. }else{
  1305. e.cancelBubble = true;
  1306. }
  1307. },
  1308. stopEvent : function(e){
  1309. this.preventDefault(e);
  1310. this.stopPropagation(e);
  1311. },
  1312. onAvailable : function(id, fn, scope){
  1313. var start = new Date();
  1314. var f = function(){
  1315. if(start.getElapsed() > 10000){
  1316. clearInterval(iid);
  1317. }
  1318. var el = document.getElementById(id);
  1319. if(el){
  1320. clearInterval(iid);
  1321. fn.call(scope||window, el);
  1322. }
  1323. };
  1324. var iid = setInterval(f, 50);
  1325. },
  1326. resolveTextNode: Ext.isGecko ? function(node){
  1327. if(!node){
  1328. return;
  1329. }
  1330. var s = HTMLElement.prototype.toString.call(node);
  1331. if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
  1332. return;
  1333. }
  1334. return node.nodeType == 3 ? node.parentNode : node;
  1335. } : function(node){
  1336. return node && node.nodeType == 3 ? node.parentNode : node;
  1337. },
  1338. getRelatedTarget: function(ev) {
  1339. ev = ev.browserEvent || ev;
  1340. var t = ev.relatedTarget;
  1341. if (!t) {
  1342. if (ev.type == "mouseout") {
  1343. t = ev.toElement;
  1344. } else if (ev.type == "mouseover") {
  1345. t = ev.fromElement;
  1346. }
  1347. }
  1348. return this.resolveTextNode(t);
  1349. }
  1350. };
  1351. Ext.lib.Ajax = function(){
  1352. var createComplete = function(cb){
  1353. return function(xhr, status){
  1354. if((status == 'error' || status == 'timeout') && cb.failure){
  1355. cb.failure.call(cb.scope||window, createResponse(cb, xhr));
  1356. }else if(cb.success){
  1357. cb.success.call(cb.scope||window, createResponse(cb, xhr));
  1358. }
  1359. };
  1360. };
  1361. var createResponse = function(cb, xhr){
  1362. var headerObj = {},
  1363. headerStr,
  1364. t,
  1365. s;
  1366. try {
  1367. headerStr = xhr.getAllResponseHeaders();
  1368. Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
  1369. t = v.indexOf(':');
  1370. if(t >= 0){
  1371. s = v.substr(0, t).toLowerCase();
  1372. if(v.charAt(t + 1) == ' '){
  1373. ++t;
  1374. }
  1375. headerObj[s] = v.substr(t + 1);
  1376. }
  1377. });
  1378. } catch(e) {}
  1379. return {
  1380. responseText: xhr.responseText,
  1381. responseXML : xhr.responseXML,
  1382. argument: cb.argument,
  1383. status: xhr.status,
  1384. statusText: xhr.statusText,
  1385. getResponseHeader : function(header){
  1386. return headerObj[header.toLowerCase()];
  1387. },
  1388. getAllResponseHeaders : function(){
  1389. return headerStr;
  1390. }
  1391. };
  1392. };
  1393. return {
  1394. request : function(method, uri, cb, data, options){
  1395. var o = {
  1396. type: method,
  1397. url: uri,
  1398. data: data,
  1399. timeout: cb.timeout,
  1400. complete: createComplete(cb)
  1401. };
  1402. if(options){
  1403. var hs = options.headers;
  1404. if(options.xmlData){
  1405. o.data = options.xmlData;
  1406. o.processData = false;
  1407. o.type = (method ? method : (options.method ? options.method : 'POST'));
  1408. if (!hs || !hs['Content-Type']){
  1409. o.contentType = 'text/xml';
  1410. }
  1411. }else if(options.jsonData){
  1412. o.data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
  1413. o.processData = false;
  1414. o.type = (method ? method : (options.method ? options.method : 'POST'));
  1415. if (!hs || !hs['Content-Type']){
  1416. o.contentType = 'application/json';
  1417. }
  1418. }
  1419. if(hs){
  1420. o.beforeSend = function(xhr){
  1421. for (var h in hs) {
  1422. if (hs.hasOwnProperty(h)) {
  1423. xhr.setRequestHeader(h, hs[h]);
  1424. }
  1425. }
  1426. };
  1427. }
  1428. }
  1429. jQuery.ajax(o);
  1430. },
  1431. formRequest : function(form, uri, cb, data, isUpload, sslUri){
  1432. jQuery.ajax({
  1433. type: Ext.getDom(form).method ||'POST',
  1434. url: uri,
  1435. data: jQuery(form).serialize()+(data?'&'+data:''),
  1436. timeout: cb.timeout,
  1437. complete: createComplete(cb)
  1438. });
  1439. },
  1440. isCallInProgress : function(trans){
  1441. return false;
  1442. },
  1443. abort : function(trans){
  1444. return false;
  1445. },
  1446. serializeForm : function(form){
  1447. return jQuery(form.dom||form).serialize();
  1448. }
  1449. };
  1450. }();
  1451. Ext.lib.Anim = function(){
  1452. var createAnim = function(cb, scope){
  1453. var animated = true;
  1454. return {
  1455. stop : function(skipToLast){
  1456. // do nothing
  1457. },
  1458. isAnimated : function(){
  1459. return animated;
  1460. },
  1461. proxyCallback : function(){
  1462. animated = false;
  1463. Ext.callback(cb, scope);
  1464. }
  1465. };
  1466. };
  1467. return {
  1468. scroll : function(el, args, duration, easing, cb, scope){
  1469. // scroll anim not supported so just scroll immediately
  1470. var anim = createAnim(cb, scope);
  1471. el = Ext.getDom(el);
  1472. if(typeof args.scroll.to[0] == 'number'){
  1473. el.scrollLeft = args.scroll.to[0];
  1474. }
  1475. if(typeof args.scroll.to[1] == 'number'){
  1476. el.scrollTop = args.scroll.to[1];
  1477. }
  1478. anim.proxyCallback();
  1479. return anim;
  1480. },
  1481. motion : function(el, args, duration, easing, cb, scope){
  1482. return this.run(el, args, duration, easing, cb, scope);
  1483. },
  1484. color : function(el, args, duration, easing, cb, scope){
  1485. // color anim not supported, so execute callback immediately
  1486. var anim = createAnim(cb, scope);
  1487. anim.proxyCallback();
  1488. return anim;
  1489. },
  1490. run : function(el, args, duration, easing, cb, scope, type){
  1491. var anim = createAnim(cb, scope), e = Ext.fly(el, '_animrun');
  1492. var o = {};
  1493. for(var k in args){
  1494. switch(k){ // jquery doesn't support, so convert
  1495. case 'points':
  1496. var by, pts;
  1497. e.position();
  1498. if(by = args.points.by){
  1499. var xy = e.getXY();
  1500. pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
  1501. }else{
  1502. pts = e.translatePoints(args.points.to);
  1503. }
  1504. o.left = pts.left;
  1505. o.top = pts.top;
  1506. if(!parseInt(e.getStyle('left'), 10)){ // auto bug
  1507. e.setLeft(0);
  1508. }
  1509. if(!parseInt(e.getStyle('top'), 10)){
  1510. e.setTop(0);
  1511. }
  1512. if(args.points.from){
  1513. e.setXY(args.points.from);
  1514. }
  1515. break;
  1516. case 'width':
  1517. o.width = args.width.to;
  1518. if (args.width.from)
  1519. e.setWidth(args.width.from);
  1520. break;
  1521. case 'height':
  1522. o.height = args.height.to;
  1523. if (args.height.from)
  1524. e.setHeight(args.height.from);
  1525. break;
  1526. case 'opacity':
  1527. o.opacity = args.opacity.to;
  1528. if (args.opacity.from)
  1529. e.setOpacity(args.opacity.from);
  1530. break;
  1531. case 'left':
  1532. o.left = args.left.to;
  1533. if (args.left.from)
  1534. e.setLeft(args.left.from);
  1535. break;
  1536. case 'top':
  1537. o.top = args.top.to;
  1538. if (args.top.from)
  1539. e.setTop(args.top.from);
  1540. break;
  1541. // jQuery can't handle callback, scope, and xy arguments, so break here
  1542. case 'callback':
  1543. case 'scope':
  1544. case 'xy':
  1545. break;
  1546. default:
  1547. o[k] = args[k].to;
  1548. if (args[k].from)
  1549. e.setStyle(k, args[k].from);
  1550. break;
  1551. }
  1552. }
  1553. // TODO: find out about easing plug in?
  1554. jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
  1555. return anim;
  1556. }
  1557. };
  1558. }();
  1559. Ext.lib.Region = function(t, r, b, l) {
  1560. this.top = t;
  1561. this[1] = t;
  1562. this.right = r;
  1563. this.bottom = b;
  1564. this.left = l;
  1565. this[0] = l;
  1566. };
  1567. Ext.lib.Region.prototype = {
  1568. contains : function(region) {
  1569. return ( region.left >= this.left &&
  1570. region.right <= this.right &&
  1571. region.top >= this.top &&
  1572. region.bottom <= this.bottom );
  1573. },
  1574. getArea : function() {
  1575. return ( (this.bottom - this.top) * (this.right - this.left) );
  1576. },
  1577. intersect : function(region) {
  1578. var t = Math.max( this.top, region.top );
  1579. var r = Math.min( this.right, region.right );
  1580. var b = Math.min( this.bottom, region.bottom );
  1581. var l = Math.max( this.left, region.left );
  1582. if (b >= t && r >= l) {
  1583. return new Ext.lib.Region(t, r, b, l);
  1584. } else {
  1585. return null;
  1586. }
  1587. },
  1588. union : function(region) {
  1589. var t = Math.min( this.top, region.top );
  1590. var r = Math.max( this.right, region.right );
  1591. var b = Math.max( this.bottom, region.bottom );
  1592. var l = Math.min( this.left, region.left );
  1593. return new Ext.lib.Region(t, r, b, l);
  1594. },
  1595. constrainTo : function(r) {
  1596. this.top = this.top.constrain(r.top, r.bottom);
  1597. this.bottom = this.bottom.constrain(r.top, r.bottom);
  1598. this.left = this.left.constrain(r.left, r.right);
  1599. this.right = this.right.constrain(r.left, r.right);
  1600. return this;
  1601. },
  1602. adjust : function(t, l, b, r){
  1603. this.top += t;
  1604. this.left += l;
  1605. this.right += r;
  1606. this.bottom += b;
  1607. return this;
  1608. }
  1609. };
  1610. Ext.lib.Region.getRegion = function(el) {
  1611. var p = Ext.lib.Dom.getXY(el);
  1612. var t = p[1];
  1613. var r = p[0] + el.offsetWidth;
  1614. var b = p[1] + el.offsetHeight;
  1615. var l = p[0];
  1616. return new Ext.lib.Region(t, r, b, l);
  1617. };
  1618. Ext.lib.Point = function(x, y) {
  1619. if (Ext.isArray(x)) {
  1620. y = x[1];
  1621. x = x[0];
  1622. }
  1623. this.x = this.right = this.left = this[0] = x;
  1624. this.y = this.top = this.bottom = this[1] = y;
  1625. };
  1626. Ext.lib.Point.prototype = new Ext.lib.Region();
  1627. // prevent IE leaks
  1628. if(Ext.isIE) {
  1629. function fnCleanUp() {
  1630. var p = Function.prototype;
  1631. delete p.createSequence;
  1632. delete p.defer;
  1633. delete p.createDelegate;
  1634. delete p.createCallback;
  1635. delete p.createInterceptor;
  1636. window.detachEvent("onunload", fnCleanUp);
  1637. }
  1638. window.attachEvent("onunload", fnCleanUp);
  1639. }
  1640. })();