Fixed a faulty image reference on menu buttons FOR REAL.
[philo.git] / contrib / gilbert / media / gilbert / Gilbert.lib.js
1 Ext.ns('Gilbert.lib');
2
3 Gilbert.lib.Desktop = Ext.extend(Ext.Panel, {
4         constructor: function(config) {
5                 Gilbert.lib.Desktop.superclass.constructor.call(this, Ext.applyIf(config||{}, {
6                         region: 'center',
7                         border: false,
8                         padding: '5',
9                         bodyStyle: 'background: none;',
10                 }));
11         },
12 });
13
14 Gilbert.lib.MainMenu = Ext.extend(Ext.Toolbar, {
15         constructor: function(application) {
16                 var application = this.application = application;
17                 Gilbert.lib.MainMenu.superclass.constructor.call(this, {
18                         region: 'north',
19                         autoHeight: true,
20                 });
21         },
22 });
23
24 Gilbert.lib.Application = Ext.extend(Ext.util.Observable, {
25         constructor: function(config) {
26                 Ext.apply(this, config, {
27                         renderTo: Ext.getBody(),
28                         plugins: [],
29                         
30                 });
31                 Gilbert.lib.Application.superclass.constructor.call(this);
32                 this.addEvents({
33                         'ready': true,
34                 });
35                 this.init();
36         },
37         init: function() {
38                 Ext.QuickTips.init();
39                 
40                 var desktop = this.desktop = new Gilbert.lib.Desktop();
41                 var mainmenu = this.mainmenu = new Gilbert.lib.MainMenu(this);
42                 var viewport = this.viewport = new Ext.Viewport({
43                         renderTo: this.renderTo,
44                         layout: 'border',
45                         items: [
46                                 this.mainmenu,
47                                 this.desktop,
48                         ],
49                 });
50                 var windows = this.windows = new Ext.WindowGroup();
51                 
52                 if (this.plugins) {
53                         if (Ext.isArray(this.plugins)) {
54                                 for (var i = 0; i < this.plugins.length; i++) {
55                                         this.plugins[i] = this.initPlugin(this.plugins[i]);
56                                 }
57                         } else {
58                                 this.plugins = this.initPlugin(this.plugins);
59                         }
60                 }
61                 
62                 this.doLayout();
63                 
64                 this.fireEvent('ready', this);
65         },
66         initPlugin: function(plugin) {
67                 plugin.init(this);
68                 return plugin;
69         },
70         createWindow: function(config, cls) {
71                 var win = new(cls||Ext.Window)(Ext.applyIf(config||{},{
72                         renderTo: this.desktop.el,
73                         manager: this.windows,
74                         constrainHeader: true,
75                 }));
76                 win.render(this.desktop.el);
77                 return win;
78         },
79         doLayout: function() {
80                 this.mainmenu.doLayout();
81                 this.viewport.doLayout();
82         }
83 });