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.

2885 lines
94 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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();(function(){
  1145. var libFlyweight;
  1146. function fly(el) {
  1147. if (!libFlyweight) {
  1148. libFlyweight = new Ext.Element.Flyweight();
  1149. }
  1150. libFlyweight.dom = el;
  1151. return libFlyweight;
  1152. }
  1153. (function(){
  1154. var doc = document,
  1155. isCSS1 = doc.compatMode == "CSS1Compat",
  1156. MAX = Math.max,
  1157. ROUND = Math.round,
  1158. PARSEINT = parseInt;
  1159. Ext.lib.Dom = {
  1160. isAncestor : function(p, c) {
  1161. var ret = false;
  1162. p = Ext.getDom(p);
  1163. c = Ext.getDom(c);
  1164. if (p && c) {
  1165. if (p.contains) {
  1166. return p.contains(c);
  1167. } else if (p.compareDocumentPosition) {
  1168. return !!(p.compareDocumentPosition(c) & 16);
  1169. } else {
  1170. while (c = c.parentNode) {
  1171. ret = c == p || ret;
  1172. }
  1173. }
  1174. }
  1175. return ret;
  1176. },
  1177. getViewWidth : function(full) {
  1178. return full ? this.getDocumentWidth() : this.getViewportWidth();
  1179. },
  1180. getViewHeight : function(full) {
  1181. return full ? this.getDocumentHeight() : this.getViewportHeight();
  1182. },
  1183. getDocumentHeight: function() {
  1184. return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());
  1185. },
  1186. getDocumentWidth: function() {
  1187. return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());
  1188. },
  1189. getViewportHeight: function(){
  1190. return Ext.isIE ?
  1191. (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
  1192. self.innerHeight;
  1193. },
  1194. getViewportWidth : function() {
  1195. return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :
  1196. Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
  1197. },
  1198. getY : function(el) {
  1199. return this.getXY(el)[1];
  1200. },
  1201. getX : function(el) {
  1202. return this.getXY(el)[0];
  1203. },
  1204. getXY : function(el) {
  1205. var p,
  1206. pe,
  1207. b,
  1208. bt,
  1209. bl,
  1210. dbd,
  1211. x = 0,
  1212. y = 0,
  1213. scroll,
  1214. hasAbsolute,
  1215. bd = (doc.body || doc.documentElement),
  1216. ret = [0,0];
  1217. el = Ext.getDom(el);
  1218. if(el != bd){
  1219. if (el.getBoundingClientRect) {
  1220. b = el.getBoundingClientRect();
  1221. scroll = fly(document).getScroll();
  1222. ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)];
  1223. } else {
  1224. p = el;
  1225. hasAbsolute = fly(el).isStyle("position", "absolute");
  1226. while (p) {
  1227. pe = fly(p);
  1228. x += p.offsetLeft;
  1229. y += p.offsetTop;
  1230. hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
  1231. if (Ext.isGecko) {
  1232. y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;
  1233. x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;
  1234. if (p != el && !pe.isStyle('overflow','visible')) {
  1235. x += bl;
  1236. y += bt;
  1237. }
  1238. }
  1239. p = p.offsetParent;
  1240. }
  1241. if (Ext.isSafari && hasAbsolute) {
  1242. x -= bd.offsetLeft;
  1243. y -= bd.offsetTop;
  1244. }
  1245. if (Ext.isGecko && !hasAbsolute) {
  1246. dbd = fly(bd);
  1247. x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;
  1248. y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;
  1249. }
  1250. p = el.parentNode;
  1251. while (p && p != bd) {
  1252. if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
  1253. x -= p.scrollLeft;
  1254. y -= p.scrollTop;
  1255. }
  1256. p = p.parentNode;
  1257. }
  1258. ret = [x,y];
  1259. }
  1260. }
  1261. return ret;
  1262. },
  1263. setXY : function(el, xy) {
  1264. (el = Ext.fly(el, '_setXY')).position();
  1265. var pts = el.translatePoints(xy),
  1266. style = el.dom.style,
  1267. pos;
  1268. for (pos in pts) {
  1269. if (!isNaN(pts[pos])) {
  1270. style[pos] = pts[pos] + "px";
  1271. }
  1272. }
  1273. },
  1274. setX : function(el, x) {
  1275. this.setXY(el, [x, false]);
  1276. },
  1277. setY : function(el, y) {
  1278. this.setXY(el, [false, y]);
  1279. }
  1280. };
  1281. })();Ext.lib.Event = function() {
  1282. var loadComplete = false,
  1283. unloadListeners = {},
  1284. retryCount = 0,
  1285. onAvailStack = [],
  1286. _interval,
  1287. locked = false,
  1288. win = window,
  1289. doc = document,
  1290. // constants
  1291. POLL_RETRYS = 200,
  1292. POLL_INTERVAL = 20,
  1293. TYPE = 0,
  1294. FN = 1,
  1295. OBJ = 2,
  1296. ADJ_SCOPE = 3,
  1297. SCROLLLEFT = 'scrollLeft',
  1298. SCROLLTOP = 'scrollTop',
  1299. UNLOAD = 'unload',
  1300. MOUSEOVER = 'mouseover',
  1301. MOUSEOUT = 'mouseout',
  1302. // private
  1303. doAdd = function() {
  1304. var ret;
  1305. if (win.addEventListener) {
  1306. ret = function(el, eventName, fn, capture) {
  1307. if (eventName == 'mouseenter') {
  1308. fn = fn.createInterceptor(checkRelatedTarget);
  1309. el.addEventListener(MOUSEOVER, fn, (capture));
  1310. } else if (eventName == 'mouseleave') {
  1311. fn = fn.createInterceptor(checkRelatedTarget);
  1312. el.addEventListener(MOUSEOUT, fn, (capture));
  1313. } else {
  1314. el.addEventListener(eventName, fn, (capture));
  1315. }
  1316. return fn;
  1317. };
  1318. } else if (win.attachEvent) {
  1319. ret = function(el, eventName, fn, capture) {
  1320. el.attachEvent("on" + eventName, fn);
  1321. return fn;
  1322. };
  1323. } else {
  1324. ret = function(){};
  1325. }
  1326. return ret;
  1327. }(),
  1328. // private
  1329. doRemove = function(){
  1330. var ret;
  1331. if (win.removeEventListener) {
  1332. ret = function (el, eventName, fn, capture) {
  1333. if (eventName == 'mouseenter') {
  1334. eventName = MOUSEOVER;
  1335. } else if (eventName == 'mouseleave') {
  1336. eventName = MOUSEOUT;
  1337. }
  1338. el.removeEventListener(eventName, fn, (capture));
  1339. };
  1340. } else if (win.detachEvent) {
  1341. ret = function (el, eventName, fn) {
  1342. el.detachEvent("on" + eventName, fn);
  1343. };
  1344. } else {
  1345. ret = function(){};
  1346. }
  1347. return ret;
  1348. }();
  1349. function checkRelatedTarget(e) {
  1350. return !elContains(e.currentTarget, pub.getRelatedTarget(e));
  1351. }
  1352. function elContains(parent, child) {
  1353. if(parent && parent.firstChild){
  1354. while(child) {
  1355. if(child === parent) {
  1356. return true;
  1357. }
  1358. child = child.parentNode;
  1359. if(child && (child.nodeType != 1)) {
  1360. child = null;
  1361. }
  1362. }
  1363. }
  1364. return false;
  1365. }
  1366. // private
  1367. function _tryPreloadAttach() {
  1368. var ret = false,
  1369. notAvail = [],
  1370. element, i, v, override,
  1371. tryAgain = !loadComplete || (retryCount > 0);
  1372. if(!locked){
  1373. locked = true;
  1374. for(i = 0; i < onAvailStack.length; ++i){
  1375. v = onAvailStack[i];
  1376. if(v && (element = doc.getElementById(v.id))){
  1377. if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
  1378. override = v.override;
  1379. element = override ? (override === true ? v.obj : override) : element;
  1380. v.fn.call(element, v.obj);
  1381. onAvailStack.remove(v);
  1382. --i;
  1383. }else{
  1384. notAvail.push(v);
  1385. }
  1386. }
  1387. }
  1388. retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
  1389. if (tryAgain) {
  1390. startInterval();
  1391. } else {
  1392. clearInterval(_interval);
  1393. _interval = null;
  1394. }
  1395. ret = !(locked = false);
  1396. }
  1397. return ret;
  1398. }
  1399. // private
  1400. function startInterval() {
  1401. if(!_interval){
  1402. var callback = function() {
  1403. _tryPreloadAttach();
  1404. };
  1405. _interval = setInterval(callback, POLL_INTERVAL);
  1406. }
  1407. }
  1408. // private
  1409. function getScroll() {
  1410. var dd = doc.documentElement,
  1411. db = doc.body;
  1412. if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
  1413. return [dd[SCROLLLEFT], dd[SCROLLTOP]];
  1414. }else if(db){
  1415. return [db[SCROLLLEFT], db[SCROLLTOP]];
  1416. }else{
  1417. return [0, 0];
  1418. }
  1419. }
  1420. // private
  1421. function getPageCoord (ev, xy) {
  1422. ev = ev.browserEvent || ev;
  1423. var coord = ev['page' + xy];
  1424. if (!coord && coord !== 0) {
  1425. coord = ev['client' + xy] || 0;
  1426. if (Ext.isIE) {
  1427. coord += getScroll()[xy == "X" ? 0 : 1];
  1428. }
  1429. }
  1430. return coord;
  1431. }
  1432. var pub = {
  1433. extAdapter: true,
  1434. onAvailable : function(p_id, p_fn, p_obj, p_override) {
  1435. onAvailStack.push({
  1436. id: p_id,
  1437. fn: p_fn,
  1438. obj: p_obj,
  1439. override: p_override,
  1440. checkReady: false });
  1441. retryCount = POLL_RETRYS;
  1442. startInterval();
  1443. },
  1444. // This function should ALWAYS be called from Ext.EventManager
  1445. addListener: function(el, eventName, fn) {
  1446. el = Ext.getDom(el);
  1447. if (el && fn) {
  1448. if (eventName == UNLOAD) {
  1449. if (unloadListeners[el.id] === undefined) {
  1450. unloadListeners[el.id] = [];
  1451. }
  1452. unloadListeners[el.id].push([eventName, fn]);
  1453. return fn;
  1454. }
  1455. return doAdd(el, eventName, fn, false);
  1456. }
  1457. return false;
  1458. },
  1459. // This function should ALWAYS be called from Ext.EventManager
  1460. removeListener: function(el, eventName, fn) {
  1461. el = Ext.getDom(el);
  1462. var i, len, li, lis;
  1463. if (el && fn) {
  1464. if(eventName == UNLOAD){
  1465. if((lis = unloadListeners[el.id]) !== undefined){
  1466. for(i = 0, len = lis.length; i < len; i++){
  1467. if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
  1468. unloadListeners[el.id].splice(i, 1);
  1469. }
  1470. }
  1471. }
  1472. return;
  1473. }
  1474. doRemove(el, eventName, fn, false);
  1475. }
  1476. },
  1477. getTarget : function(ev) {
  1478. ev = ev.browserEvent || ev;
  1479. return this.resolveTextNode(ev.target || ev.srcElement);
  1480. },
  1481. resolveTextNode : Ext.isGecko ? function(node){
  1482. if(!node){
  1483. return;
  1484. }
  1485. // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
  1486. var s = HTMLElement.prototype.toString.call(node);
  1487. if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
  1488. return;
  1489. }
  1490. return node.nodeType == 3 ? node.parentNode : node;
  1491. } : function(node){
  1492. return node && node.nodeType == 3 ? node.parentNode : node;
  1493. },
  1494. getRelatedTarget : function(ev) {
  1495. ev = ev.browserEvent || ev;
  1496. return this.resolveTextNode(ev.relatedTarget ||
  1497. (/(mouseout|mouseleave)/.test(ev.type) ? ev.toElement :
  1498. /(mouseover|mouseenter)/.test(ev.type) ? ev.fromElement : null));
  1499. },
  1500. getPageX : function(ev) {
  1501. return getPageCoord(ev, "X");
  1502. },
  1503. getPageY : function(ev) {
  1504. return getPageCoord(ev, "Y");
  1505. },
  1506. getXY : function(ev) {
  1507. return [this.getPageX(ev), this.getPageY(ev)];
  1508. },
  1509. stopEvent : function(ev) {
  1510. this.stopPropagation(ev);
  1511. this.preventDefault(ev);
  1512. },
  1513. stopPropagation : function(ev) {
  1514. ev = ev.browserEvent || ev;
  1515. if (ev.stopPropagation) {
  1516. ev.stopPropagation();
  1517. } else {
  1518. ev.cancelBubble = true;
  1519. }
  1520. },
  1521. preventDefault : function(ev) {
  1522. ev = ev.browserEvent || ev;
  1523. if (ev.preventDefault) {
  1524. ev.preventDefault();
  1525. } else {
  1526. ev.returnValue = false;
  1527. }
  1528. },
  1529. getEvent : function(e) {
  1530. e = e || win.event;
  1531. if (!e) {
  1532. var c = this.getEvent.caller;
  1533. while (c) {
  1534. e = c.arguments[0];
  1535. if (e && Event == e.constructor) {
  1536. break;
  1537. }
  1538. c = c.caller;
  1539. }
  1540. }
  1541. return e;
  1542. },
  1543. getCharCode : function(ev) {
  1544. ev = ev.browserEvent || ev;
  1545. return ev.charCode || ev.keyCode || 0;
  1546. },
  1547. //clearCache: function() {},
  1548. // deprecated, call from EventManager
  1549. getListeners : function(el, eventName) {
  1550. Ext.EventManager.getListeners(el, eventName);
  1551. },
  1552. // deprecated, call from EventManager
  1553. purgeElement : function(el, recurse, eventName) {
  1554. Ext.EventManager.purgeElement(el, recurse, eventName);
  1555. },
  1556. _load : function(e) {
  1557. loadComplete = true;
  1558. if (Ext.isIE && e !== true) {
  1559. // IE8 complains that _load is null or not an object
  1560. // so lets remove self via arguments.callee
  1561. doRemove(win, "load", arguments.callee);
  1562. }
  1563. },
  1564. _unload : function(e) {
  1565. var EU = Ext.lib.Event,
  1566. i, v, ul, id, len, scope;
  1567. for (id in unloadListeners) {
  1568. ul = unloadListeners[id];
  1569. for (i = 0, len = ul.length; i < len; i++) {
  1570. v = ul[i];
  1571. if (v) {
  1572. try{
  1573. scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
  1574. v[FN].call(scope, EU.getEvent(e), v[OBJ]);
  1575. }catch(ex){}
  1576. }
  1577. }
  1578. };
  1579. Ext.EventManager._unload();
  1580. doRemove(win, UNLOAD, EU._unload);
  1581. }
  1582. };
  1583. // Initialize stuff.
  1584. pub.on = pub.addListener;
  1585. pub.un = pub.removeListener;
  1586. if (doc && doc.body) {
  1587. pub._load(true);
  1588. } else {
  1589. doAdd(win, "load", pub._load);
  1590. }
  1591. doAdd(win, UNLOAD, pub._unload);
  1592. _tryPreloadAttach();
  1593. return pub;
  1594. }();
  1595. /*
  1596. * Portions of this file are based on pieces of Yahoo User Interface Library
  1597. * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
  1598. * YUI licensed under the BSD License:
  1599. * http://developer.yahoo.net/yui/license.txt
  1600. */
  1601. Ext.lib.Ajax = function() {
  1602. var activeX = ['Msxml2.XMLHTTP.6.0',
  1603. 'Msxml2.XMLHTTP.3.0',
  1604. 'Msxml2.XMLHTTP'],
  1605. CONTENTTYPE = 'Content-Type';
  1606. // private
  1607. function setHeader(o) {
  1608. var conn = o.conn,
  1609. prop,
  1610. headers = {};
  1611. function setTheHeaders(conn, headers){
  1612. for (prop in headers) {
  1613. if (headers.hasOwnProperty(prop)) {
  1614. conn.setRequestHeader(prop, headers[prop]);
  1615. }
  1616. }
  1617. }
  1618. Ext.apply(headers, pub.headers, pub.defaultHeaders);
  1619. setTheHeaders(conn, headers);
  1620. delete pub.headers;
  1621. }
  1622. // private
  1623. function createExceptionObject(tId, callbackArg, isAbort, isTimeout) {
  1624. return {
  1625. tId : tId,
  1626. status : isAbort ? -1 : 0,
  1627. statusText : isAbort ? 'transaction aborted' : 'communication failure',
  1628. isAbort: isAbort,
  1629. isTimeout: isTimeout,
  1630. argument : callbackArg
  1631. };
  1632. }
  1633. // private
  1634. function initHeader(label, value) {
  1635. (pub.headers = pub.headers || {})[label] = value;
  1636. }
  1637. // private
  1638. function createResponseObject(o, callbackArg) {
  1639. var headerObj = {},
  1640. headerStr,
  1641. conn = o.conn,
  1642. t,
  1643. s,
  1644. // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223
  1645. isBrokenStatus = conn.status == 1223;
  1646. try {
  1647. headerStr = o.conn.getAllResponseHeaders();
  1648. Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
  1649. t = v.indexOf(':');
  1650. if(t >= 0){
  1651. s = v.substr(0, t).toLowerCase();
  1652. if(v.charAt(t + 1) == ' '){
  1653. ++t;
  1654. }
  1655. headerObj[s] = v.substr(t + 1);
  1656. }
  1657. });
  1658. } catch(e) {}
  1659. return {
  1660. tId : o.tId,
  1661. // Normalize the status and statusText when IE returns 1223, see the above link.
  1662. status : isBrokenStatus ? 204 : conn.status,
  1663. statusText : isBrokenStatus ? 'No Content' : conn.statusText,
  1664. getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
  1665. getAllResponseHeaders : function(){return headerStr;},
  1666. responseText : conn.responseText,
  1667. responseXML : conn.responseXML,
  1668. argument : callbackArg
  1669. };
  1670. }
  1671. // private
  1672. function releaseObject(o) {
  1673. if (o.tId) {
  1674. pub.conn[o.tId] = null;
  1675. }
  1676. o.conn = null;
  1677. o = null;
  1678. }
  1679. // private
  1680. function handleTransactionResponse(o, callback, isAbort, isTimeout) {
  1681. if (!callback) {
  1682. releaseObject(o);
  1683. return;
  1684. }
  1685. var httpStatus, responseObject;
  1686. try {
  1687. if (o.conn.status !== undefined && o.conn.status != 0) {
  1688. httpStatus = o.conn.status;
  1689. }
  1690. else {
  1691. httpStatus = 13030;
  1692. }
  1693. }
  1694. catch(e) {
  1695. httpStatus = 13030;
  1696. }
  1697. if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) {
  1698. responseObject = createResponseObject(o, callback.argument);
  1699. if (callback.success) {
  1700. if (!callback.scope) {
  1701. callback.success(responseObject);
  1702. }
  1703. else {
  1704. callback.success.apply(callback.scope, [responseObject]);
  1705. }
  1706. }
  1707. }
  1708. else {
  1709. switch (httpStatus) {
  1710. case 12002:
  1711. case 12029:
  1712. case 12030:
  1713. case 12031:
  1714. case 12152:
  1715. case 13030:
  1716. responseObject = createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false), isTimeout);
  1717. if (callback.failure) {
  1718. if (!callback.scope) {
  1719. callback.failure(responseObject);
  1720. }
  1721. else {
  1722. callback.failure.apply(callback.scope, [responseObject]);
  1723. }
  1724. }
  1725. break;
  1726. default:
  1727. responseObject = createResponseObject(o, callback.argument);
  1728. if (callback.failure) {
  1729. if (!callback.scope) {
  1730. callback.failure(responseObject);
  1731. }
  1732. else {
  1733. callback.failure.apply(callback.scope, [responseObject]);
  1734. }
  1735. }
  1736. }
  1737. }
  1738. releaseObject(o);
  1739. responseObject = null;
  1740. }
  1741. function checkResponse(o, callback, conn, tId, poll, cbTimeout){
  1742. if (conn && conn.readyState == 4) {
  1743. clearInterval(poll[tId]);
  1744. poll[tId] = null;
  1745. if (cbTimeout) {
  1746. clearTimeout(pub.timeout[tId]);
  1747. pub.timeout[tId] = null;
  1748. }
  1749. handleTransactionResponse(o, callback);
  1750. }
  1751. }
  1752. function checkTimeout(o, callback){
  1753. pub.abort(o, callback, true);
  1754. }
  1755. // private
  1756. function handleReadyState(o, callback){
  1757. callback = callback || {};
  1758. var conn = o.conn,
  1759. tId = o.tId,
  1760. poll = pub.poll,
  1761. cbTimeout = callback.timeout || null;
  1762. if (cbTimeout) {
  1763. pub.conn[tId] = conn;
  1764. pub.timeout[tId] = setTimeout(checkTimeout.createCallback(o, callback), cbTimeout);
  1765. }
  1766. poll[tId] = setInterval(checkResponse.createCallback(o, callback, conn, tId, poll, cbTimeout), pub.pollInterval);
  1767. }
  1768. // private
  1769. function asyncRequest(method, uri, callback, postData) {
  1770. var o = getConnectionObject() || null;
  1771. if (o) {
  1772. o.conn.open(method, uri, true);
  1773. if (pub.useDefaultXhrHeader) {
  1774. initHeader('X-Requested-With', pub.defaultXhrHeader);
  1775. }
  1776. if(postData && pub.useDefaultHeader && (!pub.headers || !pub.headers[CONTENTTYPE])){
  1777. initHeader(CONTENTTYPE, pub.defaultPostHeader);
  1778. }
  1779. if (pub.defaultHeaders || pub.headers) {
  1780. setHeader(o);
  1781. }
  1782. handleReadyState(o, callback);
  1783. o.conn.send(postData || null);
  1784. }
  1785. return o;
  1786. }
  1787. // private
  1788. function getConnectionObject() {
  1789. var o;
  1790. try {
  1791. if (o = createXhrObject(pub.transactionId)) {
  1792. pub.transactionId++;
  1793. }
  1794. } catch(e) {
  1795. } finally {
  1796. return o;
  1797. }
  1798. }
  1799. // private
  1800. function createXhrObject(transactionId) {
  1801. var http;
  1802. try {
  1803. http = new XMLHttpRequest();
  1804. } catch(e) {
  1805. for (var i = 0; i < activeX.length; ++i) {
  1806. try {
  1807. http = new ActiveXObject(activeX[i]);
  1808. break;
  1809. } catch(e) {}
  1810. }
  1811. } finally {
  1812. return {conn : http, tId : transactionId};
  1813. }
  1814. }
  1815. var pub = {
  1816. request : function(method, uri, cb, data, options) {
  1817. if(options){
  1818. var me = this,
  1819. xmlData = options.xmlData,
  1820. jsonData = options.jsonData,
  1821. hs;
  1822. Ext.applyIf(me, options);
  1823. if(xmlData || jsonData){
  1824. hs = me.headers;
  1825. if(!hs || !hs[CONTENTTYPE]){
  1826. initHeader(CONTENTTYPE, xmlData ? 'text/xml' : 'application/json');
  1827. }
  1828. data = xmlData || (!Ext.isPrimitive(jsonData) ? Ext.encode(jsonData) : jsonData);
  1829. }
  1830. }
  1831. return asyncRequest(method || options.method || "POST", uri, cb, data);
  1832. },
  1833. serializeForm : function(form) {
  1834. var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
  1835. hasSubmit = false,
  1836. encoder = encodeURIComponent,
  1837. name,
  1838. data = '',
  1839. type,
  1840. hasValue;
  1841. Ext.each(fElements, function(element){
  1842. name = element.name;
  1843. type = element.type;
  1844. if (!element.disabled && name) {
  1845. if (/select-(one|multiple)/i.test(type)) {
  1846. Ext.each(element.options, function(opt){
  1847. if (opt.selected) {
  1848. hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified;
  1849. data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text));
  1850. }
  1851. });
  1852. } else if (!(/file|undefined|reset|button/i.test(type))) {
  1853. if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
  1854. data += encoder(name) + '=' + encoder(element.value) + '&';
  1855. hasSubmit = /submit/i.test(type);
  1856. }
  1857. }
  1858. }
  1859. });
  1860. return data.substr(0, data.length - 1);
  1861. },
  1862. useDefaultHeader : true,
  1863. defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',
  1864. useDefaultXhrHeader : true,
  1865. defaultXhrHeader : 'XMLHttpRequest',
  1866. poll : {},
  1867. timeout : {},
  1868. conn: {},
  1869. pollInterval : 50,
  1870. transactionId : 0,
  1871. // This is never called - Is it worth exposing this?
  1872. // setProgId : function(id) {
  1873. // activeX.unshift(id);
  1874. // },
  1875. // This is never called - Is it worth exposing this?
  1876. // setDefaultPostHeader : function(b) {
  1877. // this.useDefaultHeader = b;
  1878. // },
  1879. // This is never called - Is it worth exposing this?
  1880. // setDefaultXhrHeader : function(b) {
  1881. // this.useDefaultXhrHeader = b;
  1882. // },
  1883. // This is never called - Is it worth exposing this?
  1884. // setPollingInterval : function(i) {
  1885. // if (typeof i == 'number' && isFinite(i)) {
  1886. // this.pollInterval = i;
  1887. // }
  1888. // },
  1889. // This is never called - Is it worth exposing this?
  1890. // resetDefaultHeaders : function() {
  1891. // this.defaultHeaders = null;
  1892. // },
  1893. abort : function(o, callback, isTimeout) {
  1894. var me = this,
  1895. tId = o.tId,
  1896. isAbort = false;
  1897. if (me.isCallInProgress(o)) {
  1898. o.conn.abort();
  1899. clearInterval(me.poll[tId]);
  1900. me.poll[tId] = null;
  1901. clearTimeout(pub.timeout[tId]);
  1902. me.timeout[tId] = null;
  1903. handleTransactionResponse(o, callback, (isAbort = true), isTimeout);
  1904. }
  1905. return isAbort;
  1906. },
  1907. isCallInProgress : function(o) {
  1908. // if there is a connection and readyState is not 0 or 4
  1909. return o.conn && !{0:true,4:true}[o.conn.readyState];
  1910. }
  1911. };
  1912. return pub;
  1913. }();(function(){
  1914. var EXTLIB = Ext.lib,
  1915. noNegatives = /width|height|opacity|padding/i,
  1916. offsetAttribute = /^((width|height)|(top|left))$/,
  1917. defaultUnit = /width|height|top$|bottom$|left$|right$/i,
  1918. offsetUnit = /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,
  1919. isset = function(v){
  1920. return typeof v !== 'undefined';
  1921. },
  1922. now = function(){
  1923. return new Date();
  1924. };
  1925. EXTLIB.Anim = {
  1926. motion : function(el, args, duration, easing, cb, scope) {
  1927. return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  1928. },
  1929. run : function(el, args, duration, easing, cb, scope, type) {
  1930. type = type || Ext.lib.AnimBase;
  1931. if (typeof easing == "string") {
  1932. easing = Ext.lib.Easing[easing];
  1933. }
  1934. var anim = new type(el, args, duration, easing);
  1935. anim.animateX(function() {
  1936. if(Ext.isFunction(cb)){
  1937. cb.call(scope);
  1938. }
  1939. });
  1940. return anim;
  1941. }
  1942. };
  1943. EXTLIB.AnimBase = function(el, attributes, duration, method) {
  1944. if (el) {
  1945. this.init(el, attributes, duration, method);
  1946. }
  1947. };
  1948. EXTLIB.AnimBase.prototype = {
  1949. doMethod: function(attr, start, end) {
  1950. var me = this;
  1951. return me.method(me.curFrame, start, end - start, me.totalFrames);
  1952. },
  1953. setAttr: function(attr, val, unit) {
  1954. if (noNegatives.test(attr) && val < 0) {
  1955. val = 0;
  1956. }
  1957. Ext.fly(this.el, '_anim').setStyle(attr, val + unit);
  1958. },
  1959. getAttr: function(attr) {
  1960. var el = Ext.fly(this.el),
  1961. val = el.getStyle(attr),
  1962. a = offsetAttribute.exec(attr) || [];
  1963. if (val !== 'auto' && !offsetUnit.test(val)) {
  1964. return parseFloat(val);
  1965. }
  1966. return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0;
  1967. },
  1968. getDefaultUnit: function(attr) {
  1969. return defaultUnit.test(attr) ? 'px' : '';
  1970. },
  1971. animateX : function(callback, scope) {
  1972. var me = this,
  1973. f = function() {
  1974. me.onComplete.removeListener(f);
  1975. if (Ext.isFunction(callback)) {
  1976. callback.call(scope || me, me);
  1977. }
  1978. };
  1979. me.onComplete.addListener(f, me);
  1980. me.animate();
  1981. },
  1982. setRunAttr: function(attr) {
  1983. var me = this,
  1984. a = this.attributes[attr],
  1985. to = a.to,
  1986. by = a.by,
  1987. from = a.from,
  1988. unit = a.unit,
  1989. ra = (this.runAttrs[attr] = {}),
  1990. end;
  1991. if (!isset(to) && !isset(by)){
  1992. return false;
  1993. }
  1994. var start = isset(from) ? from : me.getAttr(attr);
  1995. if (isset(to)) {
  1996. end = to;
  1997. }else if(isset(by)) {
  1998. if (Ext.isArray(start)){
  1999. end = [];
  2000. for(var i=0,len=start.length; i<len; i++) {
  2001. end[i] = start[i] + by[i];
  2002. }
  2003. }else{
  2004. end = start + by;
  2005. }
  2006. }
  2007. Ext.apply(ra, {
  2008. start: start,
  2009. end: end,
  2010. unit: isset(unit) ? unit : me.getDefaultUnit(attr)
  2011. });
  2012. },
  2013. init: function(el, attributes, duration, method) {
  2014. var me = this,
  2015. actualFrames = 0,
  2016. mgr = EXTLIB.AnimMgr;
  2017. Ext.apply(me, {
  2018. isAnimated: false,
  2019. startTime: null,
  2020. el: Ext.getDom(el),
  2021. attributes: attributes || {},
  2022. duration: duration || 1,
  2023. method: method || EXTLIB.Easing.easeNone,
  2024. useSec: true,
  2025. curFrame: 0,
  2026. totalFrames: mgr.fps,
  2027. runAttrs: {},
  2028. animate: function(){
  2029. var me = this,
  2030. d = me.duration;
  2031. if(me.isAnimated){
  2032. return false;
  2033. }
  2034. me.curFrame = 0;
  2035. me.totalFrames = me.useSec ? Math.ceil(mgr.fps * d) : d;
  2036. mgr.registerElement(me);
  2037. },
  2038. stop: function(finish){
  2039. var me = this;
  2040. if(finish){
  2041. me.curFrame = me.totalFrames;
  2042. me._onTween.fire();
  2043. }
  2044. mgr.stop(me);
  2045. }
  2046. });
  2047. var onStart = function(){
  2048. var me = this,
  2049. attr;
  2050. me.onStart.fire();
  2051. me.runAttrs = {};
  2052. for(attr in this.attributes){
  2053. this.setRunAttr(attr);
  2054. }
  2055. me.isAnimated = true;
  2056. me.startTime = now();
  2057. actualFrames = 0;
  2058. };
  2059. var onTween = function(){
  2060. var me = this;
  2061. me.onTween.fire({
  2062. duration: now() - me.startTime,
  2063. curFrame: me.curFrame
  2064. });
  2065. var ra = me.runAttrs;
  2066. for (var attr in ra) {
  2067. this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
  2068. }
  2069. ++actualFrames;
  2070. };
  2071. var onComplete = function() {
  2072. var me = this,
  2073. actual = (now() - me.startTime) / 1000,
  2074. data = {
  2075. duration: actual,
  2076. frames: actualFrames,
  2077. fps: actualFrames / actual
  2078. };
  2079. me.isAnimated = false;
  2080. actualFrames = 0;
  2081. me.onComplete.fire(data);
  2082. };
  2083. me.onStart = new Ext.util.Event(me);
  2084. me.onTween = new Ext.util.Event(me);
  2085. me.onComplete = new Ext.util.Event(me);
  2086. (me._onStart = new Ext.util.Event(me)).addListener(onStart);
  2087. (me._onTween = new Ext.util.Event(me)).addListener(onTween);
  2088. (me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
  2089. }
  2090. };
  2091. Ext.lib.AnimMgr = new function() {
  2092. var me = this,
  2093. thread = null,
  2094. queue = [],
  2095. tweenCount = 0;
  2096. Ext.apply(me, {
  2097. fps: 1000,
  2098. delay: 1,
  2099. registerElement: function(tween){
  2100. queue.push(tween);
  2101. ++tweenCount;
  2102. tween._onStart.fire();
  2103. me.start();
  2104. },
  2105. unRegister: function(tween, index){
  2106. tween._onComplete.fire();
  2107. index = index || getIndex(tween);
  2108. if (index != -1) {
  2109. queue.splice(index, 1);
  2110. }
  2111. if (--tweenCount <= 0) {
  2112. me.stop();
  2113. }
  2114. },
  2115. start: function(){
  2116. if(thread === null){
  2117. thread = setInterval(me.run, me.delay);
  2118. }
  2119. },
  2120. stop: function(tween){
  2121. if(!tween){
  2122. clearInterval(thread);
  2123. for(var i = 0, len = queue.length; i < len; ++i){
  2124. if(queue[0].isAnimated){
  2125. me.unRegister(queue[0], 0);
  2126. }
  2127. }
  2128. queue = [];
  2129. thread = null;
  2130. tweenCount = 0;
  2131. }else{
  2132. me.unRegister(tween);
  2133. }
  2134. },
  2135. run: function(){
  2136. var tf, i, len, tween;
  2137. for(i = 0, len = queue.length; i<len; i++) {
  2138. tween = queue[i];
  2139. if(tween && tween.isAnimated){
  2140. tf = tween.totalFrames;
  2141. if(tween.curFrame < tf || tf === null){
  2142. ++tween.curFrame;
  2143. if(tween.useSec){
  2144. correctFrame(tween);
  2145. }
  2146. tween._onTween.fire();
  2147. }else{
  2148. me.stop(tween);
  2149. }
  2150. }
  2151. }
  2152. }
  2153. });
  2154. var getIndex = function(anim) {
  2155. var i, len;
  2156. for(i = 0, len = queue.length; i<len; i++) {
  2157. if(queue[i] === anim) {
  2158. return i;
  2159. }
  2160. }
  2161. return -1;
  2162. };
  2163. var correctFrame = function(tween) {
  2164. var frames = tween.totalFrames,
  2165. frame = tween.curFrame,
  2166. duration = tween.duration,
  2167. expected = (frame * duration * 1000 / frames),
  2168. elapsed = (now() - tween.startTime),
  2169. tweak = 0;
  2170. if(elapsed < duration * 1000){
  2171. tweak = Math.round((elapsed / expected - 1) * frame);
  2172. }else{
  2173. tweak = frames - (frame + 1);
  2174. }
  2175. if(tweak > 0 && isFinite(tweak)){
  2176. if(tween.curFrame + tweak >= frames){
  2177. tweak = frames - (frame + 1);
  2178. }
  2179. tween.curFrame += tweak;
  2180. }
  2181. };
  2182. };
  2183. EXTLIB.Bezier = new function() {
  2184. this.getPosition = function(points, t) {
  2185. var n = points.length,
  2186. tmp = [],
  2187. c = 1 - t,
  2188. i,
  2189. j;
  2190. for (i = 0; i < n; ++i) {
  2191. tmp[i] = [points[i][0], points[i][1]];
  2192. }
  2193. for (j = 1; j < n; ++j) {
  2194. for (i = 0; i < n - j; ++i) {
  2195. tmp[i][0] = c * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
  2196. tmp[i][1] = c * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
  2197. }
  2198. }
  2199. return [ tmp[0][0], tmp[0][1] ];
  2200. };
  2201. };
  2202. EXTLIB.Easing = {
  2203. easeNone: function (t, b, c, d) {
  2204. return c * t / d + b;
  2205. },
  2206. easeIn: function (t, b, c, d) {
  2207. return c * (t /= d) * t + b;
  2208. },
  2209. easeOut: function (t, b, c, d) {
  2210. return -c * (t /= d) * (t - 2) + b;
  2211. }
  2212. };
  2213. (function() {
  2214. EXTLIB.Motion = function(el, attributes, duration, method) {
  2215. if (el) {
  2216. EXTLIB.Motion.superclass.constructor.call(this, el, attributes, duration, method);
  2217. }
  2218. };
  2219. Ext.extend(EXTLIB.Motion, Ext.lib.AnimBase);
  2220. var superclass = EXTLIB.Motion.superclass,
  2221. pointsRe = /^points$/i;
  2222. Ext.apply(EXTLIB.Motion.prototype, {
  2223. setAttr: function(attr, val, unit){
  2224. var me = this,
  2225. setAttr = superclass.setAttr;
  2226. if (pointsRe.test(attr)) {
  2227. unit = unit || 'px';
  2228. setAttr.call(me, 'left', val[0], unit);
  2229. setAttr.call(me, 'top', val[1], unit);
  2230. } else {
  2231. setAttr.call(me, attr, val, unit);
  2232. }
  2233. },
  2234. getAttr: function(attr){
  2235. var me = this,
  2236. getAttr = superclass.getAttr;
  2237. return pointsRe.test(attr) ? [getAttr.call(me, 'left'), getAttr.call(me, 'top')] : getAttr.call(me, attr);
  2238. },
  2239. doMethod: function(attr, start, end){
  2240. var me = this;
  2241. return pointsRe.test(attr)
  2242. ? EXTLIB.Bezier.getPosition(me.runAttrs[attr], me.method(me.curFrame, 0, 100, me.totalFrames) / 100)
  2243. : superclass.doMethod.call(me, attr, start, end);
  2244. },
  2245. setRunAttr: function(attr){
  2246. if(pointsRe.test(attr)){
  2247. var me = this,
  2248. el = this.el,
  2249. points = this.attributes.points,
  2250. control = points.control || [],
  2251. from = points.from,
  2252. to = points.to,
  2253. by = points.by,
  2254. DOM = EXTLIB.Dom,
  2255. start,
  2256. i,
  2257. end,
  2258. len,
  2259. ra;
  2260. if(control.length > 0 && !Ext.isArray(control[0])){
  2261. control = [control];
  2262. }else{
  2263. /*
  2264. var tmp = [];
  2265. for (i = 0,len = control.length; i < len; ++i) {
  2266. tmp[i] = control[i];
  2267. }
  2268. control = tmp;
  2269. */
  2270. }
  2271. Ext.fly(el, '_anim').position();
  2272. DOM.setXY(el, isset(from) ? from : DOM.getXY(el));
  2273. start = me.getAttr('points');
  2274. if(isset(to)){
  2275. end = translateValues.call(me, to, start);
  2276. for (i = 0,len = control.length; i < len; ++i) {
  2277. control[i] = translateValues.call(me, control[i], start);
  2278. }
  2279. } else if (isset(by)) {
  2280. end = [start[0] + by[0], start[1] + by[1]];
  2281. for (i = 0,len = control.length; i < len; ++i) {
  2282. control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
  2283. }
  2284. }
  2285. ra = this.runAttrs[attr] = [start];
  2286. if (control.length > 0) {
  2287. ra = ra.concat(control);
  2288. }
  2289. ra[ra.length] = end;
  2290. }else{
  2291. superclass.setRunAttr.call(this, attr);
  2292. }
  2293. }
  2294. });
  2295. var translateValues = function(val, start) {
  2296. var pageXY = EXTLIB.Dom.getXY(this.el);
  2297. return [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
  2298. };
  2299. })();
  2300. })();// Easing functions
  2301. (function(){
  2302. // shortcuts to aid compression
  2303. var abs = Math.abs,
  2304. pi = Math.PI,
  2305. asin = Math.asin,
  2306. pow = Math.pow,
  2307. sin = Math.sin,
  2308. EXTLIB = Ext.lib;
  2309. Ext.apply(EXTLIB.Easing, {
  2310. easeBoth: function (t, b, c, d) {
  2311. return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b;
  2312. },
  2313. easeInStrong: function (t, b, c, d) {
  2314. return c * (t /= d) * t * t * t + b;
  2315. },
  2316. easeOutStrong: function (t, b, c, d) {
  2317. return -c * ((t = t / d - 1) * t * t * t - 1) + b;
  2318. },
  2319. easeBothStrong: function (t, b, c, d) {
  2320. return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b;
  2321. },
  2322. elasticIn: function (t, b, c, d, a, p) {
  2323. if (t == 0 || (t /= d) == 1) {
  2324. return t == 0 ? b : b + c;
  2325. }
  2326. p = p || (d * .3);
  2327. var s;
  2328. if (a >= abs(c)) {
  2329. s = p / (2 * pi) * asin(c / a);
  2330. } else {
  2331. a = c;
  2332. s = p / 4;
  2333. }
  2334. return -(a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b;
  2335. },
  2336. elasticOut: function (t, b, c, d, a, p) {
  2337. if (t == 0 || (t /= d) == 1) {
  2338. return t == 0 ? b : b + c;
  2339. }
  2340. p = p || (d * .3);
  2341. var s;
  2342. if (a >= abs(c)) {
  2343. s = p / (2 * pi) * asin(c / a);
  2344. } else {
  2345. a = c;
  2346. s = p / 4;
  2347. }
  2348. return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b;
  2349. },
  2350. elasticBoth: function (t, b, c, d, a, p) {
  2351. if (t == 0 || (t /= d / 2) == 2) {
  2352. return t == 0 ? b : b + c;
  2353. }
  2354. p = p || (d * (.3 * 1.5));
  2355. var s;
  2356. if (a >= abs(c)) {
  2357. s = p / (2 * pi) * asin(c / a);
  2358. } else {
  2359. a = c;
  2360. s = p / 4;
  2361. }
  2362. return t < 1 ?
  2363. -.5 * (a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b :
  2364. a * pow(2, -10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p) * .5 + c + b;
  2365. },
  2366. backIn: function (t, b, c, d, s) {
  2367. s = s || 1.70158;
  2368. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  2369. },
  2370. backOut: function (t, b, c, d, s) {
  2371. if (!s) {
  2372. s = 1.70158;
  2373. }
  2374. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  2375. },
  2376. backBoth: function (t, b, c, d, s) {
  2377. s = s || 1.70158;
  2378. return ((t /= d / 2 ) < 1) ?
  2379. c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b :
  2380. c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
  2381. },
  2382. bounceIn: function (t, b, c, d) {
  2383. return c - EXTLIB.Easing.bounceOut(d - t, 0, c, d) + b;
  2384. },
  2385. bounceOut: function (t, b, c, d) {
  2386. if ((t /= d) < (1 / 2.75)) {
  2387. return c * (7.5625 * t * t) + b;
  2388. } else if (t < (2 / 2.75)) {
  2389. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  2390. } else if (t < (2.5 / 2.75)) {
  2391. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  2392. }
  2393. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  2394. },
  2395. bounceBoth: function (t, b, c, d) {
  2396. return (t < d / 2) ?
  2397. EXTLIB.Easing.bounceIn(t * 2, 0, c, d) * .5 + b :
  2398. EXTLIB.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
  2399. }
  2400. });
  2401. })();
  2402. (function() {
  2403. var EXTLIB = Ext.lib;
  2404. // Color Animation
  2405. EXTLIB.Anim.color = function(el, args, duration, easing, cb, scope) {
  2406. return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.ColorAnim);
  2407. };
  2408. EXTLIB.ColorAnim = function(el, attributes, duration, method) {
  2409. EXTLIB.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
  2410. };
  2411. Ext.extend(EXTLIB.ColorAnim, EXTLIB.AnimBase);
  2412. var superclass = EXTLIB.ColorAnim.superclass,
  2413. colorRE = /color$/i,
  2414. transparentRE = /^transparent|rgba\(0, 0, 0, 0\)$/,
  2415. rgbRE = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
  2416. hexRE= /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
  2417. hex3RE = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
  2418. isset = function(v){
  2419. return typeof v !== 'undefined';
  2420. };
  2421. // private
  2422. function parseColor(s) {
  2423. var pi = parseInt,
  2424. base,
  2425. out = null,
  2426. c;
  2427. if (s.length == 3) {
  2428. return s;
  2429. }
  2430. Ext.each([hexRE, rgbRE, hex3RE], function(re, idx){
  2431. base = (idx % 2 == 0) ? 16 : 10;
  2432. c = re.exec(s);
  2433. if(c && c.length == 4){
  2434. out = [pi(c[1], base), pi(c[2], base), pi(c[3], base)];
  2435. return false;
  2436. }
  2437. });
  2438. return out;
  2439. }
  2440. Ext.apply(EXTLIB.ColorAnim.prototype, {
  2441. getAttr : function(attr) {
  2442. var me = this,
  2443. el = me.el,
  2444. val;
  2445. if(colorRE.test(attr)){
  2446. while(el && transparentRE.test(val = Ext.fly(el).getStyle(attr))){
  2447. el = el.parentNode;
  2448. val = "fff";
  2449. }
  2450. }else{
  2451. val = superclass.getAttr.call(me, attr);
  2452. }
  2453. return val;
  2454. },
  2455. doMethod : function(attr, start, end) {
  2456. var me = this,
  2457. val,
  2458. floor = Math.floor,
  2459. i,
  2460. len,
  2461. v;
  2462. if(colorRE.test(attr)){
  2463. val = [];
  2464. end = end || [];
  2465. for(i = 0, len = start.length; i < len; i++) {
  2466. v = start[i];
  2467. val[i] = superclass.doMethod.call(me, attr, v, end[i]);
  2468. }
  2469. val = 'rgb(' + floor(val[0]) + ',' + floor(val[1]) + ',' + floor(val[2]) + ')';
  2470. }else{
  2471. val = superclass.doMethod.call(me, attr, start, end);
  2472. }
  2473. return val;
  2474. },
  2475. setRunAttr : function(attr) {
  2476. var me = this,
  2477. a = me.attributes[attr],
  2478. to = a.to,
  2479. by = a.by,
  2480. ra;
  2481. superclass.setRunAttr.call(me, attr);
  2482. ra = me.runAttrs[attr];
  2483. if(colorRE.test(attr)){
  2484. var start = parseColor(ra.start),
  2485. end = parseColor(ra.end);
  2486. if(!isset(to) && isset(by)){
  2487. end = parseColor(by);
  2488. for(var i=0,len=start.length; i<len; i++) {
  2489. end[i] = start[i] + end[i];
  2490. }
  2491. }
  2492. ra.start = start;
  2493. ra.end = end;
  2494. }
  2495. }
  2496. });
  2497. })();
  2498. (function() {
  2499. // Scroll Animation
  2500. var EXTLIB = Ext.lib;
  2501. EXTLIB.Anim.scroll = function(el, args, duration, easing, cb, scope) {
  2502. return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.Scroll);
  2503. };
  2504. EXTLIB.Scroll = function(el, attributes, duration, method) {
  2505. if(el){
  2506. EXTLIB.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
  2507. }
  2508. };
  2509. Ext.extend(EXTLIB.Scroll, EXTLIB.ColorAnim);
  2510. var superclass = EXTLIB.Scroll.superclass,
  2511. SCROLL = 'scroll';
  2512. Ext.apply(EXTLIB.Scroll.prototype, {
  2513. doMethod : function(attr, start, end) {
  2514. var val,
  2515. me = this,
  2516. curFrame = me.curFrame,
  2517. totalFrames = me.totalFrames;
  2518. if(attr == SCROLL){
  2519. val = [me.method(curFrame, start[0], end[0] - start[0], totalFrames),
  2520. me.method(curFrame, start[1], end[1] - start[1], totalFrames)];
  2521. }else{
  2522. val = superclass.doMethod.call(me, attr, start, end);
  2523. }
  2524. return val;
  2525. },
  2526. getAttr : function(attr) {
  2527. var me = this;
  2528. if (attr == SCROLL) {
  2529. return [me.el.scrollLeft, me.el.scrollTop];
  2530. }else{
  2531. return superclass.getAttr.call(me, attr);
  2532. }
  2533. },
  2534. setAttr : function(attr, val, unit) {
  2535. var me = this;
  2536. if(attr == SCROLL){
  2537. me.el.scrollLeft = val[0];
  2538. me.el.scrollTop = val[1];
  2539. }else{
  2540. superclass.setAttr.call(me, attr, val, unit);
  2541. }
  2542. }
  2543. });
  2544. })();
  2545. if (Ext.isIE) {
  2546. function fnCleanUp() {
  2547. var p = Function.prototype;
  2548. delete p.createSequence;
  2549. delete p.defer;
  2550. delete p.createDelegate;
  2551. delete p.createCallback;
  2552. delete p.createInterceptor;
  2553. window.detachEvent("onunload", fnCleanUp);
  2554. }
  2555. window.attachEvent("onunload", fnCleanUp);
  2556. }
  2557. })();