Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3636 lines
121 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.2.1
  3. * Copyright(c) 2006-2010 Ext JS, Inc.
  4. * licensing@extjs.com
  5. * http://www.extjs.com/license
  6. */
  7. // for old browsers
  8. window.undefined = window.undefined;
  9. /**
  10. * @class Ext
  11. * Ext core utilities and functions.
  12. * @singleton
  13. */
  14. Ext = {
  15. /**
  16. * The version of the framework
  17. * @type String
  18. */
  19. version : '3.2.1',
  20. versionDetail : {
  21. major: 3,
  22. minor: 2,
  23. patch: 1
  24. }
  25. };
  26. /**
  27. * Copies all the properties of config to obj.
  28. * @param {Object} obj The receiver of the properties
  29. * @param {Object} config The source of the properties
  30. * @param {Object} defaults A different object that will also be applied for default values
  31. * @return {Object} returns obj
  32. * @member Ext apply
  33. */
  34. Ext.apply = function(o, c, defaults){
  35. // no "this" reference for friendly out of scope calls
  36. if(defaults){
  37. Ext.apply(o, defaults);
  38. }
  39. if(o && c && typeof c == 'object'){
  40. for(var p in c){
  41. o[p] = c[p];
  42. }
  43. }
  44. return o;
  45. };
  46. (function(){
  47. var idSeed = 0,
  48. toString = Object.prototype.toString,
  49. ua = navigator.userAgent.toLowerCase(),
  50. check = function(r){
  51. return r.test(ua);
  52. },
  53. DOC = document,
  54. isStrict = DOC.compatMode == "CSS1Compat",
  55. isOpera = check(/opera/),
  56. isChrome = check(/\bchrome\b/),
  57. isWebKit = check(/webkit/),
  58. isSafari = !isChrome && check(/safari/),
  59. isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
  60. isSafari3 = isSafari && check(/version\/3/),
  61. isSafari4 = isSafari && check(/version\/4/),
  62. isIE = !isOpera && check(/msie/),
  63. isIE7 = isIE && check(/msie 7/),
  64. isIE8 = isIE && check(/msie 8/),
  65. isIE6 = isIE && !isIE7 && !isIE8,
  66. isGecko = !isWebKit && check(/gecko/),
  67. isGecko2 = isGecko && check(/rv:1\.8/),
  68. isGecko3 = isGecko && check(/rv:1\.9/),
  69. isBorderBox = isIE && !isStrict,
  70. isWindows = check(/windows|win32/),
  71. isMac = check(/macintosh|mac os x/),
  72. isAir = check(/adobeair/),
  73. isLinux = check(/linux/),
  74. isSecure = /^https/i.test(window.location.protocol);
  75. // remove css image flicker
  76. if(isIE6){
  77. try{
  78. DOC.execCommand("BackgroundImageCache", false, true);
  79. }catch(e){}
  80. }
  81. Ext.apply(Ext, {
  82. /**
  83. * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
  84. * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
  85. * @type String
  86. */
  87. SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
  88. /**
  89. * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
  90. * @type Boolean
  91. */
  92. isStrict : isStrict,
  93. /**
  94. * True if the page is running over SSL
  95. * @type Boolean
  96. */
  97. isSecure : isSecure,
  98. /**
  99. * True when the document is fully initialized and ready for action
  100. * @type Boolean
  101. */
  102. isReady : false,
  103. /**
  104. * True if the {@link Ext.Fx} Class is available
  105. * @type Boolean
  106. * @property enableFx
  107. */
  108. /**
  109. * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
  110. * @type Boolean
  111. */
  112. enableGarbageCollector : true,
  113. /**
  114. * True to automatically purge event listeners during garbageCollection (defaults to false).
  115. * @type Boolean
  116. */
  117. enableListenerCollection : false,
  118. /**
  119. * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
  120. * Currently not optimized for performance.
  121. * @type Boolean
  122. */
  123. enableNestedListenerRemoval : false,
  124. /**
  125. * Indicates whether to use native browser parsing for JSON methods.
  126. * This option is ignored if the browser does not support native JSON methods.
  127. * <b>Note: Native JSON methods will not work with objects that have functions.
  128. * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
  129. * @type Boolean
  130. */
  131. USE_NATIVE_JSON : false,
  132. /**
  133. * Copies all the properties of config to obj if they don't already exist.
  134. * @param {Object} obj The receiver of the properties
  135. * @param {Object} config The source of the properties
  136. * @return {Object} returns obj
  137. */
  138. applyIf : function(o, c){
  139. if(o){
  140. for(var p in c){
  141. if(!Ext.isDefined(o[p])){
  142. o[p] = c[p];
  143. }
  144. }
  145. }
  146. return o;
  147. },
  148. /**
  149. * Generates unique ids. If the element already has an id, it is unchanged
  150. * @param {Mixed} el (optional) The element to generate an id for
  151. * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
  152. * @return {String} The generated Id.
  153. */
  154. id : function(el, prefix){
  155. el = Ext.getDom(el, true) || {};
  156. if (!el.id) {
  157. el.id = (prefix || "ext-gen") + (++idSeed);
  158. }
  159. return el.id;
  160. },
  161. /**
  162. * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
  163. * also adds the function "override()" to the subclass that can be used to override members of the class.</p>
  164. * For example, to create a subclass of Ext GridPanel:
  165. * <pre><code>
  166. MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
  167. constructor: function(config) {
  168. // Create configuration for this Grid.
  169. var store = new Ext.data.Store({...});
  170. var colModel = new Ext.grid.ColumnModel({...});
  171. // Create a new config object containing our computed properties
  172. // *plus* whatever was in the config parameter.
  173. config = Ext.apply({
  174. store: store,
  175. colModel: colModel
  176. }, config);
  177. MyGridPanel.superclass.constructor.call(this, config);
  178. // Your postprocessing here
  179. },
  180. yourMethod: function() {
  181. // etc.
  182. }
  183. });
  184. </code></pre>
  185. *
  186. * <p>This function also supports a 3-argument call in which the subclass's constructor is
  187. * passed as an argument. In this form, the parameters are as follows:</p>
  188. * <div class="mdetail-params"><ul>
  189. * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
  190. * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
  191. * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
  192. * prototype, and are therefore shared among all instances of the new class.</div></li>
  193. * </ul></div>
  194. *
  195. * @param {Function} superclass The constructor of class being extended.
  196. * @param {Object} overrides <p>A literal with members which are copied into the subclass's
  197. * prototype, and are therefore shared between all instances of the new class.</p>
  198. * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
  199. * to define the constructor of the new class, and is returned. If this property is
  200. * <i>not</i> specified, a constructor is generated and returned which just calls the
  201. * superclass's constructor passing on its parameters.</p>
  202. * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
  203. * @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
  204. */
  205. extend : function(){
  206. // inline overrides
  207. var io = function(o){
  208. for(var m in o){
  209. this[m] = o[m];
  210. }
  211. };
  212. var oc = Object.prototype.constructor;
  213. return function(sb, sp, overrides){
  214. if(typeof sp == 'object'){
  215. overrides = sp;
  216. sp = sb;
  217. sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
  218. }
  219. var F = function(){},
  220. sbp,
  221. spp = sp.prototype;
  222. F.prototype = spp;
  223. sbp = sb.prototype = new F();
  224. sbp.constructor=sb;
  225. sb.superclass=spp;
  226. if(spp.constructor == oc){
  227. spp.constructor=sp;
  228. }
  229. sb.override = function(o){
  230. Ext.override(sb, o);
  231. };
  232. sbp.superclass = sbp.supr = (function(){
  233. return spp;
  234. });
  235. sbp.override = io;
  236. Ext.override(sb, overrides);
  237. sb.extend = function(o){return Ext.extend(sb, o);};
  238. return sb;
  239. };
  240. }(),
  241. /**
  242. * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
  243. * Usage:<pre><code>
  244. Ext.override(MyClass, {
  245. newMethod1: function(){
  246. // etc.
  247. },
  248. newMethod2: function(foo){
  249. // etc.
  250. }
  251. });
  252. </code></pre>
  253. * @param {Object} origclass The class to override
  254. * @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
  255. * containing one or more methods.
  256. * @method override
  257. */
  258. override : function(origclass, overrides){
  259. if(overrides){
  260. var p = origclass.prototype;
  261. Ext.apply(p, overrides);
  262. if(Ext.isIE && overrides.hasOwnProperty('toString')){
  263. p.toString = overrides.toString;
  264. }
  265. }
  266. },
  267. /**
  268. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  269. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  270. * <pre><code>
  271. Ext.namespace('Company', 'Company.data');
  272. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  273. Company.Widget = function() { ... }
  274. Company.data.CustomStore = function(config) { ... }
  275. </code></pre>
  276. * @param {String} namespace1
  277. * @param {String} namespace2
  278. * @param {String} etc
  279. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  280. * @method namespace
  281. */
  282. namespace : function(){
  283. var o, d;
  284. Ext.each(arguments, function(v) {
  285. d = v.split(".");
  286. o = window[d[0]] = window[d[0]] || {};
  287. Ext.each(d.slice(1), function(v2){
  288. o = o[v2] = o[v2] || {};
  289. });
  290. });
  291. return o;
  292. },
  293. /**
  294. * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
  295. * @param {Object} o
  296. * @param {String} pre (optional) A prefix to add to the url encoded string
  297. * @return {String}
  298. */
  299. urlEncode : function(o, pre){
  300. var empty,
  301. buf = [],
  302. e = encodeURIComponent;
  303. Ext.iterate(o, function(key, item){
  304. empty = Ext.isEmpty(item);
  305. Ext.each(empty ? key : item, function(val){
  306. buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
  307. });
  308. });
  309. if(!pre){
  310. buf.shift();
  311. pre = '';
  312. }
  313. return pre + buf.join('');
  314. },
  315. /**
  316. * Takes an encoded URL and and converts it to an object. Example: <pre><code>
  317. Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
  318. Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
  319. </code></pre>
  320. * @param {String} string
  321. * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
  322. * @return {Object} A literal with members
  323. */
  324. urlDecode : function(string, overwrite){
  325. if(Ext.isEmpty(string)){
  326. return {};
  327. }
  328. var obj = {},
  329. pairs = string.split('&'),
  330. d = decodeURIComponent,
  331. name,
  332. value;
  333. Ext.each(pairs, function(pair) {
  334. pair = pair.split('=');
  335. name = d(pair[0]);
  336. value = d(pair[1]);
  337. obj[name] = overwrite || !obj[name] ? value :
  338. [].concat(obj[name]).concat(value);
  339. });
  340. return obj;
  341. },
  342. /**
  343. * Appends content to the query string of a URL, handling logic for whether to place
  344. * a question mark or ampersand.
  345. * @param {String} url The URL to append to.
  346. * @param {String} s The content to append to the URL.
  347. * @return (String) The resulting URL
  348. */
  349. urlAppend : function(url, s){
  350. if(!Ext.isEmpty(s)){
  351. return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
  352. }
  353. return url;
  354. },
  355. /**
  356. * Converts any iterable (numeric indices and a length property) into a true array
  357. * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
  358. * For strings, use this instead: "abc".match(/./g) => [a,b,c];
  359. * @param {Iterable} the iterable object to be turned into a true Array.
  360. * @return (Array) array
  361. */
  362. toArray : function(){
  363. return isIE ?
  364. function(a, i, j, res){
  365. res = [];
  366. for(var x = 0, len = a.length; x < len; x++) {
  367. res.push(a[x]);
  368. }
  369. return res.slice(i || 0, j || res.length);
  370. } :
  371. function(a, i, j){
  372. return Array.prototype.slice.call(a, i || 0, j || a.length);
  373. }
  374. }(),
  375. isIterable : function(v){
  376. //check for array or arguments
  377. if(Ext.isArray(v) || v.callee){
  378. return true;
  379. }
  380. //check for node list type
  381. if(/NodeList|HTMLCollection/.test(toString.call(v))){
  382. return true;
  383. }
  384. //NodeList has an item and length property
  385. //IXMLDOMNodeList has nextNode method, needs to be checked first.
  386. return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
  387. },
  388. /**
  389. * Iterates an array calling the supplied function.
  390. * @param {Array/NodeList/Mixed} array The array to be iterated. If this
  391. * argument is not really an array, the supplied function is called once.
  392. * @param {Function} fn The function to be called with each item. If the
  393. * supplied function returns false, iteration stops and this method returns
  394. * the current <code>index</code>. This function is called with
  395. * the following arguments:
  396. * <div class="mdetail-params"><ul>
  397. * <li><code>item</code> : <i>Mixed</i>
  398. * <div class="sub-desc">The item at the current <code>index</code>
  399. * in the passed <code>array</code></div></li>
  400. * <li><code>index</code> : <i>Number</i>
  401. * <div class="sub-desc">The current index within the array</div></li>
  402. * <li><code>allItems</code> : <i>Array</i>
  403. * <div class="sub-desc">The <code>array</code> passed as the first
  404. * argument to <code>Ext.each</code>.</div></li>
  405. * </ul></div>
  406. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
  407. * Defaults to the <code>item</code> at the current <code>index</code>
  408. * within the passed <code>array</code>.
  409. * @return See description for the fn parameter.
  410. */
  411. each : function(array, fn, scope){
  412. if(Ext.isEmpty(array, true)){
  413. return;
  414. }
  415. if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
  416. array = [array];
  417. }
  418. for(var i = 0, len = array.length; i < len; i++){
  419. if(fn.call(scope || array[i], array[i], i, array) === false){
  420. return i;
  421. };
  422. }
  423. },
  424. /**
  425. * Iterates either the elements in an array, or each of the properties in an object.
  426. * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
  427. * @param {Object/Array} object The object or array to be iterated
  428. * @param {Function} fn The function to be called for each iteration.
  429. * The iteration will stop if the supplied function returns false, or
  430. * all array elements / object properties have been covered. The signature
  431. * varies depending on the type of object being interated:
  432. * <div class="mdetail-params"><ul>
  433. * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
  434. * <div class="sub-desc">
  435. * When iterating an array, the supplied function is called with each item.</div></li>
  436. * <li>Objects : <tt>(String key, Object value, Object)</tt>
  437. * <div class="sub-desc">
  438. * When iterating an object, the supplied function is called with each key-value pair in
  439. * the object, and the iterated object</div></li>
  440. * </ul></div>
  441. * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
  442. * the <code>object</code> being iterated.
  443. */
  444. iterate : function(obj, fn, scope){
  445. if(Ext.isEmpty(obj)){
  446. return;
  447. }
  448. if(Ext.isIterable(obj)){
  449. Ext.each(obj, fn, scope);
  450. return;
  451. }else if(typeof obj == 'object'){
  452. for(var prop in obj){
  453. if(obj.hasOwnProperty(prop)){
  454. if(fn.call(scope || obj, prop, obj[prop], obj) === false){
  455. return;
  456. };
  457. }
  458. }
  459. }
  460. },
  461. /**
  462. * Return the dom node for the passed String (id), dom node, or Ext.Element.
  463. * Optional 'strict' flag is needed for IE since it can return 'name' and
  464. * 'id' elements by using getElementById.
  465. * Here are some examples:
  466. * <pre><code>
  467. // gets dom node based on id
  468. var elDom = Ext.getDom('elId');
  469. // gets dom node based on the dom node
  470. var elDom1 = Ext.getDom(elDom);
  471. // If we don&#39;t know if we are working with an
  472. // Ext.Element or a dom node use Ext.getDom
  473. function(el){
  474. var dom = Ext.getDom(el);
  475. // do something with the dom node
  476. }
  477. * </code></pre>
  478. * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
  479. * when this method is called to be successful.
  480. * @param {Mixed} el
  481. * @return HTMLElement
  482. */
  483. getDom : function(el, strict){
  484. if(!el || !DOC){
  485. return null;
  486. }
  487. if (el.dom){
  488. return el.dom;
  489. } else {
  490. if (typeof el == 'string') {
  491. var e = DOC.getElementById(el);
  492. // IE returns elements with the 'name' and 'id' attribute.
  493. // we do a strict check to return the element with only the id attribute
  494. if (e && isIE && strict) {
  495. if (el == e.getAttribute('id')) {
  496. return e;
  497. } else {
  498. return null;
  499. }
  500. }
  501. return e;
  502. } else {
  503. return el;
  504. }
  505. }
  506. },
  507. /**
  508. * Returns the current document body as an {@link Ext.Element}.
  509. * @return Ext.Element The document body
  510. */
  511. getBody : function(){
  512. return Ext.get(DOC.body || DOC.documentElement);
  513. },
  514. /**
  515. * Removes a DOM node from the document.
  516. */
  517. /**
  518. * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
  519. * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
  520. * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
  521. * will be ignored if passed in.</p>
  522. * @param {HTMLElement} node The node to remove
  523. */
  524. removeNode : isIE && !isIE8 ? function(){
  525. var d;
  526. return function(n){
  527. if(n && n.tagName != 'BODY'){
  528. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  529. d = d || DOC.createElement('div');
  530. d.appendChild(n);
  531. d.innerHTML = '';
  532. delete Ext.elCache[n.id];
  533. }
  534. }
  535. }() : function(n){
  536. if(n && n.parentNode && n.tagName != 'BODY'){
  537. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
  538. n.parentNode.removeChild(n);
  539. delete Ext.elCache[n.id];
  540. }
  541. },
  542. /**
  543. * <p>Returns true if the passed value is empty.</p>
  544. * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
  545. * <li>null</li>
  546. * <li>undefined</li>
  547. * <li>an empty array</li>
  548. * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
  549. * </ul></div>
  550. * @param {Mixed} value The value to test
  551. * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
  552. * @return {Boolean}
  553. */
  554. isEmpty : function(v, allowBlank){
  555. return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
  556. },
  557. /**
  558. * Returns true if the passed value is a JavaScript array, otherwise false.
  559. * @param {Mixed} value The value to test
  560. * @return {Boolean}
  561. */
  562. isArray : function(v){
  563. return toString.apply(v) === '[object Array]';
  564. },
  565. /**
  566. * Returns true if the passed object is a JavaScript date object, otherwise false.
  567. * @param {Object} object The object to test
  568. * @return {Boolean}
  569. */
  570. isDate : function(v){
  571. return toString.apply(v) === '[object Date]';
  572. },
  573. /**
  574. * Returns true if the passed value is a JavaScript Object, otherwise false.
  575. * @param {Mixed} value The value to test
  576. * @return {Boolean}
  577. */
  578. isObject : function(v){
  579. return !!v && Object.prototype.toString.call(v) === '[object Object]';
  580. },
  581. /**
  582. * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
  583. * @param {Mixed} value The value to test
  584. * @return {Boolean}
  585. */
  586. isPrimitive : function(v){
  587. return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
  588. },
  589. /**
  590. * Returns true if the passed value is a JavaScript Function, otherwise false.
  591. * @param {Mixed} value The value to test
  592. * @return {Boolean}
  593. */
  594. isFunction : function(v){
  595. return toString.apply(v) === '[object Function]';
  596. },
  597. /**
  598. * Returns true if the passed value is a number. Returns false for non-finite numbers.
  599. * @param {Mixed} value The value to test
  600. * @return {Boolean}
  601. */
  602. isNumber : function(v){
  603. return typeof v === 'number' && isFinite(v);
  604. },
  605. /**
  606. * Returns true if the passed value is a string.
  607. * @param {Mixed} value The value to test
  608. * @return {Boolean}
  609. */
  610. isString : function(v){
  611. return typeof v === 'string';
  612. },
  613. /**
  614. * Returns true if the passed value is a boolean.
  615. * @param {Mixed} value The value to test
  616. * @return {Boolean}
  617. */
  618. isBoolean : function(v){
  619. return typeof v === 'boolean';
  620. },
  621. /**
  622. * Returns true if the passed value is an HTMLElement
  623. * @param {Mixed} value The value to test
  624. * @return {Boolean}
  625. */
  626. isElement : function(v) {
  627. return v ? !!v.tagName : false;
  628. },
  629. /**
  630. * Returns true if the passed value is not undefined.
  631. * @param {Mixed} value The value to test
  632. * @return {Boolean}
  633. */
  634. isDefined : function(v){
  635. return typeof v !== 'undefined';
  636. },
  637. /**
  638. * True if the detected browser is Opera.
  639. * @type Boolean
  640. */
  641. isOpera : isOpera,
  642. /**
  643. * True if the detected browser uses WebKit.
  644. * @type Boolean
  645. */
  646. isWebKit : isWebKit,
  647. /**
  648. * True if the detected browser is Chrome.
  649. * @type Boolean
  650. */
  651. isChrome : isChrome,
  652. /**
  653. * True if the detected browser is Safari.
  654. * @type Boolean
  655. */
  656. isSafari : isSafari,
  657. /**
  658. * True if the detected browser is Safari 3.x.
  659. * @type Boolean
  660. */
  661. isSafari3 : isSafari3,
  662. /**
  663. * True if the detected browser is Safari 4.x.
  664. * @type Boolean
  665. */
  666. isSafari4 : isSafari4,
  667. /**
  668. * True if the detected browser is Safari 2.x.
  669. * @type Boolean
  670. */
  671. isSafari2 : isSafari2,
  672. /**
  673. * True if the detected browser is Internet Explorer.
  674. * @type Boolean
  675. */
  676. isIE : isIE,
  677. /**
  678. * True if the detected browser is Internet Explorer 6.x.
  679. * @type Boolean
  680. */
  681. isIE6 : isIE6,
  682. /**
  683. * True if the detected browser is Internet Explorer 7.x.
  684. * @type Boolean
  685. */
  686. isIE7 : isIE7,
  687. /**
  688. * True if the detected browser is Internet Explorer 8.x.
  689. * @type Boolean
  690. */
  691. isIE8 : isIE8,
  692. /**
  693. * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
  694. * @type Boolean
  695. */
  696. isGecko : isGecko,
  697. /**
  698. * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
  699. * @type Boolean
  700. */
  701. isGecko2 : isGecko2,
  702. /**
  703. * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
  704. * @type Boolean
  705. */
  706. isGecko3 : isGecko3,
  707. /**
  708. * True if the detected browser is Internet Explorer running in non-strict mode.
  709. * @type Boolean
  710. */
  711. isBorderBox : isBorderBox,
  712. /**
  713. * True if the detected platform is Linux.
  714. * @type Boolean
  715. */
  716. isLinux : isLinux,
  717. /**
  718. * True if the detected platform is Windows.
  719. * @type Boolean
  720. */
  721. isWindows : isWindows,
  722. /**
  723. * True if the detected platform is Mac OS.
  724. * @type Boolean
  725. */
  726. isMac : isMac,
  727. /**
  728. * True if the detected platform is Adobe Air.
  729. * @type Boolean
  730. */
  731. isAir : isAir
  732. });
  733. /**
  734. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  735. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  736. * <pre><code>
  737. Ext.namespace('Company', 'Company.data');
  738. Ext.namespace('Company.data'); // equivalent and preferable to above syntax
  739. Company.Widget = function() { ... }
  740. Company.data.CustomStore = function(config) { ... }
  741. </code></pre>
  742. * @param {String} namespace1
  743. * @param {String} namespace2
  744. * @param {String} etc
  745. * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
  746. * @method ns
  747. */
  748. Ext.ns = Ext.namespace;
  749. })();
  750. Ext.ns("Ext.util", "Ext.lib", "Ext.data");
  751. Ext.elCache = {};
  752. /**
  753. * @class Function
  754. * These functions are available on every Function object (any JavaScript function).
  755. */
  756. Ext.apply(Function.prototype, {
  757. /**
  758. * Creates an interceptor function. The passed function is called before the original one. If it returns false,
  759. * the original one is not called. The resulting function returns the results of the original function.
  760. * The passed function is called with the parameters of the original function. Example usage:
  761. * <pre><code>
  762. var sayHi = function(name){
  763. alert('Hi, ' + name);
  764. }
  765. sayHi('Fred'); // alerts "Hi, Fred"
  766. // create a new function that validates input without
  767. // directly modifying the original function:
  768. var sayHiToFriend = sayHi.createInterceptor(function(name){
  769. return name == 'Brian';
  770. });
  771. sayHiToFriend('Fred'); // no alert
  772. sayHiToFriend('Brian'); // alerts "Hi, Brian"
  773. </code></pre>
  774. * @param {Function} fcn The function to call before the original
  775. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  776. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  777. * @return {Function} The new function
  778. */
  779. createInterceptor : function(fcn, scope){
  780. var method = this;
  781. return !Ext.isFunction(fcn) ?
  782. this :
  783. function() {
  784. var me = this,
  785. args = arguments;
  786. fcn.target = me;
  787. fcn.method = method;
  788. return (fcn.apply(scope || me || window, args) !== false) ?
  789. method.apply(me || window, args) :
  790. null;
  791. };
  792. },
  793. /**
  794. * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
  795. * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
  796. * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
  797. * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
  798. * executes in the window scope.
  799. * <p>This method is required when you want to pass arguments to a callback function. If no arguments
  800. * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
  801. * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
  802. * would simply execute immediately when the code is parsed. Example usage:
  803. * <pre><code>
  804. var sayHi = function(name){
  805. alert('Hi, ' + name);
  806. }
  807. // clicking the button alerts "Hi, Fred"
  808. new Ext.Button({
  809. text: 'Say Hi',
  810. renderTo: Ext.getBody(),
  811. handler: sayHi.createCallback('Fred')
  812. });
  813. </code></pre>
  814. * @return {Function} The new function
  815. */
  816. createCallback : function(/*args...*/){
  817. // make args available, in function below
  818. var args = arguments,
  819. method = this;
  820. return function() {
  821. return method.apply(window, args);
  822. };
  823. },
  824. /**
  825. * Creates a delegate (callback) that sets the scope to obj.
  826. * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
  827. * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
  828. * callback points to obj. Example usage:
  829. * <pre><code>
  830. var sayHi = function(name){
  831. // Note this use of "this.text" here. This function expects to
  832. // execute within a scope that contains a text property. In this
  833. // example, the "this" variable is pointing to the btn object that
  834. // was passed in createDelegate below.
  835. alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
  836. }
  837. var btn = new Ext.Button({
  838. text: 'Say Hi',
  839. renderTo: Ext.getBody()
  840. });
  841. // This callback will execute in the scope of the
  842. // button instance. Clicking the button alerts
  843. // "Hi, Fred. You clicked the "Say Hi" button."
  844. btn.on('click', sayHi.createDelegate(btn, ['Fred']));
  845. </code></pre>
  846. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  847. * <b>If omitted, defaults to the browser window.</b>
  848. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  849. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  850. * if a number the args are inserted at the specified position
  851. * @return {Function} The new function
  852. */
  853. createDelegate : function(obj, args, appendArgs){
  854. var method = this;
  855. return function() {
  856. var callArgs = args || arguments;
  857. if (appendArgs === true){
  858. callArgs = Array.prototype.slice.call(arguments, 0);
  859. callArgs = callArgs.concat(args);
  860. }else if (Ext.isNumber(appendArgs)){
  861. callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
  862. var applyArgs = [appendArgs, 0].concat(args); // create method call params
  863. Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
  864. }
  865. return method.apply(obj || window, callArgs);
  866. };
  867. },
  868. /**
  869. * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
  870. * <pre><code>
  871. var sayHi = function(name){
  872. alert('Hi, ' + name);
  873. }
  874. // executes immediately:
  875. sayHi('Fred');
  876. // executes after 2 seconds:
  877. sayHi.defer(2000, this, ['Fred']);
  878. // this syntax is sometimes useful for deferring
  879. // execution of an anonymous function:
  880. (function(){
  881. alert('Anonymous');
  882. }).defer(100);
  883. </code></pre>
  884. * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
  885. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  886. * <b>If omitted, defaults to the browser window.</b>
  887. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  888. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  889. * if a number the args are inserted at the specified position
  890. * @return {Number} The timeout id that can be used with clearTimeout
  891. */
  892. defer : function(millis, obj, args, appendArgs){
  893. var fn = this.createDelegate(obj, args, appendArgs);
  894. if(millis > 0){
  895. return setTimeout(fn, millis);
  896. }
  897. fn();
  898. return 0;
  899. }
  900. });
  901. /**
  902. * @class String
  903. * These functions are available on every String object.
  904. */
  905. Ext.applyIf(String, {
  906. /**
  907. * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
  908. * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
  909. * <pre><code>
  910. var cls = 'my-class', text = 'Some text';
  911. var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
  912. // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
  913. * </code></pre>
  914. * @param {String} string The tokenized string to be formatted
  915. * @param {String} value1 The value to replace token {0}
  916. * @param {String} value2 Etc...
  917. * @return {String} The formatted string
  918. * @static
  919. */
  920. format : function(format){
  921. var args = Ext.toArray(arguments, 1);
  922. return format.replace(/\{(\d+)\}/g, function(m, i){
  923. return args[i];
  924. });
  925. }
  926. });
  927. /**
  928. * @class Array
  929. */
  930. Ext.applyIf(Array.prototype, {
  931. /**
  932. * Checks whether or not the specified object exists in the array.
  933. * @param {Object} o The object to check for
  934. * @param {Number} from (Optional) The index at which to begin the search
  935. * @return {Number} The index of o in the array (or -1 if it is not found)
  936. */
  937. indexOf : function(o, from){
  938. var len = this.length;
  939. from = from || 0;
  940. from += (from < 0) ? len : 0;
  941. for (; from < len; ++from){
  942. if(this[from] === o){
  943. return from;
  944. }
  945. }
  946. return -1;
  947. },
  948. /**
  949. * Removes the specified object from the array. If the object is not found nothing happens.
  950. * @param {Object} o The object to remove
  951. * @return {Array} this array
  952. */
  953. remove : function(o){
  954. var index = this.indexOf(o);
  955. if(index != -1){
  956. this.splice(index, 1);
  957. }
  958. return this;
  959. }
  960. });
  961. /**
  962. * @class Ext
  963. */
  964. Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu",
  965. "Ext.state", "Ext.layout", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct");
  966. /**
  967. * Namespace alloted for extensions to the framework.
  968. * @property ux
  969. * @type Object
  970. */
  971. Ext.apply(Ext, function(){
  972. var E = Ext,
  973. idSeed = 0,
  974. scrollWidth = null;
  975. return {
  976. /**
  977. * A reusable empty function
  978. * @property
  979. * @type Function
  980. */
  981. emptyFn : function(){},
  982. /**
  983. * URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images.
  984. * In older versions of IE, this defaults to "http://extjs.com/s.gif" and you should change this to a URL on your server.
  985. * For other browsers it uses an inline data URL.
  986. * @type String
  987. */
  988. BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
  989. 'http:/' + '/www.extjs.com/s.gif' :
  990. 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  991. extendX : function(supr, fn){
  992. return Ext.extend(supr, fn(supr.prototype));
  993. },
  994. /**
  995. * Returns the current HTML document object as an {@link Ext.Element}.
  996. * @return Ext.Element The document
  997. */
  998. getDoc : function(){
  999. return Ext.get(document);
  1000. },
  1001. /**
  1002. * Utility method for validating that a value is numeric, returning the specified default value if it is not.
  1003. * @param {Mixed} value Should be a number, but any type will be handled appropriately
  1004. * @param {Number} defaultValue The value to return if the original value is non-numeric
  1005. * @return {Number} Value, if numeric, else defaultValue
  1006. */
  1007. num : function(v, defaultValue){
  1008. v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
  1009. return isNaN(v) ? defaultValue : v;
  1010. },
  1011. /**
  1012. * <p>Utility method for returning a default value if the passed value is empty.</p>
  1013. * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
  1014. * <li>null</li>
  1015. * <li>undefined</li>
  1016. * <li>an empty array</li>
  1017. * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
  1018. * </ul></div>
  1019. * @param {Mixed} value The value to test
  1020. * @param {Mixed} defaultValue The value to return if the original value is empty
  1021. * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
  1022. * @return {Mixed} value, if non-empty, else defaultValue
  1023. */
  1024. value : function(v, defaultValue, allowBlank){
  1025. return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
  1026. },
  1027. /**
  1028. * Escapes the passed string for use in a regular expression
  1029. * @param {String} str
  1030. * @return {String}
  1031. */
  1032. escapeRe : function(s) {
  1033. return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
  1034. },
  1035. sequence : function(o, name, fn, scope){
  1036. o[name] = o[name].createSequence(fn, scope);
  1037. },
  1038. /**
  1039. * Applies event listeners to elements by selectors when the document is ready.
  1040. * The event name is specified with an <tt>&#64;</tt> suffix.
  1041. * <pre><code>
  1042. Ext.addBehaviors({
  1043. // add a listener for click on all anchors in element with id foo
  1044. '#foo a&#64;click' : function(e, t){
  1045. // do something
  1046. },
  1047. // add the same listener to multiple selectors (separated by comma BEFORE the &#64;)
  1048. '#foo a, #bar span.some-class&#64;mouseover' : function(){
  1049. // do something
  1050. }
  1051. });
  1052. * </code></pre>
  1053. * @param {Object} obj The list of behaviors to apply
  1054. */
  1055. addBehaviors : function(o){
  1056. if(!Ext.isReady){
  1057. Ext.onReady(function(){
  1058. Ext.addBehaviors(o);
  1059. });
  1060. } else {
  1061. var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
  1062. parts,
  1063. b,
  1064. s;
  1065. for (b in o) {
  1066. if ((parts = b.split('@'))[1]) { // for Object prototype breakers
  1067. s = parts[0];
  1068. if(!cache[s]){
  1069. cache[s] = Ext.select(s);
  1070. }
  1071. cache[s].on(parts[1], o[b]);
  1072. }
  1073. }
  1074. cache = null;
  1075. }
  1076. },
  1077. /**
  1078. * Utility method for getting the width of the browser scrollbar. This can differ depending on
  1079. * operating system settings, such as the theme or font size.
  1080. * @param {Boolean} force (optional) true to force a recalculation of the value.
  1081. * @return {Number} The width of the scrollbar.
  1082. */
  1083. getScrollBarWidth: function(force){
  1084. if(!Ext.isReady){
  1085. return 0;
  1086. }
  1087. if(force === true || scrollWidth === null){
  1088. // Append our div, do our calculation and then remove it
  1089. var div = Ext.getBody().createChild('<div class="x-hide-offsets" style="width:100px;height:50px;overflow:hidden;"><div style="height:200px;"></div></div>'),
  1090. child = div.child('div', true);
  1091. var w1 = child.offsetWidth;
  1092. div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
  1093. var w2 = child.offsetWidth;
  1094. div.remove();
  1095. // Need to add 2 to ensure we leave enough space
  1096. scrollWidth = w1 - w2 + 2;
  1097. }
  1098. return scrollWidth;
  1099. },
  1100. // deprecated
  1101. combine : function(){
  1102. var as = arguments, l = as.length, r = [];
  1103. for(var i = 0; i < l; i++){
  1104. var a = as[i];
  1105. if(Ext.isArray(a)){
  1106. r = r.concat(a);
  1107. }else if(a.length !== undefined && !a.substr){
  1108. r = r.concat(Array.prototype.slice.call(a, 0));
  1109. }else{
  1110. r.push(a);
  1111. }
  1112. }
  1113. return r;
  1114. },
  1115. /**
  1116. * Copies a set of named properties fom the source object to the destination object.
  1117. * <p>example:<pre><code>
  1118. ImageComponent = Ext.extend(Ext.BoxComponent, {
  1119. initComponent: function() {
  1120. this.autoEl = { tag: 'img' };
  1121. MyComponent.superclass.initComponent.apply(this, arguments);
  1122. this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
  1123. }
  1124. });
  1125. * </code></pre>
  1126. * @param {Object} dest The destination object.
  1127. * @param {Object} source The source object.
  1128. * @param {Array/String} names Either an Array of property names, or a comma-delimited list
  1129. * of property names to copy.
  1130. * @return {Object} The modified object.
  1131. */
  1132. copyTo : function(dest, source, names){
  1133. if(typeof names == 'string'){
  1134. names = names.split(/[,;\s]/);
  1135. }
  1136. Ext.each(names, function(name){
  1137. if(source.hasOwnProperty(name)){
  1138. dest[name] = source[name];
  1139. }
  1140. }, this);
  1141. return dest;
  1142. },
  1143. /**
  1144. * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
  1145. * DOM (if applicable) and calling their destroy functions (if available). This method is primarily
  1146. * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
  1147. * {@link Ext.util.Observable} can be passed in. Any number of elements and/or components can be
  1148. * passed into this function in a single call as separate arguments.
  1149. * @param {Mixed} arg1 An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
  1150. * @param {Mixed} arg2 (optional)
  1151. * @param {Mixed} etc... (optional)
  1152. */
  1153. destroy : function(){
  1154. Ext.each(arguments, function(arg){
  1155. if(arg){
  1156. if(Ext.isArray(arg)){
  1157. this.destroy.apply(this, arg);
  1158. }else if(typeof arg.destroy == 'function'){
  1159. arg.destroy();
  1160. }else if(arg.dom){
  1161. arg.remove();
  1162. }
  1163. }
  1164. }, this);
  1165. },
  1166. /**
  1167. * Attempts to destroy and then remove a set of named properties of the passed object.
  1168. * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
  1169. * @param {Mixed} arg1 The name of the property to destroy and remove from the object.
  1170. * @param {Mixed} etc... More property names to destroy and remove.
  1171. */
  1172. destroyMembers : function(o, arg1, arg2, etc){
  1173. for(var i = 1, a = arguments, len = a.length; i < len; i++) {
  1174. Ext.destroy(o[a[i]]);
  1175. delete o[a[i]];
  1176. }
  1177. },
  1178. /**
  1179. * Creates a copy of the passed Array with falsy values removed.
  1180. * @param {Array/NodeList} arr The Array from which to remove falsy values.
  1181. * @return {Array} The new, compressed Array.
  1182. */
  1183. clean : function(arr){
  1184. var ret = [];
  1185. Ext.each(arr, function(v){
  1186. if(!!v){
  1187. ret.push(v);
  1188. }
  1189. });
  1190. return ret;
  1191. },
  1192. /**
  1193. * Creates a copy of the passed Array, filtered to contain only unique values.
  1194. * @param {Array} arr The Array to filter
  1195. * @return {Array} The new Array containing unique values.
  1196. */
  1197. unique : function(arr){
  1198. var ret = [],
  1199. collect = {};
  1200. Ext.each(arr, function(v) {
  1201. if(!collect[v]){
  1202. ret.push(v);
  1203. }
  1204. collect[v] = true;
  1205. });
  1206. return ret;
  1207. },
  1208. /**
  1209. * Recursively flattens into 1-d Array. Injects Arrays inline.
  1210. * @param {Array} arr The array to flatten
  1211. * @return {Array} The new, flattened array.
  1212. */
  1213. flatten : function(arr){
  1214. var worker = [];
  1215. function rFlatten(a) {
  1216. Ext.each(a, function(v) {
  1217. if(Ext.isArray(v)){
  1218. rFlatten(v);
  1219. }else{
  1220. worker.push(v);
  1221. }
  1222. });
  1223. return worker;
  1224. }
  1225. return rFlatten(arr);
  1226. },
  1227. /**
  1228. * Returns the minimum value in the Array.
  1229. * @param {Array|NodeList} arr The Array from which to select the minimum value.
  1230. * @param {Function} comp (optional) a function to perform the comparision which determines minimization.
  1231. * If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1
  1232. * @return {Object} The minimum value in the Array.
  1233. */
  1234. min : function(arr, comp){
  1235. var ret = arr[0];
  1236. comp = comp || function(a,b){ return a < b ? -1 : 1; };
  1237. Ext.each(arr, function(v) {
  1238. ret = comp(ret, v) == -1 ? ret : v;
  1239. });
  1240. return ret;
  1241. },
  1242. /**
  1243. * Returns the maximum value in the Array
  1244. * @param {Array|NodeList} arr The Array from which to select the maximum value.
  1245. * @param {Function} comp (optional) a function to perform the comparision which determines maximization.
  1246. * If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1
  1247. * @return {Object} The maximum value in the Array.
  1248. */
  1249. max : function(arr, comp){
  1250. var ret = arr[0];
  1251. comp = comp || function(a,b){ return a > b ? 1 : -1; };
  1252. Ext.each(arr, function(v) {
  1253. ret = comp(ret, v) == 1 ? ret : v;
  1254. });
  1255. return ret;
  1256. },
  1257. /**
  1258. * Calculates the mean of the Array
  1259. * @param {Array} arr The Array to calculate the mean value of.
  1260. * @return {Number} The mean.
  1261. */
  1262. mean : function(arr){
  1263. return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined;
  1264. },
  1265. /**
  1266. * Calculates the sum of the Array
  1267. * @param {Array} arr The Array to calculate the sum value of.
  1268. * @return {Number} The sum.
  1269. */
  1270. sum : function(arr){
  1271. var ret = 0;
  1272. Ext.each(arr, function(v) {
  1273. ret += v;
  1274. });
  1275. return ret;
  1276. },
  1277. /**
  1278. * Partitions the set into two sets: a true set and a false set.
  1279. * Example:
  1280. * Example2:
  1281. * <pre><code>
  1282. // Example 1:
  1283. Ext.partition([true, false, true, true, false]); // [[true, true, true], [false, false]]
  1284. // Example 2:
  1285. Ext.partition(
  1286. Ext.query("p"),
  1287. function(val){
  1288. return val.className == "class1"
  1289. }
  1290. );
  1291. // true are those paragraph elements with a className of "class1",
  1292. // false set are those that do not have that className.
  1293. * </code></pre>
  1294. * @param {Array|NodeList} arr The array to partition
  1295. * @param {Function} truth (optional) a function to determine truth. If this is omitted the element
  1296. * itself must be able to be evaluated for its truthfulness.
  1297. * @return {Array} [true<Array>,false<Array>]
  1298. */
  1299. partition : function(arr, truth){
  1300. var ret = [[],[]];
  1301. Ext.each(arr, function(v, i, a) {
  1302. ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v);
  1303. });
  1304. return ret;
  1305. },
  1306. /**
  1307. * Invokes a method on each item in an Array.
  1308. * <pre><code>
  1309. // Example:
  1310. Ext.invoke(Ext.query("p"), "getAttribute", "id");
  1311. // [el1.getAttribute("id"), el2.getAttribute("id"), ..., elN.getAttribute("id")]
  1312. * </code></pre>
  1313. * @param {Array|NodeList} arr The Array of items to invoke the method on.
  1314. * @param {String} methodName The method name to invoke.
  1315. * @param {...*} args Arguments to send into the method invocation.
  1316. * @return {Array} The results of invoking the method on each item in the array.
  1317. */
  1318. invoke : function(arr, methodName){
  1319. var ret = [],
  1320. args = Array.prototype.slice.call(arguments, 2);
  1321. Ext.each(arr, function(v,i) {
  1322. if (v && typeof v[methodName] == 'function') {
  1323. ret.push(v[methodName].apply(v, args));
  1324. } else {
  1325. ret.push(undefined);
  1326. }
  1327. });
  1328. return ret;
  1329. },
  1330. /**
  1331. * Plucks the value of a property from each item in the Array
  1332. * <pre><code>
  1333. // Example:
  1334. Ext.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
  1335. * </code></pre>
  1336. * @param {Array|NodeList} arr The Array of items to pluck the value from.
  1337. * @param {String} prop The property name to pluck from each element.
  1338. * @return {Array} The value from each item in the Array.
  1339. */
  1340. pluck : function(arr, prop){
  1341. var ret = [];
  1342. Ext.each(arr, function(v) {
  1343. ret.push( v[prop] );
  1344. });
  1345. return ret;
  1346. },
  1347. /**
  1348. * <p>Zips N sets together.</p>
  1349. * <pre><code>
  1350. // Example 1:
  1351. Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
  1352. // Example 2:
  1353. Ext.zip(
  1354. [ "+", "-", "+"],
  1355. [ 12, 10, 22],
  1356. [ 43, 15, 96],
  1357. function(a, b, c){
  1358. return "$" + a + "" + b + "." + c
  1359. }
  1360. ); // ["$+12.43", "$-10.15", "$+22.96"]
  1361. * </code></pre>
  1362. * @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values.
  1363. * @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together.
  1364. * @return {Array} The zipped set.
  1365. */
  1366. zip : function(){
  1367. var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
  1368. arrs = parts[0],
  1369. fn = parts[1][0],
  1370. len = Ext.max(Ext.pluck(arrs, "length")),
  1371. ret = [];
  1372. for (var i = 0; i < len; i++) {
  1373. ret[i] = [];
  1374. if(fn){
  1375. ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
  1376. }else{
  1377. for (var j = 0, aLen = arrs.length; j < aLen; j++){
  1378. ret[i].push( arrs[j][i] );
  1379. }
  1380. }
  1381. }
  1382. return ret;
  1383. },
  1384. /**
  1385. * This is shorthand reference to {@link Ext.ComponentMgr#get}.
  1386. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
  1387. * @param {String} id The component {@link Ext.Component#id id}
  1388. * @return Ext.Component The Component, <tt>undefined</tt> if not found, or <tt>null</tt> if a
  1389. * Class was found.
  1390. */
  1391. getCmp : function(id){
  1392. return Ext.ComponentMgr.get(id);
  1393. },
  1394. /**
  1395. * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
  1396. * you may want to set this to true.
  1397. * @type Boolean
  1398. */
  1399. useShims: E.isIE6 || (E.isMac && E.isGecko2),
  1400. // inpired by a similar function in mootools library
  1401. /**
  1402. * Returns the type of object that is passed in. If the object passed in is null or undefined it
  1403. * return false otherwise it returns one of the following values:<div class="mdetail-params"><ul>
  1404. * <li><b>string</b>: If the object passed is a string</li>
  1405. * <li><b>number</b>: If the object passed is a number</li>
  1406. * <li><b>boolean</b>: If the object passed is a boolean value</li>
  1407. * <li><b>date</b>: If the object passed is a Date object</li>
  1408. * <li><b>function</b>: If the object passed is a function reference</li>
  1409. * <li><b>object</b>: If the object passed is an object</li>
  1410. * <li><b>array</b>: If the object passed is an array</li>
  1411. * <li><b>regexp</b>: If the object passed is a regular expression</li>
  1412. * <li><b>element</b>: If the object passed is a DOM Element</li>
  1413. * <li><b>nodelist</b>: If the object passed is a DOM NodeList</li>
  1414. * <li><b>textnode</b>: If the object passed is a DOM text node and contains something other than whitespace</li>
  1415. * <li><b>whitespace</b>: If the object passed is a DOM text node and contains only whitespace</li>
  1416. * </ul></div>
  1417. * @param {Mixed} object
  1418. * @return {String}
  1419. */
  1420. type : function(o){
  1421. if(o === undefined || o === null){
  1422. return false;
  1423. }
  1424. if(o.htmlElement){
  1425. return 'element';
  1426. }
  1427. var t = typeof o;
  1428. if(t == 'object' && o.nodeName) {
  1429. switch(o.nodeType) {
  1430. case 1: return 'element';
  1431. case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
  1432. }
  1433. }
  1434. if(t == 'object' || t == 'function') {
  1435. switch(o.constructor) {
  1436. case Array: return 'array';
  1437. case RegExp: return 'regexp';
  1438. case Date: return 'date';
  1439. }
  1440. if(typeof o.length == 'number' && typeof o.item == 'function') {
  1441. return 'nodelist';
  1442. }
  1443. }
  1444. return t;
  1445. },
  1446. intercept : function(o, name, fn, scope){
  1447. o[name] = o[name].createInterceptor(fn, scope);
  1448. },
  1449. // internal
  1450. callback : function(cb, scope, args, delay){
  1451. if(typeof cb == 'function'){
  1452. if(delay){
  1453. cb.defer(delay, scope, args || []);
  1454. }else{
  1455. cb.apply(scope, args || []);
  1456. }
  1457. }
  1458. }
  1459. };
  1460. }());
  1461. /**
  1462. * @class Function
  1463. * These functions are available on every Function object (any JavaScript function).
  1464. */
  1465. Ext.apply(Function.prototype, {
  1466. /**
  1467. * Create a combined function call sequence of the original function + the passed function.
  1468. * The resulting function returns the results of the original function.
  1469. * The passed fcn is called with the parameters of the original function. Example usage:
  1470. * <pre><code>
  1471. var sayHi = function(name){
  1472. alert('Hi, ' + name);
  1473. }
  1474. sayHi('Fred'); // alerts "Hi, Fred"
  1475. var sayGoodbye = sayHi.createSequence(function(name){
  1476. alert('Bye, ' + name);
  1477. });
  1478. sayGoodbye('Fred'); // both alerts show
  1479. </code></pre>
  1480. * @param {Function} fcn The function to sequence
  1481. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  1482. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  1483. * @return {Function} The new function
  1484. */
  1485. createSequence : function(fcn, scope){
  1486. var method = this;
  1487. return (typeof fcn != 'function') ?
  1488. this :
  1489. function(){
  1490. var retval = method.apply(this || window, arguments);
  1491. fcn.apply(scope || this || window, arguments);
  1492. return retval;
  1493. };
  1494. }
  1495. });
  1496. /**
  1497. * @class String
  1498. * These functions are available as static methods on the JavaScript String object.
  1499. */
  1500. Ext.applyIf(String, {
  1501. /**
  1502. * Escapes the passed string for ' and \
  1503. * @param {String} string The string to escape
  1504. * @return {String} The escaped string
  1505. * @static
  1506. */
  1507. escape : function(string) {
  1508. return string.replace(/('|\\)/g, "\\$1");
  1509. },
  1510. /**
  1511. * Pads the left side of a string with a specified character. This is especially useful
  1512. * for normalizing number and date strings. Example usage:
  1513. * <pre><code>
  1514. var s = String.leftPad('123', 5, '0');
  1515. // s now contains the string: '00123'
  1516. * </code></pre>
  1517. * @param {String} string The original string
  1518. * @param {Number} size The total length of the output string
  1519. * @param {String} char (optional) The character with which to pad the original string (defaults to empty string " ")
  1520. * @return {String} The padded string
  1521. * @static
  1522. */
  1523. leftPad : function (val, size, ch) {
  1524. var result = String(val);
  1525. if(!ch) {
  1526. ch = " ";
  1527. }
  1528. while (result.length < size) {
  1529. result = ch + result;
  1530. }
  1531. return result;
  1532. }
  1533. });
  1534. /**
  1535. * Utility function that allows you to easily switch a string between two alternating values. The passed value
  1536. * is compared to the current string, and if they are equal, the other value that was passed in is returned. If
  1537. * they are already different, the first value passed in is returned. Note that this method returns the new value
  1538. * but does not change the current string.
  1539. * <pre><code>
  1540. // alternate sort directions
  1541. sort = sort.toggle('ASC', 'DESC');
  1542. // instead of conditional logic:
  1543. sort = (sort == 'ASC' ? 'DESC' : 'ASC');
  1544. </code></pre>
  1545. * @param {String} value The value to compare to the current string
  1546. * @param {String} other The new value to use if the string already equals the first value passed in
  1547. * @return {String} The new value
  1548. */
  1549. String.prototype.toggle = function(value, other){
  1550. return this == value ? other : value;
  1551. };
  1552. /**
  1553. * Trims whitespace from either end of a string, leaving spaces within the string intact. Example:
  1554. * <pre><code>
  1555. var s = ' foo bar ';
  1556. alert('-' + s + '-'); //alerts "- foo bar -"
  1557. alert('-' + s.trim() + '-'); //alerts "-foo bar-"
  1558. </code></pre>
  1559. * @return {String} The trimmed string
  1560. */
  1561. String.prototype.trim = function(){
  1562. var re = /^\s+|\s+$/g;
  1563. return function(){ return this.replace(re, ""); };
  1564. }();
  1565. // here to prevent dependency on Date.js
  1566. /**
  1567. Returns the number of milliseconds between this date and date
  1568. @param {Date} date (optional) Defaults to now
  1569. @return {Number} The diff in milliseconds
  1570. @member Date getElapsed
  1571. */
  1572. Date.prototype.getElapsed = function(date) {
  1573. return Math.abs((date || new Date()).getTime()-this.getTime());
  1574. };
  1575. /**
  1576. * @class Number
  1577. */
  1578. Ext.applyIf(Number.prototype, {
  1579. /**
  1580. * Checks whether or not the current number is within a desired range. If the number is already within the
  1581. * range it is returned, otherwise the min or max value is returned depending on which side of the range is
  1582. * exceeded. Note that this method returns the constrained value but does not change the current number.
  1583. * @param {Number} min The minimum number in the range
  1584. * @param {Number} max The maximum number in the range
  1585. * @return {Number} The constrained value if outside the range, otherwise the current value
  1586. */
  1587. constrain : function(min, max){
  1588. return Math.min(Math.max(this, min), max);
  1589. }
  1590. });
  1591. /**
  1592. * @class Ext.util.TaskRunner
  1593. * Provides the ability to execute one or more arbitrary tasks in a multithreaded
  1594. * manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
  1595. * if needed, you can create separate instances of TaskRunner. Any number of
  1596. * separate tasks can be started at any time and will run independently of each
  1597. * other. Example usage:
  1598. * <pre><code>
  1599. // Start a simple clock task that updates a div once per second
  1600. var updateClock = function(){
  1601. Ext.fly('clock').update(new Date().format('g:i:s A'));
  1602. }
  1603. var task = {
  1604. run: updateClock,
  1605. interval: 1000 //1 second
  1606. }
  1607. var runner = new Ext.util.TaskRunner();
  1608. runner.start(task);
  1609. // equivalent using TaskMgr
  1610. Ext.TaskMgr.start({
  1611. run: updateClock,
  1612. interval: 1000
  1613. });
  1614. * </code></pre>
  1615. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1616. * Also see {@link Ext.util.DelayedTask}.
  1617. *
  1618. * @constructor
  1619. * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
  1620. * (defaults to 10)
  1621. */
  1622. Ext.util.TaskRunner = function(interval){
  1623. interval = interval || 10;
  1624. var tasks = [],
  1625. removeQueue = [],
  1626. id = 0,
  1627. running = false,
  1628. // private
  1629. stopThread = function(){
  1630. running = false;
  1631. clearInterval(id);
  1632. id = 0;
  1633. },
  1634. // private
  1635. startThread = function(){
  1636. if(!running){
  1637. running = true;
  1638. id = setInterval(runTasks, interval);
  1639. }
  1640. },
  1641. // private
  1642. removeTask = function(t){
  1643. removeQueue.push(t);
  1644. if(t.onStop){
  1645. t.onStop.apply(t.scope || t);
  1646. }
  1647. },
  1648. // private
  1649. runTasks = function(){
  1650. var rqLen = removeQueue.length,
  1651. now = new Date().getTime();
  1652. if(rqLen > 0){
  1653. for(var i = 0; i < rqLen; i++){
  1654. tasks.remove(removeQueue[i]);
  1655. }
  1656. removeQueue = [];
  1657. if(tasks.length < 1){
  1658. stopThread();
  1659. return;
  1660. }
  1661. }
  1662. for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){
  1663. t = tasks[i];
  1664. itime = now - t.taskRunTime;
  1665. if(t.interval <= itime){
  1666. rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
  1667. t.taskRunTime = now;
  1668. if(rt === false || t.taskRunCount === t.repeat){
  1669. removeTask(t);
  1670. return;
  1671. }
  1672. }
  1673. if(t.duration && t.duration <= (now - t.taskStartTime)){
  1674. removeTask(t);
  1675. }
  1676. }
  1677. };
  1678. /**
  1679. * Starts a new task.
  1680. * @method start
  1681. * @param {Object} task <p>A config object that supports the following properties:<ul>
  1682. * <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
  1683. * function will be called at each interval and passed the <code>args</code> argument if specified, and the
  1684. * current invocation count if not.</p>
  1685. * <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
  1686. * <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
  1687. * <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
  1688. * should be invoked.</div></li>
  1689. * <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
  1690. * specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
  1691. * <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
  1692. * <code>run</code> function. Defaults to the task config object.</div></li>
  1693. * <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
  1694. * the task before stopping automatically (defaults to indefinite).</div></li>
  1695. * <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
  1696. * stopping automatically (defaults to indefinite).</div></li>
  1697. * </ul></p>
  1698. * <p>Before each invocation, Ext injects the property <code>taskRunCount</code> into the task object so
  1699. * that calculations based on the repeat count can be performed.</p>
  1700. * @return {Object} The task
  1701. */
  1702. this.start = function(task){
  1703. tasks.push(task);
  1704. task.taskStartTime = new Date().getTime();
  1705. task.taskRunTime = 0;
  1706. task.taskRunCount = 0;
  1707. startThread();
  1708. return task;
  1709. };
  1710. /**
  1711. * Stops an existing running task.
  1712. * @method stop
  1713. * @param {Object} task The task to stop
  1714. * @return {Object} The task
  1715. */
  1716. this.stop = function(task){
  1717. removeTask(task);
  1718. return task;
  1719. };
  1720. /**
  1721. * Stops all tasks that are currently running.
  1722. * @method stopAll
  1723. */
  1724. this.stopAll = function(){
  1725. stopThread();
  1726. for(var i = 0, len = tasks.length; i < len; i++){
  1727. if(tasks[i].onStop){
  1728. tasks[i].onStop();
  1729. }
  1730. }
  1731. tasks = [];
  1732. removeQueue = [];
  1733. };
  1734. };
  1735. /**
  1736. * @class Ext.TaskMgr
  1737. * @extends Ext.util.TaskRunner
  1738. * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop arbitrary tasks. See
  1739. * {@link Ext.util.TaskRunner} for supported methods and task config properties.
  1740. * <pre><code>
  1741. // Start a simple clock task that updates a div once per second
  1742. var task = {
  1743. run: function(){
  1744. Ext.fly('clock').update(new Date().format('g:i:s A'));
  1745. },
  1746. interval: 1000 //1 second
  1747. }
  1748. Ext.TaskMgr.start(task);
  1749. </code></pre>
  1750. * <p>See the {@link #start} method for details about how to configure a task object.</p>
  1751. * @singleton
  1752. */
  1753. Ext.TaskMgr = new Ext.util.TaskRunner();(function(){
  1754. var libFlyweight;
  1755. function fly(el) {
  1756. if (!libFlyweight) {
  1757. libFlyweight = new Ext.Element.Flyweight();
  1758. }
  1759. libFlyweight.dom = el;
  1760. return libFlyweight;
  1761. }
  1762. (function(){
  1763. var doc = document,
  1764. isCSS1 = doc.compatMode == "CSS1Compat",
  1765. MAX = Math.max,
  1766. ROUND = Math.round,
  1767. PARSEINT = parseInt;
  1768. Ext.lib.Dom = {
  1769. isAncestor : function(p, c) {
  1770. var ret = false;
  1771. p = Ext.getDom(p);
  1772. c = Ext.getDom(c);
  1773. if (p && c) {
  1774. if (p.contains) {
  1775. return p.contains(c);
  1776. } else if (p.compareDocumentPosition) {
  1777. return !!(p.compareDocumentPosition(c) & 16);
  1778. } else {
  1779. while (c = c.parentNode) {
  1780. ret = c == p || ret;
  1781. }
  1782. }
  1783. }
  1784. return ret;
  1785. },
  1786. getViewWidth : function(full) {
  1787. return full ? this.getDocumentWidth() : this.getViewportWidth();
  1788. },
  1789. getViewHeight : function(full) {
  1790. return full ? this.getDocumentHeight() : this.getViewportHeight();
  1791. },
  1792. getDocumentHeight: function() {
  1793. return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());
  1794. },
  1795. getDocumentWidth: function() {
  1796. return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());
  1797. },
  1798. getViewportHeight: function(){
  1799. return Ext.isIE ?
  1800. (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
  1801. self.innerHeight;
  1802. },
  1803. getViewportWidth : function() {
  1804. return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :
  1805. Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
  1806. },
  1807. getY : function(el) {
  1808. return this.getXY(el)[1];
  1809. },
  1810. getX : function(el) {
  1811. return this.getXY(el)[0];
  1812. },
  1813. getXY : function(el) {
  1814. var p,
  1815. pe,
  1816. b,
  1817. bt,
  1818. bl,
  1819. dbd,
  1820. x = 0,
  1821. y = 0,
  1822. scroll,
  1823. hasAbsolute,
  1824. bd = (doc.body || doc.documentElement),
  1825. ret = [0,0];
  1826. el = Ext.getDom(el);
  1827. if(el != bd){
  1828. if (el.getBoundingClientRect) {
  1829. b = el.getBoundingClientRect();
  1830. scroll = fly(document).getScroll();
  1831. ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)];
  1832. } else {
  1833. p = el;
  1834. hasAbsolute = fly(el).isStyle("position", "absolute");
  1835. while (p) {
  1836. pe = fly(p);
  1837. x += p.offsetLeft;
  1838. y += p.offsetTop;
  1839. hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
  1840. if (Ext.isGecko) {
  1841. y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;
  1842. x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;
  1843. if (p != el && !pe.isStyle('overflow','visible')) {
  1844. x += bl;
  1845. y += bt;
  1846. }
  1847. }
  1848. p = p.offsetParent;
  1849. }
  1850. if (Ext.isSafari && hasAbsolute) {
  1851. x -= bd.offsetLeft;
  1852. y -= bd.offsetTop;
  1853. }
  1854. if (Ext.isGecko && !hasAbsolute) {
  1855. dbd = fly(bd);
  1856. x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;
  1857. y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;
  1858. }
  1859. p = el.parentNode;
  1860. while (p && p != bd) {
  1861. if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
  1862. x -= p.scrollLeft;
  1863. y -= p.scrollTop;
  1864. }
  1865. p = p.parentNode;
  1866. }
  1867. ret = [x,y];
  1868. }
  1869. }
  1870. return ret
  1871. },
  1872. setXY : function(el, xy) {
  1873. (el = Ext.fly(el, '_setXY')).position();
  1874. var pts = el.translatePoints(xy),
  1875. style = el.dom.style,
  1876. pos;
  1877. for (pos in pts) {
  1878. if(!isNaN(pts[pos])) style[pos] = pts[pos] + "px"
  1879. }
  1880. },
  1881. setX : function(el, x) {
  1882. this.setXY(el, [x, false]);
  1883. },
  1884. setY : function(el, y) {
  1885. this.setXY(el, [false, y]);
  1886. }
  1887. };
  1888. })();Ext.lib.Dom.getRegion = function(el) {
  1889. return Ext.lib.Region.getRegion(el);
  1890. };Ext.lib.Event = function() {
  1891. var loadComplete = false,
  1892. unloadListeners = {},
  1893. retryCount = 0,
  1894. onAvailStack = [],
  1895. _interval,
  1896. locked = false,
  1897. win = window,
  1898. doc = document,
  1899. // constants
  1900. POLL_RETRYS = 200,
  1901. POLL_INTERVAL = 20,
  1902. EL = 0,
  1903. TYPE = 0,
  1904. FN = 1,
  1905. WFN = 2,
  1906. OBJ = 2,
  1907. ADJ_SCOPE = 3,
  1908. SCROLLLEFT = 'scrollLeft',
  1909. SCROLLTOP = 'scrollTop',
  1910. UNLOAD = 'unload',
  1911. MOUSEOVER = 'mouseover',
  1912. MOUSEOUT = 'mouseout',
  1913. // private
  1914. doAdd = function() {
  1915. var ret;
  1916. if (win.addEventListener) {
  1917. ret = function(el, eventName, fn, capture) {
  1918. if (eventName == 'mouseenter') {
  1919. fn = fn.createInterceptor(checkRelatedTarget);
  1920. el.addEventListener(MOUSEOVER, fn, (capture));
  1921. } else if (eventName == 'mouseleave') {
  1922. fn = fn.createInterceptor(checkRelatedTarget);
  1923. el.addEventListener(MOUSEOUT, fn, (capture));
  1924. } else {
  1925. el.addEventListener(eventName, fn, (capture));
  1926. }
  1927. return fn;
  1928. };
  1929. } else if (win.attachEvent) {
  1930. ret = function(el, eventName, fn, capture) {
  1931. el.attachEvent("on" + eventName, fn);
  1932. return fn;
  1933. };
  1934. } else {
  1935. ret = function(){};
  1936. }
  1937. return ret;
  1938. }(),
  1939. // private
  1940. doRemove = function(){
  1941. var ret;
  1942. if (win.removeEventListener) {
  1943. ret = function (el, eventName, fn, capture) {
  1944. if (eventName == 'mouseenter') {
  1945. eventName = MOUSEOVER;
  1946. } else if (eventName == 'mouseleave') {
  1947. eventName = MOUSEOUT;
  1948. }
  1949. el.removeEventListener(eventName, fn, (capture));
  1950. };
  1951. } else if (win.detachEvent) {
  1952. ret = function (el, eventName, fn) {
  1953. el.detachEvent("on" + eventName, fn);
  1954. };
  1955. } else {
  1956. ret = function(){};
  1957. }
  1958. return ret;
  1959. }();
  1960. function checkRelatedTarget(e) {
  1961. return !elContains(e.currentTarget, pub.getRelatedTarget(e));
  1962. }
  1963. function elContains(parent, child) {
  1964. if(parent && parent.firstChild){
  1965. while(child) {
  1966. if(child === parent) {
  1967. return true;
  1968. }
  1969. child = child.parentNode;
  1970. if(child && (child.nodeType != 1)) {
  1971. child = null;
  1972. }
  1973. }
  1974. }
  1975. return false;
  1976. }
  1977. // private
  1978. function _tryPreloadAttach() {
  1979. var ret = false,
  1980. notAvail = [],
  1981. element, i, v, override,
  1982. tryAgain = !loadComplete || (retryCount > 0);
  1983. if(!locked){
  1984. locked = true;
  1985. for(i = 0; i < onAvailStack.length; ++i){
  1986. v = onAvailStack[i];
  1987. if(v && (element = doc.getElementById(v.id))){
  1988. if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
  1989. override = v.override;
  1990. element = override ? (override === true ? v.obj : override) : element;
  1991. v.fn.call(element, v.obj);
  1992. onAvailStack.remove(v);
  1993. --i;
  1994. }else{
  1995. notAvail.push(v);
  1996. }
  1997. }
  1998. }
  1999. retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
  2000. if (tryAgain) {
  2001. startInterval();
  2002. } else {
  2003. clearInterval(_interval);
  2004. _interval = null;
  2005. }
  2006. ret = !(locked = false);
  2007. }
  2008. return ret;
  2009. }
  2010. // private
  2011. function startInterval() {
  2012. if(!_interval){
  2013. var callback = function() {
  2014. _tryPreloadAttach();
  2015. };
  2016. _interval = setInterval(callback, POLL_INTERVAL);
  2017. }
  2018. }
  2019. // private
  2020. function getScroll() {
  2021. var dd = doc.documentElement,
  2022. db = doc.body;
  2023. if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
  2024. return [dd[SCROLLLEFT], dd[SCROLLTOP]];
  2025. }else if(db){
  2026. return [db[SCROLLLEFT], db[SCROLLTOP]];
  2027. }else{
  2028. return [0, 0];
  2029. }
  2030. }
  2031. // private
  2032. function getPageCoord (ev, xy) {
  2033. ev = ev.browserEvent || ev;
  2034. var coord = ev['page' + xy];
  2035. if (!coord && coord !== 0) {
  2036. coord = ev['client' + xy] || 0;
  2037. if (Ext.isIE) {
  2038. coord += getScroll()[xy == "X" ? 0 : 1];
  2039. }
  2040. }
  2041. return coord;
  2042. }
  2043. var pub = {
  2044. extAdapter: true,
  2045. onAvailable : function(p_id, p_fn, p_obj, p_override) {
  2046. onAvailStack.push({
  2047. id: p_id,
  2048. fn: p_fn,
  2049. obj: p_obj,
  2050. override: p_override,
  2051. checkReady: false });
  2052. retryCount = POLL_RETRYS;
  2053. startInterval();
  2054. },
  2055. // This function should ALWAYS be called from Ext.EventManager
  2056. addListener: function(el, eventName, fn) {
  2057. el = Ext.getDom(el);
  2058. if (el && fn) {
  2059. if (eventName == UNLOAD) {
  2060. if (unloadListeners[el.id] === undefined) {
  2061. unloadListeners[el.id] = [];
  2062. }
  2063. unloadListeners[el.id].push([eventName, fn]);
  2064. return fn;
  2065. }
  2066. return doAdd(el, eventName, fn, false);
  2067. }
  2068. return false;
  2069. },
  2070. // This function should ALWAYS be called from Ext.EventManager
  2071. removeListener: function(el, eventName, fn) {
  2072. el = Ext.getDom(el);
  2073. var i, len, li, lis;
  2074. if (el && fn) {
  2075. if(eventName == UNLOAD){
  2076. if((lis = unloadListeners[el.id]) !== undefined){
  2077. for(i = 0, len = lis.length; i < len; i++){
  2078. if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
  2079. unloadListeners[el.id].splice(i, 1);
  2080. }
  2081. }
  2082. }
  2083. return;
  2084. }
  2085. doRemove(el, eventName, fn, false);
  2086. }
  2087. },
  2088. getTarget : function(ev) {
  2089. ev = ev.browserEvent || ev;
  2090. return this.resolveTextNode(ev.target || ev.srcElement);
  2091. },
  2092. resolveTextNode : Ext.isGecko ? function(node){
  2093. if(!node){
  2094. return;
  2095. }
  2096. // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
  2097. var s = HTMLElement.prototype.toString.call(node);
  2098. if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
  2099. return;
  2100. }
  2101. return node.nodeType == 3 ? node.parentNode : node;
  2102. } : function(node){
  2103. return node && node.nodeType == 3 ? node.parentNode : node;
  2104. },
  2105. getRelatedTarget : function(ev) {
  2106. ev = ev.browserEvent || ev;
  2107. return this.resolveTextNode(ev.relatedTarget ||
  2108. (ev.type == MOUSEOUT ? ev.toElement :
  2109. ev.type == MOUSEOVER ? ev.fromElement : null));
  2110. },
  2111. getPageX : function(ev) {
  2112. return getPageCoord(ev, "X");
  2113. },
  2114. getPageY : function(ev) {
  2115. return getPageCoord(ev, "Y");
  2116. },
  2117. getXY : function(ev) {
  2118. return [this.getPageX(ev), this.getPageY(ev)];
  2119. },
  2120. stopEvent : function(ev) {
  2121. this.stopPropagation(ev);
  2122. this.preventDefault(ev);
  2123. },
  2124. stopPropagation : function(ev) {
  2125. ev = ev.browserEvent || ev;
  2126. if (ev.stopPropagation) {
  2127. ev.stopPropagation();
  2128. } else {
  2129. ev.cancelBubble = true;
  2130. }
  2131. },
  2132. preventDefault : function(ev) {
  2133. ev = ev.browserEvent || ev;
  2134. if (ev.preventDefault) {
  2135. ev.preventDefault();
  2136. } else {
  2137. ev.returnValue = false;
  2138. }
  2139. },
  2140. getEvent : function(e) {
  2141. e = e || win.event;
  2142. if (!e) {
  2143. var c = this.getEvent.caller;
  2144. while (c) {
  2145. e = c.arguments[0];
  2146. if (e && Event == e.constructor) {
  2147. break;
  2148. }
  2149. c = c.caller;
  2150. }
  2151. }
  2152. return e;
  2153. },
  2154. getCharCode : function(ev) {
  2155. ev = ev.browserEvent || ev;
  2156. return ev.charCode || ev.keyCode || 0;
  2157. },
  2158. //clearCache: function() {},
  2159. // deprecated, call from EventManager
  2160. getListeners : function(el, eventName) {
  2161. Ext.EventManager.getListeners(el, eventName);
  2162. },
  2163. // deprecated, call from EventManager
  2164. purgeElement : function(el, recurse, eventName) {
  2165. Ext.EventManager.purgeElement(el, recurse, eventName);
  2166. },
  2167. _load : function(e) {
  2168. loadComplete = true;
  2169. var EU = Ext.lib.Event;
  2170. if (Ext.isIE && e !== true) {
  2171. // IE8 complains that _load is null or not an object
  2172. // so lets remove self via arguments.callee
  2173. doRemove(win, "load", arguments.callee);
  2174. }
  2175. },
  2176. _unload : function(e) {
  2177. var EU = Ext.lib.Event,
  2178. i, j, l, v, ul, id, len, index, scope;
  2179. for (id in unloadListeners) {
  2180. ul = unloadListeners[id];
  2181. for (i = 0, len = ul.length; i < len; i++) {
  2182. v = ul[i];
  2183. if (v) {
  2184. try{
  2185. scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
  2186. v[FN].call(scope, EU.getEvent(e), v[OBJ]);
  2187. }catch(ex){}
  2188. }
  2189. }
  2190. };
  2191. Ext.EventManager._unload();
  2192. doRemove(win, UNLOAD, EU._unload);
  2193. }
  2194. };
  2195. // Initialize stuff.
  2196. pub.on = pub.addListener;
  2197. pub.un = pub.removeListener;
  2198. if (doc && doc.body) {
  2199. pub._load(true);
  2200. } else {
  2201. doAdd(win, "load", pub._load);
  2202. }
  2203. doAdd(win, UNLOAD, pub._unload);
  2204. _tryPreloadAttach();
  2205. return pub;
  2206. }();
  2207. /*
  2208. * Portions of this file are based on pieces of Yahoo User Interface Library
  2209. * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
  2210. * YUI licensed under the BSD License:
  2211. * http://developer.yahoo.net/yui/license.txt
  2212. */
  2213. Ext.lib.Ajax = function() {
  2214. var activeX = ['MSXML2.XMLHTTP.3.0',
  2215. 'MSXML2.XMLHTTP',
  2216. 'Microsoft.XMLHTTP'],
  2217. CONTENTTYPE = 'Content-Type';
  2218. // private
  2219. function setHeader(o) {
  2220. var conn = o.conn,
  2221. prop;
  2222. function setTheHeaders(conn, headers){
  2223. for (prop in headers) {
  2224. if (headers.hasOwnProperty(prop)) {
  2225. conn.setRequestHeader(prop, headers[prop]);
  2226. }
  2227. }
  2228. }
  2229. if (pub.defaultHeaders) {
  2230. setTheHeaders(conn, pub.defaultHeaders);
  2231. }
  2232. if (pub.headers) {
  2233. setTheHeaders(conn, pub.headers);
  2234. delete pub.headers;
  2235. }
  2236. }
  2237. // private
  2238. function createExceptionObject(tId, callbackArg, isAbort, isTimeout) {
  2239. return {
  2240. tId : tId,
  2241. status : isAbort ? -1 : 0,
  2242. statusText : isAbort ? 'transaction aborted' : 'communication failure',
  2243. isAbort: isAbort,
  2244. isTimeout: isTimeout,
  2245. argument : callbackArg
  2246. };
  2247. }
  2248. // private
  2249. function initHeader(label, value) {
  2250. (pub.headers = pub.headers || {})[label] = value;
  2251. }
  2252. // private
  2253. function createResponseObject(o, callbackArg) {
  2254. var headerObj = {},
  2255. headerStr,
  2256. conn = o.conn,
  2257. t,
  2258. s,
  2259. // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223
  2260. isBrokenStatus = conn.status == 1223;
  2261. try {
  2262. headerStr = o.conn.getAllResponseHeaders();
  2263. Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
  2264. t = v.indexOf(':');
  2265. if(t >= 0){
  2266. s = v.substr(0, t).toLowerCase();
  2267. if(v.charAt(t + 1) == ' '){
  2268. ++t;
  2269. }
  2270. headerObj[s] = v.substr(t + 1);
  2271. }
  2272. });
  2273. } catch(e) {}
  2274. return {
  2275. tId : o.tId,
  2276. // Normalize the status and statusText when IE returns 1223, see the above link.
  2277. status : isBrokenStatus ? 204 : conn.status,
  2278. statusText : isBrokenStatus ? 'No Content' : conn.statusText,
  2279. getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
  2280. getAllResponseHeaders : function(){return headerStr},
  2281. responseText : conn.responseText,
  2282. responseXML : conn.responseXML,
  2283. argument : callbackArg
  2284. };
  2285. }
  2286. // private
  2287. function releaseObject(o) {
  2288. if (o.tId) {
  2289. pub.conn[o.tId] = null;
  2290. }
  2291. o.conn = null;
  2292. o = null;
  2293. }
  2294. // private
  2295. function handleTransactionResponse(o, callback, isAbort, isTimeout) {
  2296. if (!callback) {
  2297. releaseObject(o);
  2298. return;
  2299. }
  2300. var httpStatus, responseObject;
  2301. try {
  2302. if (o.conn.status !== undefined && o.conn.status != 0) {
  2303. httpStatus = o.conn.status;
  2304. }
  2305. else {
  2306. httpStatus = 13030;
  2307. }
  2308. }
  2309. catch(e) {
  2310. httpStatus = 13030;
  2311. }
  2312. if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) {
  2313. responseObject = createResponseObject(o, callback.argument);
  2314. if (callback.success) {
  2315. if (!callback.scope) {
  2316. callback.success(responseObject);
  2317. }
  2318. else {
  2319. callback.success.apply(callback.scope, [responseObject]);
  2320. }
  2321. }
  2322. }
  2323. else {
  2324. switch (httpStatus) {
  2325. case 12002:
  2326. case 12029:
  2327. case 12030:
  2328. case 12031:
  2329. case 12152:
  2330. case 13030:
  2331. responseObject = createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false), isTimeout);
  2332. if (callback.failure) {
  2333. if (!callback.scope) {
  2334. callback.failure(responseObject);
  2335. }
  2336. else {
  2337. callback.failure.apply(callback.scope, [responseObject]);
  2338. }
  2339. }
  2340. break;
  2341. default:
  2342. responseObject = createResponseObject(o, callback.argument);
  2343. if (callback.failure) {
  2344. if (!callback.scope) {
  2345. callback.failure(responseObject);
  2346. }
  2347. else {
  2348. callback.failure.apply(callback.scope, [responseObject]);
  2349. }
  2350. }
  2351. }
  2352. }
  2353. releaseObject(o);
  2354. responseObject = null;
  2355. }
  2356. // private
  2357. function handleReadyState(o, callback){
  2358. callback = callback || {};
  2359. var conn = o.conn,
  2360. tId = o.tId,
  2361. poll = pub.poll,
  2362. cbTimeout = callback.timeout || null;
  2363. if (cbTimeout) {
  2364. pub.conn[tId] = conn;
  2365. pub.timeout[tId] = setTimeout(function() {
  2366. pub.abort(o, callback, true);
  2367. }, cbTimeout);
  2368. }
  2369. poll[tId] = setInterval(
  2370. function() {
  2371. if (conn && conn.readyState == 4) {
  2372. clearInterval(poll[tId]);
  2373. poll[tId] = null;
  2374. if (cbTimeout) {
  2375. clearTimeout(pub.timeout[tId]);
  2376. pub.timeout[tId] = null;
  2377. }
  2378. handleTransactionResponse(o, callback);
  2379. }
  2380. },
  2381. pub.pollInterval);
  2382. }
  2383. // private
  2384. function asyncRequest(method, uri, callback, postData) {
  2385. var o = getConnectionObject() || null;
  2386. if (o) {
  2387. o.conn.open(method, uri, true);
  2388. if (pub.useDefaultXhrHeader) {
  2389. initHeader('X-Requested-With', pub.defaultXhrHeader);
  2390. }
  2391. if(postData && pub.useDefaultHeader && (!pub.headers || !pub.headers[CONTENTTYPE])){
  2392. initHeader(CONTENTTYPE, pub.defaultPostHeader);
  2393. }
  2394. if (pub.defaultHeaders || pub.headers) {
  2395. setHeader(o);
  2396. }
  2397. handleReadyState(o, callback);
  2398. o.conn.send(postData || null);
  2399. }
  2400. return o;
  2401. }
  2402. // private
  2403. function getConnectionObject() {
  2404. var o;
  2405. try {
  2406. if (o = createXhrObject(pub.transactionId)) {
  2407. pub.transactionId++;
  2408. }
  2409. } catch(e) {
  2410. } finally {
  2411. return o;
  2412. }
  2413. }
  2414. // private
  2415. function createXhrObject(transactionId) {
  2416. var http;
  2417. try {
  2418. http = new XMLHttpRequest();
  2419. } catch(e) {
  2420. for (var i = 0; i < activeX.length; ++i) {
  2421. try {
  2422. http = new ActiveXObject(activeX[i]);
  2423. break;
  2424. } catch(e) {}
  2425. }
  2426. } finally {
  2427. return {conn : http, tId : transactionId};
  2428. }
  2429. }
  2430. var pub = {
  2431. request : function(method, uri, cb, data, options) {
  2432. if(options){
  2433. var me = this,
  2434. xmlData = options.xmlData,
  2435. jsonData = options.jsonData,
  2436. hs;
  2437. Ext.applyIf(me, options);
  2438. if(xmlData || jsonData){
  2439. hs = me.headers;
  2440. if(!hs || !hs[CONTENTTYPE]){
  2441. initHeader(CONTENTTYPE, xmlData ? 'text/xml' : 'application/json');
  2442. }
  2443. data = xmlData || (!Ext.isPrimitive(jsonData) ? Ext.encode(jsonData) : jsonData);
  2444. }
  2445. }
  2446. return asyncRequest(method || options.method || "POST", uri, cb, data);
  2447. },
  2448. serializeForm : function(form) {
  2449. var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
  2450. hasSubmit = false,
  2451. encoder = encodeURIComponent,
  2452. element,
  2453. options,
  2454. name,
  2455. val,
  2456. data = '',
  2457. type;
  2458. Ext.each(fElements, function(element) {
  2459. name = element.name;
  2460. type = element.type;
  2461. if (!element.disabled && name){
  2462. if(/select-(one|multiple)/i.test(type)) {
  2463. Ext.each(element.options, function(opt) {
  2464. if (opt.selected) {
  2465. data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
  2466. }
  2467. });
  2468. } else if(!/file|undefined|reset|button/i.test(type)) {
  2469. if(!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)){
  2470. data += encoder(name) + '=' + encoder(element.value) + '&';
  2471. hasSubmit = /submit/i.test(type);
  2472. }
  2473. }
  2474. }
  2475. });
  2476. return data.substr(0, data.length - 1);
  2477. },
  2478. useDefaultHeader : true,
  2479. defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',
  2480. useDefaultXhrHeader : true,
  2481. defaultXhrHeader : 'XMLHttpRequest',
  2482. poll : {},
  2483. timeout : {},
  2484. conn: {},
  2485. pollInterval : 50,
  2486. transactionId : 0,
  2487. // This is never called - Is it worth exposing this?
  2488. // setProgId : function(id) {
  2489. // activeX.unshift(id);
  2490. // },
  2491. // This is never called - Is it worth exposing this?
  2492. // setDefaultPostHeader : function(b) {
  2493. // this.useDefaultHeader = b;
  2494. // },
  2495. // This is never called - Is it worth exposing this?
  2496. // setDefaultXhrHeader : function(b) {
  2497. // this.useDefaultXhrHeader = b;
  2498. // },
  2499. // This is never called - Is it worth exposing this?
  2500. // setPollingInterval : function(i) {
  2501. // if (typeof i == 'number' && isFinite(i)) {
  2502. // this.pollInterval = i;
  2503. // }
  2504. // },
  2505. // This is never called - Is it worth exposing this?
  2506. // resetDefaultHeaders : function() {
  2507. // this.defaultHeaders = null;
  2508. // },
  2509. abort : function(o, callback, isTimeout) {
  2510. var me = this,
  2511. tId = o.tId,
  2512. isAbort = false;
  2513. if (me.isCallInProgress(o)) {
  2514. o.conn.abort();
  2515. clearInterval(me.poll[tId]);
  2516. me.poll[tId] = null;
  2517. clearTimeout(pub.timeout[tId]);
  2518. me.timeout[tId] = null;
  2519. handleTransactionResponse(o, callback, (isAbort = true), isTimeout);
  2520. }
  2521. return isAbort;
  2522. },
  2523. isCallInProgress : function(o) {
  2524. // if there is a connection and readyState is not 0 or 4
  2525. return o.conn && !{0:true,4:true}[o.conn.readyState];
  2526. }
  2527. };
  2528. return pub;
  2529. }(); Ext.lib.Region = function(t, r, b, l) {
  2530. var me = this;
  2531. me.top = t;
  2532. me[1] = t;
  2533. me.right = r;
  2534. me.bottom = b;
  2535. me.left = l;
  2536. me[0] = l;
  2537. };
  2538. Ext.lib.Region.prototype = {
  2539. contains : function(region) {
  2540. var me = this;
  2541. return ( region.left >= me.left &&
  2542. region.right <= me.right &&
  2543. region.top >= me.top &&
  2544. region.bottom <= me.bottom );
  2545. },
  2546. getArea : function() {
  2547. var me = this;
  2548. return ( (me.bottom - me.top) * (me.right - me.left) );
  2549. },
  2550. intersect : function(region) {
  2551. var me = this,
  2552. t = Math.max(me.top, region.top),
  2553. r = Math.min(me.right, region.right),
  2554. b = Math.min(me.bottom, region.bottom),
  2555. l = Math.max(me.left, region.left);
  2556. if (b >= t && r >= l) {
  2557. return new Ext.lib.Region(t, r, b, l);
  2558. }
  2559. },
  2560. union : function(region) {
  2561. var me = this,
  2562. t = Math.min(me.top, region.top),
  2563. r = Math.max(me.right, region.right),
  2564. b = Math.max(me.bottom, region.bottom),
  2565. l = Math.min(me.left, region.left);
  2566. return new Ext.lib.Region(t, r, b, l);
  2567. },
  2568. constrainTo : function(r) {
  2569. var me = this;
  2570. me.top = me.top.constrain(r.top, r.bottom);
  2571. me.bottom = me.bottom.constrain(r.top, r.bottom);
  2572. me.left = me.left.constrain(r.left, r.right);
  2573. me.right = me.right.constrain(r.left, r.right);
  2574. return me;
  2575. },
  2576. adjust : function(t, l, b, r) {
  2577. var me = this;
  2578. me.top += t;
  2579. me.left += l;
  2580. me.right += r;
  2581. me.bottom += b;
  2582. return me;
  2583. }
  2584. };
  2585. Ext.lib.Region.getRegion = function(el) {
  2586. var p = Ext.lib.Dom.getXY(el),
  2587. t = p[1],
  2588. r = p[0] + el.offsetWidth,
  2589. b = p[1] + el.offsetHeight,
  2590. l = p[0];
  2591. return new Ext.lib.Region(t, r, b, l);
  2592. }; Ext.lib.Point = function(x, y) {
  2593. if (Ext.isArray(x)) {
  2594. y = x[1];
  2595. x = x[0];
  2596. }
  2597. var me = this;
  2598. me.x = me.right = me.left = me[0] = x;
  2599. me.y = me.top = me.bottom = me[1] = y;
  2600. };
  2601. Ext.lib.Point.prototype = new Ext.lib.Region();
  2602. (function(){
  2603. var EXTLIB = Ext.lib,
  2604. noNegatives = /width|height|opacity|padding/i,
  2605. offsetAttribute = /^((width|height)|(top|left))$/,
  2606. defaultUnit = /width|height|top$|bottom$|left$|right$/i,
  2607. offsetUnit = /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,
  2608. isset = function(v){
  2609. return typeof v !== 'undefined';
  2610. },
  2611. now = function(){
  2612. return new Date();
  2613. };
  2614. EXTLIB.Anim = {
  2615. motion : function(el, args, duration, easing, cb, scope) {
  2616. return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  2617. },
  2618. run : function(el, args, duration, easing, cb, scope, type) {
  2619. type = type || Ext.lib.AnimBase;
  2620. if (typeof easing == "string") {
  2621. easing = Ext.lib.Easing[easing];
  2622. }
  2623. var anim = new type(el, args, duration, easing);
  2624. anim.animateX(function() {
  2625. if(Ext.isFunction(cb)){
  2626. cb.call(scope);
  2627. }
  2628. });
  2629. return anim;
  2630. }
  2631. };
  2632. EXTLIB.AnimBase = function(el, attributes, duration, method) {
  2633. if (el) {
  2634. this.init(el, attributes, duration, method);
  2635. }
  2636. };
  2637. EXTLIB.AnimBase.prototype = {
  2638. doMethod: function(attr, start, end) {
  2639. var me = this;
  2640. return me.method(me.curFrame, start, end - start, me.totalFrames);
  2641. },
  2642. setAttr: function(attr, val, unit) {
  2643. if (noNegatives.test(attr) && val < 0) {
  2644. val = 0;
  2645. }
  2646. Ext.fly(this.el, '_anim').setStyle(attr, val + unit);
  2647. },
  2648. getAttr: function(attr) {
  2649. var el = Ext.fly(this.el),
  2650. val = el.getStyle(attr),
  2651. a = offsetAttribute.exec(attr) || [];
  2652. if (val !== 'auto' && !offsetUnit.test(val)) {
  2653. return parseFloat(val);
  2654. }
  2655. return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0;
  2656. },
  2657. getDefaultUnit: function(attr) {
  2658. return defaultUnit.test(attr) ? 'px' : '';
  2659. },
  2660. animateX : function(callback, scope) {
  2661. var me = this,
  2662. f = function() {
  2663. me.onComplete.removeListener(f);
  2664. if (Ext.isFunction(callback)) {
  2665. callback.call(scope || me, me);
  2666. }
  2667. };
  2668. me.onComplete.addListener(f, me);
  2669. me.animate();
  2670. },
  2671. setRunAttr: function(attr) {
  2672. var me = this,
  2673. a = this.attributes[attr],
  2674. to = a.to,
  2675. by = a.by,
  2676. from = a.from,
  2677. unit = a.unit,
  2678. ra = (this.runAttrs[attr] = {}),
  2679. end;
  2680. if (!isset(to) && !isset(by)){
  2681. return false;
  2682. }
  2683. var start = isset(from) ? from : me.getAttr(attr);
  2684. if (isset(to)) {
  2685. end = to;
  2686. }else if(isset(by)) {
  2687. if (Ext.isArray(start)){
  2688. end = [];
  2689. for(var i=0,len=start.length; i<len; i++) {
  2690. end[i] = start[i] + by[i];
  2691. }
  2692. }else{
  2693. end = start + by;
  2694. }
  2695. }
  2696. Ext.apply(ra, {
  2697. start: start,
  2698. end: end,
  2699. unit: isset(unit) ? unit : me.getDefaultUnit(attr)
  2700. });
  2701. },
  2702. init: function(el, attributes, duration, method) {
  2703. var me = this,
  2704. actualFrames = 0,
  2705. mgr = EXTLIB.AnimMgr;
  2706. Ext.apply(me, {
  2707. isAnimated: false,
  2708. startTime: null,
  2709. el: Ext.getDom(el),
  2710. attributes: attributes || {},
  2711. duration: duration || 1,
  2712. method: method || EXTLIB.Easing.easeNone,
  2713. useSec: true,
  2714. curFrame: 0,
  2715. totalFrames: mgr.fps,
  2716. runAttrs: {},
  2717. animate: function(){
  2718. var me = this,
  2719. d = me.duration;
  2720. if(me.isAnimated){
  2721. return false;
  2722. }
  2723. me.curFrame = 0;
  2724. me.totalFrames = me.useSec ? Math.ceil(mgr.fps * d) : d;
  2725. mgr.registerElement(me);
  2726. },
  2727. stop: function(finish){
  2728. var me = this;
  2729. if(finish){
  2730. me.curFrame = me.totalFrames;
  2731. me._onTween.fire();
  2732. }
  2733. mgr.stop(me);
  2734. }
  2735. });
  2736. var onStart = function(){
  2737. var me = this,
  2738. attr;
  2739. me.onStart.fire();
  2740. me.runAttrs = {};
  2741. for(attr in this.attributes){
  2742. this.setRunAttr(attr);
  2743. }
  2744. me.isAnimated = true;
  2745. me.startTime = now();
  2746. actualFrames = 0;
  2747. };
  2748. var onTween = function(){
  2749. var me = this;
  2750. me.onTween.fire({
  2751. duration: now() - me.startTime,
  2752. curFrame: me.curFrame
  2753. });
  2754. var ra = me.runAttrs;
  2755. for (var attr in ra) {
  2756. this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
  2757. }
  2758. ++actualFrames;
  2759. };
  2760. var onComplete = function() {
  2761. var me = this,
  2762. actual = (now() - me.startTime) / 1000,
  2763. data = {
  2764. duration: actual,
  2765. frames: actualFrames,
  2766. fps: actualFrames / actual
  2767. };
  2768. me.isAnimated = false;
  2769. actualFrames = 0;
  2770. me.onComplete.fire(data);
  2771. };
  2772. me.onStart = new Ext.util.Event(me);
  2773. me.onTween = new Ext.util.Event(me);
  2774. me.onComplete = new Ext.util.Event(me);
  2775. (me._onStart = new Ext.util.Event(me)).addListener(onStart);
  2776. (me._onTween = new Ext.util.Event(me)).addListener(onTween);
  2777. (me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
  2778. }
  2779. };
  2780. Ext.lib.AnimMgr = new function() {
  2781. var me = this,
  2782. thread = null,
  2783. queue = [],
  2784. tweenCount = 0;
  2785. Ext.apply(me, {
  2786. fps: 1000,
  2787. delay: 1,
  2788. registerElement: function(tween){
  2789. queue.push(tween);
  2790. ++tweenCount;
  2791. tween._onStart.fire();
  2792. me.start();
  2793. },
  2794. unRegister: function(tween, index){
  2795. tween._onComplete.fire();
  2796. index = index || getIndex(tween);
  2797. if (index != -1) {
  2798. queue.splice(index, 1);
  2799. }
  2800. if (--tweenCount <= 0) {
  2801. me.stop();
  2802. }
  2803. },
  2804. start: function(){
  2805. if(thread === null){
  2806. thread = setInterval(me.run, me.delay);
  2807. }
  2808. },
  2809. stop: function(tween){
  2810. if(!tween){
  2811. clearInterval(thread);
  2812. for(var i = 0, len = queue.length; i < len; ++i){
  2813. if(queue[0].isAnimated){
  2814. me.unRegister(queue[0], 0);
  2815. }
  2816. }
  2817. queue = [];
  2818. thread = null;
  2819. tweenCount = 0;
  2820. }else{
  2821. me.unRegister(tween);
  2822. }
  2823. },
  2824. run: function(){
  2825. var tf, i, len, tween;
  2826. for(i = 0, len = queue.length; i<len; i++) {
  2827. tween = queue[i];
  2828. if(tween && tween.isAnimated){
  2829. tf = tween.totalFrames;
  2830. if(tween.curFrame < tf || tf === null){
  2831. ++tween.curFrame;
  2832. if(tween.useSec){
  2833. correctFrame(tween);
  2834. }
  2835. tween._onTween.fire();
  2836. }else{
  2837. me.stop(tween);
  2838. }
  2839. }
  2840. }
  2841. }
  2842. });
  2843. var getIndex = function(anim) {
  2844. var i, len;
  2845. for(i = 0, len = queue.length; i<len; i++) {
  2846. if(queue[i] === anim) {
  2847. return i;
  2848. }
  2849. }
  2850. return -1;
  2851. };
  2852. var correctFrame = function(tween) {
  2853. var frames = tween.totalFrames,
  2854. frame = tween.curFrame,
  2855. duration = tween.duration,
  2856. expected = (frame * duration * 1000 / frames),
  2857. elapsed = (now() - tween.startTime),
  2858. tweak = 0;
  2859. if(elapsed < duration * 1000){
  2860. tweak = Math.round((elapsed / expected - 1) * frame);
  2861. }else{
  2862. tweak = frames - (frame + 1);
  2863. }
  2864. if(tweak > 0 && isFinite(tweak)){
  2865. if(tween.curFrame + tweak >= frames){
  2866. tweak = frames - (frame + 1);
  2867. }
  2868. tween.curFrame += tweak;
  2869. }
  2870. };
  2871. };
  2872. EXTLIB.Bezier = new function() {
  2873. this.getPosition = function(points, t) {
  2874. var n = points.length,
  2875. tmp = [],
  2876. c = 1 - t,
  2877. i,
  2878. j;
  2879. for (i = 0; i < n; ++i) {
  2880. tmp[i] = [points[i][0], points[i][1]];
  2881. }
  2882. for (j = 1; j < n; ++j) {
  2883. for (i = 0; i < n - j; ++i) {
  2884. tmp[i][0] = c * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
  2885. tmp[i][1] = c * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
  2886. }
  2887. }
  2888. return [ tmp[0][0], tmp[0][1] ];
  2889. };
  2890. };
  2891. EXTLIB.Easing = {
  2892. easeNone: function (t, b, c, d) {
  2893. return c * t / d + b;
  2894. },
  2895. easeIn: function (t, b, c, d) {
  2896. return c * (t /= d) * t + b;
  2897. },
  2898. easeOut: function (t, b, c, d) {
  2899. return -c * (t /= d) * (t - 2) + b;
  2900. }
  2901. };
  2902. (function() {
  2903. EXTLIB.Motion = function(el, attributes, duration, method) {
  2904. if (el) {
  2905. EXTLIB.Motion.superclass.constructor.call(this, el, attributes, duration, method);
  2906. }
  2907. };
  2908. Ext.extend(EXTLIB.Motion, Ext.lib.AnimBase);
  2909. var superclass = EXTLIB.Motion.superclass,
  2910. proto = EXTLIB.Motion.prototype,
  2911. pointsRe = /^points$/i;
  2912. Ext.apply(EXTLIB.Motion.prototype, {
  2913. setAttr: function(attr, val, unit){
  2914. var me = this,
  2915. setAttr = superclass.setAttr;
  2916. if (pointsRe.test(attr)) {
  2917. unit = unit || 'px';
  2918. setAttr.call(me, 'left', val[0], unit);
  2919. setAttr.call(me, 'top', val[1], unit);
  2920. } else {
  2921. setAttr.call(me, attr, val, unit);
  2922. }
  2923. },
  2924. getAttr: function(attr){
  2925. var me = this,
  2926. getAttr = superclass.getAttr;
  2927. return pointsRe.test(attr) ? [getAttr.call(me, 'left'), getAttr.call(me, 'top')] : getAttr.call(me, attr);
  2928. },
  2929. doMethod: function(attr, start, end){
  2930. var me = this;
  2931. return pointsRe.test(attr)
  2932. ? EXTLIB.Bezier.getPosition(me.runAttrs[attr], me.method(me.curFrame, 0, 100, me.totalFrames) / 100)
  2933. : superclass.doMethod.call(me, attr, start, end);
  2934. },
  2935. setRunAttr: function(attr){
  2936. if(pointsRe.test(attr)){
  2937. var me = this,
  2938. el = this.el,
  2939. points = this.attributes.points,
  2940. control = points.control || [],
  2941. from = points.from,
  2942. to = points.to,
  2943. by = points.by,
  2944. DOM = EXTLIB.Dom,
  2945. start,
  2946. i,
  2947. end,
  2948. len,
  2949. ra;
  2950. if(control.length > 0 && !Ext.isArray(control[0])){
  2951. control = [control];
  2952. }else{
  2953. /*
  2954. var tmp = [];
  2955. for (i = 0,len = control.length; i < len; ++i) {
  2956. tmp[i] = control[i];
  2957. }
  2958. control = tmp;
  2959. */
  2960. }
  2961. Ext.fly(el, '_anim').position();
  2962. DOM.setXY(el, isset(from) ? from : DOM.getXY(el));
  2963. start = me.getAttr('points');
  2964. if(isset(to)){
  2965. end = translateValues.call(me, to, start);
  2966. for (i = 0,len = control.length; i < len; ++i) {
  2967. control[i] = translateValues.call(me, control[i], start);
  2968. }
  2969. } else if (isset(by)) {
  2970. end = [start[0] + by[0], start[1] + by[1]];
  2971. for (i = 0,len = control.length; i < len; ++i) {
  2972. control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
  2973. }
  2974. }
  2975. ra = this.runAttrs[attr] = [start];
  2976. if (control.length > 0) {
  2977. ra = ra.concat(control);
  2978. }
  2979. ra[ra.length] = end;
  2980. }else{
  2981. superclass.setRunAttr.call(this, attr);
  2982. }
  2983. }
  2984. });
  2985. var translateValues = function(val, start) {
  2986. var pageXY = EXTLIB.Dom.getXY(this.el);
  2987. return [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
  2988. };
  2989. })();
  2990. })();// Easing functions
  2991. (function(){
  2992. // shortcuts to aid compression
  2993. var abs = Math.abs,
  2994. pi = Math.PI,
  2995. asin = Math.asin,
  2996. pow = Math.pow,
  2997. sin = Math.sin,
  2998. EXTLIB = Ext.lib;
  2999. Ext.apply(EXTLIB.Easing, {
  3000. easeBoth: function (t, b, c, d) {
  3001. return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b;
  3002. },
  3003. easeInStrong: function (t, b, c, d) {
  3004. return c * (t /= d) * t * t * t + b;
  3005. },
  3006. easeOutStrong: function (t, b, c, d) {
  3007. return -c * ((t = t / d - 1) * t * t * t - 1) + b;
  3008. },
  3009. easeBothStrong: function (t, b, c, d) {
  3010. return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b;
  3011. },
  3012. elasticIn: function (t, b, c, d, a, p) {
  3013. if (t == 0 || (t /= d) == 1) {
  3014. return t == 0 ? b : b + c;
  3015. }
  3016. p = p || (d * .3);
  3017. var s;
  3018. if (a >= abs(c)) {
  3019. s = p / (2 * pi) * asin(c / a);
  3020. } else {
  3021. a = c;
  3022. s = p / 4;
  3023. }
  3024. return -(a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b;
  3025. },
  3026. elasticOut: function (t, b, c, d, a, p) {
  3027. if (t == 0 || (t /= d) == 1) {
  3028. return t == 0 ? b : b + c;
  3029. }
  3030. p = p || (d * .3);
  3031. var s;
  3032. if (a >= abs(c)) {
  3033. s = p / (2 * pi) * asin(c / a);
  3034. } else {
  3035. a = c;
  3036. s = p / 4;
  3037. }
  3038. return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b;
  3039. },
  3040. elasticBoth: function (t, b, c, d, a, p) {
  3041. if (t == 0 || (t /= d / 2) == 2) {
  3042. return t == 0 ? b : b + c;
  3043. }
  3044. p = p || (d * (.3 * 1.5));
  3045. var s;
  3046. if (a >= abs(c)) {
  3047. s = p / (2 * pi) * asin(c / a);
  3048. } else {
  3049. a = c;
  3050. s = p / 4;
  3051. }
  3052. return t < 1 ?
  3053. -.5 * (a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b :
  3054. a * pow(2, -10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p) * .5 + c + b;
  3055. },
  3056. backIn: function (t, b, c, d, s) {
  3057. s = s || 1.70158;
  3058. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  3059. },
  3060. backOut: function (t, b, c, d, s) {
  3061. if (!s) {
  3062. s = 1.70158;
  3063. }
  3064. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  3065. },
  3066. backBoth: function (t, b, c, d, s) {
  3067. s = s || 1.70158;
  3068. return ((t /= d / 2 ) < 1) ?
  3069. c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b :
  3070. c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
  3071. },
  3072. bounceIn: function (t, b, c, d) {
  3073. return c - EXTLIB.Easing.bounceOut(d - t, 0, c, d) + b;
  3074. },
  3075. bounceOut: function (t, b, c, d) {
  3076. if ((t /= d) < (1 / 2.75)) {
  3077. return c * (7.5625 * t * t) + b;
  3078. } else if (t < (2 / 2.75)) {
  3079. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  3080. } else if (t < (2.5 / 2.75)) {
  3081. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  3082. }
  3083. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  3084. },
  3085. bounceBoth: function (t, b, c, d) {
  3086. return (t < d / 2) ?
  3087. EXTLIB.Easing.bounceIn(t * 2, 0, c, d) * .5 + b :
  3088. EXTLIB.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
  3089. }
  3090. });
  3091. })();
  3092. (function() {
  3093. var EXTLIB = Ext.lib;
  3094. // Color Animation
  3095. EXTLIB.Anim.color = function(el, args, duration, easing, cb, scope) {
  3096. return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.ColorAnim);
  3097. }
  3098. EXTLIB.ColorAnim = function(el, attributes, duration, method) {
  3099. EXTLIB.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
  3100. };
  3101. Ext.extend(EXTLIB.ColorAnim, EXTLIB.AnimBase);
  3102. var superclass = EXTLIB.ColorAnim.superclass,
  3103. colorRE = /color$/i,
  3104. transparentRE = /^transparent|rgba\(0, 0, 0, 0\)$/,
  3105. rgbRE = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
  3106. hexRE= /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
  3107. hex3RE = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
  3108. isset = function(v){
  3109. return typeof v !== 'undefined';
  3110. };
  3111. // private
  3112. function parseColor(s) {
  3113. var pi = parseInt,
  3114. base,
  3115. out = null,
  3116. c;
  3117. if (s.length == 3) {
  3118. return s;
  3119. }
  3120. Ext.each([hexRE, rgbRE, hex3RE], function(re, idx){
  3121. base = (idx % 2 == 0) ? 16 : 10;
  3122. c = re.exec(s);
  3123. if(c && c.length == 4){
  3124. out = [pi(c[1], base), pi(c[2], base), pi(c[3], base)];
  3125. return false;
  3126. }
  3127. });
  3128. return out;
  3129. }
  3130. Ext.apply(EXTLIB.ColorAnim.prototype, {
  3131. getAttr : function(attr) {
  3132. var me = this,
  3133. el = me.el,
  3134. val;
  3135. if(colorRE.test(attr)){
  3136. while(el && transparentRE.test(val = Ext.fly(el).getStyle(attr))){
  3137. el = el.parentNode;
  3138. val = "fff";
  3139. }
  3140. }else{
  3141. val = superclass.getAttr.call(me, attr);
  3142. }
  3143. return val;
  3144. },
  3145. doMethod : function(attr, start, end) {
  3146. var me = this,
  3147. val,
  3148. floor = Math.floor,
  3149. i,
  3150. len,
  3151. v;
  3152. if(colorRE.test(attr)){
  3153. val = [];
  3154. end = end || [];
  3155. for(i = 0, len = start.length; i < len; i++) {
  3156. v = start[i];
  3157. val[i] = superclass.doMethod.call(me, attr, v, end[i]);
  3158. }
  3159. val = 'rgb(' + floor(val[0]) + ',' + floor(val[1]) + ',' + floor(val[2]) + ')';
  3160. }else{
  3161. val = superclass.doMethod.call(me, attr, start, end);
  3162. }
  3163. return val;
  3164. },
  3165. setRunAttr : function(attr) {
  3166. var me = this,
  3167. a = me.attributes[attr],
  3168. to = a.to,
  3169. by = a.by,
  3170. ra;
  3171. superclass.setRunAttr.call(me, attr);
  3172. ra = me.runAttrs[attr];
  3173. if(colorRE.test(attr)){
  3174. var start = parseColor(ra.start),
  3175. end = parseColor(ra.end);
  3176. if(!isset(to) && isset(by)){
  3177. end = parseColor(by);
  3178. for(var i=0,len=start.length; i<len; i++) {
  3179. end[i] = start[i] + end[i];
  3180. }
  3181. }
  3182. ra.start = start;
  3183. ra.end = end;
  3184. }
  3185. }
  3186. });
  3187. })();
  3188. (function() {
  3189. // Scroll Animation
  3190. var EXTLIB = Ext.lib;
  3191. EXTLIB.Anim.scroll = function(el, args, duration, easing, cb, scope) {
  3192. return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.Scroll);
  3193. };
  3194. EXTLIB.Scroll = function(el, attributes, duration, method) {
  3195. if(el){
  3196. EXTLIB.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
  3197. }
  3198. };
  3199. Ext.extend(EXTLIB.Scroll, EXTLIB.ColorAnim);
  3200. var superclass = EXTLIB.Scroll.superclass,
  3201. SCROLL = 'scroll';
  3202. Ext.apply(EXTLIB.Scroll.prototype, {
  3203. doMethod : function(attr, start, end) {
  3204. var val,
  3205. me = this,
  3206. curFrame = me.curFrame,
  3207. totalFrames = me.totalFrames;
  3208. if(attr == SCROLL){
  3209. val = [me.method(curFrame, start[0], end[0] - start[0], totalFrames),
  3210. me.method(curFrame, start[1], end[1] - start[1], totalFrames)];
  3211. }else{
  3212. val = superclass.doMethod.call(me, attr, start, end);
  3213. }
  3214. return val;
  3215. },
  3216. getAttr : function(attr) {
  3217. var me = this;
  3218. if (attr == SCROLL) {
  3219. return [me.el.scrollLeft, me.el.scrollTop];
  3220. }else{
  3221. return superclass.getAttr.call(me, attr);
  3222. }
  3223. },
  3224. setAttr : function(attr, val, unit) {
  3225. var me = this;
  3226. if(attr == SCROLL){
  3227. me.el.scrollLeft = val[0];
  3228. me.el.scrollTop = val[1];
  3229. }else{
  3230. superclass.setAttr.call(me, attr, val, unit);
  3231. }
  3232. }
  3233. });
  3234. })();
  3235. if(Ext.isIE) {
  3236. function fnCleanUp() {
  3237. var p = Function.prototype;
  3238. delete p.createSequence;
  3239. delete p.defer;
  3240. delete p.createDelegate;
  3241. delete p.createCallback;
  3242. delete p.createInterceptor;
  3243. window.detachEvent("onunload", fnCleanUp);
  3244. }
  3245. window.attachEvent("onunload", fnCleanUp);
  3246. }
  3247. })();