3 * Copyright(c) 2006-2010 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.layout.BorderLayout
9 * @extends Ext.layout.ContainerLayout
10 * <p>This is a multi-pane, application-oriented UI layout style that supports multiple
11 * nested panels, automatic {@link Ext.layout.BorderLayout.Region#split split} bars between
12 * {@link Ext.layout.BorderLayout.Region#BorderLayout.Region regions} and built-in
13 * {@link Ext.layout.BorderLayout.Region#collapsible expanding and collapsing} of regions.</p>
14 * <p>This class is intended to be extended or created via the <tt>layout:'border'</tt>
15 * {@link Ext.Container#layout} config, and should generally not need to be created directly
16 * via the new keyword.</p>
17 * <p>BorderLayout does not have any direct config options (other than inherited ones).
18 * All configuration options available for customizing the BorderLayout are at the
19 * {@link Ext.layout.BorderLayout.Region} and {@link Ext.layout.BorderLayout.SplitRegion}
21 * <p>Example usage:</p>
23 var myBorderPanel = new Ext.Panel({
24 {@link Ext.Component#renderTo renderTo}: document.body,
25 {@link Ext.BoxComponent#width width}: 700,
26 {@link Ext.BoxComponent#height height}: 500,
27 {@link Ext.Panel#title title}: 'Border Layout',
28 {@link Ext.Container#layout layout}: 'border',
29 {@link Ext.Container#items items}: [{
30 {@link Ext.Panel#title title}: 'South Region is resizable',
31 {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}: 'south', // position for region
32 {@link Ext.BoxComponent#height height}: 100,
33 {@link Ext.layout.BorderLayout.Region#split split}: true, // enable resizing
34 {@link Ext.SplitBar#minSize minSize}: 75, // defaults to {@link Ext.layout.BorderLayout.Region#minHeight 50}
35 {@link Ext.SplitBar#maxSize maxSize}: 150,
36 {@link Ext.layout.BorderLayout.Region#margins margins}: '0 5 5 5'
38 // xtype: 'panel' implied by default
39 {@link Ext.Panel#title title}: 'West Region is collapsible',
40 {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}:'west',
41 {@link Ext.layout.BorderLayout.Region#margins margins}: '5 0 0 5',
42 {@link Ext.BoxComponent#width width}: 200,
43 {@link Ext.layout.BorderLayout.Region#collapsible collapsible}: true, // make collapsible
44 {@link Ext.layout.BorderLayout.Region#cmargins cmargins}: '5 5 0 5', // adjust top margin when collapsed
45 {@link Ext.Component#id id}: 'west-region-container',
46 {@link Ext.Container#layout layout}: 'fit',
47 {@link Ext.Panel#unstyled unstyled}: true
49 {@link Ext.Panel#title title}: 'Center Region',
50 {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}: 'center', // center region is required, no width/height specified
51 {@link Ext.Component#xtype xtype}: 'container',
52 {@link Ext.Container#layout layout}: 'fit',
53 {@link Ext.layout.BorderLayout.Region#margins margins}: '5 5 0 0'
57 * <p><b><u>Notes</u></b>:</p><div class="mdetail-params"><ul>
58 * <li>Any container using the BorderLayout <b>must</b> have a child item with <tt>region:'center'</tt>.
59 * The child item in the center region will always be resized to fill the remaining space not used by
60 * the other regions in the layout.</li>
61 * <li>Any child items with a region of <tt>west</tt> or <tt>east</tt> must have <tt>width</tt> defined
62 * (an integer representing the number of pixels that the region should take up).</li>
63 * <li>Any child items with a region of <tt>north</tt> or <tt>south</tt> must have <tt>height</tt> defined.</li>
64 * <li>The regions of a BorderLayout are <b>fixed at render time</b> and thereafter, its child Components may not be removed or added</b>. To add/remove
65 * Components within a BorderLayout, have them wrapped by an additional Container which is directly
66 * managed by the BorderLayout. If the region is to be collapsible, the Container used directly
67 * by the BorderLayout manager should be a Panel. In the following example a Container (an Ext.Panel)
68 * is added to the west region:
69 * <div style="margin-left:16px"><pre><code>
70 wrc = {@link Ext#getCmp Ext.getCmp}('west-region-container');
71 wrc.{@link Ext.Panel#removeAll removeAll}();
72 wrc.{@link Ext.Container#add add}({
76 wrc.{@link Ext.Container#doLayout doLayout}();
79 * <li> To reference a {@link Ext.layout.BorderLayout.Region Region}:
80 * <div style="margin-left:16px"><pre><code>
81 wr = myBorderPanel.layout.west;
86 Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {
94 targetCls: 'x-border-layout-ct',
96 getLayoutTargetSize : function() {
97 var target = this.container.getLayoutTarget();
98 return target ? target.getViewSize() : {};
102 onLayout : function(ct, target){
103 var collapsed, i, c, pos, items = ct.items.items, len = items.length;
106 for(i = 0; i < len; i++) {
115 c.getPositionEl().addClass('x-border-panel');
117 this[pos] = pos != 'center' && c.split ?
118 new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
119 new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
120 this[pos].render(target, c);
122 this.rendered = true;
125 var size = this.getLayoutTargetSize();
126 if(size.width < 20 || size.height < 20){ // display none?
128 this.restoreCollapsed = collapsed;
131 }else if(this.restoreCollapsed){
132 collapsed = this.restoreCollapsed;
133 delete this.restoreCollapsed;
136 var w = size.width, h = size.height,
137 centerW = w, centerH = h, centerY = 0, centerX = 0,
138 n = this.north, s = this.south, west = this.west, e = this.east, c = this.center,
139 b, m, totalWidth, totalHeight;
140 if(!c && Ext.layout.BorderLayout.WARN !== false){
141 throw 'No center region defined in BorderLayout ' + ct.id;
144 if(n && n.isVisible()){
147 b.width = w - (m.left+m.right);
150 centerY = b.height + b.y + m.bottom;
154 if(s && s.isVisible()){
157 b.width = w - (m.left+m.right);
159 totalHeight = (b.height + m.top + m.bottom);
160 b.y = h - totalHeight + m.top;
161 centerH -= totalHeight;
164 if(west && west.isVisible()){
166 m = west.getMargins();
167 b.height = centerH - (m.top+m.bottom);
169 b.y = centerY + m.top;
170 totalWidth = (b.width + m.left + m.right);
171 centerX += totalWidth;
172 centerW -= totalWidth;
175 if(e && e.isVisible()){
178 b.height = centerH - (m.top+m.bottom);
179 totalWidth = (b.width + m.left + m.right);
180 b.x = w - totalWidth + m.left;
181 b.y = centerY + m.top;
182 centerW -= totalWidth;
190 width: centerW - (m.left+m.right),
191 height: centerH - (m.top+m.bottom)
193 c.applyLayout(centerBox);
196 for(i = 0, len = collapsed.length; i < len; i++){
197 collapsed[i].collapse(false);
200 if(Ext.isIE && Ext.isStrict){ // workaround IE strict repainting issue
203 // Putting a border layout into an overflowed container is NOT correct and will make a second layout pass necessary.
204 if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
205 var ts = this.getLayoutTargetSize();
206 if (ts.width != size.width || ts.height != size.height){
207 this.adjustmentPass = true;
208 this.onLayout(ct, target);
211 delete this.adjustmentPass;
214 destroy: function() {
215 var r = ['north', 'south', 'east', 'west'], i, region;
216 for (i = 0; i < r.length; i++) {
221 }else if (region.split){
222 region.split.destroy(true);
226 Ext.layout.BorderLayout.superclass.destroy.call(this);
230 * @property activeItem
236 * @class Ext.layout.BorderLayout.Region
237 * <p>This is a region of a {@link Ext.layout.BorderLayout BorderLayout} that acts as a subcontainer
238 * within the layout. Each region has its own {@link Ext.layout.ContainerLayout layout} that is
239 * independent of other regions and the containing BorderLayout, and can be any of the
240 * {@link Ext.layout.ContainerLayout valid Ext layout types}.</p>
241 * <p>Region size is managed automatically and cannot be changed by the user -- for
242 * {@link #split resizable regions}, see {@link Ext.layout.BorderLayout.SplitRegion}.</p>
244 * Create a new Region.
245 * @param {Layout} layout The {@link Ext.layout.BorderLayout BorderLayout} instance that is managing this Region.
246 * @param {Object} config The configuration options
247 * @param {String} position The region position. Valid values are: <tt>north</tt>, <tt>south</tt>,
248 * <tt>east</tt>, <tt>west</tt> and <tt>center</tt>. Every {@link Ext.layout.BorderLayout BorderLayout}
249 * <b>must have a center region</b> for the primary content -- all other regions are optional.
251 Ext.layout.BorderLayout.Region = function(layout, config, pos){
252 Ext.apply(this, config);
253 this.layout = layout;
256 if(typeof this.margins == 'string'){
257 this.margins = this.layout.parseMargins(this.margins);
259 this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins);
260 if(this.collapsible){
261 if(typeof this.cmargins == 'string'){
262 this.cmargins = this.layout.parseMargins(this.cmargins);
264 if(this.collapseMode == 'mini' && !this.cmargins){
265 this.cmargins = {left:0,top:0,right:0,bottom:0};
267 this.cmargins = Ext.applyIf(this.cmargins || {},
268 pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
273 Ext.layout.BorderLayout.Region.prototype = {
275 * @cfg {Boolean} animFloat
276 * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated
277 * panel that will close again once the user mouses out of that panel (or clicks out if
278 * <tt>{@link #autoHide} = false</tt>). Setting <tt>{@link #animFloat} = false</tt> will
279 * prevent the open and close of these floated panels from being animated (defaults to <tt>true</tt>).
282 * @cfg {Boolean} autoHide
283 * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated
284 * panel. If <tt>autoHide = true</tt>, the panel will automatically hide after the user mouses
285 * out of the panel. If <tt>autoHide = false</tt>, the panel will continue to display until the
286 * user clicks outside of the panel (defaults to <tt>true</tt>).
289 * @cfg {String} collapseMode
290 * <tt>collapseMode</tt> supports two configuration values:<div class="mdetail-params"><ul>
291 * <li><b><tt>undefined</tt></b> (default)<div class="sub-desc">By default, {@link #collapsible}
292 * regions are collapsed by clicking the expand/collapse tool button that renders into the region's
293 * title bar.</div></li>
294 * <li><b><tt>'mini'</tt></b><div class="sub-desc">Optionally, when <tt>collapseMode</tt> is set to
295 * <tt>'mini'</tt> the region's split bar will also display a small collapse button in the center of
296 * the bar. In <tt>'mini'</tt> mode the region will collapse to a thinner bar than in normal mode.
299 * <p><b>Note</b>: if a collapsible region does not have a title bar, then set <tt>collapseMode =
300 * 'mini'</tt> and <tt>{@link #split} = true</tt> in order for the region to be {@link #collapsible}
301 * by the user as the expand/collapse tool button (that would go in the title bar) will not be rendered.</p>
302 * <p>See also <tt>{@link #cmargins}</tt>.</p>
305 * @cfg {Object} margins
306 * An object containing margins to apply to the region when in the expanded state in the
310 right: (right margin),
311 bottom: (bottom margin),
314 * <p>May also be a string containing space-separated, numeric margin values. The order of the
315 * sides associated with each value matches the way CSS processes margin values:</p>
316 * <p><div class="mdetail-params"><ul>
317 * <li>If there is only one value, it applies to all sides.</li>
318 * <li>If there are two values, the top and bottom borders are set to the first value and the
319 * right and left are set to the second.</li>
320 * <li>If there are three values, the top is set to the first value, the left and right are set
321 * to the second, and the bottom is set to the third.</li>
322 * <li>If there are four values, they apply to the top, right, bottom, and left, respectively.</li>
324 * <p>Defaults to:</p><pre><code>
325 * {top:0, right:0, bottom:0, left:0}
329 * @cfg {Object} cmargins
330 * An object containing margins to apply to the region when in the collapsed state in the
334 right: (right margin),
335 bottom: (bottom margin),
338 * <p>May also be a string containing space-separated, numeric margin values. The order of the
339 * sides associated with each value matches the way CSS processes margin values.</p>
341 * <li>If there is only one value, it applies to all sides.</li>
342 * <li>If there are two values, the top and bottom borders are set to the first value and the
343 * right and left are set to the second.</li>
344 * <li>If there are three values, the top is set to the first value, the left and right are set
345 * to the second, and the bottom is set to the third.</li>
346 * <li>If there are four values, they apply to the top, right, bottom, and left, respectively.</li>
350 * @cfg {Boolean} collapsible
351 * <p><tt>true</tt> to allow the user to collapse this region (defaults to <tt>false</tt>). If
352 * <tt>true</tt>, an expand/collapse tool button will automatically be rendered into the title
353 * bar of the region, otherwise the button will not be shown.</p>
354 * <p><b>Note</b>: that a title bar is required to display the collapse/expand toggle button -- if
355 * no <tt>title</tt> is specified for the region's panel, the region will only be collapsible if
356 * <tt>{@link #collapseMode} = 'mini'</tt> and <tt>{@link #split} = true</tt>.
360 * @cfg {Boolean} split
361 * <p><tt>true</tt> to create a {@link Ext.layout.BorderLayout.SplitRegion SplitRegion} and
362 * display a 5px wide {@link Ext.SplitBar} between this region and its neighbor, allowing the user to
363 * resize the regions dynamically. Defaults to <tt>false</tt> creating a
364 * {@link Ext.layout.BorderLayout.Region Region}.</p><br>
365 * <p><b>Notes</b>:</p><div class="mdetail-params"><ul>
366 * <li>this configuration option is ignored if <tt>region='center'</tt></li>
367 * <li>when <tt>split == true</tt>, it is common to specify a
368 * <tt>{@link Ext.SplitBar#minSize minSize}</tt> and <tt>{@link Ext.SplitBar#maxSize maxSize}</tt>
369 * for the {@link Ext.BoxComponent BoxComponent} representing the region. These are not native
370 * configs of {@link Ext.BoxComponent BoxComponent}, and are used only by this class.</li>
371 * <li>if <tt>{@link #collapseMode} = 'mini'</tt> requires <tt>split = true</tt> to reserve space
372 * for the collapse tool</tt></li>
377 * @cfg {Boolean} floatable
378 * <tt>true</tt> to allow clicking a collapsed region's bar to display the region's panel floated
379 * above the layout, <tt>false</tt> to force the user to fully expand a collapsed region by
380 * clicking the expand button to see it again (defaults to <tt>true</tt>).
384 * @cfg {Number} minWidth
385 * <p>The minimum allowable width in pixels for this region (defaults to <tt>50</tt>).
386 * <tt>maxWidth</tt> may also be specified.</p><br>
387 * <p><b>Note</b>: setting the <tt>{@link Ext.SplitBar#minSize minSize}</tt> /
388 * <tt>{@link Ext.SplitBar#maxSize maxSize}</tt> supersedes any specified
389 * <tt>minWidth</tt> / <tt>maxWidth</tt>.</p>
393 * @cfg {Number} minHeight
394 * The minimum allowable height in pixels for this region (defaults to <tt>50</tt>)
395 * <tt>maxHeight</tt> may also be specified.</p><br>
396 * <p><b>Note</b>: setting the <tt>{@link Ext.SplitBar#minSize minSize}</tt> /
397 * <tt>{@link Ext.SplitBar#maxSize maxSize}</tt> supersedes any specified
398 * <tt>minHeight</tt> / <tt>maxHeight</tt>.</p>
403 defaultMargins : {left:0,top:0,right:0,bottom:0},
405 defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
407 defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
411 * True if this region is collapsed. Read-only.
418 * This region's panel. Read-only.
423 * This region's layout. Read-only.
428 * This region's layout position (north, south, east, west or center). Read-only.
434 render : function(ct, p){
436 p.el.enableDisplayMode();
440 var gs = p.getState, ps = this.position;
441 p.getState = function(){
442 return Ext.apply(gs.call(p) || {}, this.state);
443 }.createDelegate(this);
446 p.allowQueuedExpand = false;
448 beforecollapse: this.beforeCollapse,
449 collapse: this.onCollapse,
450 beforeexpand: this.beforeExpand,
451 expand: this.onExpand,
456 if(this.collapsible || this.floatable){
458 p.slideAnchor = this.getSlideAnchor();
460 if(p.tools && p.tools.toggle){
461 p.tools.toggle.addClass('x-tool-collapse-'+ps);
462 p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
468 getCollapsedEl : function(){
469 if(!this.collapsedEl){
470 if(!this.toolTemplate){
471 var tt = new Ext.Template(
472 '<div class="x-tool x-tool-{id}"> </div>'
474 tt.disableFormats = true;
476 Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
478 this.collapsedEl = this.targetEl.createChild({
479 cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
480 id: this.panel.id + '-xcollapsed'
482 this.collapsedEl.enableDisplayMode('block');
484 if(this.collapseMode == 'mini'){
485 this.collapsedEl.addClass('x-layout-cmini-'+this.position);
486 this.miniCollapsedEl = this.collapsedEl.createChild({
487 cls: "x-layout-mini x-layout-mini-"+this.position, html: " "
489 this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
490 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
491 this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
493 if(this.collapsible !== false && !this.hideCollapseTool) {
494 var t = this.toolTemplate.append(
495 this.collapsedEl.dom,
496 {id:'expand-'+this.position}, true);
497 t.addClassOnOver('x-tool-expand-'+this.position+'-over');
498 t.on('click', this.onExpandClick, this, {stopEvent:true});
500 if(this.floatable !== false || this.titleCollapse){
501 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
502 this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
506 return this.collapsedEl;
510 onExpandClick : function(e){
512 this.panel.expand(false);
519 onCollapseClick : function(e){
520 this.panel.collapse();
524 beforeCollapse : function(p, animate){
525 this.lastAnim = animate;
529 this.getCollapsedEl().show();
530 var el = this.panel.getEl();
531 this.originalZIndex = el.getStyle('z-index');
532 el.setStyle('z-index', 100);
533 this.isCollapsed = true;
534 this.layout.layout();
538 onCollapse : function(animate){
539 this.panel.el.setStyle('z-index', 1);
540 if(this.lastAnim === false || this.panel.animCollapse === false){
541 this.getCollapsedEl().dom.style.visibility = 'visible';
543 this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
545 this.state.collapsed = true;
546 this.panel.saveState();
550 beforeExpand : function(animate){
554 var c = this.getCollapsedEl();
556 if(this.position == 'east' || this.position == 'west'){
557 this.panel.setSize(undefined, c.getHeight());
559 this.panel.setSize(c.getWidth(), undefined);
562 c.dom.style.visibility = 'hidden';
563 this.panel.el.setStyle('z-index', this.floatingZIndex);
567 onExpand : function(){
568 this.isCollapsed = false;
572 this.layout.layout();
573 this.panel.el.setStyle('z-index', this.originalZIndex);
574 this.state.collapsed = false;
575 this.panel.saveState();
579 collapseClick : function(e){
591 if(this.isCollapsed){
592 this.getCollapsedEl().hide();
593 }else if(this.splitEl){
600 if(this.isCollapsed){
601 this.getCollapsedEl().show();
602 }else if(this.splitEl){
608 * True if this region is currently visible, else false.
611 isVisible : function(){
612 return !this.panel.hidden;
616 * Returns the current margins for this region. If the region is collapsed, the
617 * {@link #cmargins} (collapsed margins) value will be returned, otherwise the
618 * {@link #margins} value will be returned.
619 * @return {Object} An object containing the element's margins: <tt>{left: (left
620 * margin), top: (top margin), right: (right margin), bottom: (bottom margin)}</tt>
622 getMargins : function(){
623 return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
627 * Returns the current size of this region. If the region is collapsed, the size of the
628 * collapsedEl will be returned, otherwise the size of the region's panel will be returned.
629 * @return {Object} An object containing the element's size: <tt>{width: (element width),
630 * height: (element height)}</tt>
632 getSize : function(){
633 return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
637 * Sets the specified panel as the container element for this region.
638 * @param {Ext.Panel} panel The new panel
640 setPanel : function(panel){
645 * Returns the minimum allowable width for this region.
646 * @return {Number} The minimum width
648 getMinWidth: function(){
649 return this.minWidth;
653 * Returns the minimum allowable height for this region.
654 * @return {Number} The minimum height
656 getMinHeight: function(){
657 return this.minHeight;
661 applyLayoutCollapsed : function(box){
662 var ce = this.getCollapsedEl();
663 ce.setLeftTop(box.x, box.y);
664 ce.setSize(box.width, box.height);
668 applyLayout : function(box){
669 if(this.isCollapsed){
670 this.applyLayoutCollapsed(box);
672 this.panel.setPosition(box.x, box.y);
673 this.panel.setSize(box.width, box.height);
678 beforeSlide: function(){
679 this.panel.beforeEffect();
683 afterSlide : function(){
684 this.panel.afterEffect();
688 initAutoHide : function(){
689 if(this.autoHide !== false){
690 if(!this.autoHideHd){
691 var st = new Ext.util.DelayedTask(this.slideIn, this);
693 "mouseout": function(e){
694 if(!e.within(this.el, true)){
698 "mouseover" : function(e){
704 this.el.on(this.autoHideHd);
705 this.collapsedEl.on(this.autoHideHd);
710 clearAutoHide : function(){
711 if(this.autoHide !== false){
712 this.el.un("mouseout", this.autoHideHd.mouseout);
713 this.el.un("mouseover", this.autoHideHd.mouseover);
714 this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
715 this.collapsedEl.un("mouseover", this.autoHideHd.mouseover);
720 clearMonitor : function(){
721 Ext.getDoc().un("click", this.slideInIf, this);
725 * If this Region is {@link #floatable}, this method slides this Region into full visibility <i>over the top
726 * of the center Region</i> where it floats until either {@link #slideIn} is called, or other regions of the layout
727 * are clicked, or the mouse exits the Region.
729 slideOut : function(){
730 if(this.isSlid || this.el.hasActiveFx()){
734 var ts = this.panel.tools, dh, pc;
740 // Temporarily clear the collapsed flag so we can onResize the panel on the slide
741 pc = this.panel.collapsed;
742 this.panel.collapsed = false;
744 if(this.position == 'east' || this.position == 'west'){
745 // Temporarily clear the deferHeight flag so we can size the height on the slide
746 dh = this.panel.deferHeight;
747 this.panel.deferHeight = false;
749 this.panel.setSize(undefined, this.collapsedEl.getHeight());
751 // Put the deferHeight flag back after setSize
752 this.panel.deferHeight = dh;
754 this.panel.setSize(this.collapsedEl.getWidth(), undefined);
757 // Put the collapsed flag back after onResize
758 this.panel.collapsed = pc;
760 this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
761 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
762 this.el.setStyle("z-index", this.floatingZIndex+2);
763 this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
764 if(this.animFloat !== false){
766 this.el.slideIn(this.getSlideAnchor(), {
767 callback: function(){
770 Ext.getDoc().on("click", this.slideInIf, this);
777 Ext.getDoc().on("click", this.slideInIf, this);
782 afterSlideIn : function(){
783 this.clearAutoHide();
786 this.el.setStyle("z-index", "");
787 this.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
788 this.el.dom.style.left = this.restoreLT[0];
789 this.el.dom.style.top = this.restoreLT[1];
791 var ts = this.panel.tools;
798 * If this Region is {@link #floatable}, and this Region has been slid into floating visibility, then this method slides
799 * this region back into its collapsed state.
801 slideIn : function(cb){
802 if(!this.isSlid || this.el.hasActiveFx()){
807 if(this.animFloat !== false){
809 this.el.slideOut(this.getSlideAnchor(), {
810 callback: function(){
826 slideInIf : function(e){
827 if(!e.within(this.el)){
857 getAnchor : function(){
858 return this.anchors[this.position];
862 getCollapseAnchor : function(){
863 return this.canchors[this.position];
867 getSlideAnchor : function(){
868 return this.sanchors[this.position];
872 getAlignAdj : function(){
873 var cm = this.cmargins;
874 switch(this.position){
891 getExpandAdj : function(){
892 var c = this.collapsedEl, cm = this.cmargins;
893 switch(this.position){
895 return [-(cm.right+c.getWidth()+cm.left), 0];
898 return [cm.right+c.getWidth()+cm.left, 0];
901 return [0, -(cm.top+cm.bottom+c.getHeight())];
904 return [0, cm.top+cm.bottom+c.getHeight()];
909 destroy : function(){
910 Ext.destroy(this.miniCollapsedEl, this.collapsedEl);
915 * @class Ext.layout.BorderLayout.SplitRegion
916 * @extends Ext.layout.BorderLayout.Region
917 * <p>This is a specialized type of {@link Ext.layout.BorderLayout.Region BorderLayout region} that
918 * has a built-in {@link Ext.SplitBar} for user resizing of regions. The movement of the split bar
919 * is configurable to move either {@link #tickSize smooth or incrementally}.</p>
921 * Create a new SplitRegion.
922 * @param {Layout} layout The {@link Ext.layout.BorderLayout BorderLayout} instance that is managing this Region.
923 * @param {Object} config The configuration options
924 * @param {String} position The region position. Valid values are: north, south, east, west and center. Every
925 * BorderLayout must have a center region for the primary content -- all other regions are optional.
927 Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
928 Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
930 this.applyLayout = this.applyFns[pos];
933 Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
935 * @cfg {Number} tickSize
936 * The increment, in pixels by which to move this Region's {@link Ext.SplitBar SplitBar}.
937 * By default, the {@link Ext.SplitBar SplitBar} moves smoothly.
940 * @cfg {String} splitTip
941 * The tooltip to display when the user hovers over a
942 * {@link Ext.layout.BorderLayout.Region#collapsible non-collapsible} region's split bar
943 * (defaults to <tt>"Drag to resize."</tt>). Only applies if
944 * <tt>{@link #useSplitTips} = true</tt>.
946 splitTip : "Drag to resize.",
948 * @cfg {String} collapsibleSplitTip
949 * The tooltip to display when the user hovers over a
950 * {@link Ext.layout.BorderLayout.Region#collapsible collapsible} region's split bar
951 * (defaults to "Drag to resize. Double click to hide."). Only applies if
952 * <tt>{@link #useSplitTips} = true</tt>.
954 collapsibleSplitTip : "Drag to resize. Double click to hide.",
956 * @cfg {Boolean} useSplitTips
957 * <tt>true</tt> to display a tooltip when the user hovers over a region's split bar
958 * (defaults to <tt>false</tt>). The tooltip text will be the value of either
959 * <tt>{@link #splitTip}</tt> or <tt>{@link #collapsibleSplitTip}</tt> as appropriate.
961 useSplitTips : false,
966 orientation: Ext.SplitBar.VERTICAL,
967 placement: Ext.SplitBar.TOP,
968 maxFn : 'getVMaxSize',
969 minProp: 'minHeight',
973 orientation: Ext.SplitBar.VERTICAL,
974 placement: Ext.SplitBar.BOTTOM,
975 maxFn : 'getVMaxSize',
976 minProp: 'minHeight',
980 orientation: Ext.SplitBar.HORIZONTAL,
981 placement: Ext.SplitBar.RIGHT,
982 maxFn : 'getHMaxSize',
987 orientation: Ext.SplitBar.HORIZONTAL,
988 placement: Ext.SplitBar.LEFT,
989 maxFn : 'getHMaxSize',
997 west : function(box){
998 if(this.isCollapsed){
999 return this.applyLayoutCollapsed(box);
1001 var sd = this.splitEl.dom, s = sd.style;
1002 this.panel.setPosition(box.x, box.y);
1003 var sw = sd.offsetWidth;
1004 s.left = (box.x+box.width-sw)+'px';
1005 s.top = (box.y)+'px';
1006 s.height = Math.max(0, box.height)+'px';
1007 this.panel.setSize(box.width-sw, box.height);
1009 east : function(box){
1010 if(this.isCollapsed){
1011 return this.applyLayoutCollapsed(box);
1013 var sd = this.splitEl.dom, s = sd.style;
1014 var sw = sd.offsetWidth;
1015 this.panel.setPosition(box.x+sw, box.y);
1016 s.left = (box.x)+'px';
1017 s.top = (box.y)+'px';
1018 s.height = Math.max(0, box.height)+'px';
1019 this.panel.setSize(box.width-sw, box.height);
1021 north : function(box){
1022 if(this.isCollapsed){
1023 return this.applyLayoutCollapsed(box);
1025 var sd = this.splitEl.dom, s = sd.style;
1026 var sh = sd.offsetHeight;
1027 this.panel.setPosition(box.x, box.y);
1028 s.left = (box.x)+'px';
1029 s.top = (box.y+box.height-sh)+'px';
1030 s.width = Math.max(0, box.width)+'px';
1031 this.panel.setSize(box.width, box.height-sh);
1033 south : function(box){
1034 if(this.isCollapsed){
1035 return this.applyLayoutCollapsed(box);
1037 var sd = this.splitEl.dom, s = sd.style;
1038 var sh = sd.offsetHeight;
1039 this.panel.setPosition(box.x, box.y+sh);
1040 s.left = (box.x)+'px';
1041 s.top = (box.y)+'px';
1042 s.width = Math.max(0, box.width)+'px';
1043 this.panel.setSize(box.width, box.height-sh);
1048 render : function(ct, p){
1049 Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
1051 var ps = this.position;
1053 this.splitEl = ct.createChild({
1054 cls: "x-layout-split x-layout-split-"+ps, html: " ",
1055 id: this.panel.id + '-xsplit'
1058 if(this.collapseMode == 'mini'){
1059 this.miniSplitEl = this.splitEl.createChild({
1060 cls: "x-layout-mini x-layout-mini-"+ps, html: " "
1062 this.miniSplitEl.addClassOnOver('x-layout-mini-over');
1063 this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
1066 var s = this.splitSettings[ps];
1068 this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
1069 this.split.tickSize = this.tickSize;
1070 this.split.placement = s.placement;
1071 this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
1072 this.split.minSize = this.minSize || this[s.minProp];
1073 this.split.on("beforeapply", this.onSplitMove, this);
1074 this.split.useShim = this.useShim === true;
1075 this.maxSize = this.maxSize || this[s.maxProp];
1078 this.splitEl.hide();
1081 if(this.useSplitTips){
1082 this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
1084 if(this.collapsible){
1085 this.splitEl.on("dblclick", this.onCollapseClick, this);
1089 //docs inherit from superclass
1090 getSize : function(){
1091 if(this.isCollapsed){
1092 return this.collapsedEl.getSize();
1094 var s = this.panel.getSize();
1095 if(this.position == 'north' || this.position == 'south'){
1096 s.height += this.splitEl.dom.offsetHeight;
1098 s.width += this.splitEl.dom.offsetWidth;
1104 getHMaxSize : function(){
1105 var cmax = this.maxSize || 10000;
1106 var center = this.layout.center;
1107 return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
1111 getVMaxSize : function(){
1112 var cmax = this.maxSize || 10000;
1113 var center = this.layout.center;
1114 return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
1118 onSplitMove : function(split, newSize){
1119 var s = this.panel.getSize();
1120 this.lastSplitSize = newSize;
1121 if(this.position == 'north' || this.position == 'south'){
1122 this.panel.setSize(s.width, newSize);
1123 this.state.height = newSize;
1125 this.panel.setSize(newSize, s.height);
1126 this.state.width = newSize;
1128 this.layout.layout();
1129 this.panel.saveState();
1134 * Returns a reference to the split bar in use by this region.
1135 * @return {Ext.SplitBar} The split bar
1137 getSplitBar : function(){
1142 destroy : function() {
1143 Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
1144 Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
1148 Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;