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
93 this.initialConfig
.items
[1].width
= TYPO3
.configuration
.moduleMenuWidth
;
94 // call parent constructor
95 TYPO3
.Viewport
.superclass
.initComponent
.apply(this, arguments
);
97 this.ContentContainer
= Ext
.ComponentMgr
.get('typo3-contentContainer');
98 this.NavigationContainer
= Ext
.ComponentMgr
.get('typo3-navigationContainer');
99 this.Topbar
= Ext
.ComponentMgr
.get('typo3-topbar');
100 this.ModuleMenuContainer
= Ext
.ComponentMgr
.get('typo3-module-menu');
102 // adds the debug console and some listeners to consider the initial hiding of
103 // the debug console (the viewport needs to be resized if it's expand/collapse)
104 // -> see the TYPO3.BackendSizeManager
105 this.DebugConsole
= Ext
.ComponentMgr
.get('typo3-debug-console');
106 this.DebugConsole
.addListener({
110 this.fireEvent('resize');
116 this.fireEvent('resize');
123 * Loads a module into the content container
125 * @param mainModuleName string name of the main module (e.g. web)
126 * @param subModuleName string name of the sub module (e.g. page)
127 * @param contentScript string the content provider (path to a php script)
130 loadModule: function(mainModuleName
, subModuleName
, contentScript
) {
131 var navigationWidgetActive
= false;
132 var widgetMainModule
= '';
133 var widgetSubModule
= '';
135 for (var widgetId
in this.navigationWidgetMetaData
) {
136 widgetMainModule
= this.navigationWidgetMetaData
[widgetId
].mainModule
;
137 widgetSubModule
= this.navigationWidgetMetaData
[widgetId
].subModule
;
138 widget
= this.navigationWidgetMetaData
[widgetId
].widget
;
140 if ((widgetMainModule
=== mainModuleName
|| widgetMainModule
=== '*') &&
141 (widgetSubModule
=== subModuleName
|| widgetSubModule
=== '*')
144 navigationWidgetActive
= true;
150 if (navigationWidgetActive
) {
151 this.NavigationContainer
.show();
153 this.NavigationContainer
.hide();
156 // append the typo3 path if it wasn't already applied
157 // this is important for backwards compatibility (e.g. shortcuts)
158 if (contentScript
.indexOf(top
.TS
.PATH_typo3
) !== 0) {
159 contentScript
= top
.TS
.PATH_typo3
+ contentScript
;
161 Ext
.get('content').set({
165 this.NavigationContainer
.ownerCt
.doLayout();
169 * Adds the given widget to the navigation container. The key will be the id attribute
170 * of the given widget.
172 * @param mainModule string main module or wildcard (*) for all
173 * @param subModule string sub module or wildcard (*) for all
174 * @param widget object ExtJS widget (e.g. an Ext.Panel); must contain an id attribute!
177 registerNavigationWidget: function(mainModule
, subModule
, widget
) {
178 // only one instance of specific widget may be exists!
179 if (this.navigationWidgetMetaData
[widget
.id
] === undefined) {
180 this.navigationWidgetMetaData
[widget
.id
] = {
181 mainModule
: mainModule
,
182 subModule
: subModule
,
186 // always take the full width and height
187 widget
.anchor
= '100% 100%';
188 this.NavigationContainer
.add(widget
);
193 Ext
.reg('typo3Viewport', TYPO3
.Viewport
);