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.bootstrap.layout.Split = function(config){
20 this.cursor = config.cursor;
21 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
24 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
26 splitTip : "Drag to resize.",
27 collapsibleSplitTip : "Drag to resize. Double click to hide.",
30 applyConfig : function(config){
31 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
34 onRender : function(ctr,pos) {
36 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
37 if(!this.config.split){
42 var splitEl = Roo.DomHelper.append(ctr.dom, {
44 id: this.el.id + "-split",
45 cls: "roo-layout-split roo-layout-split-"+this.position,
48 /** The SplitBar for this region
49 * @type Roo.SplitBar */
50 // does not exist yet...
51 Roo.log([this.position, this.orientation]);
53 this.split = new Roo.bootstrap.SplitBar({
54 dragElement : splitEl,
55 resizingElement: this.el,
56 orientation : this.orientation
59 this.split.on("moved", this.onSplitMove, this);
60 this.split.useShim = this.config.useShim === true;
61 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
62 if(this.useSplitTips){
63 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
65 //if(config.collapsible){
66 // this.split.el.on("dblclick", this.collapse, this);
69 if(typeof this.config.minSize != "undefined"){
70 this.split.minSize = this.config.minSize;
72 if(typeof this.config.maxSize != "undefined"){
73 this.split.maxSize = this.config.maxSize;
75 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
81 getHMaxSize : function(){
82 var cmax = this.config.maxSize || 10000;
83 var center = this.mgr.getRegion("center");
84 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
87 getVMaxSize : function(){
88 var cmax = this.config.maxSize || 10000;
89 var center = this.mgr.getRegion("center");
90 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
93 onSplitMove : function(split, newSize){
94 this.fireEvent("resized", this, newSize);
98 * Returns the {@link Roo.SplitBar} for this region.
99 * @return {Roo.SplitBar}
101 getSplitBar : function(){
107 Roo.bootstrap.layout.Split.superclass.hide.call(this);
110 hideSplitter : function(){
112 this.split.el.setLocation(-2000,-2000);
113 this.split.el.hide();
119 this.split.el.show();
121 Roo.bootstrap.layout.Split.superclass.show.call(this);
124 beforeSlide: function(){
125 if(Roo.isGecko){// firefox overflow auto bug workaround
128 this.tabs.bodyEl.clip();
130 if(this.activePanel){
131 this.activePanel.getEl().clip();
133 if(this.activePanel.beforeSlide){
134 this.activePanel.beforeSlide();
140 afterSlide : function(){
141 if(Roo.isGecko){// firefox overflow auto bug workaround
142 this.bodyEl.unclip();
144 this.tabs.bodyEl.unclip();
146 if(this.activePanel){
147 this.activePanel.getEl().unclip();
148 if(this.activePanel.afterSlide){
149 this.activePanel.afterSlide();
155 initAutoHide : function(){
156 if(this.autoHide !== false){
157 if(!this.autoHideHd){
158 var st = new Roo.util.DelayedTask(this.slideIn, this);
160 "mouseout": function(e){
161 if(!e.within(this.el, true)){
165 "mouseover" : function(e){
171 this.el.on(this.autoHideHd);
175 clearAutoHide : function(){
176 if(this.autoHide !== false){
177 this.el.un("mouseout", this.autoHideHd.mouseout);
178 this.el.un("mouseover", this.autoHideHd.mouseover);
182 clearMonitor : function(){
183 Roo.get(document).un("click", this.slideInIf, this);
186 // these names are backwards but not changed for compat
187 slideOut : function(){
188 if(this.isSlid || this.el.hasActiveFx()){
192 if(this.collapseBtn){
193 this.collapseBtn.hide();
195 this.closeBtnState = this.closeBtn.getStyle('display');
196 this.closeBtn.hide();
198 this.stickBtn.show();
201 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
203 this.el.setStyle("z-index", 10001);
204 this.el.slideIn(this.getSlideAnchor(), {
205 callback: function(){
208 Roo.get(document).on("click", this.slideInIf, this);
209 this.fireEvent("slideshow", this);
216 afterSlideIn : function(){
217 this.clearAutoHide();
220 this.el.setStyle("z-index", "");
221 if(this.collapseBtn){
222 this.collapseBtn.show();
224 this.closeBtn.setStyle('display', this.closeBtnState);
226 this.stickBtn.hide();
228 this.fireEvent("slidehide", this);
231 slideIn : function(cb){
232 if(!this.isSlid || this.el.hasActiveFx()){
238 this.el.slideOut(this.getSlideAnchor(), {
239 callback: function(){
240 this.el.setLeftTop(-10000, -10000);
250 slideInIf : function(e){
251 if(!e.within(this.el)){
256 animateCollapse : function(){
258 this.el.setStyle("z-index", 20000);
259 var anchor = this.getSlideAnchor();
260 this.el.slideOut(anchor, {
261 callback : function(){
262 this.el.setStyle("z-index", "");
263 this.collapsedEl.slideIn(anchor, {duration:.3});
265 this.el.setLocation(-10000,-10000);
267 this.fireEvent("collapsed", this);
274 animateExpand : function(){
276 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
277 this.el.setStyle("z-index", 20000);
278 this.collapsedEl.hide({
281 this.el.slideIn(this.getSlideAnchor(), {
282 callback : function(){
283 this.el.setStyle("z-index", "");
286 this.split.el.show();
288 this.fireEvent("invalidated", this);
289 this.fireEvent("expanded", this);
317 getAnchor : function(){
318 return this.anchors[this.position];
321 getCollapseAnchor : function(){
322 return this.canchors[this.position];
325 getSlideAnchor : function(){
326 return this.sanchors[this.position];
329 getAlignAdj : function(){
330 var cm = this.cmargins;
331 switch(this.position){
347 getExpandAdj : function(){
348 var c = this.collapsedEl, cm = this.cmargins;
349 switch(this.position){
351 return [-(cm.right+c.getWidth()+cm.left), 0];
354 return [cm.right+c.getWidth()+cm.left, 0];
357 return [0, -(cm.top+cm.bottom+c.getHeight())];
360 return [0, cm.top+cm.bottom+c.getHeight()];