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.

2449 lines
85 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.2.1
  3. * Copyright(c) 2006-2010 Ext JS, Inc.
  4. * licensing@extjs.com
  5. * http://www.extjs.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.2.1',
  20. versionDetail : {
  21. major: 3,
  22. minor: 2,
  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. isStrict = DOC.compatMode == "CSS1Compat",
  55. isOpera = check(/opera/),
  56. isChrome = check(/\bchrome\b/),
  57. isWebKit = check(/webkit/),
  58. isSafari = !isChrome && check(/safari/),
  59. isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
  60. isSafari3 = isSafari && check(/version\/3/),
  61. isSafari4 = isSafari && check(/version\/4/),
  62. isIE = !isOpera && check(/msie/),
  63. isIE7 = isIE && check(/msie 7/),
  64. isIE8 = isIE && check(/msie 8/),
  65. isIE6 = isIE && !isIE7 && !isIE8,
  66. isGecko = !isWebKit && check(/gecko/),
  67. isGecko2 = isGecko && check(/rv:1\.8/),
  68. isGecko3 = isGecko && check(/rv:1\.9/),
  69. isBorderBox = isIE && !isStrict,
  70. isWindows = check(/windows|win32/),
  71. isMac = check(/macintosh|mac os x/),
  72. isAir = check(/adobeair/),
  73. isLinux = check(/linux/),
  74. isSecure = /^https/i.test(window.location.protocol);
  75. // remove css image flicker
  76. if(isIE6){
  77. try{
  78. DOC.execCommand("BackgroundImageCache", false, true);
  79. }catch(e){}
  80. }
  81. Ext.apply(Ext, {
  82. /**
  83. * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
  84. * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
  85. * @type String
  86. */
  87. SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
  88. /**
  89. * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
  90. * @type Boolean
  91. */
  92. isStrict : isStrict,
  93. /**
  94. * True if the page is running over SSL
  95. * @type Boolean
  96. */
  97. isSecure : isSecure,
  98. /**
  99. * True when the document is fully initialized and ready for action
  100. * @type Boolean
  101. */
  102. isReady : false,
  103. /**
  104. * True if the {@link Ext.Fx} Class is available
  105. * @type Boolean
  106. * @property enableFx
  107. */
  108. /**
  109. * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
  110. * @type Boolean
  111. */
  112. enableGarbageCollector : true,
  113. /**
  114. * True to automatically purge event listeners during garbageCollection (defaults to false).
  115. * @type Boolean
  116. */
  117. enableListenerCollection : false,
  118. /**
  119. * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
  120. * Currently not optimized for performance.
  121. * @type Boolean
  122. */
  123. enableNestedListenerRemoval : false,
  124. /**
  125. * Indicates whether to use native browser parsing for JSON methods.
  126. * This option is ignored if the browser does not support native JSON methods.
  127. * <b>Note: Native JSON methods will not work with objects that have functions.
  128. * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
  129. * @type Boolean
  130. */
  131. USE_NATIVE_JSON : false,
  132. /**
  133. * Copies all the properties of config to obj if they don't already exist.
  134. * @param {Object} obj The receiver of the properties
  135. * @param {Object} config The source of the properties
  136. * @return {Object} returns obj
  137. */
  138. applyIf : function(o, c){
  139. if(o){
  140. for(var p in c){
  141. if(!Ext.isDefined(o[p])){
  142. o[p] = c[p];
  143. }
  144. }
  145. }
  146. return o;
  147. },
  148. /**
  149. * Generates unique ids. If the element already has an id, it is unchanged
  150. * @param {Mixed} el (optional) The element to generate an id for
  151. * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
  152. * @return {String} The generated Id.
  153. */
  154. id : function(el, prefix){
  155. el = Ext.getDom(el, true) || {};
  156. if (!el.id) {
  157. el.id = (prefix || "ext-gen") + (++idSeed);
  158. }
  159. return el.id;
  160. },
  161. /**
  162. * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
  163. * also adds the function "override()" to the subclass that can be used to override members of the class.</p>
  164. * For example, to create a subclass of Ext GridPanel:
  165. * <pre><code>
  166. MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
  167. constructor: function(config) {
  168. // Create configuration for this Grid.
  169. var store = new Ext.data.Store({...});
  170. var colModel = new Ext.grid.ColumnModel({...});
  171. // Create a new config object containing our computed properties
  172. // *plus* whatever was in the config parameter.
  173. config = Ext.apply({
  174. store: store,
  175. colModel: colModel
  176. }, config);
  177. MyGridPanel.superclass.constructor.call(this, config);
  178. // Your postprocessing here
  179. },
  180. yourMethod: function() {
  181. // etc.
  182. }
  183. });
  184. </code></pre>
  185. *
  186. * <p>This function also supports a 3-argument call in which the subclass's constructor is
  187. * passed as an argument. In this form, the parameters are as follows:</p>
  188. * <div class="mdetail-params"><ul>
  189. * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
  190. * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
  191. * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
  192. * prototype, and are therefore shared among all instances of the new class.</div></li>
  193. * </ul></div>
  194. *
  195. * @param {Function} superclass The constructor of class being extended.
  196. * @param {Object} overrides <p>A literal with members which are copied into the subclass's
  197. * prototype, and are therefore shared between all instances of the new class.</p>
  198. * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
  199. * to define the constructor of the new class, and is returned. If this property is
  200. * <i>not</i> specified, a constructor is generated and returned which just calls the
  201. * superclass's constructor passing on its parameters.</p>
  202. * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
  203. * @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
  204. */
  205. extend : function(){
  206. // inline overrides
  207. var io = function(o){
  208. for(var m in o){
  209. this[m] = o[m];
  210. }
  211. };
  212. var oc = Object.prototype.constructor;
  213. return function(sb, sp, overrides){
  214. if(typeof sp == 'object'){
  215. overrides = sp;
  216. sp = sb;
  217. sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
  218. }
  219. var F = function(){},
  220. sbp,
  221. spp = sp.prototype;
  222. F.prototype = spp;
  223. sbp = sb.prototype = new F();
  224. sbp.constructor=sb;
  225. sb.superclass=spp;
  226. if(spp.constructor == oc){
  227. spp.constructor=sp;
  228. }
  229. sb.override = function(o){
  230. Ext.override(sb, o);
  231. };
  232. sbp.superclass = sbp.supr = (function(){
  233. return spp;
  234. });
  235. sbp.override = io;
  236. Ext.override(sb, overrides);
  237. sb.extend = function(o){return Ext.extend(sb, o);};
  238. return sb;
  239. };
  240. }(),
  241. /**
  242. * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
  243. * Usage:<pre><code>
  244. Ext.override(MyClass, {
  245. newMethod1: function(){
  246. // etc.
  247. },
  248. newMethod2: function(foo){
  249. // etc.
  250. }
  251. });
  252. </code></pre>
  253. * @param {Object} origclass The class to override
  254. * @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
  255. * containing one or more methods.
  256. * @method override
  257. */
  258. override : function(origclass, overrides){
  259. if(overrides){
  260. var p = origclass.prototype;
  261. Ext.apply(p, overrides);
  262. if(Ext.isIE && overrides.hasOwnProperty('toString')){
  263. p.toString = overrides.toString;
  264. }
  265. }
  266. },
  267. /**
  268. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  269. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  270. * <pre><code>
  271. Ext.namespace('Company', 'Company.data');
  272. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  273. Company.Widget = function() { ... }
  274. Company.data.CustomStore = function(config) { ... }
  275. </code></pre>
  276. * @param {String} namespace1
  277. * @param {String} namespace2
  278. * @param {String} etc
  279. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  280. * @method namespace
  281. */
  282. namespace : function(){
  283. var o, d;
  284. Ext.each(arguments, function(v) {
  285. d = v.split(".");
  286. o = window[d[0]] = window[d[0]] || {};
  287. Ext.each(d.slice(1), function(v2){
  288. o = o[v2] = o[v2] || {};
  289. });
  290. });
  291. return o;
  292. },
  293. /**
  294. * 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.
  295. * @param {Object} o
  296. * @param {String} pre (optional) A prefix to add to the url encoded string
  297. * @return {String}
  298. */
  299. urlEncode : function(o, pre){
  300. var empty,
  301. buf = [],
  302. e = encodeURIComponent;
  303. Ext.iterate(o, function(key, item){
  304. empty = Ext.isEmpty(item);
  305. Ext.each(empty ? key : item, function(val){
  306. buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
  307. });
  308. });
  309. if(!pre){
  310. buf.shift();
  311. pre = '';
  312. }
  313. return pre + buf.join('');
  314. },
  315. /**
  316. * Takes an encoded URL and and converts it to an object. Example: <pre><code>
  317. Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
  318. Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
  319. </code></pre>
  320. * @param {String} string
  321. * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
  322. * @return {Object} A literal with members
  323. */
  324. urlDecode : function(string, overwrite){
  325. if(Ext.isEmpty(string)){
  326. return {};
  327. }
  328. var obj = {},
  329. pairs = string.split('&'),
  330. d = decodeURIComponent,
  331. name,
  332. value;
  333. Ext.each(pairs, function(pair) {
  334. pair = pair.split('=');
  335. name = d(pair[0]);
  336. value = d(pair[1]);
  337. obj[name] = overwrite || !obj[name] ? value :
  338. [].concat(obj[name]).concat(value);
  339. });
  340. return obj;
  341. },
  342. /**
  343. * Appends content to the query string of a URL, handling logic for whether to place
  344. * a question mark or ampersand.
  345. * @param {String} url The URL to append to.
  346. * @param {String} s The content to append to the URL.
  347. * @return (String) The resulting URL
  348. */
  349. urlAppend : function(url, s){
  350. if(!Ext.isEmpty(s)){
  351. return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
  352. }
  353. return url;
  354. },
  355. /**
  356. * Converts any iterable (numeric indices and a length property) into a true array
  357. * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
  358. * For strings, use this instead: "abc".match(/./g) => [a,b,c];
  359. * @param {Iterable} the iterable object to be turned into a true Array.
  360. * @return (Array) array
  361. */
  362. toArray : function(){
  363. return isIE ?
  364. function(a, i, j, res){
  365. res = [];
  366. for(var x = 0, len = a.length; x < len; x++) {
  367. res.push(a[x]);
  368. }
  369. return res.slice(i || 0, j || res.length);
  370. } :
  371. function(a, i, j){
  372. return Array.prototype.slice.call(a, i || 0, j || a.length);
  373. }
  374. }(),
  375. isIterable : function(v){
  376. //check for array or arguments
  377. if(Ext.isArray(v) || v.callee){
  378. return true;
  379. }
  380. //check for node list type
  381. if(/NodeList|HTMLCollection/.test(toString.call(v))){
  382. return true;
  383. }
  384. //NodeList has an item and length property
  385. //IXMLDOMNodeList has nextNode method, needs to be checked first.
  386. return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
  387. },
  388. /**
  389. * Iterates an array calling the supplied function.
  390. * @param {Array/NodeList/Mixed} array The array to be iterated. If this
  391. * argument is not really an array, the supplied function is called once.
  392. * @param {Function} fn The function to be called with each item. If the
  393. * supplied function returns false, iteration stops and this method returns
  394. * the current <code>index</code>. This function is called with
  395. * the following arguments:
  396. * <div class="mdetail-params"><ul>
  397. * <li><code>item</code> : <i>Mixed</i>
  398. * <div class="sub-desc">The item at the current <code>index</code>
  399. * in the passed <code>array</code></div></li>
  400. * <li><code>index</code> : <i>Number</i>
  401. * <div class="sub-desc">The current index within the array</div></li>
  402. * <li><code>allItems</code> : <i>Array</i>
  403. * <div class="sub-desc">The <code>array</code> passed as the first
  404. * argument to <code>Ext.each</code>.</div></li>
  405. * </ul></div>
  406. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
  407. * Defaults to the <code>item</code> at the current <code>index</code>
  408. * within the passed <code>array</code>.
  409. * @return See description for the fn parameter.
  410. */
  411. each : function(array, fn, scope){
  412. if(Ext.isEmpty(array, true)){
  413. return;
  414. }
  415. if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
  416. array = [array];
  417. }
  418. for(var i = 0, len = array.length; i < len; i++){
  419. if(fn.call(scope || array[i], array[i], i, array) === false){
  420. return i;
  421. };
  422. }
  423. },
  424. /**
  425. * Iterates either the elements in an array, or each of the properties in an object.
  426. * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
  427. * @param {Object/Array} object The object or array to be iterated
  428. * @param {Function} fn The function to be called for each iteration.
  429. * The iteration will stop if the supplied function returns false, or
  430. * all array elements / object properties have been covered. The signature
  431. * varies depending on the type of object being interated:
  432. * <div class="mdetail-params"><ul>
  433. * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
  434. * <div class="sub-desc">
  435. * When iterating an array, the supplied function is called with each item.</div></li>
  436. * <li>Objects : <tt>(String key, Object value, Object)</tt>
  437. * <div class="sub-desc">
  438. * When iterating an object, the supplied function is called with each key-value pair in
  439. * the object, and the iterated object</div></li>
  440. * </ul></div>
  441. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
  442. * the <code>object</code> being iterated.
  443. */
  444. iterate : function(obj, fn, scope){
  445. if(Ext.isEmpty(obj)){
  446. return;
  447. }
  448. if(Ext.isIterable(obj)){
  449. Ext.each(obj, fn, scope);
  450. return;
  451. }else if(typeof obj == 'object'){
  452. for(var prop in obj){
  453. if(obj.hasOwnProperty(prop)){
  454. if(fn.call(scope || obj, prop, obj[prop], obj) === false){
  455. return;
  456. };
  457. }
  458. }
  459. }
  460. },
  461. /**
  462. * Return the dom node for the passed String (id), dom node, or Ext.Element.
  463. * Optional 'strict' flag is needed for IE since it can return 'name' and
  464. * 'id' elements by using getElementById.
  465. * Here are some examples:
  466. * <pre><code>
  467. // gets dom node based on id
  468. var elDom = Ext.getDom('elId');
  469. // gets dom node based on the dom node
  470. var elDom1 = Ext.getDom(elDom);
  471. // If we don&#39;t know if we are working with an
  472. // Ext.Element or a dom node use Ext.getDom
  473. function(el){
  474. var dom = Ext.getDom(el);
  475. // do something with the dom node
  476. }
  477. * </code></pre>
  478. * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
  479. * when this method is called to be successful.
  480. * @param {Mixed} el
  481. * @return HTMLElement
  482. */
  483. getDom : function(el, strict){
  484. if(!el || !DOC){
  485. return null;
  486. }
  487. if (el.dom){
  488. return el.dom;
  489. } else {
  490. if (typeof el == 'string') {
  491. var e = DOC.getElementById(el);
  492. // IE returns elements with the 'name' and 'id' attribute.
  493. // we do a strict check to return the element with only the id attribute
  494. if (e && isIE && strict) {
  495. if (el == e.getAttribute('id')) {
  496. return e;
  497. } else {
  498. return null;
  499. }
  500. }
  501. return e;
  502. } else {
  503. return el;
  504. }
  505. }
  506. },
  507. /**
  508. * Returns the current document body as an {@link Ext.Element}.
  509. * @return Ext.Element The document body
  510. */
  511. getBody : function(){
  512. return Ext.get(DOC.body || DOC.documentElement);
  513. },
  514. /**
  515. * Removes a DOM node from the document.
  516. */
  517. /**
  518. * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
  519. * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
  520. * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
  521. * will be ignored if passed in.</p>
  522. * @param {HTMLElement} node The node to remove
  523. */
  524. removeNode : isIE && !isIE8 ? function(){
  525. var d;
  526. return function(n){
  527. if(n && n.tagName != 'BODY'){
  528. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  529. d = d || DOC.createElement('div');
  530. d.appendChild(n);
  531. d.innerHTML = '';
  532. delete Ext.elCache[n.id];
  533. }
  534. }
  535. }() : function(n){
  536. if(n && n.parentNode && n.tagName != 'BODY'){
  537. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  538. n.parentNode.removeChild(n);
  539. delete Ext.elCache[n.id];
  540. }
  541. },
  542. /**
  543. * <p>Returns true if the passed value is empty.</p>
  544. * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
  545. * <li>null</li>
  546. * <li>undefined</li>
  547. * <li>an empty array</li>
  548. * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
  549. * </ul></div>
  550. * @param {Mixed} value The value to test
  551. * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
  552. * @return {Boolean}
  553. */
  554. isEmpty : function(v, allowBlank){
  555. return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
  556. },
  557. /**
  558. * Returns true if the passed value is a JavaScript array, otherwise false.
  559. * @param {Mixed} value The value to test
  560. * @return {Boolean}
  561. */
  562. isArray : function(v){
  563. return toString.apply(v) === '[object Array]';
  564. },
  565. /**
  566. * Returns true if the passed object is a JavaScript date object, otherwise false.
  567. * @param {Object} object The object to test
  568. * @return {Boolean}
  569. */
  570. isDate : function(v){
  571. return toString.apply(v) === '[object Date]';
  572. },
  573. /**
  574. * Returns true if the passed value is a JavaScript Object, otherwise false.
  575. * @param {Mixed} value The value to test
  576. * @return {Boolean}
  577. */
  578. isObject : function(v){
  579. return !!v && Object.prototype.toString.call(v) === '[object Object]';
  580. },
  581. /**
  582. * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
  583. * @param {Mixed} value The value to test
  584. * @return {Boolean}
  585. */
  586. isPrimitive : function(v){
  587. return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
  588. },
  589. /**
  590. * Returns true if the passed value is a JavaScript Function, otherwise false.
  591. * @param {Mixed} value The value to test
  592. * @return {Boolean}
  593. */
  594. isFunction : function(v){
  595. return toString.apply(v) === '[object Function]';
  596. },
  597. /**
  598. * Returns true if the passed value is a number. Returns false for non-finite numbers.
  599. * @param {Mixed} value The value to test
  600. * @return {Boolean}
  601. */
  602. isNumber : function(v){
  603. return typeof v === 'number' && isFinite(v);
  604. },
  605. /**
  606. * Returns true if the passed value is a string.
  607. * @param {Mixed} value The value to test
  608. * @return {Boolean}
  609. */
  610. isString : function(v){
  611. return typeof v === 'string';
  612. },
  613. /**
  614. * Returns true if the passed value is a boolean.
  615. * @param {Mixed} value The value to test
  616. * @return {Boolean}
  617. */
  618. isBoolean : function(v){
  619. return typeof v === 'boolean';
  620. },
  621. /**
  622. * Returns true if the passed value is an HTMLElement
  623. * @param {Mixed} value The value to test
  624. * @return {Boolean}
  625. */
  626. isElement : function(v) {
  627. return v ? !!v.tagName : false;
  628. },
  629. /**
  630. * Returns true if the passed value is not undefined.
  631. * @param {Mixed} value The value to test
  632. * @return {Boolean}
  633. */
  634. isDefined : function(v){
  635. return typeof v !== 'undefined';
  636. },
  637. /**
  638. * True if the detected browser is Opera.
  639. * @type Boolean
  640. */
  641. isOpera : isOpera,
  642. /**
  643. * True if the detected browser uses WebKit.
  644. * @type Boolean
  645. */
  646. isWebKit : isWebKit,
  647. /**
  648. * True if the detected browser is Chrome.
  649. * @type Boolean
  650. */
  651. isChrome : isChrome,
  652. /**
  653. * True if the detected browser is Safari.
  654. * @type Boolean
  655. */
  656. isSafari : isSafari,
  657. /**
  658. * True if the detected browser is Safari 3.x.
  659. * @type Boolean
  660. */
  661. isSafari3 : isSafari3,
  662. /**
  663. * True if the detected browser is Safari 4.x.
  664. * @type Boolean
  665. */
  666. isSafari4 : isSafari4,
  667. /**
  668. * True if the detected browser is Safari 2.x.
  669. * @type Boolean
  670. */
  671. isSafari2 : isSafari2,
  672. /**
  673. * True if the detected browser is Internet Explorer.
  674. * @type Boolean
  675. */
  676. isIE : isIE,
  677. /**
  678. * True if the detected browser is Internet Explorer 6.x.
  679. * @type Boolean
  680. */
  681. isIE6 : isIE6,
  682. /**
  683. * True if the detected browser is Internet Explorer 7.x.
  684. * @type Boolean
  685. */
  686. isIE7 : isIE7,
  687. /**
  688. * True if the detected browser is Internet Explorer 8.x.
  689. * @type Boolean
  690. */
  691. isIE8 : isIE8,
  692. /**
  693. * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
  694. * @type Boolean
  695. */
  696. isGecko : isGecko,
  697. /**
  698. * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
  699. * @type Boolean
  700. */
  701. isGecko2 : isGecko2,
  702. /**
  703. * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
  704. * @type Boolean
  705. */
  706. isGecko3 : isGecko3,
  707. /**
  708. * True if the detected browser is Internet Explorer running in non-strict mode.
  709. * @type Boolean
  710. */
  711. isBorderBox : isBorderBox,
  712. /**
  713. * True if the detected platform is Linux.
  714. * @type Boolean
  715. */
  716. isLinux : isLinux,
  717. /**
  718. * True if the detected platform is Windows.
  719. * @type Boolean
  720. */
  721. isWindows : isWindows,
  722. /**
  723. * True if the detected platform is Mac OS.
  724. * @type Boolean
  725. */
  726. isMac : isMac,
  727. /**
  728. * True if the detected platform is Adobe Air.
  729. * @type Boolean
  730. */
  731. isAir : isAir
  732. });
  733. /**
  734. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  735. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  736. * <pre><code>
  737. Ext.namespace('Company', 'Company.data');
  738. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  739. Company.Widget = function() { ... }
  740. Company.data.CustomStore = function(config) { ... }
  741. </code></pre>
  742. * @param {String} namespace1
  743. * @param {String} namespace2
  744. * @param {String} etc
  745. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  746. * @method ns
  747. */
  748. Ext.ns = Ext.namespace;
  749. })();
  750. Ext.ns("Ext.util", "Ext.lib", "Ext.data");
  751. Ext.elCache = {};
  752. /**
  753. * @class Function
  754. * These functions are available on every Function object (any JavaScript function).
  755. */
  756. Ext.apply(Function.prototype, {
  757. /**
  758. * Creates an interceptor function. The passed function is called before the original one. If it returns false,
  759. * the original one is not called. The resulting function returns the results of the original function.
  760. * The passed function is called with the parameters of the original function. Example usage:
  761. * <pre><code>
  762. var sayHi = function(name){
  763. alert('Hi, ' + name);
  764. }
  765. sayHi('Fred'); // alerts "Hi, Fred"
  766. // create a new function that validates input without
  767. // directly modifying the original function:
  768. var sayHiToFriend = sayHi.createInterceptor(function(name){
  769. return name == 'Brian';
  770. });
  771. sayHiToFriend('Fred'); // no alert
  772. sayHiToFriend('Brian'); // alerts "Hi, Brian"
  773. </code></pre>
  774. * @param {Function} fcn The function to call before the original
  775. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  776. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  777. * @return {Function} The new function
  778. */
  779. createInterceptor : function(fcn, scope){
  780. var method = this;
  781. return !Ext.isFunction(fcn) ?
  782. this :
  783. function() {
  784. var me = this,
  785. args = arguments;
  786. fcn.target = me;
  787. fcn.method = method;
  788. return (fcn.apply(scope || me || window, args) !== false) ?
  789. method.apply(me || window, args) :
  790. null;
  791. };
  792. },
  793. /**
  794. * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
  795. * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
  796. * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
  797. * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
  798. * executes in the window scope.
  799. * <p>This method is required when you want to pass arguments to a callback function. If no arguments
  800. * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
  801. * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
  802. * would simply execute immediately when the code is parsed. Example usage:
  803. * <pre><code>
  804. var sayHi = function(name){
  805. alert('Hi, ' + name);
  806. }
  807. // clicking the button alerts "Hi, Fred"
  808. new Ext.Button({
  809. text: 'Say Hi',
  810. renderTo: Ext.getBody(),
  811. handler: sayHi.createCallback('Fred')
  812. });
  813. </code></pre>
  814. * @return {Function} The new function
  815. */
  816. createCallback : function(/*args...*/){
  817. // make args available, in function below
  818. var args = arguments,
  819. method = this;
  820. return function() {
  821. return method.apply(window, args);
  822. };
  823. },
  824. /**
  825. * Creates a delegate (callback) that sets the scope to obj.
  826. * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
  827. * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
  828. * callback points to obj. Example usage:
  829. * <pre><code>
  830. var sayHi = function(name){
  831. // Note this use of "this.text" here. This function expects to
  832. // execute within a scope that contains a text property. In this
  833. // example, the "this" variable is pointing to the btn object that
  834. // was passed in createDelegate below.
  835. alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
  836. }
  837. var btn = new Ext.Button({
  838. text: 'Say Hi',
  839. renderTo: Ext.getBody()
  840. });
  841. // This callback will execute in the scope of the
  842. // button instance. Clicking the button alerts
  843. // "Hi, Fred. You clicked the "Say Hi" button."
  844. btn.on('click', sayHi.createDelegate(btn, ['Fred']));
  845. </code></pre>
  846. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  847. * <b>If omitted, defaults to the browser window.</b>
  848. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  849. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  850. * if a number the args are inserted at the specified position
  851. * @return {Function} The new function
  852. */
  853. createDelegate : function(obj, args, appendArgs){
  854. var method = this;
  855. return function() {
  856. var callArgs = args || arguments;
  857. if (appendArgs === true){
  858. callArgs = Array.prototype.slice.call(arguments, 0);
  859. callArgs = callArgs.concat(args);
  860. }else if (Ext.isNumber(appendArgs)){
  861. callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
  862. var applyArgs = [appendArgs, 0].concat(args); // create method call params
  863. Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
  864. }
  865. return method.apply(obj || window, callArgs);
  866. };
  867. },
  868. /**
  869. * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
  870. * <pre><code>
  871. var sayHi = function(name){
  872. alert('Hi, ' + name);
  873. }
  874. // executes immediately:
  875. sayHi('Fred');
  876. // executes after 2 seconds:
  877. sayHi.defer(2000, this, ['Fred']);
  878. // this syntax is sometimes useful for deferring
  879. // execution of an anonymous function:
  880. (function(){
  881. alert('Anonymous');
  882. }).defer(100);
  883. </code></pre>
  884. * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
  885. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  886. * <b>If omitted, defaults to the browser window.</b>
  887. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  888. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  889. * if a number the args are inserted at the specified position
  890. * @return {Number} The timeout id that can be used with clearTimeout
  891. */
  892. defer : function(millis, obj, args, appendArgs){
  893. var fn = this.createDelegate(obj, args, appendArgs);
  894. if(millis > 0){
  895. return setTimeout(fn, millis);
  896. }
  897. fn();
  898. return 0;
  899. }
  900. });
  901. /**
  902. * @class String
  903. * These functions are available on every String object.
  904. */
  905. Ext.applyIf(String, {
  906. /**
  907. * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
  908. * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
  909. * <pre><code>
  910. var cls = 'my-class', text = 'Some text';
  911. var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
  912. // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
  913. * </code></pre>
  914. * @param {String} string The tokenized string to be formatted
  915. * @param {String} value1 The value to replace token {0}
  916. * @param {String} value2 Etc...
  917. * @return {String} The formatted string
  918. * @static
  919. */
  920. format : function(format){
  921. var args = Ext.toArray(arguments, 1);
  922. return format.replace(/\{(\d+)\}/g, function(m, i){
  923. return args[i];
  924. });
  925. }
  926. });
  927. /**
  928. * @class Array
  929. */
  930. Ext.applyIf(Array.prototype, {
  931. /**
  932. * Checks whether or not the specified object exists in the array.
  933. * @param {Object} o The object to check for
  934. * @param {Number} from (Optional) The index at which to begin the search
  935. * @return {Number} The index of o in the array (or -1 if it is not found)
  936. */
  937. indexOf : function(o, from){
  938. var len = this.length;
  939. from = from || 0;
  940. from += (from < 0) ? len : 0;
  941. for (; from < len; ++from){
  942. if(this[from] === o){
  943. return from;
  944. }
  945. }
  946. return -1;
  947. },
  948. /**
  949. * Removes the specified object from the array. If the object is not found nothing happens.
  950. * @param {Object} o The object to remove
  951. * @return {Array} this array
  952. */
  953. remove : function(o){
  954. var index = this.indexOf(o);
  955. if(index != -1){
  956. this.splice(index, 1);
  957. }
  958. return this;
  959. }
  960. });
  961. /**
  962. * @class Ext
  963. */
  964. Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu",
  965. "Ext.state", "Ext.layout", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct");
  966. /**
  967. * Namespace alloted for extensions to the framework.
  968. * @property ux
  969. * @type Object
  970. */
  971. Ext.apply(Ext, function(){
  972. var E = Ext,
  973. idSeed = 0,
  974. scrollWidth = null;
  975. return {
  976. /**
  977. * A reusable empty function
  978. * @property
  979. * @type Function
  980. */
  981. emptyFn : function(){},
  982. /**
  983. * URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images.
  984. * In older versions of IE, this defaults to "http://extjs.com/s.gif" and you should change this to a URL on your server.
  985. * For other browsers it uses an inline data URL.
  986. * @type String
  987. */
  988. BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
  989. 'http:/' + '/www.extjs.com/s.gif' :
  990. 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  991. extendX : function(supr, fn){
  992. return Ext.extend(supr, fn(supr.prototype));
  993. },
  994. /**
  995. * Returns the current HTML document object as an {@link Ext.Element}.
  996. * @return Ext.Element The document
  997. */
  998. getDoc : function(){
  999. return Ext.get(document);
  1000. },
  1001. /**
  1002. * Utility method for validating that a value is numeric, returning the specified default value if it is not.
  1003. * @param {Mixed} value Should be a number, but any type will be handled appropriately
  1004. * @param {Number} defaultValue The value to return if the original value is non-numeric
  1005. * @return {Number} Value, if numeric, else defaultValue
  1006. */
  1007. num : function(v, defaultValue){
  1008. v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
  1009. return isNaN(v) ? defaultValue : v;
  1010. },
  1011. /**
  1012. * <p>Utility method for returning a default value if the passed value is empty.</p>
  1013. * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
  1014. * <li>null</li>
  1015. * <li>undefined</li>
  1016. * <li>an empty array</li>
  1017. * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
  1018. * </ul></div>
  1019. * @param {Mixed} value The value to test
  1020. * @param {Mixed} defaultValue The value to return if the original value is empty
  1021. * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
  1022. * @return {Mixed} value, if non-empty, else defaultValue
  1023. */
  1024. value : function(v, defaultValue, allowBlank){
  1025. return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
  1026. },
  1027. /**
  1028. * Escapes the passed string for use in a regular expression
  1029. * @param {String} str
  1030. * @return {String}
  1031. */
  1032. escapeRe : function(s) {
  1033. return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
  1034. },
  1035. sequence : function(o, name, fn, scope){
  1036. o[name] = o[name].createSequence(fn, scope);
  1037. },
  1038. /**
  1039. * Applies event listeners to elements by selectors when the document is ready.
  1040. * The event name is specified with an <tt>&#64;</tt> suffix.
  1041. * <pre><code>
  1042. Ext.addBehaviors({
  1043. // add a listener for click on all anchors in element with id foo
  1044. '#foo a&#64;click' : function(e, t){
  1045. // do something
  1046. },
  1047. // add the same listener to multiple selectors (separated by comma BEFORE the &#64;)
  1048. '#foo a, #bar span.some-class&#64;mouseover' : function(){
  1049. // do something
  1050. }
  1051. });
  1052. * </code></pre>
  1053. * @param {Object} obj The list of behaviors to apply
  1054. */
  1055. addBehaviors : function(o){
  1056. if(!Ext.isReady){
  1057. Ext.onReady(function(){
  1058. Ext.addBehaviors(o);
  1059. });
  1060. } else {
  1061. var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
  1062. parts,
  1063. b,
  1064. s;
  1065. for (b in o) {
  1066. if ((parts = b.split('@'))[1]) { // for Object prototype breakers
  1067. s = parts[0];
  1068. if(!cache[s]){
  1069. cache[s] = Ext.select(s);
  1070. }
  1071. cache[s].on(parts[1], o[b]);
  1072. }
  1073. }
  1074. cache = null;
  1075. }
  1076. },
  1077. /**
  1078. * Utility method for getting the width of the browser scrollbar. This can differ depending on
  1079. * operating system settings, such as the theme or font size.
  1080. * @param {Boolean} force (optional) true to force a recalculation of the value.
  1081. * @return {Number} The width of the scrollbar.
  1082. */
  1083. getScrollBarWidth: function(force){
  1084. if(!Ext.isReady){
  1085. return 0;
  1086. }
  1087. if(force === true || scrollWidth === null){
  1088. // Append our div, do our calculation and then remove it
  1089. var div = Ext.getBody().createChild('<div class="x-hide-offsets" style="width:100px;height:50px;overflow:hidden;"><div style="height:200px;"></div></div>'),
  1090. child = div.child('div', true);
  1091. var w1 = child.offsetWidth;
  1092. div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
  1093. var w2 = child.offsetWidth;
  1094. div.remove();
  1095. // Need to add 2 to ensure we leave enough space
  1096. scrollWidth = w1 - w2 + 2;
  1097. }
  1098. return scrollWidth;
  1099. },
  1100. // deprecated
  1101. combine : function(){
  1102. var as = arguments, l = as.length, r = [];
  1103. for(var i = 0; i < l; i++){
  1104. var a = as[i];
  1105. if(Ext.isArray(a)){
  1106. r = r.concat(a);
  1107. }else if(a.length !== undefined && !a.substr){
  1108. r = r.concat(Array.prototype.slice.call(a, 0));
  1109. }else{
  1110. r.push(a);
  1111. }
  1112. }
  1113. return r;
  1114. },
  1115. /**
  1116. * Copies a set of named properties fom the source object to the destination object.
  1117. * <p>example:<pre><code>
  1118. ImageComponent = Ext.extend(Ext.BoxComponent, {
  1119. initComponent: function() {
  1120. this.autoEl = { tag: 'img' };
  1121. MyComponent.superclass.initComponent.apply(this, arguments);
  1122. this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
  1123. }
  1124. });
  1125. * </code></pre>
  1126. * @param {Object} dest The destination object.
  1127. * @param {Object} source The source object.
  1128. * @param {Array/String} names Either an Array of property names, or a comma-delimited list
  1129. * of property names to copy.
  1130. * @return {Object} The modified object.
  1131. */
  1132. copyTo : function(dest, source, names){
  1133. if(typeof names == 'string'){
  1134. names = names.split(/[,;\s]/);
  1135. }
  1136. Ext.each(names, function(name){
  1137. if(source.hasOwnProperty(name)){
  1138. dest[name] = source[name];
  1139. }
  1140. }, this);
  1141. return dest;
  1142. },
  1143. /**
  1144. * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
  1145. * DOM (if applicable) and calling their destroy functions (if available). This method is primarily
  1146. * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
  1147. * {@link Ext.util.Observable} can be passed in. Any number of elements and/or components can be
  1148. * passed into this function in a single call as separate arguments.
  1149. * @param {Mixed} arg1 An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
  1150. * @param {Mixed} arg2 (optional)
  1151. * @param {Mixed} etc... (optional)
  1152. */
  1153. destroy : function(){
  1154. Ext.each(arguments, function(arg){
  1155. if(arg){
  1156. if(Ext.isArray(arg)){
  1157. this.destroy.apply(this, arg);
  1158. }else if(typeof arg.destroy == 'function'){
  1159. arg.destroy();
  1160. }else if(arg.dom){
  1161. arg.remove();
  1162. }
  1163. }
  1164. }, this);
  1165. },
  1166. /**
  1167. * Attempts to destroy and then remove a set of named properties of the passed object.
  1168. * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
  1169. * @param {Mixed} arg1 The name of the property to destroy and remove from the object.
  1170. * @param {Mixed} etc... More property names to destroy and remove.
  1171. */
  1172. destroyMembers : function(o, arg1, arg2, etc){
  1173. for(var i = 1, a = arguments, len = a.length; i < len; i++) {
  1174. Ext.destroy(o[a[i]]);
  1175. delete o[a[i]];
  1176. }
  1177. },
  1178. /**
  1179. * Creates a copy of the passed Array with falsy values removed.
  1180. * @param {Array/NodeList} arr The Array from which to remove falsy values.
  1181. * @return {Array} The new, compressed Array.
  1182. */
  1183. clean : function(arr){
  1184. var ret = [];
  1185. Ext.each(arr, function(v){
  1186. if(!!v){
  1187. ret.push(v);
  1188. }
  1189. });
  1190. return ret;
  1191. },
  1192. /**
  1193. * Creates a copy of the passed Array, filtered to contain only unique values.
  1194. * @param {Array} arr The Array to filter
  1195. * @return {Array} The new Array containing unique values.
  1196. */
  1197. unique : function(arr){
  1198. var ret = [],
  1199. collect = {};
  1200. Ext.each(arr, function(v) {
  1201. if(!collect[v]){
  1202. ret.push(v);
  1203. }
  1204. collect[v] = true;
  1205. });
  1206. return ret;
  1207. },
  1208. /**
  1209. * Recursively flattens into 1-d Array. Injects Arrays inline.
  1210. * @param {Array} arr The array to flatten
  1211. * @return {Array} The new, flattened array.
  1212. */
  1213. flatten : function(arr){
  1214. var worker = [];
  1215. function rFlatten(a) {
  1216. Ext.each(a, function(v) {
  1217. if(Ext.isArray(v)){
  1218. rFlatten(v);
  1219. }else{
  1220. worker.push(v);
  1221. }
  1222. });
  1223. return worker;
  1224. }
  1225. return rFlatten(arr);
  1226. },
  1227. /**
  1228. * Returns the minimum value in the Array.
  1229. * @param {Array|NodeList} arr The Array from which to select the minimum value.
  1230. * @param {Function} comp (optional) a function to perform the comparision which determines minimization.
  1231. * If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1
  1232. * @return {Object} The minimum value in the Array.
  1233. */
  1234. min : function(arr, comp){
  1235. var ret = arr[0];
  1236. comp = comp || function(a,b){ return a < b ? -1 : 1; };
  1237. Ext.each(arr, function(v) {
  1238. ret = comp(ret, v) == -1 ? ret : v;
  1239. });
  1240. return ret;
  1241. },
  1242. /**
  1243. * Returns the maximum value in the Array
  1244. * @param {Array|NodeList} arr The Array from which to select the maximum value.
  1245. * @param {Function} comp (optional) a function to perform the comparision which determines maximization.
  1246. * If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1
  1247. * @return {Object} The maximum value in the Array.
  1248. */
  1249. max : function(arr, comp){
  1250. var ret = arr[0];
  1251. comp = comp || function(a,b){ return a > b ? 1 : -1; };
  1252. Ext.each(arr, function(v) {
  1253. ret = comp(ret, v) == 1 ? ret : v;
  1254. });
  1255. return ret;
  1256. },
  1257. /**
  1258. * Calculates the mean of the Array
  1259. * @param {Array} arr The Array to calculate the mean value of.
  1260. * @return {Number} The mean.
  1261. */
  1262. mean : function(arr){
  1263. return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined;
  1264. },
  1265. /**
  1266. * Calculates the sum of the Array
  1267. * @param {Array} arr The Array to calculate the sum value of.
  1268. * @return {Number} The sum.
  1269. */
  1270. sum : function(arr){
  1271. var ret = 0;
  1272. Ext.each(arr, function(v) {
  1273. ret += v;
  1274. });
  1275. return ret;
  1276. },
  1277. /**
  1278. * Partitions the set into two sets: a true set and a false set.
  1279. * Example:
  1280. * Example2:
  1281. * <pre><code>
  1282. // Example 1:
  1283. Ext.partition([true, false, true, true, false]); // [[true, true, true], [false, false]]
  1284. // Example 2:
  1285. Ext.partition(
  1286. Ext.query("p"),
  1287. function(val){
  1288. return val.className == "class1"
  1289. }
  1290. );
  1291. // true are those paragraph elements with a className of "class1",
  1292. // false set are those that do not have that className.
  1293. * </code></pre>
  1294. * @param {Array|NodeList} arr The array to partition
  1295. * @param {Function} truth (optional) a function to determine truth. If this is omitted the element
  1296. * itself must be able to be evaluated for its truthfulness.
  1297. * @return {Array} [true<Array>,false<Array>]
  1298. */
  1299. partition : function(arr, truth){
  1300. var ret = [[],[]];
  1301. Ext.each(arr, function(v, i, a) {
  1302. ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v);
  1303. });
  1304. return ret;
  1305. },
  1306. /**
  1307. * Invokes a method on each item in an Array.
  1308. * <pre><code>
  1309. // Example:
  1310. Ext.invoke(Ext.query("p"), "getAttribute", "id");
  1311. // [el1.getAttribute("id"), el2.getAttribute("id"), ..., elN.getAttribute("id")]
  1312. * </code></pre>
  1313. * @param {Array|NodeList} arr The Array of items to invoke the method on.
  1314. * @param {String} methodName The method name to invoke.
  1315. * @param {...*} args Arguments to send into the method invocation.
  1316. * @return {Array} The results of invoking the method on each item in the array.
  1317. */
  1318. invoke : function(arr, methodName){
  1319. var ret = [],
  1320. args = Array.prototype.slice.call(arguments, 2);
  1321. Ext.each(arr, function(v,i) {
  1322. if (v && typeof v[methodName] == 'function') {
  1323. ret.push(v[methodName].apply(v, args));
  1324. } else {
  1325. ret.push(undefined);
  1326. }
  1327. });
  1328. return ret;
  1329. },
  1330. /**
  1331. * Plucks the value of a property from each item in the Array
  1332. * <pre><code>
  1333. // Example:
  1334. Ext.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
  1335. * </code></pre>
  1336. * @param {Array|NodeList} arr The Array of items to pluck the value from.
  1337. * @param {String} prop The property name to pluck from each element.
  1338. * @return {Array} The value from each item in the Array.
  1339. */
  1340. pluck : function(arr, prop){
  1341. var ret = [];
  1342. Ext.each(arr, function(v) {
  1343. ret.push( v[prop] );
  1344. });
  1345. return ret;
  1346. },
  1347. /**
  1348. * <p>Zips N sets together.</p>
  1349. * <pre><code>
  1350. // Example 1:
  1351. Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
  1352. // Example 2:
  1353. Ext.zip(
  1354. [ "+", "-", "+"],
  1355. [ 12, 10, 22],
  1356. [ 43, 15, 96],
  1357. function(a, b, c){
  1358. return "$" + a + "" + b + "." + c
  1359. }
  1360. ); // ["$+12.43", "$-10.15", "$+22.96"]
  1361. * </code></pre>
  1362. * @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values.
  1363. * @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together.
  1364. * @return {Array} The zipped set.
  1365. */
  1366. zip : function(){
  1367. var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
  1368. arrs = parts[0],
  1369. fn = parts[1][0],
  1370. len = Ext.max(Ext.pluck(arrs, "length")),
  1371. ret = [];
  1372. for (var i = 0; i < len; i++) {
  1373. ret[i] = [];
  1374. if(fn){
  1375. ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
  1376. }else{
  1377. for (var j = 0, aLen = arrs.length; j < aLen; j++){
  1378. ret[i].push( arrs[j][i] );
  1379. }
  1380. }
  1381. }
  1382. return ret;
  1383. },
  1384. /**
  1385. * This is shorthand reference to {@link Ext.ComponentMgr#get}.
  1386. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
  1387. * @param {String} id The component {@link Ext.Component#id id}
  1388. * @return Ext.Component The Component, <tt>undefined</tt> if not found, or <tt>null</tt> if a
  1389. * Class was found.
  1390. */
  1391. getCmp : function(id){
  1392. return Ext.ComponentMgr.get(id);
  1393. },
  1394. /**
  1395. * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
  1396. * you may want to set this to true.
  1397. * @type Boolean
  1398. */
  1399. useShims: E.isIE6 || (E.isMac && E.isGecko2),
  1400. // inpired by a similar function in mootools library
  1401. /**
  1402. * Returns the type of object that is passed in. If the object passed in is null or undefined it
  1403. * return false otherwise it returns one of the following values:<div class="mdetail-params"><ul>
  1404. * <li><b>string</b>: If the object passed is a string</li>
  1405. * <li><b>number</b>: If the object passed is a number</li>
  1406. * <li><b>boolean</b>: If the object passed is a boolean value</li>
  1407. * <li><b>date</b>: If the object passed is a Date object</li>
  1408. * <li><b>function</b>: If the object passed is a function reference</li>
  1409. * <li><b>object</b>: If the object passed is an object</li>
  1410. * <li><b>array</b>: If the object passed is an array</li>
  1411. * <li><b>regexp</b>: If the object passed is a regular expression</li>
  1412. * <li><b>element</b>: If the object passed is a DOM Element</li>
  1413. * <li><b>nodelist</b>: If the object passed is a DOM NodeList</li>
  1414. * <li><b>textnode</b>: If the object passed is a DOM text node and contains something other than whitespace</li>
  1415. * <li><b>whitespace</b>: If the object passed is a DOM text node and contains only whitespace</li>
  1416. * </ul></div>
  1417. * @param {Mixed} object
  1418. * @return {String}
  1419. */
  1420. type : function(o){
  1421. if(o === undefined || o === null){
  1422. return false;
  1423. }
  1424. if(o.htmlElement){
  1425. return 'element';
  1426. }
  1427. var t = typeof o;
  1428. if(t == 'object' && o.nodeName) {
  1429. switch(o.nodeType) {
  1430. case 1: return 'element';
  1431. case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
  1432. }
  1433. }
  1434. if(t == 'object' || t == 'function') {
  1435. switch(o.constructor) {
  1436. case Array: return 'array';
  1437. case RegExp: return 'regexp';
  1438. case Date: return 'date';
  1439. }
  1440. if(typeof o.length == 'number' && typeof o.item == 'function') {
  1441. return 'nodelist';
  1442. }
  1443. }
  1444. return t;
  1445. },
  1446. intercept : function(o, name, fn, scope){
  1447. o[name] = o[name].createInterceptor(fn, scope);
  1448. },
  1449. // internal
  1450. callback : function(cb, scope, args, delay){
  1451. if(typeof cb == 'function'){
  1452. if(delay){
  1453. cb.defer(delay, scope, args || []);
  1454. }else{
  1455. cb.apply(scope, args || []);
  1456. }
  1457. }
  1458. }
  1459. };
  1460. }());
  1461. /**
  1462. * @class Function
  1463. * These functions are available on every Function object (any JavaScript function).
  1464. */
  1465. Ext.apply(Function.prototype, {
  1466. /**
  1467. * Create a combined function call sequence of the original function + the passed function.
  1468. * The resulting function returns the results of the original function.
  1469. * The passed fcn is called with the parameters of the original function. Example usage:
  1470. * <pre><code>
  1471. var sayHi = function(name){
  1472. alert('Hi, ' + name);
  1473. }
  1474. sayHi('Fred'); // alerts "Hi, Fred"
  1475. var sayGoodbye = sayHi.createSequence(function(name){
  1476. alert('Bye, ' + name);
  1477. });
  1478. sayGoodbye('Fred'); // both alerts show
  1479. </code></pre>
  1480. * @param {Function} fcn The function to sequence
  1481. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  1482. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  1483. * @return {Function} The new function
  1484. */
  1485. createSequence : function(fcn, scope){
  1486. var method = this;
  1487. return (typeof fcn != 'function') ?
  1488. this :
  1489. function(){
  1490. var retval = method.apply(this || window, arguments);
  1491. fcn.apply(scope || this || window, arguments);
  1492. return retval;
  1493. };
  1494. }
  1495. });
  1496. /**
  1497. * @class String
  1498. * These functions are available as static methods on the JavaScript String object.
  1499. */
  1500. Ext.applyIf(String, {
  1501. /**
  1502. * Escapes the passed string for ' and \
  1503. * @param {String} string The string to escape
  1504. * @return {String} The escaped string
  1505. * @static
  1506. */
  1507. escape : function(string) {
  1508. return string.replace(/('|\\)/g, "\\$1");
  1509. },
  1510. /**
  1511. * Pads the left side of a string with a specified character. This is especially useful
  1512. * for normalizing number and date strings. Example usage:
  1513. * <pre><code>
  1514. var s = String.leftPad('123', 5, '0');
  1515. // s now contains the string: '00123'
  1516. * </code></pre>
  1517. * @param {String} string The original string
  1518. * @param {Number} size The total length of the output string
  1519. * @param {String} char (optional) The character with which to pad the original string (defaults to empty string " ")
  1520. * @return {String} The padded string
  1521. * @static
  1522. */
  1523. leftPad : function (val, size, ch) {
  1524. var result = String(val);
  1525. if(!ch) {
  1526. ch = " ";
  1527. }
  1528. while (result.length < size) {
  1529. result = ch + result;
  1530. }
  1531. return result;
  1532. }
  1533. });
  1534. /**
  1535. * Utility function that allows you to easily switch a string between two alternating values. The passed value
  1536. * is compared to the current string, and if they are equal, the other value that was passed in is returned. If
  1537. * they are already different, the first value passed in is returned. Note that this method returns the new value
  1538. * but does not change the current string.
  1539. * <pre><code>
  1540. // alternate sort directions
  1541. sort = sort.toggle('ASC', 'DESC');
  1542. // instead of conditional logic:
  1543. sort = (sort == 'ASC' ? 'DESC' : 'ASC');
  1544. </code></pre>
  1545. * @param {String} value The value to compare to the current string
  1546. * @param {String} other The new value to use if the string already equals the first value passed in
  1547. * @return {String} The new value
  1548. */
  1549. String.prototype.toggle = function(value, other){
  1550. return this == value ? other : value;
  1551. };
  1552. /**
  1553. * Trims whitespace from either end of a string, leaving spaces within the string intact. Example:
  1554. * <pre><code>
  1555. var s = ' foo bar ';
  1556. alert('-' + s + '-'); //alerts "- foo bar -"
  1557. alert('-' + s.trim() + '-'); //alerts "-foo bar-"
  1558. </code></pre>
  1559. * @return {String} The trimmed string
  1560. */
  1561. String.prototype.trim = function(){
  1562. var re = /^\s+|\s+$/g;
  1563. return function(){ return this.replace(re, ""); };
  1564. }();
  1565. // here to prevent dependency on Date.js
  1566. /**
  1567. Returns the number of milliseconds between this date and date
  1568. @param {Date} date (optional) Defaults to now
  1569. @return {Number} The diff in milliseconds
  1570. @member Date getElapsed
  1571. */
  1572. Date.prototype.getElapsed = function(date) {
  1573. return Math.abs((date || new Date()).getTime()-this.getTime());
  1574. };
  1575. /**
  1576. * @class Number
  1577. */
  1578. Ext.applyIf(Number.prototype, {
  1579. /**
  1580. * Checks whether or not the current number is within a desired range. If the number is already within the
  1581. * range it is returned, otherwise the min or max value is returned depending on which side of the range is
  1582. * exceeded. Note that this method returns the constrained value but does not change the current number.
  1583. * @param {Number} min The minimum number in the range
  1584. * @param {Number} max The maximum number in the range
  1585. * @return {Number} The constrained value if outside the range, otherwise the current value
  1586. */
  1587. constrain : function(min, max){
  1588. return Math.min(Math.max(this, min), max);
  1589. }
  1590. });
  1591. /**
  1592. * @class Ext.util.TaskRunner
  1593. * Provides the ability to execute one or more arbitrary tasks in a multithreaded
  1594. * manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
  1595. * if needed, you can create separate instances of TaskRunner. Any number of
  1596. * separate tasks can be started at any time and will run independently of each
  1597. * other. Example usage:
  1598. * <pre><code>
  1599. // Start a simple clock task that updates a div once per second
  1600. var updateClock = function(){
  1601. Ext.fly('clock').update(new Date().format('g:i:s A'));
  1602. }
  1603. var task = {
  1604. run: updateClock,
  1605. interval: 1000 //1 second
  1606. }
  1607. var runner = new Ext.util.TaskRunner();
  1608. runner.start(task);
  1609. // equivalent using TaskMgr
  1610. Ext.TaskMgr.start({
  1611. run: updateClock,
  1612. interval: 1000
  1613. });
  1614. * </code></pre>
  1615. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1616. * Also see {@link Ext.util.DelayedTask}.
  1617. *
  1618. * @constructor
  1619. * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
  1620. * (defaults to 10)
  1621. */
  1622. Ext.util.TaskRunner = function(interval){
  1623. interval = interval || 10;
  1624. var tasks = [],
  1625. removeQueue = [],
  1626. id = 0,
  1627. running = false,
  1628. // private
  1629. stopThread = function(){
  1630. running = false;
  1631. clearInterval(id);
  1632. id = 0;
  1633. },
  1634. // private
  1635. startThread = function(){
  1636. if(!running){
  1637. running = true;
  1638. id = setInterval(runTasks, interval);
  1639. }
  1640. },
  1641. // private
  1642. removeTask = function(t){
  1643. removeQueue.push(t);
  1644. if(t.onStop){
  1645. t.onStop.apply(t.scope || t);
  1646. }
  1647. },
  1648. // private
  1649. runTasks = function(){
  1650. var rqLen = removeQueue.length,
  1651. now = new Date().getTime();
  1652. if(rqLen > 0){
  1653. for(var i = 0; i < rqLen; i++){
  1654. tasks.remove(removeQueue[i]);
  1655. }
  1656. removeQueue = [];
  1657. if(tasks.length < 1){
  1658. stopThread();
  1659. return;
  1660. }
  1661. }
  1662. for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){
  1663. t = tasks[i];
  1664. itime = now - t.taskRunTime;
  1665. if(t.interval <= itime){
  1666. rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
  1667. t.taskRunTime = now;
  1668. if(rt === false || t.taskRunCount === t.repeat){
  1669. removeTask(t);
  1670. return;
  1671. }
  1672. }
  1673. if(t.duration && t.duration <= (now - t.taskStartTime)){
  1674. removeTask(t);
  1675. }
  1676. }
  1677. };
  1678. /**
  1679. * Starts a new task.
  1680. * @method start
  1681. * @param {Object} task <p>A config object that supports the following properties:<ul>
  1682. * <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
  1683. * function will be called at each interval and passed the <code>args</code> argument if specified, and the
  1684. * current invocation count if not.</p>
  1685. * <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
  1686. * <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
  1687. * <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
  1688. * should be invoked.</div></li>
  1689. * <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
  1690. * specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
  1691. * <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
  1692. * <code>run</code> function. Defaults to the task config object.</div></li>
  1693. * <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
  1694. * the task before stopping automatically (defaults to indefinite).</div></li>
  1695. * <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
  1696. * stopping automatically (defaults to indefinite).</div></li>
  1697. * </ul></p>
  1698. * <p>Before each invocation, Ext injects the property <code>taskRunCount</code> into the task object so
  1699. * that calculations based on the repeat count can be performed.</p>
  1700. * @return {Object} The task
  1701. */
  1702. this.start = function(task){
  1703. tasks.push(task);
  1704. task.taskStartTime = new Date().getTime();
  1705. task.taskRunTime = 0;
  1706. task.taskRunCount = 0;
  1707. startThread();
  1708. return task;
  1709. };
  1710. /**
  1711. * Stops an existing running task.
  1712. * @method stop
  1713. * @param {Object} task The task to stop
  1714. * @return {Object} The task
  1715. */
  1716. this.stop = function(task){
  1717. removeTask(task);
  1718. return task;
  1719. };
  1720. /**
  1721. * Stops all tasks that are currently running.
  1722. * @method stopAll
  1723. */
  1724. this.stopAll = function(){
  1725. stopThread();
  1726. for(var i = 0, len = tasks.length; i < len; i++){
  1727. if(tasks[i].onStop){
  1728. tasks[i].onStop();
  1729. }
  1730. }
  1731. tasks = [];
  1732. removeQueue = [];
  1733. };
  1734. };
  1735. /**
  1736. * @class Ext.TaskMgr
  1737. * @extends Ext.util.TaskRunner
  1738. * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop arbitrary tasks. See
  1739. * {@link Ext.util.TaskRunner} for supported methods and task config properties.
  1740. * <pre><code>
  1741. // Start a simple clock task that updates a div once per second
  1742. var task = {
  1743. run: function(){
  1744. Ext.fly('clock').update(new Date().format('g:i:s A'));
  1745. },
  1746. interval: 1000 //1 second
  1747. }
  1748. Ext.TaskMgr.start(task);
  1749. </code></pre>
  1750. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1751. * @singleton
  1752. */
  1753. Ext.TaskMgr = new Ext.util.TaskRunner();if(typeof jQuery == "undefined"){
  1754. throw "Unable to load Ext, jQuery not found.";
  1755. }
  1756. (function(){
  1757. var libFlyweight;
  1758. Ext.lib.Dom = {
  1759. getViewWidth : function(full){
  1760. // jQuery doesn't report full window size on document query, so max both
  1761. return full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
  1762. },
  1763. getViewHeight : function(full){
  1764. // jQuery doesn't report full window size on document query, so max both
  1765. return full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
  1766. },
  1767. isAncestor : function(p, c){
  1768. var ret = false;
  1769. p = Ext.getDom(p);
  1770. c = Ext.getDom(c);
  1771. if (p && c) {
  1772. if (p.contains) {
  1773. return p.contains(c);
  1774. } else if (p.compareDocumentPosition) {
  1775. return !!(p.compareDocumentPosition(c) & 16);
  1776. } else {
  1777. while (c = c.parentNode) {
  1778. ret = c == p || ret;
  1779. }
  1780. }
  1781. }
  1782. return ret;
  1783. },
  1784. getRegion : function(el){
  1785. return Ext.lib.Region.getRegion(el);
  1786. },
  1787. //////////////////////////////////////////////////////////////////////////////////////
  1788. // Use of jQuery.offset() removed to promote consistent behavior across libs.
  1789. // JVS 05/23/07
  1790. //////////////////////////////////////////////////////////////////////////////////////
  1791. getY : function(el){
  1792. return this.getXY(el)[1];
  1793. },
  1794. getX : function(el){
  1795. return this.getXY(el)[0];
  1796. },
  1797. getXY : function(el) {
  1798. var p, pe, b, scroll, bd = (document.body || document.documentElement);
  1799. el = Ext.getDom(el);
  1800. if(el == bd){
  1801. return [0, 0];
  1802. }
  1803. if (el.getBoundingClientRect) {
  1804. b = el.getBoundingClientRect();
  1805. scroll = fly(document).getScroll();
  1806. return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
  1807. }
  1808. var x = 0, y = 0;
  1809. p = el;
  1810. var hasAbsolute = fly(el).getStyle("position") == "absolute";
  1811. while (p) {
  1812. x += p.offsetLeft;
  1813. y += p.offsetTop;
  1814. if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
  1815. hasAbsolute = true;
  1816. }
  1817. if (Ext.isGecko) {
  1818. pe = fly(p);
  1819. var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
  1820. var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
  1821. x += bl;
  1822. y += bt;
  1823. if (p != el && pe.getStyle('overflow') != 'visible') {
  1824. x += bl;
  1825. y += bt;
  1826. }
  1827. }
  1828. p = p.offsetParent;
  1829. }
  1830. if (Ext.isSafari && hasAbsolute) {
  1831. x -= bd.offsetLeft;
  1832. y -= bd.offsetTop;
  1833. }
  1834. if (Ext.isGecko && !hasAbsolute) {
  1835. var dbd = fly(bd);
  1836. x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
  1837. y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
  1838. }
  1839. p = el.parentNode;
  1840. while (p && p != bd) {
  1841. if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
  1842. x -= p.scrollLeft;
  1843. y -= p.scrollTop;
  1844. }
  1845. p = p.parentNode;
  1846. }
  1847. return [x, y];
  1848. },
  1849. setXY : function(el, xy){
  1850. el = Ext.fly(el, '_setXY');
  1851. el.position();
  1852. var pts = el.translatePoints(xy);
  1853. if(xy[0] !== false){
  1854. el.dom.style.left = pts.left + "px";
  1855. }
  1856. if(xy[1] !== false){
  1857. el.dom.style.top = pts.top + "px";
  1858. }
  1859. },
  1860. setX : function(el, x){
  1861. this.setXY(el, [x, false]);
  1862. },
  1863. setY : function(el, y){
  1864. this.setXY(el, [false, y]);
  1865. }
  1866. };
  1867. // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
  1868. function fly(el){
  1869. if(!libFlyweight){
  1870. libFlyweight = new Ext.Element.Flyweight();
  1871. }
  1872. libFlyweight.dom = el;
  1873. return libFlyweight;
  1874. }
  1875. Ext.lib.Event = {
  1876. getPageX : function(e){
  1877. e = e.browserEvent || e;
  1878. return e.pageX;
  1879. },
  1880. getPageY : function(e){
  1881. e = e.browserEvent || e;
  1882. return e.pageY;
  1883. },
  1884. getXY : function(e){
  1885. e = e.browserEvent || e;
  1886. return [e.pageX, e.pageY];
  1887. },
  1888. getTarget : function(e){
  1889. return e.target;
  1890. },
  1891. // all Ext events will go through event manager which provides scoping
  1892. on : function(el, eventName, fn, scope, override){
  1893. jQuery(el).bind(eventName, fn);
  1894. },
  1895. un : function(el, eventName, fn){
  1896. jQuery(el).unbind(eventName, fn);
  1897. },
  1898. purgeElement : function(el){
  1899. jQuery(el).unbind();
  1900. },
  1901. preventDefault : function(e){
  1902. e = e.browserEvent || e;
  1903. if(e.preventDefault){
  1904. e.preventDefault();
  1905. }else{
  1906. e.returnValue = false;
  1907. }
  1908. },
  1909. stopPropagation : function(e){
  1910. e = e.browserEvent || e;
  1911. if(e.stopPropagation){
  1912. e.stopPropagation();
  1913. }else{
  1914. e.cancelBubble = true;
  1915. }
  1916. },
  1917. stopEvent : function(e){
  1918. this.preventDefault(e);
  1919. this.stopPropagation(e);
  1920. },
  1921. onAvailable : function(id, fn, scope){
  1922. var start = new Date();
  1923. var f = function(){
  1924. if(start.getElapsed() > 10000){
  1925. clearInterval(iid);
  1926. }
  1927. var el = document.getElementById(id);
  1928. if(el){
  1929. clearInterval(iid);
  1930. fn.call(scope||window, el);
  1931. }
  1932. };
  1933. var iid = setInterval(f, 50);
  1934. },
  1935. resolveTextNode: Ext.isGecko ? function(node){
  1936. if(!node){
  1937. return;
  1938. }
  1939. var s = HTMLElement.prototype.toString.call(node);
  1940. if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
  1941. return;
  1942. }
  1943. return node.nodeType == 3 ? node.parentNode : node;
  1944. } : function(node){
  1945. return node && node.nodeType == 3 ? node.parentNode : node;
  1946. },
  1947. getRelatedTarget: function(ev) {
  1948. ev = ev.browserEvent || ev;
  1949. var t = ev.relatedTarget;
  1950. if (!t) {
  1951. if (ev.type == "mouseout") {
  1952. t = ev.toElement;
  1953. } else if (ev.type == "mouseover") {
  1954. t = ev.fromElement;
  1955. }
  1956. }
  1957. return this.resolveTextNode(t);
  1958. }
  1959. };
  1960. Ext.lib.Ajax = function(){
  1961. var createComplete = function(cb){
  1962. return function(xhr, status){
  1963. if((status == 'error' || status == 'timeout') && cb.failure){
  1964. cb.failure.call(cb.scope||window, createResponse(cb, xhr));
  1965. }else if(cb.success){
  1966. cb.success.call(cb.scope||window, createResponse(cb, xhr));
  1967. }
  1968. };
  1969. };
  1970. var createResponse = function(cb, xhr){
  1971. var headerObj = {},
  1972. headerStr,
  1973. t,
  1974. s;
  1975. try {
  1976. headerStr = xhr.getAllResponseHeaders();
  1977. Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
  1978. t = v.indexOf(':');
  1979. if(t >= 0){
  1980. s = v.substr(0, t).toLowerCase();
  1981. if(v.charAt(t + 1) == ' '){
  1982. ++t;
  1983. }
  1984. headerObj[s] = v.substr(t + 1);
  1985. }
  1986. });
  1987. } catch(e) {}
  1988. return {
  1989. responseText: xhr.responseText,
  1990. responseXML : xhr.responseXML,
  1991. argument: cb.argument,
  1992. status: xhr.status,
  1993. statusText: xhr.statusText,
  1994. getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
  1995. getAllResponseHeaders : function(){return headerStr}
  1996. };
  1997. };
  1998. return {
  1999. request : function(method, uri, cb, data, options){
  2000. var o = {
  2001. type: method,
  2002. url: uri,
  2003. data: data,
  2004. timeout: cb.timeout,
  2005. complete: createComplete(cb)
  2006. };
  2007. if(options){
  2008. var hs = options.headers;
  2009. if(options.xmlData){
  2010. o.data = options.xmlData;
  2011. o.processData = false;
  2012. o.type = (method ? method : (options.method ? options.method : 'POST'));
  2013. if (!hs || !hs['Content-Type']){
  2014. o.contentType = 'text/xml';
  2015. }
  2016. }else if(options.jsonData){
  2017. o.data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
  2018. o.processData = false;
  2019. o.type = (method ? method : (options.method ? options.method : 'POST'));
  2020. if (!hs || !hs['Content-Type']){
  2021. o.contentType = 'application/json';
  2022. }
  2023. }
  2024. if(hs){
  2025. o.beforeSend = function(xhr){
  2026. for(var h in hs){
  2027. if(hs.hasOwnProperty(h)){
  2028. xhr.setRequestHeader(h, hs[h]);
  2029. }
  2030. }
  2031. }
  2032. }
  2033. }
  2034. jQuery.ajax(o);
  2035. },
  2036. formRequest : function(form, uri, cb, data, isUpload, sslUri){
  2037. jQuery.ajax({
  2038. type: Ext.getDom(form).method ||'POST',
  2039. url: uri,
  2040. data: jQuery(form).serialize()+(data?'&'+data:''),
  2041. timeout: cb.timeout,
  2042. complete: createComplete(cb)
  2043. });
  2044. },
  2045. isCallInProgress : function(trans){
  2046. return false;
  2047. },
  2048. abort : function(trans){
  2049. return false;
  2050. },
  2051. serializeForm : function(form){
  2052. return jQuery(form.dom||form).serialize();
  2053. }
  2054. };
  2055. }();
  2056. Ext.lib.Anim = function(){
  2057. var createAnim = function(cb, scope){
  2058. var animated = true;
  2059. return {
  2060. stop : function(skipToLast){
  2061. // do nothing
  2062. },
  2063. isAnimated : function(){
  2064. return animated;
  2065. },
  2066. proxyCallback : function(){
  2067. animated = false;
  2068. Ext.callback(cb, scope);
  2069. }
  2070. };
  2071. };
  2072. return {
  2073. scroll : function(el, args, duration, easing, cb, scope){
  2074. // scroll anim not supported so just scroll immediately
  2075. var anim = createAnim(cb, scope);
  2076. el = Ext.getDom(el);
  2077. if(typeof args.scroll.to[0] == 'number'){
  2078. el.scrollLeft = args.scroll.to[0];
  2079. }
  2080. if(typeof args.scroll.to[1] == 'number'){
  2081. el.scrollTop = args.scroll.to[1];
  2082. }
  2083. anim.proxyCallback();
  2084. return anim;
  2085. },
  2086. motion : function(el, args, duration, easing, cb, scope){
  2087. return this.run(el, args, duration, easing, cb, scope);
  2088. },
  2089. color : function(el, args, duration, easing, cb, scope){
  2090. // color anim not supported, so execute callback immediately
  2091. var anim = createAnim(cb, scope);
  2092. anim.proxyCallback();
  2093. return anim;
  2094. },
  2095. run : function(el, args, duration, easing, cb, scope, type){
  2096. var anim = createAnim(cb, scope), e = Ext.fly(el, '_animrun');
  2097. var o = {};
  2098. for(var k in args){
  2099. switch(k){ // jquery doesn't support, so convert
  2100. case 'points':
  2101. var by, pts;
  2102. e.position();
  2103. if(by = args.points.by){
  2104. var xy = e.getXY();
  2105. pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
  2106. }else{
  2107. pts = e.translatePoints(args.points.to);
  2108. }
  2109. o.left = pts.left;
  2110. o.top = pts.top;
  2111. if(!parseInt(e.getStyle('left'), 10)){ // auto bug
  2112. e.setLeft(0);
  2113. }
  2114. if(!parseInt(e.getStyle('top'), 10)){
  2115. e.setTop(0);
  2116. }
  2117. if(args.points.from){
  2118. e.setXY(args.points.from);
  2119. }
  2120. break;
  2121. case 'width':
  2122. o.width = args.width.to;
  2123. if (args.width.from)
  2124. e.setWidth(args.width.from);
  2125. break;
  2126. case 'height':
  2127. o.height = args.height.to;
  2128. if (args.height.from)
  2129. e.setHeight(args.height.from);
  2130. break;
  2131. case 'opacity':
  2132. o.opacity = args.opacity.to;
  2133. if (args.opacity.from)
  2134. e.setOpacity(args.opacity.from);
  2135. break;
  2136. case 'left':
  2137. o.left = args.left.to;
  2138. if (args.left.from)
  2139. e.setLeft(args.left.from);
  2140. break;
  2141. case 'top':
  2142. o.top = args.top.to;
  2143. if (args.top.from)
  2144. e.setTop(args.top.from);
  2145. break;
  2146. // jQuery can't handle callback, scope, and xy arguments, so break here
  2147. case 'callback':
  2148. case 'scope':
  2149. case 'xy':
  2150. break;
  2151. default:
  2152. o[k] = args[k].to;
  2153. if (args[k].from)
  2154. e.setStyle(k, args[k].from);
  2155. break;
  2156. }
  2157. }
  2158. // TODO: find out about easing plug in?
  2159. jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
  2160. return anim;
  2161. }
  2162. };
  2163. }();
  2164. Ext.lib.Region = function(t, r, b, l) {
  2165. this.top = t;
  2166. this[1] = t;
  2167. this.right = r;
  2168. this.bottom = b;
  2169. this.left = l;
  2170. this[0] = l;
  2171. };
  2172. Ext.lib.Region.prototype = {
  2173. contains : function(region) {
  2174. return ( region.left >= this.left &&
  2175. region.right <= this.right &&
  2176. region.top >= this.top &&
  2177. region.bottom <= this.bottom );
  2178. },
  2179. getArea : function() {
  2180. return ( (this.bottom - this.top) * (this.right - this.left) );
  2181. },
  2182. intersect : function(region) {
  2183. var t = Math.max( this.top, region.top );
  2184. var r = Math.min( this.right, region.right );
  2185. var b = Math.min( this.bottom, region.bottom );
  2186. var l = Math.max( this.left, region.left );
  2187. if (b >= t && r >= l) {
  2188. return new Ext.lib.Region(t, r, b, l);
  2189. } else {
  2190. return null;
  2191. }
  2192. },
  2193. union : function(region) {
  2194. var t = Math.min( this.top, region.top );
  2195. var r = Math.max( this.right, region.right );
  2196. var b = Math.max( this.bottom, region.bottom );
  2197. var l = Math.min( this.left, region.left );
  2198. return new Ext.lib.Region(t, r, b, l);
  2199. },
  2200. constrainTo : function(r) {
  2201. this.top = this.top.constrain(r.top, r.bottom);
  2202. this.bottom = this.bottom.constrain(r.top, r.bottom);
  2203. this.left = this.left.constrain(r.left, r.right);
  2204. this.right = this.right.constrain(r.left, r.right);
  2205. return this;
  2206. },
  2207. adjust : function(t, l, b, r){
  2208. this.top += t;
  2209. this.left += l;
  2210. this.right += r;
  2211. this.bottom += b;
  2212. return this;
  2213. }
  2214. };
  2215. Ext.lib.Region.getRegion = function(el) {
  2216. var p = Ext.lib.Dom.getXY(el);
  2217. var t = p[1];
  2218. var r = p[0] + el.offsetWidth;
  2219. var b = p[1] + el.offsetHeight;
  2220. var l = p[0];
  2221. return new Ext.lib.Region(t, r, b, l);
  2222. };
  2223. Ext.lib.Point = function(x, y) {
  2224. if (Ext.isArray(x)) {
  2225. y = x[1];
  2226. x = x[0];
  2227. }
  2228. this.x = this.right = this.left = this[0] = x;
  2229. this.y = this.top = this.bottom = this[1] = y;
  2230. };
  2231. Ext.lib.Point.prototype = new Ext.lib.Region();
  2232. // prevent IE leaks
  2233. if(Ext.isIE) {
  2234. function fnCleanUp() {
  2235. var p = Function.prototype;
  2236. delete p.createSequence;
  2237. delete p.defer;
  2238. delete p.createDelegate;
  2239. delete p.createCallback;
  2240. delete p.createInterceptor;
  2241. window.detachEvent("onunload", fnCleanUp);
  2242. }
  2243. window.attachEvent("onunload", fnCleanUp);
  2244. }
  2245. })();