64b6246f735083f74363a7e12c82af0173583bec.svn-base 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.app.App = function(cfg) {
  7. Ext.apply(this, cfg);
  8. this.addEvents({
  9. 'ready' : true,
  10. 'beforeunload' : true
  11. });
  12. Ext.onReady(this.initApp, this);
  13. };
  14. Ext.extend(Ext.app.App, Ext.util.Observable, {
  15. isReady : false,
  16. startMenu : null,
  17. modules : null,
  18. getStartConfig : function() {
  19. },
  20. initApp : function() {
  21. this.startConfig = this.startConfig || this.getStartConfig();
  22. this.desktop = new Ext.Desktop(this);
  23. this.launcher = this.desktop.taskbar.startMenu;
  24. this.modules = this.getModules();
  25. if (this.modules) {
  26. this.initModules(this.modules);
  27. }
  28. this.init();
  29. Ext.EventManager
  30. .on(window, 'beforeunload', this.onUnload, this);
  31. this.fireEvent('ready', this);
  32. this.isReady = true;
  33. },
  34. getModules : Ext.emptyFn,
  35. init : Ext.emptyFn,
  36. initModules : function(ms) {
  37. for (var i = 0, len = ms.length; i < len; i++) {
  38. var m = ms[i];
  39. this.launcher.add(m.launcher);
  40. m.app = this;
  41. }
  42. },
  43. getModule : function(name) {
  44. var ms = this.modules;
  45. for (var i = 0, len = ms.length; i < len; i++) {
  46. if (ms[i].id == name || ms[i].appType == name) {
  47. return ms[i];
  48. }
  49. }
  50. return '';
  51. },
  52. onReady : function(fn, scope) {
  53. if (!this.isReady) {
  54. this.on('ready', fn, scope);
  55. } else {
  56. fn.call(scope, this);
  57. }
  58. },
  59. getDesktop : function() {
  60. return this.desktop;
  61. },
  62. onUnload : function(e) {
  63. if (this.fireEvent('beforeunload', this) === false) {
  64. e.stopEvent();
  65. }
  66. }
  67. });