4 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
5 * @author Cornelius Weiss <c.weiss@metaways.de>
6 * @copyright Copyright (c) 2007-2010 Metaways Infosystems GmbH (http://www.metaways.de)
9 Ext.ns('Tine.Tinebase');
12 * Tine 2.0 jsclient MainScreen.
14 * @namespace Tine.Tinebase
15 * @class Tine.Tinebase.MainScreenPanel
18 * @author Cornelius Weiss <c.weiss@metaways.de>
20 Tine.Tinebase.MainScreenPanel = Ext.extend(Ext.Panel, {
30 * @type {Tine.Tinebase.Application}
35 * @cfg {String} appPickerStyle "tabs" or "pile" defaults to "tabs"
37 appPickerStyle: 'tabs',
42 initComponent: function() {
43 // NOTE: this is a cruid method to create some kind of singleton...
44 Tine.Tinebase.MainScreen = this;
47 Tine.Tinebase.appMgr.on('activate', this.onAppActivate, this);
49 this.supr().initComponent.call(this);
55 initLayout: function() {
57 cls: 'tine-mainscreen-topbox',
59 html: '<div class="tine-mainscreen-topbox-left"></div><div class="tine-mainscreen-topbox-middle"></div><div class="tine-mainscreen-topbox-right"></div>'
61 cls: 'tine-mainscreen-mainmenu',
65 items: this.getMainMenu()
67 cls: 'tine-mainscreen-apptabs',
68 hidden: this.appPickerStyle != 'tabs',
70 height: Ext.isGecko ? 22 : 20,
71 items: new Tine.Tinebase.AppTabsPanel({
75 cls: 'tine-mainscreen-centerpanel',
80 cls: 'tine-mainscreen-centerpanel-north',
89 cls: 'tine-mainscreen-centerpanel-center',
101 cls: 'tine-mainscreen-centerpanel-west',
111 collapseMode: 'mini',
115 afterrender: function() {
116 // add to scrollmanager
117 if (arguments[0] && arguments[0].hasOwnProperty('body')) {
118 Ext.dd.ScrollManager.register(arguments[0].body);
124 buttonAlign : 'center'
129 cls: 'tine-mainscreen-centerpanel-west-modules',
141 cls: 'tine-mainscreen-centerpanel-west-treecards',
160 getMainMenu: function() {
161 if (! this.mainMenu) {
162 this.mainMenu = new Tine.Tinebase.MainMenu({
163 showMainMenu: this.appPickerStyle != 'tabs'
167 return this.mainMenu;
171 * appMgr app activation listener
173 * @param {Tine.Application} app
175 onAppActivate: function(app) {
176 Tine.log.info('Activating app ' + app.appName);
180 // set document / browser title
181 var postfix = (Tine.Tinebase.registry.get('titlePostfix')) ? Tine.Tinebase.registry.get('titlePostfix') : '',
182 // some apps (Felamimail atm) can add application specific title postfixes
183 // TODO generalize this
184 appPostfix = (document.title.match(/^\([0-9]+\) /)) ? document.title.match(/^\([0-9]+\) /)[0] : '';
185 document.title = Ext.util.Format.stripTags(appPostfix + Tine.title + postfix + ' - ' + app.getTitle());
189 * executed after rendering process
193 afterRender: function() {
194 this.supr().afterRender.apply(this, arguments);
196 this.activateDefaultApp();
198 // check for new version
199 // TODO add helper function for fetching config ... this condition sucks.
200 if (( ! Tine.Tinebase.registry.get("config")
201 || ! Tine.Tinebase.registry.get("config").versionCheck
202 || Tine.Tinebase.registry.get("config").versionCheck.value
203 ) && Tine.Tinebase.common.hasRight('check_version', 'Tinebase')
205 Tine.widgets.VersionCheck();
208 if (Tine.Tinebase.registry.get('mustchangepw')) {
209 var passwordDialog = new Tine.Tinebase.PasswordChangeDialog({
210 title: _('Your password expired. Please enter a new user password:')
212 passwordDialog.show();
217 * activate default application
219 * NOTE: this fn waits for treecard panel to be rendered
223 activateDefaultApp: function() {
224 if (Ext.getCmp('treecards').rendered) {
225 Tine.Tinebase.appMgr.activate();
227 this.activateDefaultApp.defer(10, this);
232 * sets the active content panel
234 * @param {Ext.Panel} item Panel to activate
235 * @param {Bool} keep keep panel
237 setActiveContentPanel: function(panel, keep) {
238 var cardPanel = Ext.getCmp('center-panel');
241 this.cleanupCardPanelItems(cardPanel);
242 this.setActiveCardPanelItem(cardPanel, panel);
246 * sets the active tree panel
248 * @param {Ext.Panel} panel Panel to activate
249 * @param {Bool} keep keep panel
251 setActiveTreePanel: function(panel, keep) {
252 var cardPanel = Ext.getCmp('treecards');
254 this.cleanupCardPanelItems(cardPanel);
255 this.setActiveCardPanelItem(cardPanel, panel);
259 * sets the active module tree panel
261 * @param {Ext.Panel} panel Panel to activate
262 * @param {Bool} keep keep panel
264 setActiveModulePanel: function(panel, keep) {
265 var modulePanel = Ext.getCmp('moduletree');
267 this.cleanupCardPanelItems(modulePanel);
268 this.setActiveCardPanelItem(modulePanel, panel);
274 * @param {Ext.Toolbar} panel toolbar to activate
275 * @param {Bool} keep keep panel
277 setActiveToolbar: function(panel, keep) {
278 var cardPanel = Ext.getCmp('north-panel-2');
281 this.cleanupCardPanelItems(cardPanel);
282 this.setActiveCardPanelItem(cardPanel, panel);
286 * gets the currently displayed toolbar
288 * @return {Ext.Toolbar}
290 getActiveToolbar: function() {
291 var northPanel = Ext.getCmp('north-panel-2');
293 if (northPanel.layout.activeItem && northPanel.layout.activeItem.el) {
294 return northPanel.layout.activeItem.el;
301 * remove all items which should not be keeped -> don't have a keep flag
303 * @param {Ext.Panel} cardPanel
305 cleanupCardPanelItems: function(cardPanel) {
306 if (cardPanel.items) {
307 for (var i=0,p; i<cardPanel.items.length; i++){
308 p = cardPanel.items.get(i);
317 * add or set given item
319 * @param {Ext.Panel} cardPanel
320 * @param {Ext.Panel} item
322 setActiveCardPanelItem: function(cardPanel, item) {
323 if (cardPanel.items.indexOf(item) !== -1) {
324 cardPanel.layout.setActiveItem(item.id);
327 cardPanel.layout.setActiveItem(item.id);
328 cardPanel.doLayout();