1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | |
---|
10 | // Sample desktop configuration |
---|
11 | MyDesktop = new Ext.app.App({ |
---|
12 | init :function(){ |
---|
13 | Ext.QuickTips.init(); |
---|
14 | }, |
---|
15 | |
---|
16 | getModules : function(){ |
---|
17 | return [ |
---|
18 | new MyDesktop.GridWindow(), |
---|
19 | new MyDesktop.TabWindow(), |
---|
20 | new MyDesktop.AccordionWindow(), |
---|
21 | new MyDesktop.BogusMenuModule(), |
---|
22 | new MyDesktop.BogusModule() |
---|
23 | ]; |
---|
24 | }, |
---|
25 | |
---|
26 | // config for the start menu |
---|
27 | getStartConfig : function(){ |
---|
28 | return { |
---|
29 | title: 'Jack Slocum', |
---|
30 | iconCls: 'user', |
---|
31 | toolItems: [{ |
---|
32 | text:'Settings', |
---|
33 | iconCls:'settings', |
---|
34 | scope:this |
---|
35 | },'-',{ |
---|
36 | text:'Logout', |
---|
37 | iconCls:'logout', |
---|
38 | scope:this |
---|
39 | }] |
---|
40 | }; |
---|
41 | } |
---|
42 | }); |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | /* |
---|
47 | * Example windows |
---|
48 | */ |
---|
49 | MyDesktop.GridWindow = Ext.extend(Ext.app.Module, { |
---|
50 | id:'grid-win', |
---|
51 | init : function(){ |
---|
52 | this.launcher = { |
---|
53 | text: 'Grid Window', |
---|
54 | iconCls:'icon-grid', |
---|
55 | handler : this.createWindow, |
---|
56 | scope: this |
---|
57 | } |
---|
58 | }, |
---|
59 | |
---|
60 | createWindow : function(){ |
---|
61 | var desktop = this.app.getDesktop(); |
---|
62 | var win = desktop.getWindow('grid-win'); |
---|
63 | if(!win){ |
---|
64 | win = desktop.createWindow({ |
---|
65 | id: 'grid-win', |
---|
66 | title:'Grid Window', |
---|
67 | width:740, |
---|
68 | height:480, |
---|
69 | iconCls: 'icon-grid', |
---|
70 | shim:false, |
---|
71 | animCollapse:false, |
---|
72 | constrainHeader:true, |
---|
73 | |
---|
74 | layout: 'fit', |
---|
75 | items: |
---|
76 | new Ext.grid.GridPanel({ |
---|
77 | border:false, |
---|
78 | ds: new Ext.data.Store({ |
---|
79 | reader: new Ext.data.ArrayReader({}, [ |
---|
80 | {name: 'company'}, |
---|
81 | {name: 'price', type: 'float'}, |
---|
82 | {name: 'change', type: 'float'}, |
---|
83 | {name: 'pctChange', type: 'float'} |
---|
84 | ]), |
---|
85 | data: Ext.grid.dummyData |
---|
86 | }), |
---|
87 | cm: new Ext.grid.ColumnModel([ |
---|
88 | new Ext.grid.RowNumberer(), |
---|
89 | {header: "Company", width: 120, sortable: true, dataIndex: 'company'}, |
---|
90 | {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'}, |
---|
91 | {header: "Change", width: 70, sortable: true, dataIndex: 'change'}, |
---|
92 | {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'} |
---|
93 | ]), |
---|
94 | |
---|
95 | viewConfig: { |
---|
96 | forceFit:true |
---|
97 | }, |
---|
98 | //autoExpandColumn:'company', |
---|
99 | |
---|
100 | tbar:[{ |
---|
101 | text:'Add Something', |
---|
102 | tooltip:'Add a new row', |
---|
103 | iconCls:'add' |
---|
104 | }, '-', { |
---|
105 | text:'Options', |
---|
106 | tooltip:'Blah blah blah blaht', |
---|
107 | iconCls:'option' |
---|
108 | },'-',{ |
---|
109 | text:'Remove Something', |
---|
110 | tooltip:'Remove the selected item', |
---|
111 | iconCls:'remove' |
---|
112 | }] |
---|
113 | }) |
---|
114 | }); |
---|
115 | } |
---|
116 | win.show(); |
---|
117 | } |
---|
118 | }); |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | MyDesktop.TabWindow = Ext.extend(Ext.app.Module, { |
---|
123 | id:'tab-win', |
---|
124 | init : function(){ |
---|
125 | this.launcher = { |
---|
126 | text: 'Tab Window', |
---|
127 | iconCls:'tabs', |
---|
128 | handler : this.createWindow, |
---|
129 | scope: this |
---|
130 | } |
---|
131 | }, |
---|
132 | |
---|
133 | createWindow : function(){ |
---|
134 | var desktop = this.app.getDesktop(); |
---|
135 | var win = desktop.getWindow('tab-win'); |
---|
136 | if(!win){ |
---|
137 | win = desktop.createWindow({ |
---|
138 | id: 'tab-win', |
---|
139 | title:'Tab Window', |
---|
140 | width:740, |
---|
141 | height:480, |
---|
142 | iconCls: 'tabs', |
---|
143 | shim:false, |
---|
144 | animCollapse:false, |
---|
145 | border:false, |
---|
146 | constrainHeader:true, |
---|
147 | |
---|
148 | layout: 'fit', |
---|
149 | items: |
---|
150 | new Ext.TabPanel({ |
---|
151 | activeTab:0, |
---|
152 | |
---|
153 | items: [{ |
---|
154 | title: 'Tab Text 1', |
---|
155 | header:false, |
---|
156 | html : '<p>Something useful would be in here.</p>', |
---|
157 | border:false |
---|
158 | },{ |
---|
159 | title: 'Tab Text 2', |
---|
160 | header:false, |
---|
161 | html : '<p>Something useful would be in here.</p>', |
---|
162 | border:false |
---|
163 | },{ |
---|
164 | title: 'Tab Text 3', |
---|
165 | header:false, |
---|
166 | html : '<p>Something useful would be in here.</p>', |
---|
167 | border:false |
---|
168 | },{ |
---|
169 | title: 'Tab Text 4', |
---|
170 | header:false, |
---|
171 | html : '<p>Something useful would be in here.</p>', |
---|
172 | border:false |
---|
173 | }] |
---|
174 | }) |
---|
175 | }); |
---|
176 | } |
---|
177 | win.show(); |
---|
178 | } |
---|
179 | }); |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, { |
---|
184 | id:'acc-win', |
---|
185 | init : function(){ |
---|
186 | this.launcher = { |
---|
187 | text: 'Accordion Window', |
---|
188 | iconCls:'accordion', |
---|
189 | handler : this.createWindow, |
---|
190 | scope: this |
---|
191 | } |
---|
192 | }, |
---|
193 | |
---|
194 | createWindow : function(){ |
---|
195 | var desktop = this.app.getDesktop(); |
---|
196 | var win = desktop.getWindow('acc-win'); |
---|
197 | if(!win){ |
---|
198 | win = desktop.createWindow({ |
---|
199 | id: 'acc-win', |
---|
200 | title: 'Accordion Window', |
---|
201 | width:250, |
---|
202 | height:400, |
---|
203 | iconCls: 'accordion', |
---|
204 | shim:false, |
---|
205 | animCollapse:false, |
---|
206 | constrainHeader:true, |
---|
207 | |
---|
208 | tbar:[{ |
---|
209 | tooltip:{title:'Rich Tooltips', text:'Let your users know what they can do!'}, |
---|
210 | iconCls:'connect' |
---|
211 | },'-',{ |
---|
212 | tooltip:'Add a new user', |
---|
213 | iconCls:'user-add' |
---|
214 | },' ',{ |
---|
215 | tooltip:'Remove the selected user', |
---|
216 | iconCls:'user-delete' |
---|
217 | }], |
---|
218 | |
---|
219 | layout:'accordion', |
---|
220 | border:false, |
---|
221 | layoutConfig: { |
---|
222 | animate:false |
---|
223 | }, |
---|
224 | |
---|
225 | items: [ |
---|
226 | new Ext.tree.TreePanel({ |
---|
227 | id:'im-tree', |
---|
228 | title: 'Online Users', |
---|
229 | loader: new Ext.tree.TreeLoader(), |
---|
230 | rootVisible:false, |
---|
231 | lines:false, |
---|
232 | autoScroll:true, |
---|
233 | tools:[{ |
---|
234 | id:'refresh', |
---|
235 | on:{ |
---|
236 | click: function(){ |
---|
237 | var tree = Ext.getCmp('im-tree'); |
---|
238 | tree.body.mask('Loading', 'x-mask-loading'); |
---|
239 | tree.root.reload(); |
---|
240 | tree.root.collapse(true, false); |
---|
241 | setTimeout(function(){ // mimic a server call |
---|
242 | tree.body.unmask(); |
---|
243 | tree.root.expand(true, true); |
---|
244 | }, 1000); |
---|
245 | } |
---|
246 | } |
---|
247 | }], |
---|
248 | root: new Ext.tree.AsyncTreeNode({ |
---|
249 | text:'Online', |
---|
250 | children:[{ |
---|
251 | text:'Friends', |
---|
252 | expanded:true, |
---|
253 | children:[{ |
---|
254 | text:'Jack', |
---|
255 | iconCls:'user', |
---|
256 | leaf:true |
---|
257 | },{ |
---|
258 | text:'Brian', |
---|
259 | iconCls:'user', |
---|
260 | leaf:true |
---|
261 | },{ |
---|
262 | text:'Jon', |
---|
263 | iconCls:'user', |
---|
264 | leaf:true |
---|
265 | },{ |
---|
266 | text:'Tim', |
---|
267 | iconCls:'user', |
---|
268 | leaf:true |
---|
269 | },{ |
---|
270 | text:'Nige', |
---|
271 | iconCls:'user', |
---|
272 | leaf:true |
---|
273 | },{ |
---|
274 | text:'Fred', |
---|
275 | iconCls:'user', |
---|
276 | leaf:true |
---|
277 | },{ |
---|
278 | text:'Bob', |
---|
279 | iconCls:'user', |
---|
280 | leaf:true |
---|
281 | }] |
---|
282 | },{ |
---|
283 | text:'Family', |
---|
284 | expanded:true, |
---|
285 | children:[{ |
---|
286 | text:'Kelly', |
---|
287 | iconCls:'user-girl', |
---|
288 | leaf:true |
---|
289 | },{ |
---|
290 | text:'Sara', |
---|
291 | iconCls:'user-girl', |
---|
292 | leaf:true |
---|
293 | },{ |
---|
294 | text:'Zack', |
---|
295 | iconCls:'user-kid', |
---|
296 | leaf:true |
---|
297 | },{ |
---|
298 | text:'John', |
---|
299 | iconCls:'user-kid', |
---|
300 | leaf:true |
---|
301 | }] |
---|
302 | }] |
---|
303 | }) |
---|
304 | }), { |
---|
305 | title: 'Settings', |
---|
306 | html:'<p>Something useful would be in here.</p>', |
---|
307 | autoScroll:true |
---|
308 | },{ |
---|
309 | title: 'Even More Stuff', |
---|
310 | html : '<p>Something useful would be in here.</p>' |
---|
311 | },{ |
---|
312 | title: 'My Stuff', |
---|
313 | html : '<p>Something useful would be in here.</p>' |
---|
314 | } |
---|
315 | ] |
---|
316 | }); |
---|
317 | } |
---|
318 | win.show(); |
---|
319 | } |
---|
320 | }); |
---|
321 | |
---|
322 | // for example purposes |
---|
323 | var windowIndex = 0; |
---|
324 | |
---|
325 | MyDesktop.BogusModule = Ext.extend(Ext.app.Module, { |
---|
326 | init : function(){ |
---|
327 | this.launcher = { |
---|
328 | text: 'Window '+(++windowIndex), |
---|
329 | iconCls:'bogus', |
---|
330 | handler : this.createWindow, |
---|
331 | scope: this, |
---|
332 | windowId:windowIndex |
---|
333 | } |
---|
334 | }, |
---|
335 | |
---|
336 | createWindow : function(src){ |
---|
337 | var desktop = this.app.getDesktop(); |
---|
338 | var win = desktop.getWindow('bogus'+src.windowId); |
---|
339 | if(!win){ |
---|
340 | win = desktop.createWindow({ |
---|
341 | id: 'bogus'+src.windowId, |
---|
342 | title:src.text, |
---|
343 | width:640, |
---|
344 | height:480, |
---|
345 | html : '<p>Something useful would be in here.</p>', |
---|
346 | iconCls: 'bogus', |
---|
347 | shim:false, |
---|
348 | animCollapse:false, |
---|
349 | constrainHeader:true |
---|
350 | }); |
---|
351 | } |
---|
352 | win.show(); |
---|
353 | } |
---|
354 | }); |
---|
355 | |
---|
356 | |
---|
357 | MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, { |
---|
358 | init : function(){ |
---|
359 | this.launcher = { |
---|
360 | text: 'Bogus Submenu', |
---|
361 | iconCls: 'bogus', |
---|
362 | handler: function() { |
---|
363 | return false; |
---|
364 | }, |
---|
365 | menu: { |
---|
366 | items:[{ |
---|
367 | text: 'Bogus Window '+(++windowIndex), |
---|
368 | iconCls:'bogus', |
---|
369 | handler : this.createWindow, |
---|
370 | scope: this, |
---|
371 | windowId: windowIndex |
---|
372 | },{ |
---|
373 | text: 'Bogus Window '+(++windowIndex), |
---|
374 | iconCls:'bogus', |
---|
375 | handler : this.createWindow, |
---|
376 | scope: this, |
---|
377 | windowId: windowIndex |
---|
378 | },{ |
---|
379 | text: 'Bogus Window '+(++windowIndex), |
---|
380 | iconCls:'bogus', |
---|
381 | handler : this.createWindow, |
---|
382 | scope: this, |
---|
383 | windowId: windowIndex |
---|
384 | },{ |
---|
385 | text: 'Bogus Window '+(++windowIndex), |
---|
386 | iconCls:'bogus', |
---|
387 | handler : this.createWindow, |
---|
388 | scope: this, |
---|
389 | windowId: windowIndex |
---|
390 | },{ |
---|
391 | text: 'Bogus Window '+(++windowIndex), |
---|
392 | iconCls:'bogus', |
---|
393 | handler : this.createWindow, |
---|
394 | scope: this, |
---|
395 | windowId: windowIndex |
---|
396 | }] |
---|
397 | } |
---|
398 | } |
---|
399 | } |
---|
400 | }); |
---|
401 | |
---|
402 | |
---|
403 | // Array data for the grid |
---|
404 | Ext.grid.dummyData = [ |
---|
405 | ['3m Co',71.72,0.02,0.03,'9/1 12:00am'], |
---|
406 | ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'], |
---|
407 | ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'], |
---|
408 | ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'], |
---|
409 | ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'], |
---|
410 | ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'], |
---|
411 | ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'], |
---|
412 | ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'], |
---|
413 | ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'], |
---|
414 | ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'], |
---|
415 | ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'], |
---|
416 | ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'], |
---|
417 | ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'], |
---|
418 | ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'], |
---|
419 | ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'], |
---|
420 | ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'], |
---|
421 | ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'], |
---|
422 | ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'], |
---|
423 | ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'], |
---|
424 | ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am'] |
---|
425 | ]; |
---|