f4b1331678ed13249ee0ad503e7d6c81bc39e96f
[Packages/TYPO3.CMS.git] / typo3 / js / extjs / viewport.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2010-2011 Stefan Galinski <stefan.galinski@gmail.com>
5 * All rights reserved
6 *
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.
12 *
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.
17 *
18 *
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.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 Ext.ns('TYPO3');
28
29 // override splitregion to fit the splitbars in our design
30 Ext.override(Ext.layout.BorderLayout.SplitRegion, {
31 render : function(ct, p) {
32 Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
33
34 var ps = this.position;
35
36 this.splitEl = ct.createChild({
37 cls: "x-layout-split x-layout-split-" + ps, html: " ",
38 id: this.panel.id + '-xsplit'
39 });
40
41 if (this.enableChildSplit) {
42 this.splitChildEl = this.splitEl.createChild({
43 cls: 'x-layout-mini-wrapper'
44 });
45
46 }
47 if (this.collapseMode == 'mini') {
48 this.miniSplitEl = this.splitEl.createChild({
49 cls: "x-layout-mini x-layout-mini-" + ps, html: " "
50 });
51 this.miniSplitEl.addClassOnOver('x-layout-mini-over');
52 this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
53 }
54
55 var s = this.splitSettings[ps];
56
57 if (this.enableChildSplit) {
58 this.split = new Ext.SplitBar(this.splitChildEl.dom, p.el, s.orientation);
59 } else {
60 this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
61 }
62 this.split.tickSize = this.tickSize;
63 this.split.placement = s.placement;
64 this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
65 this.split.minSize = this.minSize || this[s.minProp];
66 this.split.on("beforeapply", this.onSplitMove, this);
67 this.split.useShim = this.useShim === true;
68 this.maxSize = this.maxSize || this[s.maxProp];
69
70 if (p.hidden) {
71 this.splitEl.hide();
72 }
73
74 if (this.useSplitTips) {
75 this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
76 }
77 if (this.collapsible) {
78 this.splitEl.on("dblclick", this.onCollapseClick, this);
79 }
80 }
81 });
82 /**
83 * Extends the viewport with some functionality for TYPO3.
84 *
85 * @author Stefan Galinski <stefan.galinski@gmail.com>
86 */
87 TYPO3.Viewport = Ext.extend(Ext.Viewport, {
88 /**
89 * Contains the navigation widgets in a simple array and identified by an unique idea
90 *
91 * @see registerNavigationWidget()
92 * @var object
93 */
94 navigationWidgetContainer: {},
95
96 /**
97 * Contains the meta informations of the navigation widgets
98 *
99 * @see registerNavigationWidget()
100 * @var object
101 */
102 navigationWidgetMetaData: {},
103
104 /**
105 * The topbar area
106 *
107 * @var Ext.Panel
108 */
109 Topbar: null,
110
111 /**
112 * The content area
113 *
114 * @var Ext.Panel
115 */
116 ContentContainer: null,
117
118 /**
119 * The navigation frame area
120 *
121 * @var Ext.Panel
122 */
123 NavigationContainer: null,
124
125 /**
126 * Dummy panel, shown when no NavigationContainer is in use
127 *
128 * @var Ext.Panel
129 */
130 NavigationDummy: null,
131
132 /**
133 * The iframe navigation component
134 *
135 * @var TYPO3.iframePanel
136 */
137 NavigationIframe: null,
138
139 /**
140 * The module menu area
141 *
142 * @var Ext.Panel
143 */
144 ModuleMenuContainer: null,
145
146 /**
147 * The debug console
148 *
149 * @var Ext.TabPanel
150 */
151 DebugConsole: null,
152
153 /**
154 * Initializes the ExtJS viewport with the given configuration.
155 *
156 * @return void
157 */
158 initComponent: function() {
159 // adjust the module menu and the height of the topbar
160 this.initialConfig.items[0].height = TYPO3.configuration.topBarHeight;
161
162 var moduleMenu = this.initialConfig.items[1];
163 moduleMenu.width = TYPO3.configuration.moduleMenuWidth;
164
165 // call parent constructor
166 TYPO3.Viewport.superclass.initComponent.apply(this, arguments);
167
168 this.ContentContainer = Ext.getCmp('typo3-contentContainer');
169 this.NavigationContainer = Ext.getCmp('typo3-navigationContainer');
170 this.NavigationDummy = Ext.getCmp('typo3-navigationDummy');
171 this.NavigationIframe = Ext.getCmp('typo3-navigationIframe');
172 this.Topbar = Ext.getCmp('typo3-topbar');
173 this.ModuleMenuContainer = Ext.getCmp('typo3-module-menu');
174 this.DebugConsole = Ext.getCmp('typo3-debug-console');
175
176 }
177 });
178
179 Ext.reg('typo3Viewport', TYPO3.Viewport);