4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
13 * @class Roo.bootstrap.layout.Manager
14 * @extends Roo.bootstrap.Component
16 * Base class for layout managers.
18 Roo.bootstrap.layout.Manager = function(config)
20 this.monitorWindowResize = true; // do this before we apply configuration.
22 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
28 /** false to disable window resize monitoring @type Boolean */
34 * Fires when a layout is performed.
35 * @param {Roo.LayoutManager} this
39 * @event regionresized
40 * Fires when the user resizes a region.
41 * @param {Roo.LayoutRegion} region The resized region
42 * @param {Number} newSize The new size (width for east/west, height for north/south)
44 "regionresized" : true,
46 * @event regioncollapsed
47 * Fires when a region is collapsed.
48 * @param {Roo.LayoutRegion} region The collapsed region
50 "regioncollapsed" : true,
52 * @event regionexpanded
53 * Fires when a region is expanded.
54 * @param {Roo.LayoutRegion} region The expanded region
56 "regionexpanded" : true
58 this.updating = false;
61 this.el = Roo.get(config.el);
67 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
72 monitorWindowResize : true,
78 onRender : function(ct, position)
81 this.el = Roo.get(ct);
84 //this.fireEvent('render',this);
88 initEvents: function()
93 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
94 document.body.scroll = "no";
95 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
96 this.el.position('relative');
99 this.el.addClass("roo-layout-container");
100 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
101 if(this.el.dom != document.body ) {
102 this.el.on('resize', this.layout,this);
103 this.el.on('show', this.layout,this);
109 * Returns true if this layout is currently being updated
112 isUpdating : function(){
113 return this.updating;
117 * Suspend the LayoutManager from doing auto-layouts while
118 * making multiple add or remove calls
120 beginUpdate : function(){
121 this.updating = true;
125 * Restore auto-layouts and optionally disable the manager from performing a layout
126 * @param {Boolean} noLayout true to disable a layout update
128 endUpdate : function(noLayout){
129 this.updating = false;
139 onRegionResized : function(region, newSize){
140 this.fireEvent("regionresized", region, newSize);
144 onRegionCollapsed : function(region){
145 this.fireEvent("regioncollapsed", region);
148 onRegionExpanded : function(region){
149 this.fireEvent("regionexpanded", region);
153 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
154 * performs box-model adjustments.
155 * @return {Object} The size as an object {width: (the width), height: (the height)}
157 getViewSize : function()
160 if(this.el.dom != document.body){
161 size = this.el.getSize();
163 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
165 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
166 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
171 * Returns the Element this layout is bound to.
172 * @return {Roo.Element}
179 * Returns the specified region.
180 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
181 * @return {Roo.LayoutRegion}
183 getRegion : function(target){
184 return this.regions[target.toLowerCase()];
187 onWindowResize : function(){
188 if(this.monitorWindowResize){