4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-layout-container-Border'>/**
19 </span> * This is a multi-pane, application-oriented UI layout style that supports multiple nested panels, automatic bars
20 * between regions and built-in {@link Ext.panel.Panel#collapsible expanding and collapsing} of regions.
22 * This class is intended to be extended or created via the `layout:'border'` {@link Ext.container.Container#layout}
23 * config, and should generally not need to be created directly via the new keyword.
26 * Ext.create('Ext.panel.Panel', {
29 * title: 'Border Layout',
32 * title: 'South Region is resizable',
33 * region: 'south', // position for region
36 * split: true, // enable resizing
39 * // xtype: 'panel' implied by default
40 * title: 'West Region is collapsible',
45 * collapsible: true, // make collapsible
46 * id: 'west-region-container',
49 * title: 'Center Region',
50 * region: 'center', // center region is required, no width/height specified
55 * renderTo: Ext.getBody()
60 * - Any Container using the Border layout **must** have a child item with `region:'center'`.
61 * The child item in the center region will always be resized to fill the remaining space
62 * not used by the other regions in the layout.
64 * - Any child items with a region of `west` or `east` may be configured with either an initial
65 * `width`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage width
66 * **string** (Which is simply divided by 100 and used as a flex value).
67 * The 'center' region has a flex value of `1`.
69 * - Any child items with a region of `north` or `south` may be configured with either an initial
70 * `height`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage height
71 * **string** (Which is simply divided by 100 and used as a flex value).
72 * The 'center' region has a flex value of `1`.
74 * - The regions of a BorderLayout are **fixed at render time** and thereafter, its child
75 * Components may not be removed or added**. To add/remove Components within a BorderLayout,
76 * have them wrapped by an additional Container which is directly managed by the BorderLayout.
77 * If the region is to be collapsible, the Container used directly by the BorderLayout manager
78 * should be a Panel. In the following example a Container (an Ext.panel.Panel) is added to
81 * wrc = {@link Ext#getCmp Ext.getCmp}('west-region-container');
82 * wrc.{@link Ext.container.Container#removeAll removeAll}();
83 * wrc.{@link Ext.container.Container#add add}({
84 * title: 'Added Panel',
85 * html: 'Some content'
88 * - **There is no BorderLayout.Region class in ExtJS 4.0+**
90 Ext.define('Ext.layout.container.Border', {
92 alias: ['layout.border'],
93 extend: 'Ext.layout.container.Container',
94 requires: ['Ext.resizer.Splitter', 'Ext.container.Container', 'Ext.fx.Anim'],
95 alternateClassName: 'Ext.layout.BorderLayout',
97 targetCls: Ext.baseCSSPrefix + 'border-layout-ct',
99 itemCls: Ext.baseCSSPrefix + 'border-item',
101 bindToOwnerCtContainer: true,
103 percentageRe: /(\d+)%/,
112 constructor: function(config) {
113 this.initialConfig = config;
114 this.callParent(arguments);
117 onLayout: function() {
119 if (!me.borderLayoutInitialized) {
120 me.initializeBorderLayout();
123 // Delegate this operation to the shadow "V" or "H" box layout, and then down to any embedded layout.
124 me.fixHeightConstraints();
125 me.shadowLayout.onLayout();
126 if (me.embeddedContainer) {
127 me.embeddedContainer.layout.onLayout();
130 // If the panel was originally configured with collapsed: true, it will have
131 // been initialized with a "borderCollapse" flag: Collapse it now before the first layout.
132 if (!me.initialCollapsedComplete) {
133 Ext.iterate(me.regions, function(name, region){
134 if (region.borderCollapse) {
135 me.onBeforeRegionCollapse(region, region.collapseDirection, false, 0);
138 me.initialCollapsedComplete = true;
142 isValidParent : function(item, target, position) {
143 if (!this.borderLayoutInitialized) {
144 this.initializeBorderLayout();
147 // Delegate this operation to the shadow "V" or "H" box layout.
148 return this.shadowLayout.isValidParent(item, target, position);
151 beforeLayout: function() {
152 if (!this.borderLayoutInitialized) {
153 this.initializeBorderLayout();
156 // Delegate this operation to the shadow "V" or "H" box layout.
157 this.shadowLayout.beforeLayout();
159 // note: don't call base because that does a renderItems again
162 renderItems: function(items, target) {
164 Ext.Error.raise('This should not be called');
168 renderItem: function(item) {
170 Ext.Error.raise('This should not be called');
174 renderChildren: function() {
175 if (!this.borderLayoutInitialized) {
176 this.initializeBorderLayout();
179 this.shadowLayout.renderChildren();
183 * Gathers items for a layout operation. Injected into child Box layouts through configuration.
184 * We must not include child items which are floated over the layout (are primed with a slide out animation)
186 getVisibleItems: function() {
187 return Ext.ComponentQuery.query(':not([slideOutAnim])', this.callParent(arguments));
190 initializeBorderLayout: function() {
193 items = me.getLayoutItems(),
195 regions = (me.regions = {}),
202 // Map of Splitters for each region
206 for (; i < ln; i++) {
208 regions[comp.region] = comp;
210 // Intercept collapsing to implement showing an alternate Component as a collapsed placeholder
211 if (comp.region != 'center' && comp.collapsible && comp.collapseMode != 'header') {
213 // This layout intercepts any initial collapsed state. Panel must not do this itself.
214 comp.borderCollapse = comp.collapsed;
215 comp.collapsed = false;
218 beforecollapse: me.onBeforeRegionCollapse,
219 beforeexpand: me.onBeforeRegionExpand,
220 destroy: me.onRegionDestroy,
227 if (!regions.center) {
228 Ext.Error.raise("You must specify a center region when defining a BorderLayout.");
231 comp = regions.center;
236 comp.maintainFlex = true;
238 // Begin the VBox and HBox item list.
241 comp.collapseDirection = Ext.Component.DIRECTION_LEFT;
242 hBoxItems.push(comp);
244 hBoxItems.push(me.splitters.west = me.createSplitter(comp));
246 percentage = Ext.isString(comp.width) && comp.width.match(me.percentageRe);
248 horizontalFlex += (comp.flex = parseInt(percentage[1], 10) / 100);
252 comp = regions.north;
254 comp.collapseDirection = Ext.Component.DIRECTION_TOP;
255 vBoxItems.push(comp);
257 vBoxItems.push(me.splitters.north = me.createSplitter(comp));
259 percentage = Ext.isString(comp.height) && comp.height.match(me.percentageRe);
261 verticalFlex += (comp.flex = parseInt(percentage[1], 10) / 100);
266 // Decide into which Collection the center region goes.
267 if (regions.north || regions.south) {
268 if (regions.east || regions.west) {
270 // Create the embedded center. Mark it with the region: 'center' property so that it can be identified as the center.
271 vBoxItems.push(me.embeddedContainer = Ext.create('Ext.container.Container', {
274 id: me.owner.id + '-embedded-center',
275 cls: Ext.baseCSSPrefix + 'border-item',
276 flex: regions.center.flex,
281 getVisibleItems: me.getVisibleItems
284 hBoxItems.push(regions.center);
286 // No east or west: the original center goes straight into the vbox
288 vBoxItems.push(regions.center);
291 // If we have no north or south, then the center is part of the HBox items
293 hBoxItems.push(regions.center);
296 // Finish off the VBox and HBox item list.
297 comp = regions.south;
299 comp.collapseDirection = Ext.Component.DIRECTION_BOTTOM;
301 vBoxItems.push(me.splitters.south = me.createSplitter(comp));
303 percentage = Ext.isString(comp.height) && comp.height.match(me.percentageRe);
305 verticalFlex += (comp.flex = parseInt(percentage[1], 10) / 100);
308 vBoxItems.push(comp);
312 comp.collapseDirection = Ext.Component.DIRECTION_RIGHT;
314 hBoxItems.push(me.splitters.east = me.createSplitter(comp));
316 percentage = Ext.isString(comp.width) && comp.width.match(me.percentageRe);
318 horizontalFlex += (comp.flex = parseInt(percentage[1], 10) / 100);
321 hBoxItems.push(comp);
324 // Create the injected "items" collections for the Containers.
325 // If we have north or south, then the shadow Container will be a VBox.
326 // If there are also east or west regions, its center will be a shadow HBox.
327 // If there are *only* east or west regions, then the shadow layout will be an HBox (or Fit).
328 if (regions.north || regions.south) {
330 me.shadowContainer = Ext.create('Ext.container.Container', {
333 layout: Ext.applyIf({
336 getVisibleItems: me.getVisibleItems
339 me.createItems(me.shadowContainer, vBoxItems);
341 // Allow the Splitters to orientate themselves
342 if (me.splitters.north) {
343 me.splitters.north.ownerCt = me.shadowContainer;
345 if (me.splitters.south) {
346 me.splitters.south.ownerCt = me.shadowContainer;
349 // Inject items into the HBox Container if there is one - if there was an east or west.
350 if (me.embeddedContainer) {
351 me.embeddedContainer.ownerCt = me.shadowContainer;
352 me.createItems(me.embeddedContainer, hBoxItems);
354 // Allow the Splitters to orientate themselves
355 if (me.splitters.east) {
356 me.splitters.east.ownerCt = me.embeddedContainer;
358 if (me.splitters.west) {
359 me.splitters.west.ownerCt = me.embeddedContainer;
362 // These spliiters need to be constrained by components one-level below
363 // the component in their vobx. We update the min/maxHeight on the helper
364 // (embeddedContainer) prior to starting the split/drag. This has to be
365 // done on-the-fly to allow min/maxHeight of the E/C/W regions to be set
367 Ext.each([me.splitters.north, me.splitters.south], function (splitter) {
369 splitter.on('beforedragstart', me.fixHeightConstraints, me);
373 // The east or west region wanted a percentage
374 if (horizontalFlex) {
375 regions.center.flex -= horizontalFlex;
377 // The north or south region wanted a percentage
379 me.embeddedContainer.flex -= verticalFlex;
382 // The north or south region wanted a percentage
384 regions.center.flex -= verticalFlex;
388 // If we have no north or south, then there's only one Container, and it's
389 // an HBox, or, if only a center region was specified, a Fit.
391 me.shadowContainer = Ext.create('Ext.container.Container', {
394 layout: Ext.applyIf({
395 type: (hBoxItems.length == 1) ? 'fit' : 'hbox',
399 me.createItems(me.shadowContainer, hBoxItems);
401 // Allow the Splitters to orientate themselves
402 if (me.splitters.east) {
403 me.splitters.east.ownerCt = me.shadowContainer;
405 if (me.splitters.west) {
406 me.splitters.west.ownerCt = me.shadowContainer;
409 // The east or west region wanted a percentage
410 if (horizontalFlex) {
411 regions.center.flex -= verticalFlex;
415 // Create upward links from the region Components to their shadow ownerCts
416 for (i = 0, items = me.shadowContainer.items.items, ln = items.length; i < ln; i++) {
417 items[i].shadowOwnerCt = me.shadowContainer;
419 if (me.embeddedContainer) {
420 for (i = 0, items = me.embeddedContainer.items.items, ln = items.length; i < ln; i++) {
421 items[i].shadowOwnerCt = me.embeddedContainer;
425 // This is the layout that we delegate all operations to
426 me.shadowLayout = me.shadowContainer.getLayout();
428 me.borderLayoutInitialized = true;
431 setupState: function(comp){
432 var getState = comp.getState;
433 comp.getState = function(){
434 // call the original getState
435 var state = getState.call(comp) || {},
436 region = comp.region;
438 state.collapsed = !!comp.collapsed;
439 if (region == 'west' || region == 'east') {
440 state.width = comp.getWidth();
442 state.height = comp.getHeight();
446 comp.addStateEvents(['collapse', 'expand', 'resize']);
449 <span id='Ext-layout-container-Border-method-createItems'> /**
450 </span> * Create the items collection for our shadow/embedded containers
453 createItems: function(container, items){
454 // Have to inject an items Collection *after* construction.
455 // The child items of the shadow layout must retain their original, user-defined ownerCt
456 delete container.items;
457 container.initItems();
458 container.items.addAll(items);
462 // Create a splitter for a child of the layout.
463 createSplitter: function(comp) {
465 interceptCollapse = (comp.collapseMode != 'header'),
468 resizer = Ext.create('Ext.resizer.Splitter', {
469 hidden: !!comp.hidden,
470 collapseTarget: comp,
471 performCollapse: !interceptCollapse,
472 listeners: interceptCollapse ? {
474 fn: Ext.Function.bind(me.onSplitterCollapseClick, me, [comp]),
475 element: 'collapseEl'
480 // Mini collapse means that the splitter is the placeholder Component
481 if (comp.collapseMode == 'mini') {
482 comp.placeholder = resizer;
483 resizer.collapsedCls = comp.collapsedCls;
486 // Arrange to hide/show a region's associated splitter when the region is hidden/shown
488 hide: me.onRegionVisibilityChange,
489 show: me.onRegionVisibilityChange,
496 // Propagates the min/maxHeight values from the inner hbox items to its container.
497 fixHeightConstraints: function () {
499 ct = me.embeddedContainer,
500 maxHeight = 1e99, minHeight = -1;
506 ct.items.each(function (item) {
507 if (Ext.isNumber(item.maxHeight)) {
508 maxHeight = Math.max(maxHeight, item.maxHeight);
510 if (Ext.isNumber(item.minHeight)) {
511 minHeight = Math.max(minHeight, item.minHeight);
515 ct.maxHeight = maxHeight;
516 ct.minHeight = minHeight;
519 // Hide/show a region's associated splitter when the region is hidden/shown
520 onRegionVisibilityChange: function(comp){
521 this.splitters[comp.region][comp.hidden ? 'hide' : 'show']();
525 // Called when a splitter mini-collapse tool is clicked on.
526 // The listener is only added if this layout is controlling collapsing,
527 // not if the component's collapseMode is 'mini' or 'header'.
528 onSplitterCollapseClick: function(comp) {
529 if (comp.collapsed) {
530 this.onPlaceHolderToolClick(null, null, null, {client: comp});
536 <span id='Ext-layout-container-Border-method-getPlaceholder'> /**
537 </span> * Return the {@link Ext.panel.Panel#placeholder placeholder} Component to which the passed child Panel of the
538 * layout will collapse. By default, this will be a {@link Ext.panel.Header Header} component (Docked to the
539 * appropriate border). See {@link Ext.panel.Panel#placeholder placeholder}. config to customize this.
541 * **Note that this will be a fully instantiated Component, but will only be _rendered_ when the Panel is first
543 * @param {Ext.panel.Panel} panel The child Panel of the layout for which to return the {@link
544 * Ext.panel.Panel#placeholder placeholder}.
545 * @return {Ext.Component} The Panel's {@link Ext.panel.Panel#placeholder placeholder} unless the {@link
546 * Ext.panel.Panel#collapseMode collapseMode} is `'header'`, in which case _undefined_ is returned.
548 getPlaceholder: function(comp) {
550 placeholder = comp.placeholder,
551 shadowContainer = comp.shadowOwnerCt,
552 shadowLayout = shadowContainer.layout,
553 oppositeDirection = Ext.panel.Panel.prototype.getOppositeDirection(comp.collapseDirection),
554 horiz = (comp.region == 'north' || comp.region == 'south');
556 // No placeholder if the collapse mode is not the Border layout default
557 if (comp.collapseMode == 'header') {
561 // Provide a replacement Container with an expand tool
563 if (comp.collapseMode == 'mini') {
564 placeholder = Ext.create('Ext.resizer.Splitter', {
565 id: 'collapse-placeholder-' + comp.id,
566 collapseTarget: comp,
567 performCollapse: false,
570 fn: Ext.Function.bind(me.onSplitterCollapseClick, me, [comp]),
571 element: 'collapseEl'
575 placeholder.addCls(placeholder.collapsedCls);
578 id: 'collapse-placeholder-' + comp.id,
579 margins: comp.initialConfig.margins || Ext.getClass(comp).prototype.margins,
581 orientation: horiz ? 'horizontal' : 'vertical',
583 textCls: comp.headerTextCls,
584 iconCls: comp.iconCls,
585 baseCls: comp.baseCls + '-header',
587 indicateDrag: comp.draggable,
588 cls: Ext.baseCSSPrefix + 'region-collapsed-placeholder ' + Ext.baseCSSPrefix + 'region-collapsed-' + comp.collapseDirection + '-placeholder ' + comp.collapsedCls,
589 listeners: comp.floatable ? {
592 me.floatCollapsedPanel(e, comp);
598 // Hack for IE6/7/IEQuirks's inability to display an inline-block
599 if ((Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks)) && !horiz) {
600 placeholder.width = 25;
602 if (!comp.hideCollapseTool) {
603 placeholder[horiz ? 'tools' : 'items'] = [{
606 type: 'expand-' + oppositeDirection,
607 handler: me.onPlaceHolderToolClick,
612 placeholder = me.owner.createComponent(placeholder);
613 if (comp.isXType('panel')) {
615 titlechange: me.onRegionTitleChange,
616 iconchange: me.onRegionIconChange,
622 // The collapsed Component holds a reference to its placeholder and vice versa
623 comp.placeholder = placeholder;
624 placeholder.comp = comp;
629 <span id='Ext-layout-container-Border-method-onRegionTitleChange'> /**
631 * Update the placeholder title when panel title has been set or changed.
633 onRegionTitleChange: function(comp, newTitle) {
634 comp.placeholder.setTitle(newTitle);
637 <span id='Ext-layout-container-Border-method-onRegionIconChange'> /**
639 * Update the placeholder iconCls when panel iconCls has been set or changed.
641 onRegionIconChange: function(comp, newIconCls) {
642 comp.placeholder.setIconCls(newIconCls);
645 <span id='Ext-layout-container-Border-method-calculateChildBox'> /**
647 * Calculates the size and positioning of the passed child item. Must be present because Panel's expand,
648 * when configured with a flex, calls this method on its ownerCt's layout.
649 * @param {Ext.Component} child The child Component to calculate the box for
650 * @return {Object} Object containing box measurements for the child. Properties are left,top,width,height.
652 calculateChildBox: function(comp) {
654 if (me.shadowContainer.items.contains(comp)) {
655 return me.shadowContainer.layout.calculateChildBox(comp);
657 else if (me.embeddedContainer && me.embeddedContainer.items.contains(comp)) {
658 return me.embeddedContainer.layout.calculateChildBox(comp);
662 <span id='Ext-layout-container-Border-method-onBeforeRegionCollapse'> /**
664 * Intercepts the Panel's own collapse event and perform's substitution of the Panel
665 * with a placeholder Header orientated in the appropriate dimension.
666 * @param comp The Panel being collapsed.
669 * @returns {Boolean} false to inhibit the Panel from performing its own collapse.
671 onBeforeRegionCollapse: function(comp, direction, animate) {
672 if (comp.collapsedChangingLayout) {
674 if (Ext.global.console && Ext.global.console.warn) {
675 Ext.global.console.warn(Ext.getDisplayName(arguments.callee), 'aborted because the collapsed state is in the middle of changing');
680 comp.collapsedChangingLayout = true;
684 miniCollapse = comp.collapseMode == 'mini',
685 shadowContainer = comp.shadowOwnerCt,
686 shadowLayout = shadowContainer.layout,
687 placeholder = comp.placeholder,
688 sl = me.owner.suspendLayout,
689 scsl = shadowContainer.suspendLayout,
690 isNorthOrWest = (comp.region == 'north' || comp.region == 'west'); // Flag to keep the placeholder non-adjacent to any Splitter
692 // Do not trigger a layout during transition to collapsed Component
693 me.owner.suspendLayout = true;
694 shadowContainer.suspendLayout = true;
696 // Prevent upward notifications from downstream layouts
697 shadowLayout.layoutBusy = true;
698 if (shadowContainer.componentLayout) {
699 shadowContainer.componentLayout.layoutBusy = true;
701 me.shadowContainer.layout.layoutBusy = true;
702 me.layoutBusy = true;
703 me.owner.componentLayout.layoutBusy = true;
705 // Provide a replacement Container with an expand tool
707 placeholder = me.getPlaceholder(comp);
710 // placeholder already in place; show it.
711 if (placeholder.shadowOwnerCt === shadowContainer) {
714 // Insert the collapsed placeholder Component into the appropriate Box layout shadow Container
715 // It must go next to its client Component, but non-adjacent to the splitter so splitter can find its collapse client.
716 // Inject an ownerCt value pointing to the owner, border layout Container as the user will expect.
718 shadowContainer.insert(shadowContainer.items.indexOf(comp) + (isNorthOrWest ? 0 : 1), placeholder);
719 placeholder.shadowOwnerCt = shadowContainer;
720 placeholder.ownerCt = me.owner;
723 // Flag the collapsing Component as hidden and show the placeholder.
724 // This causes the shadow Box layout's calculateChildBoxes to calculate the correct new arrangement.
725 // We hide or slideOut the Component's element
728 if (!placeholder.rendered) {
729 shadowLayout.renderItem(placeholder, shadowLayout.innerCt);
731 // The inserted placeholder does not have the proper size, so copy the width
732 // for N/S or the height for E/W from the component. This fixes EXTJSIV-1562
733 // without recursive layouts. This is only an issue initially. After this time,
734 // placeholder will have the correct width/height set by the layout (which has
735 // already happened when we get here initially).
736 if (comp.region == 'north' || comp.region == 'south') {
737 placeholder.setCalculatedSize(comp.getWidth());
739 placeholder.setCalculatedSize(undefined, comp.getHeight());
743 // Jobs to be done after the collapse has been done
744 function afterCollapse() {
745 // Reinstate automatic laying out.
746 me.owner.suspendLayout = sl;
747 shadowContainer.suspendLayout = scsl;
748 delete shadowLayout.layoutBusy;
749 if (shadowContainer.componentLayout) {
750 delete shadowContainer.componentLayout.layoutBusy;
752 delete me.shadowContainer.layout.layoutBusy;
753 delete me.layoutBusy;
754 delete me.owner.componentLayout.layoutBusy;
755 delete comp.collapsedChangingLayout;
757 // Fire the collapse event: The Panel has in fact been collapsed, but by substitution of an alternative Component
758 comp.collapsed = true;
759 comp.fireEvent('collapse', comp);
763 * Set everything to the new positions. Note that we
764 * only want to animate the collapse if it wasn't configured
765 * initially with collapsed: true
767 if (comp.animCollapse && me.initialCollapsedComplete) {
768 shadowLayout.layout();
769 compEl.dom.style.zIndex = 100;
771 // If we're mini-collapsing, the placholder is a Splitter. We don't want it to "bounce in"
773 placeholder.el.hide();
775 compEl.slideOut(me.slideDirection[comp.region], {
776 duration: Ext.Number.from(comp.animCollapse, Ext.fx.Anim.prototype.duration),
778 afteranimate: function() {
779 compEl.show().setLeftTop(-10000, -10000);
780 compEl.dom.style.zIndex = '';
782 // If we're mini-collapsing, the placholder is a Splitter. We don't want it to "bounce in"
784 placeholder.el.slideIn(me.slideDirection[comp.region], {
794 compEl.setLeftTop(-10000, -10000);
795 shadowLayout.layout();
802 // Hijack the expand operation to remove the placeholder and slide the region back in.
803 onBeforeRegionExpand: function(comp, animate) {
804 // We don't check for comp.collapsedChangingLayout here because onPlaceHolderToolClick does it
805 this.onPlaceHolderToolClick(null, null, null, {client: comp, shouldFireBeforeexpand: false});
809 // Called when the collapsed placeholder is clicked to reinstate a "collapsed" (in reality hidden) Panel.
810 onPlaceHolderToolClick: function(e, target, owner, tool) {
814 // Hide the placeholder unless it was the Component's preexisting splitter
815 hidePlaceholder = (comp.collapseMode != 'mini') || !comp.split,
818 placeholder = comp.placeholder,
819 placeholderEl = placeholder.el,
820 shadowContainer = comp.shadowOwnerCt,
821 shadowLayout = shadowContainer.layout,
823 sl = me.owner.suspendLayout,
824 scsl = shadowContainer.suspendLayout,
827 if (comp.collapsedChangingLayout) {
829 if (Ext.global.console && Ext.global.console.warn) {
830 Ext.global.console.warn(Ext.getDisplayName(arguments.callee), 'aborted because the collapsed state is in the middle of changing');
835 if (tool.shouldFireBeforeexpand !== false && comp.fireEvent('beforeexpand', comp, true) === false) {
838 comp.collapsedChangingLayout = true;
839 // If the slide in is still going, stop it.
840 // This will either leave the Component in its fully floated state (which is processed below)
841 // or in its collapsed state. Either way, we expand it..
842 if (comp.getActiveAnimation()) {
843 comp.stopAnimation();
846 // If the Component is fully floated when they click the placeholder Tool,
847 // it will be primed with a slide out animation object... so delete that
848 // and remove the mouseout listeners
849 if (comp.slideOutAnim) {
850 // Remove mouse leave monitors
851 compEl.un(comp.panelMouseMon);
852 placeholderEl.un(comp.placeholderMouseMon);
854 delete comp.slideOutAnim;
855 delete comp.panelMouseMon;
856 delete comp.placeholderMouseMon;
858 // If the Panel was floated and primed with a slideOut animation, we don't want to animate its layout operation.
862 // Do not trigger a layout during transition to expanded Component
863 me.owner.suspendLayout = true;
864 shadowContainer.suspendLayout = true;
866 // Prevent upward notifications from downstream layouts
867 shadowLayout.layoutBusy = true;
868 if (shadowContainer.componentLayout) {
869 shadowContainer.componentLayout.layoutBusy = true;
871 me.shadowContainer.layout.layoutBusy = true;
872 me.layoutBusy = true;
873 me.owner.componentLayout.layoutBusy = true;
875 // Unset the hidden and collapsed flags set in onBeforeRegionCollapse. The shadowLayout will now take it into account
876 // Find where the shadow Box layout plans to put the expanding Component.
878 comp.collapsed = false;
879 if (hidePlaceholder) {
880 placeholder.hidden = true;
882 toCompBox = shadowLayout.calculateChildBox(comp);
884 // Show the collapse tool in case it was hidden by the slide-in
885 if (comp.collapseTool) {
886 comp.collapseTool.show();
889 // If we're going to animate, we need to hide the component before moving it back into position
890 if (comp.animCollapse && !isFloating) {
891 compEl.setStyle('visibility', 'hidden');
893 compEl.setLeftTop(toCompBox.left, toCompBox.top);
895 // Equalize the size of the expanding Component prior to animation
896 // in case the layout area has changed size during the time it was collapsed.
897 curSize = comp.getSize();
898 if (curSize.height != toCompBox.height || curSize.width != toCompBox.width) {
899 me.setItemSize(comp, toCompBox.width, toCompBox.height);
902 // Jobs to be done after the expand has been done
903 function afterExpand() {
904 // Reinstate automatic laying out.
905 me.owner.suspendLayout = sl;
906 shadowContainer.suspendLayout = scsl;
907 delete shadowLayout.layoutBusy;
908 if (shadowContainer.componentLayout) {
909 delete shadowContainer.componentLayout.layoutBusy;
911 delete me.shadowContainer.layout.layoutBusy;
912 delete me.layoutBusy;
913 delete me.owner.componentLayout.layoutBusy;
914 delete comp.collapsedChangingLayout;
916 // In case it was floated out and they clicked the re-expand tool
917 comp.removeCls(Ext.baseCSSPrefix + 'border-region-slide-in');
919 // Fire the expand event: The Panel has in fact been expanded, but by removal of an alternative Component
920 comp.fireEvent('expand', comp);
923 // Hide the placeholder
924 if (hidePlaceholder) {
925 placeholder.el.hide();
928 // Slide the expanding Component to its new position.
929 // When that is done, layout the layout.
930 if (comp.animCollapse && !isFloating) {
931 compEl.dom.style.zIndex = 100;
932 compEl.slideIn(me.slideDirection[comp.region], {
933 duration: Ext.Number.from(comp.animCollapse, Ext.fx.Anim.prototype.duration),
935 afteranimate: function() {
936 compEl.dom.style.zIndex = '';
938 shadowLayout.onLayout();
944 shadowLayout.onLayout();
949 floatCollapsedPanel: function(e, comp) {
951 if (comp.floatable === false) {
957 placeholder = comp.placeholder,
958 placeholderEl = placeholder.el,
959 shadowContainer = comp.shadowOwnerCt,
960 shadowLayout = shadowContainer.layout,
961 placeholderBox = shadowLayout.getChildBox(placeholder),
962 scsl = shadowContainer.suspendLayout,
963 curSize, toCompBox, compAnim;
965 // Ignore clicks on tools.
966 if (e.getTarget('.' + Ext.baseCSSPrefix + 'tool')) {
970 // It's *being* animated, ignore the click.
971 // Possible future enhancement: Stop and *reverse* the current active Fx.
972 if (compEl.getActiveAnimation()) {
976 // If the Component is already fully floated when they click the placeholder,
977 // it will be primed with a slide out animation object... so slide it out.
978 if (comp.slideOutAnim) {
979 me.slideOutFloatedComponent(comp);
983 // Function to be called when the mouse leaves the floated Panel
984 // Slide out when the mouse leaves the region bounded by the slid Component and its placeholder.
985 function onMouseLeaveFloated(e) {
986 var slideRegion = compEl.getRegion().union(placeholderEl.getRegion()).adjust(1, -1, -1, 1);
988 // If mouse is not within slide Region, slide it out
989 if (!slideRegion.contains(e.getPoint())) {
990 me.slideOutFloatedComponent(comp);
994 // Monitor for mouseouting of the placeholder. Hide it if they exit for half a second or more
995 comp.placeholderMouseMon = placeholderEl.monitorMouseLeave(500, onMouseLeaveFloated);
997 // Do not trigger a layout during slide out of the Component
998 shadowContainer.suspendLayout = true;
1000 // Prevent upward notifications from downstream layouts
1001 me.layoutBusy = true;
1002 me.owner.componentLayout.layoutBusy = true;
1004 // The collapse tool is hidden while slid.
1005 // It is re-shown on expand.
1006 if (comp.collapseTool) {
1007 comp.collapseTool.hide();
1010 // Set flags so that the layout will calculate the boxes for what we want
1011 comp.hidden = false;
1012 comp.collapsed = false;
1013 placeholder.hidden = true;
1015 // Recalculate new arrangement of the Component being floated.
1016 toCompBox = shadowLayout.calculateChildBox(comp);
1017 placeholder.hidden = false;
1019 // Component to appear just after the placeholder, whatever "after" means in the context of the shadow Box layout.
1020 if (comp.region == 'north' || comp.region == 'west') {
1021 toCompBox[shadowLayout.parallelBefore] += placeholderBox[shadowLayout.parallelPrefix] - 1;
1023 toCompBox[shadowLayout.parallelBefore] -= (placeholderBox[shadowLayout.parallelPrefix] - 1);
1025 compEl.setStyle('visibility', 'hidden');
1026 compEl.setLeftTop(toCompBox.left, toCompBox.top);
1028 // Equalize the size of the expanding Component prior to animation
1029 // in case the layout area has changed size during the time it was collapsed.
1030 curSize = comp.getSize();
1031 if (curSize.height != toCompBox.height || curSize.width != toCompBox.width) {
1032 me.setItemSize(comp, toCompBox.width, toCompBox.height);
1035 // This animation slides the collapsed Component's el out to just beyond its placeholder
1038 afteranimate: function() {
1039 shadowContainer.suspendLayout = scsl;
1040 delete me.layoutBusy;
1041 delete me.owner.componentLayout.layoutBusy;
1043 // Prime the Component with an Anim config object to slide it back out
1044 compAnim.listeners = {
1045 afterAnimate: function() {
1046 compEl.show().removeCls(Ext.baseCSSPrefix + 'border-region-slide-in').setLeftTop(-10000, -10000);
1048 // Reinstate the correct, current state after slide out animation finishes
1050 comp.collapsed = true;
1051 delete comp.slideOutAnim;
1052 delete comp.panelMouseMon;
1053 delete comp.placeholderMouseMon;
1056 comp.slideOutAnim = compAnim;
1062 // Give the element the correct class which places it at a high z-index
1063 compEl.addCls(Ext.baseCSSPrefix + 'border-region-slide-in');
1065 // Begin the slide in
1066 compEl.slideIn(me.slideDirection[comp.region], compAnim);
1068 // Monitor for mouseouting of the slid area. Hide it if they exit for half a second or more
1069 comp.panelMouseMon = compEl.monitorMouseLeave(500, onMouseLeaveFloated);
1073 slideOutFloatedComponent: function(comp) {
1074 var compEl = comp.el,
1077 // Remove mouse leave monitors
1078 compEl.un(comp.panelMouseMon);
1079 comp.placeholder.el.un(comp.placeholderMouseMon);
1081 // Slide the Component out
1082 compEl.slideOut(this.slideDirection[comp.region], comp.slideOutAnim);
1084 delete comp.slideOutAnim;
1085 delete comp.panelMouseMon;
1086 delete comp.placeholderMouseMon;
1091 * Ensure any collapsed placeholder Component is destroyed along with its region.
1092 * Can't do this in onDestroy because they may remove a Component and use it elsewhere.
1094 onRegionDestroy: function(comp) {
1095 var placeholder = comp.placeholder;
1097 delete placeholder.ownerCt;
1098 placeholder.destroy();
1104 * Ensure any shadow Containers are destroyed.
1105 * Ensure we don't keep references to Components.
1107 onDestroy: function() {
1109 shadowContainer = me.shadowContainer,
1110 embeddedContainer = me.embeddedContainer;
1112 if (shadowContainer) {
1113 delete shadowContainer.ownerCt;
1114 Ext.destroy(shadowContainer);
1117 if (embeddedContainer) {
1118 delete embeddedContainer.ownerCt;
1119 Ext.destroy(embeddedContainer);
1122 delete me.splitters;
1123 delete me.shadowContainer;
1124 delete me.embeddedContainer;
1125 me.callParent(arguments);