]> git.proxmox.com Git - extjs.git/blob - extjs/build/examples/classic/sandbox/js/App.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / classic / sandbox / js / App.js
1 /*!
2 * Ext JS Library 3.3.1
3 * Copyright(c) 2006-2014 Sencha Inc.
4 * licensing@sencha.com
5 * http://www.sencha.com/license
6 */
7 Ext.app.App = function(cfg){
8 Ext.apply(this, cfg);
9 this.addEvents({
10 'ready' : true,
11 'beforeunload' : true
12 });
13
14 Ext.onReady(this.initApp, this);
15 };
16
17 Ext.extend(Ext.app.App, Ext.util.Observable, {
18 isReady: false,
19 startMenu: null,
20 modules: null,
21
22 getStartConfig : function(){
23
24 },
25
26 initApp : function(){
27 this.startConfig = this.startConfig || this.getStartConfig();
28
29 this.desktop = new Ext.Desktop(this);
30
31 this.launcher = this.desktop.taskbar.startMenu;
32
33 this.modules = this.getModules();
34 if(this.modules){
35 this.initModules(this.modules);
36 }
37
38 this.init();
39
40 Ext.getWin().on('beforeunload', this.onUnload, this);
41 this.fireEvent('ready', this);
42 this.isReady = true;
43 },
44
45 getModules : Ext.emptyFn,
46 init : Ext.emptyFn,
47
48 initModules : function(ms){
49 for(var i = 0, len = ms.length; i < len; i++){
50 var m = ms[i];
51 this.launcher.add(m.launcher);
52 m.app = this;
53 }
54 },
55
56 getModule : function(name){
57 var ms = this.modules;
58 for(var i = 0, len = ms.length; i < len; i++){
59 if(ms[i].id == name || ms[i].appType == name){
60 return ms[i];
61 }
62 }
63 return '';
64 },
65
66 onReady : function(fn, scope){
67 if(!this.isReady){
68 this.on('ready', fn, scope);
69 }else{
70 fn.call(scope, this);
71 }
72 },
73
74 getDesktop : function(){
75 return this.desktop;
76 },
77
78 onUnload : function(e){
79 if(this.fireEvent('beforeunload', this) === false){
80 e.stopEvent();
81 }
82 }
83 });