]> git.proxmox.com Git - extjs.git/blame - extjs/packages/ux/classic/src/desktop/App.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / ux / classic / src / desktop / App.js
CommitLineData
6527f429
DM
1/**\r
2 * Ext JS Library\r
3 * Copyright(c) 2006-2014 Sencha Inc.\r
4 * licensing@sencha.com\r
5 * http://www.sencha.com/license\r
6 * @class Ext.ux.desktop.App\r
7 */\r
8Ext.define('Ext.ux.desktop.App', {\r
9 mixins: {\r
10 observable: 'Ext.util.Observable'\r
11 },\r
12\r
13 requires: [\r
14 'Ext.container.Viewport',\r
15\r
16 'Ext.ux.desktop.Desktop'\r
17 ],\r
18\r
19 isReady: false,\r
20 modules: null,\r
21 useQuickTips: true,\r
22\r
23 constructor: function (config) {\r
24 var me = this;\r
25\r
26 me.mixins.observable.constructor.call(this, config);\r
27\r
28 if (Ext.isReady) {\r
29 Ext.Function.defer(me.init, 10, me);\r
30 } else {\r
31 Ext.onReady(me.init, me);\r
32 }\r
33 },\r
34\r
35 init: function() {\r
36 var me = this, desktopCfg;\r
37\r
38 if (me.useQuickTips) {\r
39 Ext.QuickTips.init();\r
40 }\r
41\r
42 me.modules = me.getModules();\r
43 if (me.modules) {\r
44 me.initModules(me.modules);\r
45 }\r
46\r
47 desktopCfg = me.getDesktopConfig();\r
48 me.desktop = new Ext.ux.desktop.Desktop(desktopCfg);\r
49\r
50 me.viewport = new Ext.container.Viewport({\r
51 layout: 'fit',\r
52 items: [ me.desktop ]\r
53 });\r
54\r
55 Ext.getWin().on('beforeunload', me.onUnload, me);\r
56\r
57 me.isReady = true;\r
58 me.fireEvent('ready', me);\r
59 },\r
60\r
61 /**\r
62 * This method returns the configuration object for the Desktop object. A derived\r
63 * class can override this method, call the base version to build the config and\r
64 * then modify the returned object before returning it.\r
65 */\r
66 getDesktopConfig: function () {\r
67 var me = this, cfg = {\r
68 app: me,\r
69 taskbarConfig: me.getTaskbarConfig()\r
70 };\r
71\r
72 Ext.apply(cfg, me.desktopConfig);\r
73 return cfg;\r
74 },\r
75\r
76 getModules: Ext.emptyFn,\r
77\r
78 /**\r
79 * This method returns the configuration object for the Start Button. A derived\r
80 * class can override this method, call the base version to build the config and\r
81 * then modify the returned object before returning it.\r
82 */\r
83 getStartConfig: function () {\r
84 var me = this,\r
85 cfg = {\r
86 app: me,\r
87 menu: []\r
88 },\r
89 launcher;\r
90\r
91 Ext.apply(cfg, me.startConfig);\r
92\r
93 Ext.each(me.modules, function (module) {\r
94 launcher = module.launcher;\r
95 if (launcher) {\r
96 launcher.handler = launcher.handler || Ext.bind(me.createWindow, me, [module]);\r
97 cfg.menu.push(module.launcher);\r
98 }\r
99 });\r
100\r
101 return cfg;\r
102 },\r
103\r
104 createWindow: function(module) {\r
105 var window = module.createWindow();\r
106 window.show();\r
107 },\r
108\r
109 /**\r
110 * This method returns the configuration object for the TaskBar. A derived class\r
111 * can override this method, call the base version to build the config and then\r
112 * modify the returned object before returning it.\r
113 */\r
114 getTaskbarConfig: function () {\r
115 var me = this, cfg = {\r
116 app: me,\r
117 startConfig: me.getStartConfig()\r
118 };\r
119\r
120 Ext.apply(cfg, me.taskbarConfig);\r
121 return cfg;\r
122 },\r
123\r
124 initModules : function(modules) {\r
125 var me = this;\r
126 Ext.each(modules, function (module) {\r
127 module.app = me;\r
128 });\r
129 },\r
130\r
131 getModule : function(name) {\r
132 var ms = this.modules;\r
133 for (var i = 0, len = ms.length; i < len; i++) {\r
134 var m = ms[i];\r
135 if (m.id == name || m.appType == name) {\r
136 return m;\r
137 }\r
138 }\r
139 return null;\r
140 },\r
141\r
142 onReady : function(fn, scope) {\r
143 if (this.isReady) {\r
144 fn.call(scope, this);\r
145 } else {\r
146 this.on({\r
147 ready: fn,\r
148 scope: scope,\r
149 single: true\r
150 });\r
151 }\r
152 },\r
153\r
154 getDesktop : function() {\r
155 return this.desktop;\r
156 },\r
157\r
158 onUnload : function(e) {\r
159 if (this.fireEvent('beforeunload', this) === false) {\r
160 e.stopEvent();\r
161 }\r
162 }\r
163});\r