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">
15 * @class Roo.SplitLayoutRegion
16 * @extends Roo.LayoutRegion
17 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
19 Roo.SplitLayoutRegion = function(mgr, config, pos, cursor){
21 Roo.SplitLayoutRegion.superclass.constructor.call(this, mgr, config, pos);
24 Roo.extend(Roo.SplitLayoutRegion, Roo.LayoutRegion, {
25 splitTip : "Drag to resize.",
26 collapsibleSplitTip : "Drag to resize. Double click to hide.",
29 applyConfig : function(config){
30 Roo.SplitLayoutRegion.superclass.applyConfig.call(this, config);
33 var splitEl = Roo.DomHelper.append(this.mgr.el.dom,
34 {tag: "div", id: this.el.id + "-split", cls: "x-layout-split x-layout-split-"+this.position, html: " "});
35 /** The SplitBar for this region
36 * @type Roo.SplitBar */
37 this.split = new Roo.SplitBar(splitEl, this.el, this.orientation);
38 this.split.on("moved", this.onSplitMove, this);
39 this.split.useShim = config.useShim === true;
40 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
41 if(this.useSplitTips){
42 this.split.el.dom.title = config.collapsible ? this.collapsibleSplitTip : this.splitTip;
44 if(config.collapsible){
45 this.split.el.on("dblclick", this.collapse, this);
48 if(typeof config.minSize != "undefined"){
49 this.split.minSize = config.minSize;
51 if(typeof config.maxSize != "undefined"){
52 this.split.maxSize = config.maxSize;
54 if(config.hideWhenEmpty || config.hidden || config.collapsed){
60 getHMaxSize : function(){
61 var cmax = this.config.maxSize || 10000;
62 var center = this.mgr.getRegion("center");
63 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
66 getVMaxSize : function(){
67 var cmax = this.config.maxSize || 10000;
68 var center = this.mgr.getRegion("center");
69 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
72 onSplitMove : function(split, newSize){
73 this.fireEvent("resized", this, newSize);
77 * Returns the {@link Roo.SplitBar} for this region.
78 * @return {Roo.SplitBar}
80 getSplitBar : function(){
86 Roo.SplitLayoutRegion.superclass.hide.call(this);
89 hideSplitter : function(){
91 this.split.el.setLocation(-2000,-2000);
100 Roo.SplitLayoutRegion.superclass.show.call(this);
103 beforeSlide: function(){
104 if(Roo.isGecko){// firefox overflow auto bug workaround
107 this.tabs.bodyEl.clip();
109 if(this.activePanel){
110 this.activePanel.getEl().clip();
112 if(this.activePanel.beforeSlide){
113 this.activePanel.beforeSlide();
119 afterSlide : function(){
120 if(Roo.isGecko){// firefox overflow auto bug workaround
121 this.bodyEl.unclip();
123 this.tabs.bodyEl.unclip();
125 if(this.activePanel){
126 this.activePanel.getEl().unclip();
127 if(this.activePanel.afterSlide){
128 this.activePanel.afterSlide();
134 initAutoHide : function(){
135 if(this.autoHide !== false){
136 if(!this.autoHideHd){
137 var st = new Roo.util.DelayedTask(this.slideIn, this);
139 "mouseout": function(e){
140 if(!e.within(this.el, true)){
144 "mouseover" : function(e){
150 this.el.on(this.autoHideHd);
154 clearAutoHide : function(){
155 if(this.autoHide !== false){
156 this.el.un("mouseout", this.autoHideHd.mouseout);
157 this.el.un("mouseover", this.autoHideHd.mouseover);
161 clearMonitor : function(){
162 Roo.get(document).un("click", this.slideInIf, this);
165 // these names are backwards but not changed for compat
166 slideOut : function(){
167 if(this.isSlid || this.el.hasActiveFx()){
171 if(this.collapseBtn){
172 this.collapseBtn.hide();
174 this.closeBtnState = this.closeBtn.getStyle('display');
175 this.closeBtn.hide();
177 this.stickBtn.show();
180 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
182 this.el.setStyle("z-index", 10001);
183 this.el.slideIn(this.getSlideAnchor(), {
184 callback: function(){
187 Roo.get(document).on("click", this.slideInIf, this);
188 this.fireEvent("slideshow", this);
195 afterSlideIn : function(){
196 this.clearAutoHide();
199 this.el.setStyle("z-index", "");
200 if(this.collapseBtn){
201 this.collapseBtn.show();
203 this.closeBtn.setStyle('display', this.closeBtnState);
205 this.stickBtn.hide();
207 this.fireEvent("slidehide", this);
210 slideIn : function(cb){
211 if(!this.isSlid || this.el.hasActiveFx()){
217 this.el.slideOut(this.getSlideAnchor(), {
218 callback: function(){
219 this.el.setLeftTop(-10000, -10000);
229 slideInIf : function(e){
230 if(!e.within(this.el)){
235 animateCollapse : function(){
237 this.el.setStyle("z-index", 20000);
238 var anchor = this.getSlideAnchor();
239 this.el.slideOut(anchor, {
240 callback : function(){
241 this.el.setStyle("z-index", "");
242 this.collapsedEl.slideIn(anchor, {duration:.3});
244 this.el.setLocation(-10000,-10000);
246 this.fireEvent("collapsed", this);
253 animateExpand : function(){
255 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
256 this.el.setStyle("z-index", 20000);
257 this.collapsedEl.hide({
260 this.el.slideIn(this.getSlideAnchor(), {
261 callback : function(){
262 this.el.setStyle("z-index", "");
265 this.split.el.show();
267 this.fireEvent("invalidated", this);
268 this.fireEvent("expanded", this);
296 getAnchor : function(){
297 return this.anchors[this.position];
300 getCollapseAnchor : function(){
301 return this.canchors[this.position];
304 getSlideAnchor : function(){
305 return this.sanchors[this.position];
308 getAlignAdj : function(){
309 var cm = this.cmargins;
310 switch(this.position){
326 getExpandAdj : function(){
327 var c = this.collapsedEl, cm = this.cmargins;
328 switch(this.position){
330 return [-(cm.right+c.getWidth()+cm.left), 0];
333 return [cm.right+c.getWidth()+cm.left, 0];
336 return [0, -(cm.top+cm.bottom+c.getHeight())];
339 return [0, cm.top+cm.bottom+c.getHeight()];