f2d9f78d93957b9cf6440f9e3e5ccd498cdf9def
[roojs1] / Roo / bootstrap / layout / Center.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11 /*
12  * These classes are private internal classes
13  */
14 Roo.bootstrap.layout.Center = function(config){
15     config.region = "center";
16     Roo.bootstrap.layout.Region.call(this, config);
17     this.visible = true;
18     this.minWidth = config.minWidth || 20;
19     this.minHeight = config.minHeight || 20;
20 };
21
22 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
23     hide : function(){
24         // center panel can't be hidden
25     },
26     
27     show : function(){
28         // center panel can't be hidden
29     },
30     
31     getMinWidth: function(){
32         return this.minWidth;
33     },
34     
35     getMinHeight: function(){
36         return this.minHeight;
37     }
38 });
39
40
41
42
43  
44
45
46
47
48
49 Roo.bootstrap.layout.North = function(config)
50 {
51     config.region = 'north';
52     config.cursor = 'n-resize';
53     
54     Roo.bootstrap.layout.Split.call(this, config);
55     
56     
57     if(this.split){
58         this.split.placement = Roo.bootstrap.SplitBar.TOP;
59         this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
60         this.split.el.addClass("roo-layout-split-v");
61     }
62     var size = config.initialSize || config.height;
63     if(typeof size != "undefined"){
64         this.el.setHeight(size);
65     }
66 };
67 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
68 {
69     orientation: Roo.bootstrap.SplitBar.VERTICAL,
70     
71     
72     
73     getBox : function(){
74         if(this.collapsed){
75             return this.collapsedEl.getBox();
76         }
77         var box = this.el.getBox();
78         if(this.split){
79             box.height += this.split.el.getHeight();
80         }
81         return box;
82     },
83     
84     updateBox : function(box){
85         if(this.split && !this.collapsed){
86             box.height -= this.split.el.getHeight();
87             this.split.el.setLeft(box.x);
88             this.split.el.setTop(box.y+box.height);
89             this.split.el.setWidth(box.width);
90         }
91         if(this.collapsed){
92             this.updateBody(box.width, null);
93         }
94         Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
95     }
96 });
97
98
99
100
101
102 Roo.bootstrap.layout.South = function(config){
103     config.region = 'south';
104     config.cursor = 's-resize';
105     Roo.bootstrap.layout.Split.call(this, config);
106     if(this.split){
107         this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
108         this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
109         this.split.el.addClass("roo-layout-split-v");
110     }
111     var size = config.initialSize || config.height;
112     if(typeof size != "undefined"){
113         this.el.setHeight(size);
114     }
115 };
116
117 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
118     orientation: Roo.bootstrap.SplitBar.VERTICAL,
119     getBox : function(){
120         if(this.collapsed){
121             return this.collapsedEl.getBox();
122         }
123         var box = this.el.getBox();
124         if(this.split){
125             var sh = this.split.el.getHeight();
126             box.height += sh;
127             box.y -= sh;
128         }
129         return box;
130     },
131     
132     updateBox : function(box){
133         if(this.split && !this.collapsed){
134             var sh = this.split.el.getHeight();
135             box.height -= sh;
136             box.y += sh;
137             this.split.el.setLeft(box.x);
138             this.split.el.setTop(box.y-sh);
139             this.split.el.setWidth(box.width);
140         }
141         if(this.collapsed){
142             this.updateBody(box.width, null);
143         }
144         Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
145     }
146 });
147
148 Roo.bootstrap.layout.East = function(config){
149     config.region = "east";
150     config.cursor = "e-resize";
151     Roo.bootstrap.layout.Split.call(this, config);
152     if(this.split){
153         this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
154         this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
155         this.split.el.addClass("roo-layout-split-h");
156     }
157     var size = config.initialSize || config.width;
158     if(typeof size != "undefined"){
159         this.el.setWidth(size);
160     }
161 };
162 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
163     orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
164     getBox : function(){
165         if(this.collapsed){
166             return this.collapsedEl.getBox();
167         }
168         var box = this.el.getBox();
169         if(this.split){
170             var sw = this.split.el.getWidth();
171             box.width += sw;
172             box.x -= sw;
173         }
174         return box;
175     },
176
177     updateBox : function(box){
178         if(this.split && !this.collapsed){
179             var sw = this.split.el.getWidth();
180             box.width -= sw;
181             this.split.el.setLeft(box.x);
182             this.split.el.setTop(box.y);
183             this.split.el.setHeight(box.height);
184             box.x += sw;
185         }
186         if(this.collapsed){
187             this.updateBody(null, box.height);
188         }
189         Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
190     }
191 });
192
193 Roo.bootstrap.layout.West = function(config){
194     config.region = "west";
195     config.cursor = "w-resize";
196     
197     Roo.bootstrap.layout.Split.call(this, config);
198     if(this.split){
199         this.split.placement = Roo.bootstrap.SplitBar.LEFT;
200         this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
201         this.split.el.addClass("roo-layout-split-h");
202     }
203     
204 };
205 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
206     orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
207     
208     onRender: function(ctr, pos)
209     {
210         Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
211         var size = this.config.initialSize || this.config.width;
212         if(typeof size != "undefined"){
213             this.el.setWidth(size);
214         }
215     },
216     
217     getBox : function(){
218         if(this.collapsed){
219             return this.collapsedEl.getBox();
220         }
221         var box = this.el.getBox();
222         if(this.split){
223             box.width += this.split.el.getWidth();
224         }
225         return box;
226     },
227     
228     updateBox : function(box){
229         if(this.split && !this.collapsed){
230             var sw = this.split.el.getWidth();
231             box.width -= sw;
232             this.split.el.setLeft(box.x+box.width);
233             this.split.el.setTop(box.y);
234             this.split.el.setHeight(box.height);
235         }
236         if(this.collapsed){
237             this.updateBody(null, box.height);
238         }
239         Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
240     }
241 });