1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-panel.Panel-method-constructor'><span id='Ext-panel.Panel'>/**
2 </span></span> * @class Ext.panel.Panel
3 * @extends Ext.panel.AbstractPanel
4 * <p>Panel is a container that has specific functionality and structural components that make
5 * it the perfect building block for application-oriented user interfaces.</p>
6 * <p>Panels are, by virtue of their inheritance from {@link Ext.container.Container}, capable
7 * of being configured with a {@link Ext.container.Container#layout layout}, and containing child Components.</p>
8 * <p>When either specifying child {@link Ext.Component#items items} of a Panel, or dynamically {@link Ext.container.Container#add adding} Components
9 * to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether
10 * those child elements need to be sized using one of Ext&#39;s built-in <code><b>{@link Ext.container.Container#layout layout}</b></code> schemes. By
11 * default, Panels use the {@link Ext.layout.container.Auto Auto} scheme. This simply renders
12 * child components, appending them one after the other inside the Container, and <b>does not apply any sizing</b>
14 * {@img Ext.panel.Panel/panel.png Panel components}
15 * <p>A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate
16 * {@link #header}, {@link #footer} and {@link #body} sections (see {@link #frame} for additional
17 * information).</p>
18 * <p>Panel also provides built-in {@link #collapsible collapsible, expandable} and {@link #closable} behavior.
19 * Panels can be easily dropped into any {@link Ext.container.Container Container} or layout, and the
20 * layout and rendering pipeline is {@link Ext.container.Container#add completely managed by the framework}.</p>
21 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Panel resulting in removal of the Panel
22 * and the destruction of any descendant Components. This makes the Panel object, and all its descendants <b>unusable</b>. To enable the close
23 * tool to simply <i>hide</i> a Panel for later re-use, configure the Panel with <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
24 * <p>Usually, Panels are used as constituents within an application, in which case, they would be used as child items of Containers,
25 * and would themselves use Ext.Components as child {@link #items}. However to illustrate simply rendering a Panel into the document,
26 * here&#39;s how to do it:<pre><code>
27 Ext.create('Ext.panel.Panel', {
30 html: '&lt;p&gt;World!&lt;/p&gt;',
31 renderTo: document.body
33 </code></pre></p>
34 * <p>A more realistic scenario is a Panel created to house input fields which will not be rendered, but used as a constituent part of a Container:<pre><code>
35 var filterPanel = Ext.create('Ext.panel.Panel', {
36 bodyPadding: 5, // Don&#39;t want content to crunch against the borders
40 fieldLabel: 'Start date'
43 fieldLabel: 'End date'
46 </code></pre></p>
47 * <p>Note that the Panel above is not configured to render into the document, nor is it configured with a size or position. In a real world scenario,
48 * the Container into which the Panel is added will use a {@link #layout} to render, size and position its child Components.</p>
49 * <p>Panels will often use specific {@link #layout}s to provide an application with shape and structure by containing and arranging child
50 * Components: <pre><code>
51 var resultsPanel = Ext.create('Ext.panel.Panel', {
55 renderTo: document.body,
57 type: 'vbox', // Arrange child items vertically
58 align: 'stretch', // Each takes up full width
61 items: [{ // Results grid specified as a config object with an xtype of 'grid'
63 columns: [{header: 'Column One'}], // One header just for show. There&#39;s no data,
64 store: Ext.create('Ext.data.ArrayStore', {}), // A dummy empty data store
65 flex: 1 // Use 1/3 of Container&#39;s height (hint to Box layout)
67 xtype: 'splitter' // A splitter between the two child items
68 }, { // Details Panel specified as a config object (no xtype defaults to 'panel').
72 fieldLabel: 'Data item',
74 }], // An array of form fields
75 flex: 2 // Use 2/3 of Container&#39;s height (hint to Box layout)
78 </code></pre>
79 * The example illustrates one possible method of displaying search results. The Panel contains a grid with the resulting data arranged
80 * in rows. Each selected row may be displayed in detail in the Panel below. The {@link Ext.layout.container.VBox vbox} layout is used
81 * to arrange the two vertically. It is configured to stretch child items horizontally to full width. Child items may either be configured
82 * with a numeric height, or with a <code>flex</code> value to distribute available space proportionately.</p>
83 * <p>This Panel itself may be a child item of, for exaple, a {@link Ext.tab.Panel} which will size its child items to fit within its
84 * content area.</p>
85 * <p>Using these techniques, as long as the <b>layout</b> is chosen and configured correctly, an application may have any level of
86 * nested containment, all dynamically sized according to configuration, the user&#39;s preference and available browser size.</p>
88 * @param {Object} config The config object
91 Ext.define('Ext.panel.Panel', {
92 extend: 'Ext.panel.AbstractPanel',
99 'Ext.layout.component.Dock'
101 alias: 'widget.panel',
102 alternateClassName: 'Ext.Panel',
104 <span id='Ext-panel.Panel-cfg-collapsedCls'> /**
105 </span> * @cfg {String} collapsedCls
106 * A CSS class to add to the panel&#39;s element after it has been collapsed (defaults to
107 * <code>'collapsed'</code>).
109 collapsedCls: 'collapsed',
111 <span id='Ext-panel.Panel-cfg-animCollapse'> /**
112 </span> * @cfg {Boolean} animCollapse
113 * <code>true</code> to animate the transition when the panel is collapsed, <code>false</code> to skip the
114 * animation (defaults to <code>true</code> if the {@link Ext.fx.Anim} class is available, otherwise <code>false</code>).
115 * May also be specified as the animation duration in milliseconds.
117 animCollapse: Ext.enableFx,
119 <span id='Ext-panel.Panel-cfg-minButtonWidth'> /**
120 </span> * @cfg {Number} minButtonWidth
121 * Minimum width of all footer toolbar buttons in pixels (defaults to <tt>75</tt>). If set, this will
122 * be used as the default value for the <tt>{@link Ext.button.Button#minWidth}</tt> config of
123 * each Button added to the <b>footer toolbar</b> via the {@link #fbar} or {@link #buttons} configurations.
124 * It will be ignored for buttons that have a minWidth configured some other way, e.g. in their own config
125 * object or via the {@link Ext.container.Container#config-defaults defaults} of their parent container.
129 <span id='Ext-panel.Panel-cfg-collapsed'> /**
130 </span> * @cfg {Boolean} collapsed
131 * <code>true</code> to render the panel collapsed, <code>false</code> to render it expanded (defaults to
132 * <code>false</code>).
136 <span id='Ext-panel.Panel-cfg-collapseFirst'> /**
137 </span> * @cfg {Boolean} collapseFirst
138 * <code>true</code> to make sure the collapse/expand toggle button always renders first (to the left of)
139 * any other tools in the panel&#39;s title bar, <code>false</code> to render it last (defaults to <code>true</code>).
143 <span id='Ext-panel.Panel-cfg-hideCollapseTool'> /**
144 </span> * @cfg {Boolean} hideCollapseTool
145 * <code>true</code> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
146 * <code>false</code> to display it (defaults to <code>false</code>).
148 hideCollapseTool: false,
150 <span id='Ext-panel.Panel-cfg-titleCollapse'> /**
151 </span> * @cfg {Boolean} titleCollapse
152 * <code>true</code> to allow expanding and collapsing the panel (when <code>{@link #collapsible} = true</code>)
153 * by clicking anywhere in the header bar, <code>false</code>) to allow it only by clicking to tool button
154 * (defaults to <code>false</code>)).
156 titleCollapse: false,
158 <span id='Ext-panel.Panel-cfg-collapseMode'> /**
159 </span> * @cfg {String} collapseMode
160 * <p><b>Important: this config is only effective for {@link #collapsible} Panels which are direct child items of a {@link Ext.layout.container.Border border layout}.</b></p>
161 * <p>When <i>not</i> a direct child item of a {@link Ext.layout.container.Border border layout}, then the Panel&#39;s header remains visible, and the body is collapsed to zero dimensions.
162 * If the Panel has no header, then a new header (orientated correctly depending on the {@link #collapseDirection}) will be inserted to show a the title and a re-expand tool.</p>
163 * <p>When a child item of a {@link Ext.layout.container.Border border layout}, this config has two options:
164 * <div class="mdetail-params"><ul>
165 * <li><b><code>undefined/omitted</code></b><div class="sub-desc">When collapsed, a placeholder {@link Ext.panel.Header Header} is injected into the layout to represent the Panel
166 * and to provide a UI with a Tool to allow the user to re-expand the Panel.</div></li>
167 * <li><b><code>header</code></b> : <div class="sub-desc">The Panel collapses to leave its header visible as when not inside a {@link Ext.layout.container.Border border layout}.</div></li>
168 * </ul></div></p>
171 <span id='Ext-panel.Panel-cfg-placeholder'> /**
172 </span> * @cfg {Mixed} placeholder
173 * <p><b>Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a {@link Ext.layout.container.Border border layout}
174 * when not using the <code>'header'</code> {@link #collapseMode}.</b></p>
175 * <p><b>Optional.</b> A Component (or config object for a Component) to show in place of this Panel when this Panel is collapsed by a
176 * {@link Ext.layout.container.Border border layout}. Defaults to a generated {@link Ext.panel.Header Header}
177 * containing a {@link Ext.panel.Tool Tool} to re-expand the Panel.</p>
180 <span id='Ext-panel.Panel-cfg-floatable'> /**
181 </span> * @cfg {Boolean} floatable
182 * <p><b>Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a {@link Ext.layout.container.Border border layout}.</b></p>
183 * <tt>true</tt> to allow clicking a collapsed Panel&#39;s {@link #placeholder} to display the Panel floated
184 * above the layout, <tt>false</tt> to force the user to fully expand a collapsed region by
185 * clicking the expand button to see it again (defaults to <tt>true</tt>).
189 <span id='Ext-panel.Panel-cfg-collapsible'> /**
190 </span> * @cfg {Boolean} collapsible
191 * <p>True to make the panel collapsible and have an expand/collapse toggle Tool added into
192 * the header tool button area. False to keep the panel sized either statically, or by an owning layout manager, with no toggle Tool (defaults to false).</p>
193 * See {@link #collapseMode} and {@link #collapseDirection}
197 <span id='Ext-panel.Panel-cfg-collapseDirection'> /**
198 </span> * @cfg {Boolean} collapseDirection
199 * <p>The direction to collapse the Panel when the toggle button is clicked.</p>
200 * <p>Defaults to the {@link #headerPosition}</p>
201 * <p><b>Important: This config is <u>ignored</u> for {@link #collapsible} Panels which are direct child items of a {@link Ext.layout.container.Border border layout}.</b></p>
202 * <p>Specify as <code>'top'</code>, <code>'bottom'</code>, <code>'left'</code> or <code>'right'</code>.</p>
205 <span id='Ext-panel.Panel-cfg-closable'> /**
206 </span> * @cfg {Boolean} closable
207 * <p>True to display the 'close' tool button and allow the user to close the window, false to
208 * hide the button and disallow closing the window (defaults to <code>false</code>).</p>
209 * <p>By default, when close is requested by clicking the close button in the header, the {@link #close}
210 * method will be called. This will <i>{@link Ext.Component#destroy destroy}</i> the Panel and its content
211 * meaning that it may not be reused.</p>
212 * <p>To make closing a Panel <i>hide</i> the Panel so that it may be reused, set
213 * {@link #closeAction} to 'hide'.</p>
217 <span id='Ext-panel.Panel-cfg-closeAction'> /**
218 </span> * @cfg {String} closeAction
219 * <p>The action to take when the close header tool is clicked:
220 * <div class="mdetail-params"><ul>
221 * <li><b><code>'{@link #destroy}'</code></b> : <b>Default</b><div class="sub-desc">
222 * {@link #destroy remove} the window from the DOM and {@link Ext.Component#destroy destroy}
223 * it and all descendant Components. The window will <b>not</b> be available to be
224 * redisplayed via the {@link #show} method.
225 * </div></li>
226 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
227 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
228 * The window will be available to be redisplayed via the {@link #show} method.
229 * </div></li>
230 * </ul></div>
231 * <p><b>Note:</b> This behavior has changed! setting *does* affect the {@link #close} method
232 * which will invoke the approriate closeAction.
234 closeAction: 'destroy',
236 <span id='Ext-panel.Panel-cfg-dockedItems'> /**
237 </span> * @cfg {Object/Array} dockedItems
238 * A component or series of components to be added as docked items to this panel.
239 * The docked items can be docked to either the top, right, left or bottom of a panel.
240 * This is typically used for things like toolbars or tab bars:
241 * <pre><code>
242 var panel = new Ext.panel.Panel({
247 text: 'Docked to the top'
250 });</pre></code>
253 <span id='Ext-panel.Panel-cfg-preventHeader'> /**
254 </span> * @cfg {Boolean} preventHeader Prevent a Header from being created and shown. Defaults to false.
256 preventHeader: false,
258 <span id='Ext-panel.Panel-cfg-headerPosition'> /**
259 </span> * @cfg {String} headerPosition Specify as <code>'top'</code>, <code>'bottom'</code>, <code>'left'</code> or <code>'right'</code>. Defaults to <code>'top'</code>.
261 headerPosition: 'top',
263 <span id='Ext-panel.Panel-cfg-frame'> /**
264 </span> * @cfg {Boolean} frame
265 * True to apply a frame to the panel.
269 <span id='Ext-panel.Panel-cfg-frameHeader'> /**
270 </span> * @cfg {Boolean} frameHeader
271 * True to apply a frame to the panel panels header (if 'frame' is true).
275 <span id='Ext-panel.Panel-cfg-tools'> /**
276 </span> * @cfg {Array} tools
277 * An array of {@link Ext.panel.Tool} configs/instances to be added to the header tool area. The tools are stored as child
278 * components of the header container. They can be accessed using {@link #down} and {#query}, as well as the other
279 * component methods. The toggle tool is automatically created if {@link #collapsible} is set to true.
280 * <p>Note that, apart from the toggle tool which is provided when a panel is collapsible, these
281 * tools only provide the visual button. Any required functionality must be provided by adding
282 * handlers that implement the necessary behavior.</p>
283 * <p>Example usage:</p>
284 * <pre><code>
287 qtip: 'Refresh form Data',
289 handler: function(event, toolEl, panel){
296 handler: function(event, toolEl, panel){
300 </code></pre>
304 initComponent: function() {
309 <span id='Ext-panel.Panel-event-titlechange'> /**
310 </span> * @event titlechange
311 * Fires after the Panel title has been set or changed.
312 * @param {Ext.panel.Panel} p the Panel which has been resized.
313 * @param {String} newTitle The new title.
314 * @param {String} oldTitle The previous panel title.
317 <span id='Ext-panel.Panel-event-iconchange'> /**
318 </span> * @event iconchange
319 * Fires after the Panel iconCls has been set or changed.
320 * @param {Ext.panel.Panel} p the Panel which has been resized.
321 * @param {String} newIconCls The new iconCls.
322 * @param {String} oldIconCls The previous panel iconCls.
332 me.setUI('default-framed');
337 me.collapseDirection = me.collapseDirection || me.headerPosition || Ext.Component.DIRECTION_TOP;
339 // Backwards compatibility
343 setBorder: function(border) {
345 // method = (border === false || border === 0) ? 'addClsWithUI' : 'removeClsWithUI';
347 // me.callParent(arguments);
349 // if (me.collapsed) {
350 // me[method](me.collapsedCls + '-noborder');
354 // me.header.setBorder(border);
355 // if (me.collapsed) {
356 // me.header[method](me.collapsedCls + '-noborder');
360 this.callParent(arguments);
363 beforeDestroy: function() {
371 initAria: function() {
373 this.initHeaderAria();
376 initHeaderAria: function() {
380 if (el && header) {
381 el.dom.setAttribute('aria-labelledby', header.titleCmp.id);
385 getHeader: function() {
389 <span id='Ext-panel.Panel-method-setTitle'> /**
390 </span> * Set a title for the panel&#39;s header. See {@link Ext.panel.Header#title}.
391 * @param {String} newTitle
393 setTitle: function(newTitle) {
395 oldTitle = this.title;
399 me.header.setTitle(newTitle);
405 me.reExpander.setTitle(newTitle);
407 me.fireEvent('titlechange', me, newTitle, oldTitle);
410 <span id='Ext-panel.Panel-method-setIconCls'> /**
411 </span> * Set the iconCls for the panel&#39;s header. See {@link Ext.panel.Header#iconCls}.
412 * @param {String} newIconCls
414 setIconCls: function(newIconCls) {
416 oldIconCls = me.iconCls;
418 me.iconCls = newIconCls;
419 var header = me.header;
421 header.setIconCls(newIconCls);
423 me.fireEvent('iconchange', me, newIconCls, oldIconCls);
426 bridgeToolbars: function() {
430 minButtonWidth = me.minButtonWidth;
432 function initToolbar (toolbar, pos) {
433 if (Ext.isArray(toolbar)) {
439 else if (!toolbar.xtype) {
440 toolbar.xtype = 'toolbar';
443 if (pos == 'left' || pos == 'right') {
444 toolbar.vertical = true;
449 // Backwards compatibility
451 <span id='Ext-panel.Panel-cfg-tbar'> /**
452 </span> * @cfg {Object/Array} tbar
454 Convenience method. Short for 'Top Bar'.
457 { xtype: 'button', text: 'Button 1' }
466 { xtype: 'button', text: 'Button 1' }
473 me.addDocked(initToolbar(me.tbar, 'top'));
477 <span id='Ext-panel.Panel-cfg-bbar'> /**
478 </span> * @cfg {Object/Array} bbar
480 Convenience method. Short for 'Bottom Bar'.
483 { xtype: 'button', text: 'Button 1' }
492 { xtype: 'button', text: 'Button 1' }
499 me.addDocked(initToolbar(me.bbar, 'bottom'));
503 <span id='Ext-panel.Panel-cfg-buttons'> /**
504 </span> * @cfg {Object/Array} buttons
506 Convenience method used for adding buttons docked to the bottom right of the panel. This is a
507 synonym for the {@link #fbar} config.
518 defaults: {minWidth: {@link #minButtonWidth}},
520 { xtype: 'component', flex: 1 },
521 { xtype: 'button', text: 'Button 1' }
525 The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
526 each of the buttons in the buttons toolbar.
531 me.fbar = me.buttons;
535 <span id='Ext-panel.Panel-cfg-fbar'> /**
536 </span> * @cfg {Object/Array} fbar
538 Convenience method used for adding items to the bottom right of the panel. Short for Footer Bar.
541 { type: 'button', text: 'Button 1' }
549 defaults: {minWidth: {@link #minButtonWidth}},
551 { xtype: 'component', flex: 1 },
552 { xtype: 'button', text: 'Button 1' }
556 The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
557 each of the buttons in the fbar.
562 fbar = initToolbar(me.fbar, 'bottom');
565 // Apply the minButtonWidth config to buttons in the toolbar
566 if (minButtonWidth) {
567 fbarDefaults = fbar.defaults;
568 fbar.defaults = function(config) {
569 var defaults = fbarDefaults || {};
570 if ((!config.xtype || config.xtype === 'button' || (config.isComponent && config.isXType('button'))) &&
571 !('minWidth' in defaults)) {
572 defaults = Ext.apply({minWidth: minButtonWidth}, defaults);
578 fbar = me.addDocked(fbar)[0];
587 <span id='Ext-panel.Panel-cfg-lbar'> /**
588 </span> * @cfg {Object/Array} lbar
590 * Convenience method. Short for 'Left Bar' (left-docked, vertical toolbar).
593 * { xtype: 'button', text: 'Button 1' }
602 * { xtype: 'button', text: 'Button 1' }
609 me.addDocked(initToolbar(me.lbar, 'left'));
613 <span id='Ext-panel.Panel-cfg-rbar'> /**
614 </span> * @cfg {Object/Array} rbar
616 * Convenience method. Short for 'Right Bar' (right-docked, vertical toolbar).
619 * { xtype: 'button', text: 'Button 1' }
628 * { xtype: 'button', text: 'Button 1' }
635 me.addDocked(initToolbar(me.rbar, 'right'));
640 <span id='Ext-panel.Panel-method-initTools'> /**
642 * Tools are a Panel-specific capabilty.
643 * Panel uses initTools. Subclasses may contribute tools by implementing addTools.
645 initTools: function() {
648 me.tools = me.tools || [];
650 // Add a collapse tool unless configured to not show a collapse tool
651 // or to not even show a header.
652 if (me.collapsible && !(me.hideCollapseTool || me.header === false)) {
653 me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';
654 me.collapseTool = me.expandTool = me.createComponent({
656 type: 'collapse-' + me.collapseDirection,
657 expandType: me.getOppositeDirection(me.collapseDirection),
658 handler: me.toggleCollapse,
662 // Prepend collapse tool is configured to do so.
663 if (me.collapseFirst) {
664 me.tools.unshift(me.collapseTool);
668 // Add subclass-specific tools.
671 // Make Panel closable.
673 me.addClsWithUI('closable');
676 handler: Ext.Function.bind(me.close, this, [])
680 // Append collapse tool if needed.
681 if (me.collapseTool && !me.collapseFirst) {
682 me.tools.push(me.collapseTool);
686 <span id='Ext-panel.Panel-property-addTools'> /**
688 * Template method to be implemented in subclasses to add their tools after the collapsible tool.
690 addTools: Ext.emptyFn,
692 <span id='Ext-panel.Panel-method-close'> /**
693 </span> * <p>Closes the Panel. By default, this method, removes it from the DOM, {@link Ext.Component#destroy destroy}s
694 * the Panel object and all its descendant Components. The {@link #beforeclose beforeclose}
695 * event is fired before the close happens and will cancel the close action if it returns false.<p>
696 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
697 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
698 * To hide the Panel without destroying it, call {@link #hide}.</p>
701 if (this.fireEvent('beforeclose', this) !== false) {
707 doClose: function() {
708 this.fireEvent('close', this);
709 this[this.closeAction]();
712 onRender: function(ct, position) {
716 // Add class-specific header tools.
717 // Panel adds collapsible and closable.
720 // Dock the header/title
723 // If initially collapsed, collapsed flag must indicate true current state at this point.
724 // Do collapse after the first time the Panel's structure has been laid out.
726 me.collapsed = false;
727 topContainer = me.findLayoutController();
728 if (!me.hidden && topContainer) {
730 afterlayout: function() {
731 me.collapse(null, false, true);
736 me.afterComponentLayout = function() {
737 delete me.afterComponentLayout;
738 Ext.getClass(me).prototype.afterComponentLayout.apply(me, arguments);
739 me.collapse(null, false, true);
744 // Call to super after adding the header, to prevent an unnecessary re-layout
745 me.callParent(arguments);
748 <span id='Ext-panel.Panel-method-updateHeader'> /**
749 </span> * Create, hide, or show the header component as appropriate based on the current config.
751 * @param {Boolean} force True to force the the header to be created
753 updateHeader: function(force) {
759 if (!me.preventHeader && (force || title || (tools && tools.length))) {
761 header = me.header = Ext.create('Ext.panel.Header', {
763 orientation : (me.headerPosition == 'left' || me.headerPosition == 'right') ? 'vertical' : 'horizontal',
764 dock : me.headerPosition || 'top',
765 textCls : me.headerTextCls,
766 iconCls : me.iconCls,
767 baseCls : me.baseCls + '-header',
770 indicateDrag: me.draggable,
772 frame : me.frame && me.frameHeader,
773 ignoreParentFrame : me.frame || me.overlapHeader,
774 ignoreBorderManagement: me.frame || me.ignoreHeaderBorderManagement,
775 listeners : me.collapsible && me.titleCollapse ? {
776 click: me.toggleCollapse,
780 me.addDocked(header, 0);
782 // Reference the Header's tool array.
783 // Header injects named references.
784 me.tools = header.tools;
794 setUI: function(ui) {
797 me.callParent(arguments);
805 getContentTarget: function() {
809 getTargetEl: function() {
810 return this.body || this.frameBody || this.el;
813 addTool: function(tool) {
814 this.tools.push(tool);
815 var header = this.header;
817 header.addTool(tool);
822 getOppositeDirection: function(d) {
823 var c = Ext.Component;
825 case c.DIRECTION_TOP:
826 return c.DIRECTION_BOTTOM;
827 case c.DIRECTION_RIGHT:
828 return c.DIRECTION_LEFT;
829 case c.DIRECTION_BOTTOM:
830 return c.DIRECTION_TOP;
831 case c.DIRECTION_LEFT:
832 return c.DIRECTION_RIGHT;
836 <span id='Ext-panel.Panel-method-collapse'> /**
837 </span> * Collapses the panel body so that the body becomes hidden. Docked Components parallel to the
838 * border towards which the collapse takes place will remain visible. Fires the {@link #beforecollapse} event which will
839 * cancel the collapse action if it returns false.
840 * @param {Number} direction. The direction to collapse towards. Must be one of<ul>
841 * <li>Ext.Component.DIRECTION_TOP</li>
842 * <li>Ext.Component.DIRECTION_RIGHT</li>
843 * <li>Ext.Component.DIRECTION_BOTTOM</li>
844 * <li>Ext.Component.DIRECTION_LEFT</li></ul>
845 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
846 * {@link #animCollapse} panel config)
847 * @return {Ext.panel.Panel} this
849 collapse: function(direction, animate, /* private - passed if called at render time */ internal) {
852 height = me.getHeight(),
853 width = me.getWidth(),
856 dockedItems = me.dockedItems.items,
857 dockedItemCount = dockedItems.length,
871 afteranimate: me.afterCollapse,
874 duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration)
877 reExpanderOrientation,
884 direction = me.collapseDirection;
887 // If internal (Called because of initial collapsed state), then no animation, and no events.
890 } else if (me.collapsed || me.fireEvent('beforecollapse', me, direction, animate) === false) {
894 reExpanderDock = direction;
895 me.expandDirection = me.getOppositeDirection(direction);
897 // Track docked items which we hide during collapsed state
898 me.hiddenDocked = [];
901 case c.DIRECTION_TOP:
902 case c.DIRECTION_BOTTOM:
903 me.expandedSize = me.getHeight();
904 reExpanderOrientation = 'horizontal';
905 collapseDimension = 'height';
906 getDimension = 'getHeight';
907 setDimension = 'setHeight';
909 // Collect the height of the visible header.
910 // Hide all docked items except the header.
911 // Hide *ALL* docked items if we're going to end up hiding the whole Panel anyway
912 for (; i < dockedItemCount; i++) {
913 comp = dockedItems[i];
914 if (comp.isVisible()) {
915 if (comp.isHeader && (!comp.dock || comp.dock == 'top' || comp.dock == 'bottom')) {
918 me.hiddenDocked.push(comp);
923 if (direction == Ext.Component.DIRECTION_BOTTOM) {
924 pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
929 case c.DIRECTION_LEFT:
930 case c.DIRECTION_RIGHT:
931 me.expandedSize = me.getWidth();
932 reExpanderOrientation = 'vertical';
933 collapseDimension = 'width';
934 getDimension = 'getWidth';
935 setDimension = 'setWidth';
937 // Collect the height of the visible header.
938 // Hide all docked items except the header.
939 // Hide *ALL* docked items if we're going to end up hiding the whole Panel anyway
940 for (; i < dockedItemCount; i++) {
941 comp = dockedItems[i];
942 if (comp.isVisible()) {
943 if (comp.isHeader && (comp.dock == 'left' || comp.dock == 'right')) {
946 me.hiddenDocked.push(comp);
951 if (direction == Ext.Component.DIRECTION_RIGHT) {
952 pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
953 anim.from.left = pos;
958 throw('Panel collapse must be passed a valid Component collapse direction');
961 // No scrollbars when we shrink this Panel
962 // And no laying out of any children... we're effectively *hiding* the body
963 me.setAutoScroll(false);
964 me.suspendLayout = true;
965 me.body.setVisibilityMode(Ext.core.Element.DISPLAY);
967 // Disable toggle tool during animated collapse
968 if (animate && me.collapseTool) {
969 me.collapseTool.disable();
972 // Add the collapsed class now, so that collapsed CSS rules are applied before measurements are taken.
973 me.addClsWithUI(me.collapsedCls);
974 // if (me.border === false) {
975 // me.addClsWithUI(me.collapsedCls + '-noborder');
978 // We found a header: Measure it to find the collapse-to size.
980 //we must add the collapsed cls to the header and then remove to get the proper height
981 reExpander.addClsWithUI(me.collapsedCls);
982 reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
983 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
984 reExpander.addClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
987 frameInfo = reExpander.getFrameInfo();
990 newSize = reExpander[getDimension]() + (frameInfo ? frameInfo[direction] : 0);
993 reExpander.removeClsWithUI(me.collapsedCls);
994 reExpander.removeClsWithUI(me.collapsedCls + '-' + reExpander.dock);
995 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
996 reExpander.removeClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
999 // No header: Render and insert a temporary one, and then measure it.
1002 hideMode: 'offsets',
1005 orientation: reExpanderOrientation,
1006 dock: reExpanderDock,
1007 textCls: me.headerTextCls,
1008 iconCls: me.iconCls,
1009 baseCls: me.baseCls + '-header',
1011 frame: me.frame && me.frameHeader,
1012 ignoreParentFrame: me.frame || me.overlapHeader,
1013 indicateDrag: me.draggable,
1014 cls: me.baseCls + '-collapsed-placeholder ' + ' ' + Ext.baseCSSPrefix + 'docked ' + me.baseCls + '-' + me.ui + '-collapsed',
1017 reExpander[(reExpander.orientation == 'horizontal') ? 'tools' : 'items'] = [{
1019 type: 'expand-' + me.expandDirection,
1020 handler: me.toggleCollapse,
1024 // Capture the size of the re-expander.
1025 // For vertical headers in IE6 and IE7, this will be sized by a CSS rule in _panel.scss
1026 reExpander = me.reExpander = Ext.create('Ext.panel.Header', reExpander);
1027 newSize = reExpander[getDimension]() + ((reExpander.frame) ? reExpander.frameSize[direction] : 0);
1030 // Insert the new docked item
1031 me.insertDocked(0, reExpander);
1034 me.reExpander = reExpander;
1035 me.reExpander.addClsWithUI(me.collapsedCls);
1036 me.reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
1037 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1038 me.reExpander.addClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
1041 // If collapsing right or down, we'll be also animating the left or top.
1042 if (direction == Ext.Component.DIRECTION_RIGHT) {
1043 anim.to.left = pos + (width - newSize);
1044 } else if (direction == Ext.Component.DIRECTION_BOTTOM) {
1045 anim.to.top = pos + (height - newSize);
1048 // Animate to the new size
1049 anim.to[collapseDimension] = newSize;
1051 // Remove any flex config before we attempt to collapse.
1052 me.savedFlex = me.flex;
1053 me.savedMinWidth = me.minWidth;
1054 me.savedMinHeight = me.minHeight;
1062 me.setSize(anim.to.width, anim.to.height);
1063 if (Ext.isDefined(anim.to.left) || Ext.isDefined(anim.to.top)) {
1064 me.setPosition(anim.to.left, anim.to.top);
1066 me.afterCollapse(false, internal);
1071 afterCollapse: function(animated, internal) {
1074 l = me.hiddenDocked.length;
1076 me.minWidth = me.savedMinWidth;
1077 me.minHeight = me.savedMinHeight;
1080 for (; i < l; i++) {
1081 me.hiddenDocked[i].hide();
1083 if (me.reExpander) {
1084 me.reExpander.updateFrame();
1085 me.reExpander.show();
1087 me.collapsed = true;
1090 me.doComponentLayout();
1094 me.resizer.disable();
1097 // If me Panel was configured with a collapse tool in its header, flip it's type
1098 if (me.collapseTool) {
1099 me.collapseTool.setType('expand-' + me.expandDirection);
1102 me.fireEvent('collapse', me);
1105 // Re-enable the toggle tool after an animated collapse
1106 if (animated && me.collapseTool) {
1107 me.collapseTool.enable();
1111 <span id='Ext-panel.Panel-method-expand'> /**
1112 </span> * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
1113 * cancel the expand action if it returns false.
1114 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1115 * {@link #animCollapse} panel config)
1116 * @return {Ext.panel.Panel} this
1118 expand: function(animate) {
1119 if (!this.collapsed || this.fireEvent('beforeexpand', this, animate) === false) {
1124 l = me.hiddenDocked.length,
1125 direction = me.expandDirection,
1126 height = me.getHeight(),
1127 width = me.getWidth(),
1128 pos, anim, satisfyJSLint;
1130 // Disable toggle tool during animated expand
1131 if (animate && me.collapseTool) {
1132 me.collapseTool.disable();
1135 // Show any docked items that we hid on collapse
1136 // And hide the injected reExpander Header
1137 for (; i < l; i++) {
1138 me.hiddenDocked[i].hidden = false;
1139 me.hiddenDocked[i].el.show();
1141 if (me.reExpander) {
1142 if (me.reExpander.temporary) {
1143 me.reExpander.hide();
1145 me.reExpander.removeClsWithUI(me.collapsedCls);
1146 me.reExpander.removeClsWithUI(me.collapsedCls + '-' + me.reExpander.dock);
1147 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1148 me.reExpander.removeClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
1150 me.reExpander.updateFrame();
1154 // If me Panel was configured with a collapse tool in its header, flip it's type
1155 if (me.collapseTool) {
1156 me.collapseTool.setType('collapse-' + me.collapseDirection);
1159 // Unset the flag before the potential call to calculateChildBox to calculate our newly flexed size
1160 me.collapsed = false;
1162 // Collapsed means body element was hidden
1165 // Remove any collapsed styling before any animation begins
1166 me.removeClsWithUI(me.collapsedCls);
1167 // if (me.border === false) {
1168 // me.removeClsWithUI(me.collapsedCls + '-noborder');
1179 afteranimate: me.afterExpand,
1184 if ((direction == Ext.Component.DIRECTION_TOP) || (direction == Ext.Component.DIRECTION_BOTTOM)) {
1186 // If autoHeight, measure the height now we have shown the body element.
1187 if (me.autoHeight) {
1188 me.setCalculatedSize(me.width, null);
1189 anim.to.height = me.getHeight();
1191 // Must size back down to collapsed for the animation.
1192 me.setCalculatedSize(me.width, anim.from.height);
1194 // If we were flexed, then we can't just restore to the saved size.
1195 // We must restore to the currently correct, flexed size, so we much ask the Box layout what that is.
1196 else if (me.savedFlex) {
1197 me.flex = me.savedFlex;
1198 anim.to.height = me.ownerCt.layout.calculateChildBox(me).height;
1201 // Else, restore to saved height
1203 anim.to.height = me.expandedSize;
1206 // top needs animating upwards
1207 if (direction == Ext.Component.DIRECTION_TOP) {
1208 pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
1209 anim.from.top = pos;
1210 anim.to.top = pos - (anim.to.height - height);
1212 } else if ((direction == Ext.Component.DIRECTION_LEFT) || (direction == Ext.Component.DIRECTION_RIGHT)) {
1214 // If autoWidth, measure the width now we have shown the body element.
1216 me.setCalculatedSize(null, me.height);
1217 anim.to.width = me.getWidth();
1219 // Must size back down to collapsed for the animation.
1220 me.setCalculatedSize(anim.from.width, me.height);
1222 // If we were flexed, then we can't just restore to the saved size.
1223 // We must restore to the currently correct, flexed size, so we much ask the Box layout what that is.
1224 else if (me.savedFlex) {
1225 me.flex = me.savedFlex;
1226 anim.to.width = me.ownerCt.layout.calculateChildBox(me).width;
1229 // Else, restore to saved width
1231 anim.to.width = me.expandedSize;
1234 // left needs animating leftwards
1235 if (direction == Ext.Component.DIRECTION_LEFT) {
1236 pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
1237 anim.from.left = pos;
1238 anim.to.left = pos - (anim.to.width - width);
1245 me.setSize(anim.to.width, anim.to.height);
1247 me.setLeft(anim.to.x);
1250 me.setTop(anim.to.y);
1252 me.afterExpand(false);
1258 afterExpand: function(animated) {
1260 me.setAutoScroll(me.initialConfig.autoScroll);
1262 // Restored to a calculated flex. Delete the set width and height properties so that flex works from now on.
1264 me.flex = me.savedFlex;
1265 delete me.savedFlex;
1270 // Reinstate layout out after Panel has re-expanded
1271 delete me.suspendLayout;
1272 if (animated && me.ownerCt) {
1273 me.ownerCt.doLayout();
1277 me.resizer.enable();
1280 me.fireEvent('expand', me);
1282 // Re-enable the toggle tool after an animated expand
1283 if (animated && me.collapseTool) {
1284 me.collapseTool.enable();
1288 <span id='Ext-panel.Panel-method-toggleCollapse'> /**
1289 </span> * Shortcut for performing an {@link #expand} or {@link #collapse} based on the current state of the panel.
1290 * @return {Ext.panel.Panel} this
1292 toggleCollapse: function() {
1293 if (this.collapsed) {
1294 this.expand(this.animCollapse);
1296 this.collapse(this.collapseDirection, this.animCollapse);
1302 getKeyMap : function(){
1304 this.keyMap = Ext.create('Ext.util.KeyMap', this.el, this.keys);
1310 initDraggable : function(){
1311 <span id='Ext-panel.Panel-property-dd'> /**
1312 </span> * <p>If this Panel is configured {@link #draggable}, this property will contain
1313 * an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
1314 * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
1315 * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
1316 * @type Ext.dd.DragSource.
1319 this.dd = Ext.create('Ext.panel.DD', this, Ext.isBoolean(this.draggable) ? null : this.draggable);
1322 // private - helper function for ghost
1323 ghostTools : function() {
1325 origTools = this.initialConfig.tools;
1328 Ext.each(origTools, function(tool) {
1329 // Some tools can be full components, and copying them into the ghost
1330 // actually removes them from the owning panel. You could also potentially
1331 // end up with duplicate DOM ids as well. To avoid any issues we just make
1332 // a simple bare-minimum clone of each tool for ghosting purposes.
1346 // private - used for dragging
1347 ghost: function(cls) {
1349 ghostPanel = me.ghostPanel,
1353 ghostPanel = Ext.create('Ext.panel.Panel', {
1354 renderTo: document.body,
1358 frame: Ext.supports.CSS3BorderRadius ? me.frame : false,
1360 overlapHeader: me.overlapHeader,
1361 headerPosition: me.headerPosition,
1362 width: me.getWidth(),
1363 height: me.getHeight(),
1364 iconCls: me.iconCls,
1365 baseCls: me.baseCls,
1366 tools: me.ghostTools(),
1367 cls: me.baseCls + '-ghost ' + (cls ||'')
1369 me.ghostPanel = ghostPanel;
1371 ghostPanel.floatParent = me.floatParent;
1373 ghostPanel.setZIndex(Ext.Number.from(me.el.getStyle('zIndex'), 0));
1375 ghostPanel.toFront();
1377 ghostPanel.el.show();
1378 ghostPanel.setPosition(box.x, box.y);
1379 ghostPanel.setSize(box.width, box.height);
1381 if (me.floatingItems) {
1382 me.floatingItems.hide();
1388 unghost: function(show, matchPosition) {
1390 if (!me.ghostPanel) {
1393 if (show !== false) {
1395 if (matchPosition !== false) {
1396 me.setPosition(me.ghostPanel.getPosition());
1398 if (me.floatingItems) {
1399 me.floatingItems.show();
1401 Ext.defer(me.focus, 10, me);
1403 me.ghostPanel.el.hide();
1406 initResizable: function(resizable) {
1407 if (this.collapsed) {
1408 resizable.disabled = true;
1410 this.callParent([resizable]);
1413 </pre></pre></body></html>