1 /***************************************************************
4 * (c) 2010 Stefan Galinski <stefan.galinski@gmail.com>
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 * A copy is found in the textfile GPL.txt and important notices to the license
16 * from the author is found in LICENSE.txt distributed with these scripts.
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
30 * Extends the viewport with some functionality for TYPO3.
32 * @author Stefan Galinski <stefan.galinski@gmail.com>
34 TYPO3
.Viewport
= Ext
.extend(Ext
.Viewport
, {
36 * Contains the navigation widgets in a simple array and identified by an unique idea
38 * @see registerNavigationWidget()
41 navigationWidgetContainer
: {},
44 * Contains the meta informations of the navigation widgets
46 * @see registerNavigationWidget()
49 navigationWidgetMetaData
: {},
63 ContentContainer
: null,
66 * The navigation frame area
70 NavigationContainer
: null,
73 * The module menu area
77 ModuleMenuContainer
: null,
87 * Initializes the ExtJS viewport with the given configuration.
91 initComponent: function() {
92 // adjust the width of module menu and the height of the topbar
93 this.initialConfig
.items
[0].height
= TYPO3
.configuration
.topBarHeight
;
94 this.initialConfig
.items
[1].width
= TYPO3
.configuration
.moduleMenuWidth
;
96 // call parent constructor
97 TYPO3
.Viewport
.superclass
.initComponent
.apply(this, arguments
);
99 this.ContentContainer
= Ext
.ComponentMgr
.get('typo3-contentContainer');
100 this.NavigationContainer
= Ext
.ComponentMgr
.get('typo3-navigationContainer');
101 this.Topbar
= Ext
.ComponentMgr
.get('typo3-topbar');
102 this.ModuleMenuContainer
= Ext
.ComponentMgr
.get('typo3-module-menu');
104 // adds the debug console and some listeners to consider the initial hiding of
105 // the debug console (the viewport needs to be resized if it's expand/collapse)
106 // -> see the TYPO3.BackendSizeManager
107 this.DebugConsole
= Ext
.ComponentMgr
.get('typo3-debug-console');
108 this.DebugConsole
.addListener({
112 this.fireEvent('resize');
118 this.fireEvent('resize');
125 * Loads a module into the content container
127 * @param mainModuleName string name of the main module (e.g. web)
128 * @param subModuleName string name of the sub module (e.g. page)
129 * @param contentScript string the content provider (path to a php script)
132 loadModule: function(mainModuleName
, subModuleName
, contentScript
) {
133 var navigationWidgetActive
= false;
134 var widgetMainModule
= '';
135 var widgetSubModule
= '';
137 for (var widgetId
in this.navigationWidgetMetaData
) {
138 widgetMainModule
= this.navigationWidgetMetaData
[widgetId
].mainModule
;
139 widgetSubModule
= this.navigationWidgetMetaData
[widgetId
].subModule
;
140 widget
= this.navigationWidgetMetaData
[widgetId
].widget
;
142 if ((widgetMainModule
=== mainModuleName
|| widgetMainModule
=== '*') &&
143 (widgetSubModule
=== subModuleName
|| widgetSubModule
=== '*')
146 navigationWidgetActive
= true;
152 if (navigationWidgetActive
) {
153 this.NavigationContainer
.show();
155 this.NavigationContainer
.hide();
158 // append the typo3 path if it wasn't already applied
159 // this is important for backwards compatibility (e.g. shortcuts)
160 if (contentScript
.indexOf(top
.TS
.PATH_typo3
) !== 0) {
161 contentScript
= top
.TS
.PATH_typo3
+ contentScript
;
163 Ext
.get('content').set({
167 this.NavigationContainer
.ownerCt
.doLayout();
171 * Adds the given widget to the navigation container. The key will be the id attribute
172 * of the given widget.
174 * @param mainModule string main module or wildcard (*) for all
175 * @param subModule string sub module or wildcard (*) for all
176 * @param widget object ExtJS widget (e.g. an Ext.Panel); must contain an id attribute!
179 registerNavigationWidget: function(mainModule
, subModule
, widget
) {
180 // only one instance of specific widget may be exists!
181 if (this.navigationWidgetMetaData
[widget
.id
] === undefined) {
182 this.navigationWidgetMetaData
[widget
.id
] = {
183 mainModule
: mainModule
,
184 subModule
: subModule
,
188 // always take the full width and height
189 widget
.anchor
= '100% 100%';
190 this.NavigationContainer
.add(widget
);
195 Ext
.reg('typo3Viewport', TYPO3
.Viewport
);