4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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-panel-Panel-method-constructor'><span id='Ext-panel-Panel'>/**
19 </span></span> * @class Ext.panel.Panel
20 * @extends Ext.panel.AbstractPanel
21 * <p>Panel is a container that has specific functionality and structural components that make
22 * it the perfect building block for application-oriented user interfaces.</p>
23 * <p>Panels are, by virtue of their inheritance from {@link Ext.container.Container}, capable
24 * of being configured with a {@link Ext.container.Container#layout layout}, and containing child Components.</p>
25 * <p>When either specifying child {@link Ext.Component#items items} of a Panel, or dynamically {@link Ext.container.Container#add adding} Components
26 * to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether
27 * 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
28 * default, Panels use the {@link Ext.layout.container.Auto Auto} scheme. This simply renders
29 * child components, appending them one after the other inside the Container, and <b>does not apply any sizing</b>
31 * {@img Ext.panel.Panel/panel.png Panel components}
32 * <p>A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate
33 * {@link #header}, {@link #footer} and {@link #body} sections (see {@link #frame} for additional
34 * information).</p>
35 * <p>Panel also provides built-in {@link #collapsible collapsible, expandable} and {@link #closable} behavior.
36 * Panels can be easily dropped into any {@link Ext.container.Container Container} or layout, and the
37 * layout and rendering pipeline is {@link Ext.container.Container#add completely managed by the framework}.</p>
38 * <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
39 * and the destruction of any descendant Components. This makes the Panel object, and all its descendants <b>unusable</b>. To enable the close
40 * 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>
41 * <p>Usually, Panels are used as constituents within an application, in which case, they would be used as child items of Containers,
42 * and would themselves use Ext.Components as child {@link #items}. However to illustrate simply rendering a Panel into the document,
43 * here&#39;s how to do it:<pre><code>
44 Ext.create('Ext.panel.Panel', {
47 html: '&lt;p&gt;World!&lt;/p&gt;',
48 renderTo: document.body
50 </code></pre></p>
51 * <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>
52 var filterPanel = Ext.create('Ext.panel.Panel', {
53 bodyPadding: 5, // Don&#39;t want content to crunch against the borders
57 fieldLabel: 'Start date'
60 fieldLabel: 'End date'
63 </code></pre></p>
64 * <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,
65 * the Container into which the Panel is added will use a {@link #layout} to render, size and position its child Components.</p>
66 * <p>Panels will often use specific {@link #layout}s to provide an application with shape and structure by containing and arranging child
67 * Components: <pre><code>
68 var resultsPanel = Ext.create('Ext.panel.Panel', {
72 renderTo: document.body,
74 type: 'vbox', // Arrange child items vertically
75 align: 'stretch', // Each takes up full width
78 items: [{ // Results grid specified as a config object with an xtype of 'grid'
80 columns: [{header: 'Column One'}], // One header just for show. There&#39;s no data,
81 store: Ext.create('Ext.data.ArrayStore', {}), // A dummy empty data store
82 flex: 1 // Use 1/3 of Container&#39;s height (hint to Box layout)
84 xtype: 'splitter' // A splitter between the two child items
85 }, { // Details Panel specified as a config object (no xtype defaults to 'panel').
89 fieldLabel: 'Data item',
91 }], // An array of form fields
92 flex: 2 // Use 2/3 of Container&#39;s height (hint to Box layout)
95 </code></pre>
96 * The example illustrates one possible method of displaying search results. The Panel contains a grid with the resulting data arranged
97 * in rows. Each selected row may be displayed in detail in the Panel below. The {@link Ext.layout.container.VBox vbox} layout is used
98 * to arrange the two vertically. It is configured to stretch child items horizontally to full width. Child items may either be configured
99 * with a numeric height, or with a <code>flex</code> value to distribute available space proportionately.</p>
100 * <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
101 * content area.</p>
102 * <p>Using these techniques, as long as the <b>layout</b> is chosen and configured correctly, an application may have any level of
103 * nested containment, all dynamically sized according to configuration, the user&#39;s preference and available browser size.</p>
105 * @param {Object} config The config object
108 Ext.define('Ext.panel.Panel', {
109 extend: 'Ext.panel.AbstractPanel',
116 'Ext.layout.component.Dock'
118 alias: 'widget.panel',
119 alternateClassName: 'Ext.Panel',
121 <span id='Ext-panel-Panel-cfg-collapsedCls'> /**
122 </span> * @cfg {String} collapsedCls
123 * A CSS class to add to the panel&#39;s element after it has been collapsed (defaults to
124 * <code>'collapsed'</code>).
126 collapsedCls: 'collapsed',
128 <span id='Ext-panel-Panel-cfg-animCollapse'> /**
129 </span> * @cfg {Boolean} animCollapse
130 * <code>true</code> to animate the transition when the panel is collapsed, <code>false</code> to skip the
131 * animation (defaults to <code>true</code> if the {@link Ext.fx.Anim} class is available, otherwise <code>false</code>).
132 * May also be specified as the animation duration in milliseconds.
134 animCollapse: Ext.enableFx,
136 <span id='Ext-panel-Panel-cfg-minButtonWidth'> /**
137 </span> * @cfg {Number} minButtonWidth
138 * Minimum width of all footer toolbar buttons in pixels (defaults to <tt>75</tt>). If set, this will
139 * be used as the default value for the <tt>{@link Ext.button.Button#minWidth}</tt> config of
140 * each Button added to the <b>footer toolbar</b> via the {@link #fbar} or {@link #buttons} configurations.
141 * It will be ignored for buttons that have a minWidth configured some other way, e.g. in their own config
142 * object or via the {@link Ext.container.Container#config-defaults defaults} of their parent container.
146 <span id='Ext-panel-Panel-cfg-collapsed'> /**
147 </span> * @cfg {Boolean} collapsed
148 * <code>true</code> to render the panel collapsed, <code>false</code> to render it expanded (defaults to
149 * <code>false</code>).
153 <span id='Ext-panel-Panel-cfg-collapseFirst'> /**
154 </span> * @cfg {Boolean} collapseFirst
155 * <code>true</code> to make sure the collapse/expand toggle button always renders first (to the left of)
156 * any other tools in the panel&#39;s title bar, <code>false</code> to render it last (defaults to <code>true</code>).
160 <span id='Ext-panel-Panel-cfg-hideCollapseTool'> /**
161 </span> * @cfg {Boolean} hideCollapseTool
162 * <code>true</code> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
163 * <code>false</code> to display it (defaults to <code>false</code>).
165 hideCollapseTool: false,
167 <span id='Ext-panel-Panel-cfg-titleCollapse'> /**
168 </span> * @cfg {Boolean} titleCollapse
169 * <code>true</code> to allow expanding and collapsing the panel (when <code>{@link #collapsible} = true</code>)
170 * by clicking anywhere in the header bar, <code>false</code>) to allow it only by clicking to tool button
171 * (defaults to <code>false</code>)).
173 titleCollapse: false,
175 <span id='Ext-panel-Panel-cfg-collapseMode'> /**
176 </span> * @cfg {String} collapseMode
177 * <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>
178 * <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.
179 * 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>
180 * <p>When a child item of a {@link Ext.layout.container.Border border layout}, this config has two options:
181 * <div class="mdetail-params"><ul>
182 * <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
183 * and to provide a UI with a Tool to allow the user to re-expand the Panel.</div></li>
184 * <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>
185 * </ul></div></p>
188 <span id='Ext-panel-Panel-cfg-placeholder'> /**
189 </span> * @cfg {Mixed} placeholder
190 * <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}
191 * when not using the <code>'header'</code> {@link #collapseMode}.</b></p>
192 * <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
193 * {@link Ext.layout.container.Border border layout}. Defaults to a generated {@link Ext.panel.Header Header}
194 * containing a {@link Ext.panel.Tool Tool} to re-expand the Panel.</p>
197 <span id='Ext-panel-Panel-cfg-floatable'> /**
198 </span> * @cfg {Boolean} floatable
199 * <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>
200 * <tt>true</tt> to allow clicking a collapsed Panel&#39;s {@link #placeholder} to display the Panel floated
201 * above the layout, <tt>false</tt> to force the user to fully expand a collapsed region by
202 * clicking the expand button to see it again (defaults to <tt>true</tt>).
206 <span id='Ext-panel-Panel-cfg-overlapHeader'> /**
207 </span> * @cfg {Mixed} overlapHeader
208 * True to overlap the header in a panel over the framing of the panel itself. This is needed when frame:true (and is done automatically for you). Otherwise it is undefined.
209 * If you manually add rounded corners to a panel header which does not have frame:true, this will need to be set to true.
212 <span id='Ext-panel-Panel-cfg-collapsible'> /**
213 </span> * @cfg {Boolean} collapsible
214 * <p>True to make the panel collapsible and have an expand/collapse toggle Tool added into
215 * 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>
216 * See {@link #collapseMode} and {@link #collapseDirection}
220 <span id='Ext-panel-Panel-cfg-collapseDirection'> /**
221 </span> * @cfg {Boolean} collapseDirection
222 * <p>The direction to collapse the Panel when the toggle button is clicked.</p>
223 * <p>Defaults to the {@link #headerPosition}</p>
224 * <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>
225 * <p>Specify as <code>'top'</code>, <code>'bottom'</code>, <code>'left'</code> or <code>'right'</code>.</p>
228 <span id='Ext-panel-Panel-cfg-closable'> /**
229 </span> * @cfg {Boolean} closable
230 * <p>True to display the 'close' tool button and allow the user to close the window, false to
231 * hide the button and disallow closing the window (defaults to <code>false</code>).</p>
232 * <p>By default, when close is requested by clicking the close button in the header, the {@link #close}
233 * method will be called. This will <i>{@link Ext.Component#destroy destroy}</i> the Panel and its content
234 * meaning that it may not be reused.</p>
235 * <p>To make closing a Panel <i>hide</i> the Panel so that it may be reused, set
236 * {@link #closeAction} to 'hide'.</p>
240 <span id='Ext-panel-Panel-cfg-closeAction'> /**
241 </span> * @cfg {String} closeAction
242 * <p>The action to take when the close header tool is clicked:
243 * <div class="mdetail-params"><ul>
244 * <li><b><code>'{@link #destroy}'</code></b> : <b>Default</b><div class="sub-desc">
245 * {@link #destroy remove} the window from the DOM and {@link Ext.Component#destroy destroy}
246 * it and all descendant Components. The window will <b>not</b> be available to be
247 * redisplayed via the {@link #show} method.
248 * </div></li>
249 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
250 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
251 * The window will be available to be redisplayed via the {@link #show} method.
252 * </div></li>
253 * </ul></div>
254 * <p><b>Note:</b> This behavior has changed! setting *does* affect the {@link #close} method
255 * which will invoke the approriate closeAction.
257 closeAction: 'destroy',
259 <span id='Ext-panel-Panel-cfg-dockedItems'> /**
260 </span> * @cfg {Object/Array} dockedItems
261 * A component or series of components to be added as docked items to this panel.
262 * The docked items can be docked to either the top, right, left or bottom of a panel.
263 * This is typically used for things like toolbars or tab bars:
264 * <pre><code>
265 var panel = new Ext.panel.Panel({
270 text: 'Docked to the top'
273 });</pre></code>
276 <span id='Ext-panel-Panel-cfg-preventHeader'> /**
277 </span> * @cfg {Boolean} preventHeader Prevent a Header from being created and shown. Defaults to false.
279 preventHeader: false,
281 <span id='Ext-panel-Panel-cfg-headerPosition'> /**
282 </span> * @cfg {String} headerPosition Specify as <code>'top'</code>, <code>'bottom'</code>, <code>'left'</code> or <code>'right'</code>. Defaults to <code>'top'</code>.
284 headerPosition: 'top',
286 <span id='Ext-panel-Panel-cfg-frame'> /**
287 </span> * @cfg {Boolean} frame
288 * True to apply a frame to the panel.
292 <span id='Ext-panel-Panel-cfg-frameHeader'> /**
293 </span> * @cfg {Boolean} frameHeader
294 * True to apply a frame to the panel panels header (if 'frame' is true).
298 <span id='Ext-panel-Panel-cfg-tools'> /**
299 </span> * @cfg {Array} tools
300 * An array of {@link Ext.panel.Tool} configs/instances to be added to the header tool area. The tools are stored as child
301 * components of the header container. They can be accessed using {@link #down} and {#query}, as well as the other
302 * component methods. The toggle tool is automatically created if {@link #collapsible} is set to true.
303 * <p>Note that, apart from the toggle tool which is provided when a panel is collapsible, these
304 * tools only provide the visual button. Any required functionality must be provided by adding
305 * handlers that implement the necessary behavior.</p>
306 * <p>Example usage:</p>
307 * <pre><code>
310 qtip: 'Refresh form Data',
312 handler: function(event, toolEl, panel){
319 handler: function(event, toolEl, panel){
323 </code></pre>
327 initComponent: function() {
332 <span id='Ext-panel-Panel-event-titlechange'> /**
333 </span> * @event titlechange
334 * Fires after the Panel title has been set or changed.
335 * @param {Ext.panel.Panel} p the Panel which has been resized.
336 * @param {String} newTitle The new title.
337 * @param {String} oldTitle The previous panel title.
340 <span id='Ext-panel-Panel-event-iconchange'> /**
341 </span> * @event iconchange
342 * Fires after the Panel iconCls has been set or changed.
343 * @param {Ext.panel.Panel} p the Panel which has been resized.
344 * @param {String} newIconCls The new iconCls.
345 * @param {String} oldIconCls The previous panel iconCls.
355 me.setUI('default-framed');
360 me.collapseDirection = me.collapseDirection || me.headerPosition || Ext.Component.DIRECTION_TOP;
362 // Backwards compatibility
366 setBorder: function(border) {
368 // method = (border === false || border === 0) ? 'addClsWithUI' : 'removeClsWithUI';
370 // me.callParent(arguments);
372 // if (me.collapsed) {
373 // me[method](me.collapsedCls + '-noborder');
377 // me.header.setBorder(border);
378 // if (me.collapsed) {
379 // me.header[method](me.collapsedCls + '-noborder');
383 this.callParent(arguments);
386 beforeDestroy: function() {
394 initAria: function() {
396 this.initHeaderAria();
399 initHeaderAria: function() {
403 if (el && header) {
404 el.dom.setAttribute('aria-labelledby', header.titleCmp.id);
408 getHeader: function() {
412 <span id='Ext-panel-Panel-method-setTitle'> /**
413 </span> * Set a title for the panel&#39;s header. See {@link Ext.panel.Header#title}.
414 * @param {String} newTitle
416 setTitle: function(newTitle) {
418 oldTitle = this.title;
422 me.header.setTitle(newTitle);
428 me.reExpander.setTitle(newTitle);
430 me.fireEvent('titlechange', me, newTitle, oldTitle);
433 <span id='Ext-panel-Panel-method-setIconCls'> /**
434 </span> * Set the iconCls for the panel&#39;s header. See {@link Ext.panel.Header#iconCls}.
435 * @param {String} newIconCls
437 setIconCls: function(newIconCls) {
439 oldIconCls = me.iconCls;
441 me.iconCls = newIconCls;
442 var header = me.header;
444 header.setIconCls(newIconCls);
446 me.fireEvent('iconchange', me, newIconCls, oldIconCls);
449 bridgeToolbars: function() {
453 minButtonWidth = me.minButtonWidth;
455 function initToolbar (toolbar, pos) {
456 if (Ext.isArray(toolbar)) {
462 else if (!toolbar.xtype) {
463 toolbar.xtype = 'toolbar';
466 if (pos == 'left' || pos == 'right') {
467 toolbar.vertical = true;
472 // Backwards compatibility
474 <span id='Ext-panel-Panel-cfg-tbar'> /**
475 </span> * @cfg {Object/Array} tbar
477 Convenience method. Short for 'Top Bar'.
480 { xtype: 'button', text: 'Button 1' }
489 { xtype: 'button', text: 'Button 1' }
496 me.addDocked(initToolbar(me.tbar, 'top'));
500 <span id='Ext-panel-Panel-cfg-bbar'> /**
501 </span> * @cfg {Object/Array} bbar
503 Convenience method. Short for 'Bottom Bar'.
506 { xtype: 'button', text: 'Button 1' }
515 { xtype: 'button', text: 'Button 1' }
522 me.addDocked(initToolbar(me.bbar, 'bottom'));
526 <span id='Ext-panel-Panel-cfg-buttons'> /**
527 </span> * @cfg {Object/Array} buttons
529 Convenience method used for adding buttons docked to the bottom right of the panel. This is a
530 synonym for the {@link #fbar} config.
541 defaults: {minWidth: {@link #minButtonWidth}},
543 { xtype: 'component', flex: 1 },
544 { xtype: 'button', text: 'Button 1' }
548 The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
549 each of the buttons in the buttons toolbar.
554 me.fbar = me.buttons;
558 <span id='Ext-panel-Panel-cfg-fbar'> /**
559 </span> * @cfg {Object/Array} fbar
561 Convenience method used for adding items to the bottom right of the panel. Short for Footer Bar.
564 { type: 'button', text: 'Button 1' }
572 defaults: {minWidth: {@link #minButtonWidth}},
574 { xtype: 'component', flex: 1 },
575 { xtype: 'button', text: 'Button 1' }
579 The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
580 each of the buttons in the fbar.
585 fbar = initToolbar(me.fbar, 'bottom');
588 // Apply the minButtonWidth config to buttons in the toolbar
589 if (minButtonWidth) {
590 fbarDefaults = fbar.defaults;
591 fbar.defaults = function(config) {
592 var defaults = fbarDefaults || {};
593 if ((!config.xtype || config.xtype === 'button' || (config.isComponent && config.isXType('button'))) &&
594 !('minWidth' in defaults)) {
595 defaults = Ext.apply({minWidth: minButtonWidth}, defaults);
601 fbar = me.addDocked(fbar)[0];
610 <span id='Ext-panel-Panel-cfg-lbar'> /**
611 </span> * @cfg {Object/Array} lbar
613 * Convenience method. Short for 'Left Bar' (left-docked, vertical toolbar).
616 * { xtype: 'button', text: 'Button 1' }
625 * { xtype: 'button', text: 'Button 1' }
632 me.addDocked(initToolbar(me.lbar, 'left'));
636 <span id='Ext-panel-Panel-cfg-rbar'> /**
637 </span> * @cfg {Object/Array} rbar
639 * Convenience method. Short for 'Right Bar' (right-docked, vertical toolbar).
642 * { xtype: 'button', text: 'Button 1' }
651 * { xtype: 'button', text: 'Button 1' }
658 me.addDocked(initToolbar(me.rbar, 'right'));
663 <span id='Ext-panel-Panel-method-initTools'> /**
665 * Tools are a Panel-specific capabilty.
666 * Panel uses initTools. Subclasses may contribute tools by implementing addTools.
668 initTools: function() {
671 me.tools = me.tools || [];
673 // Add a collapse tool unless configured to not show a collapse tool
674 // or to not even show a header.
675 if (me.collapsible && !(me.hideCollapseTool || me.header === false)) {
676 me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';
677 me.collapseTool = me.expandTool = me.createComponent({
679 type: 'collapse-' + me.collapseDirection,
680 expandType: me.getOppositeDirection(me.collapseDirection),
681 handler: me.toggleCollapse,
685 // Prepend collapse tool is configured to do so.
686 if (me.collapseFirst) {
687 me.tools.unshift(me.collapseTool);
691 // Add subclass-specific tools.
694 // Make Panel closable.
696 me.addClsWithUI('closable');
699 handler: Ext.Function.bind(me.close, this, [])
703 // Append collapse tool if needed.
704 if (me.collapseTool && !me.collapseFirst) {
705 me.tools.push(me.collapseTool);
709 <span id='Ext-panel-Panel-property-addTools'> /**
711 * Template method to be implemented in subclasses to add their tools after the collapsible tool.
713 addTools: Ext.emptyFn,
715 <span id='Ext-panel-Panel-method-close'> /**
716 </span> * <p>Closes the Panel. By default, this method, removes it from the DOM, {@link Ext.Component#destroy destroy}s
717 * the Panel object and all its descendant Components. The {@link #beforeclose beforeclose}
718 * event is fired before the close happens and will cancel the close action if it returns false.<p>
719 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
720 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
721 * To hide the Panel without destroying it, call {@link #hide}.</p>
724 if (this.fireEvent('beforeclose', this) !== false) {
730 doClose: function() {
731 this.fireEvent('close', this);
732 this[this.closeAction]();
735 onRender: function(ct, position) {
739 // Add class-specific header tools.
740 // Panel adds collapsible and closable.
743 // Dock the header/title
746 // If initially collapsed, collapsed flag must indicate true current state at this point.
747 // Do collapse after the first time the Panel's structure has been laid out.
749 me.collapsed = false;
750 topContainer = me.findLayoutController();
751 if (!me.hidden && topContainer) {
753 afterlayout: function() {
754 me.collapse(null, false, true);
759 me.afterComponentLayout = function() {
760 delete me.afterComponentLayout;
761 Ext.getClass(me).prototype.afterComponentLayout.apply(me, arguments);
762 me.collapse(null, false, true);
767 // Call to super after adding the header, to prevent an unnecessary re-layout
768 me.callParent(arguments);
771 <span id='Ext-panel-Panel-method-updateHeader'> /**
772 </span> * Create, hide, or show the header component as appropriate based on the current config.
774 * @param {Boolean} force True to force the the header to be created
776 updateHeader: function(force) {
782 if (!me.preventHeader && (force || title || (tools && tools.length))) {
784 header = me.header = Ext.create('Ext.panel.Header', {
786 orientation : (me.headerPosition == 'left' || me.headerPosition == 'right') ? 'vertical' : 'horizontal',
787 dock : me.headerPosition || 'top',
788 textCls : me.headerTextCls,
789 iconCls : me.iconCls,
790 baseCls : me.baseCls + '-header',
793 indicateDrag: me.draggable,
795 frame : me.frame && me.frameHeader,
796 ignoreParentFrame : me.frame || me.overlapHeader,
797 ignoreBorderManagement: me.frame || me.ignoreHeaderBorderManagement,
798 listeners : me.collapsible && me.titleCollapse ? {
799 click: me.toggleCollapse,
803 me.addDocked(header, 0);
805 // Reference the Header's tool array.
806 // Header injects named references.
807 me.tools = header.tools;
817 setUI: function(ui) {
820 me.callParent(arguments);
828 getContentTarget: function() {
832 getTargetEl: function() {
833 return this.body || this.frameBody || this.el;
836 addTool: function(tool) {
837 this.tools.push(tool);
838 var header = this.header;
840 header.addTool(tool);
845 getOppositeDirection: function(d) {
846 var c = Ext.Component;
848 case c.DIRECTION_TOP:
849 return c.DIRECTION_BOTTOM;
850 case c.DIRECTION_RIGHT:
851 return c.DIRECTION_LEFT;
852 case c.DIRECTION_BOTTOM:
853 return c.DIRECTION_TOP;
854 case c.DIRECTION_LEFT:
855 return c.DIRECTION_RIGHT;
859 <span id='Ext-panel-Panel-method-collapse'> /**
860 </span> * Collapses the panel body so that the body becomes hidden. Docked Components parallel to the
861 * border towards which the collapse takes place will remain visible. Fires the {@link #beforecollapse} event which will
862 * cancel the collapse action if it returns false.
863 * @param {Number} direction. The direction to collapse towards. Must be one of<ul>
864 * <li>Ext.Component.DIRECTION_TOP</li>
865 * <li>Ext.Component.DIRECTION_RIGHT</li>
866 * <li>Ext.Component.DIRECTION_BOTTOM</li>
867 * <li>Ext.Component.DIRECTION_LEFT</li></ul>
868 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
869 * {@link #animCollapse} panel config)
870 * @return {Ext.panel.Panel} this
872 collapse: function(direction, animate, /* private - passed if called at render time */ internal) {
875 height = me.getHeight(),
876 width = me.getWidth(),
879 dockedItems = me.dockedItems.items,
880 dockedItemCount = dockedItems.length,
894 afteranimate: me.afterCollapse,
897 duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration)
900 reExpanderOrientation,
907 direction = me.collapseDirection;
910 // If internal (Called because of initial collapsed state), then no animation, and no events.
913 } else if (me.collapsed || me.fireEvent('beforecollapse', me, direction, animate) === false) {
917 reExpanderDock = direction;
918 me.expandDirection = me.getOppositeDirection(direction);
920 // Track docked items which we hide during collapsed state
921 me.hiddenDocked = [];
924 case c.DIRECTION_TOP:
925 case c.DIRECTION_BOTTOM:
926 me.expandedSize = me.getHeight();
927 reExpanderOrientation = 'horizontal';
928 collapseDimension = 'height';
929 getDimension = 'getHeight';
930 setDimension = 'setHeight';
932 // Collect the height of the visible header.
933 // Hide all docked items except the header.
934 // Hide *ALL* docked items if we're going to end up hiding the whole Panel anyway
935 for (; i < dockedItemCount; i++) {
936 comp = dockedItems[i];
937 if (comp.isVisible()) {
938 if (comp.isHeader && (!comp.dock || comp.dock == 'top' || comp.dock == 'bottom')) {
941 me.hiddenDocked.push(comp);
946 if (direction == Ext.Component.DIRECTION_BOTTOM) {
947 pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
952 case c.DIRECTION_LEFT:
953 case c.DIRECTION_RIGHT:
954 me.expandedSize = me.getWidth();
955 reExpanderOrientation = 'vertical';
956 collapseDimension = 'width';
957 getDimension = 'getWidth';
958 setDimension = 'setWidth';
960 // Collect the height of the visible header.
961 // Hide all docked items except the header.
962 // Hide *ALL* docked items if we're going to end up hiding the whole Panel anyway
963 for (; i < dockedItemCount; i++) {
964 comp = dockedItems[i];
965 if (comp.isVisible()) {
966 if (comp.isHeader && (comp.dock == 'left' || comp.dock == 'right')) {
969 me.hiddenDocked.push(comp);
974 if (direction == Ext.Component.DIRECTION_RIGHT) {
975 pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
976 anim.from.left = pos;
981 throw('Panel collapse must be passed a valid Component collapse direction');
984 // No scrollbars when we shrink this Panel
985 // And no laying out of any children... we're effectively *hiding* the body
986 me.setAutoScroll(false);
987 me.suspendLayout = true;
988 me.body.setVisibilityMode(Ext.core.Element.DISPLAY);
990 // Disable toggle tool during animated collapse
991 if (animate && me.collapseTool) {
992 me.collapseTool.disable();
995 // Add the collapsed class now, so that collapsed CSS rules are applied before measurements are taken.
996 me.addClsWithUI(me.collapsedCls);
997 // if (me.border === false) {
998 // me.addClsWithUI(me.collapsedCls + '-noborder');
1001 // We found a header: Measure it to find the collapse-to size.
1003 //we must add the collapsed cls to the header and then remove to get the proper height
1004 reExpander.addClsWithUI(me.collapsedCls);
1005 reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
1006 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1007 reExpander.addClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
1010 frameInfo = reExpander.getFrameInfo();
1013 newSize = reExpander[getDimension]() + (frameInfo ? frameInfo[direction] : 0);
1016 reExpander.removeClsWithUI(me.collapsedCls);
1017 reExpander.removeClsWithUI(me.collapsedCls + '-' + reExpander.dock);
1018 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1019 reExpander.removeClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
1022 // No header: Render and insert a temporary one, and then measure it.
1025 hideMode: 'offsets',
1028 orientation: reExpanderOrientation,
1029 dock: reExpanderDock,
1030 textCls: me.headerTextCls,
1031 iconCls: me.iconCls,
1032 baseCls: me.baseCls + '-header',
1034 frame: me.frame && me.frameHeader,
1035 ignoreParentFrame: me.frame || me.overlapHeader,
1036 indicateDrag: me.draggable,
1037 cls: me.baseCls + '-collapsed-placeholder ' + ' ' + Ext.baseCSSPrefix + 'docked ' + me.baseCls + '-' + me.ui + '-collapsed',
1040 if (!me.hideCollapseTool) {
1041 reExpander[(reExpander.orientation == 'horizontal') ? 'tools' : 'items'] = [{
1043 type: 'expand-' + me.expandDirection,
1044 handler: me.toggleCollapse,
1049 // Capture the size of the re-expander.
1050 // For vertical headers in IE6 and IE7, this will be sized by a CSS rule in _panel.scss
1051 reExpander = me.reExpander = Ext.create('Ext.panel.Header', reExpander);
1052 newSize = reExpander[getDimension]() + ((reExpander.frame) ? reExpander.frameSize[direction] : 0);
1055 // Insert the new docked item
1056 me.insertDocked(0, reExpander);
1059 me.reExpander = reExpander;
1060 me.reExpander.addClsWithUI(me.collapsedCls);
1061 me.reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
1062 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1063 me.reExpander.addClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
1066 // If collapsing right or down, we'll be also animating the left or top.
1067 if (direction == Ext.Component.DIRECTION_RIGHT) {
1068 anim.to.left = pos + (width - newSize);
1069 } else if (direction == Ext.Component.DIRECTION_BOTTOM) {
1070 anim.to.top = pos + (height - newSize);
1073 // Animate to the new size
1074 anim.to[collapseDimension] = newSize;
1076 // Remove any flex config before we attempt to collapse.
1077 me.savedFlex = me.flex;
1078 me.savedMinWidth = me.minWidth;
1079 me.savedMinHeight = me.minHeight;
1087 // EXTJSIV-1937 (would like to use setCalculateSize)
1088 // save width/height here, expand puts them back
1089 me.uncollapsedSize = { width: me.width, height: me.height };
1091 me.setSize(anim.to.width, anim.to.height);
1092 if (Ext.isDefined(anim.to.left) || Ext.isDefined(anim.to.top)) {
1093 me.setPosition(anim.to.left, anim.to.top);
1095 me.afterCollapse(false, internal);
1100 afterCollapse: function(animated, internal) {
1103 l = me.hiddenDocked.length;
1105 me.minWidth = me.savedMinWidth;
1106 me.minHeight = me.savedMinHeight;
1109 for (; i < l; i++) {
1110 me.hiddenDocked[i].hide();
1112 if (me.reExpander) {
1113 me.reExpander.updateFrame();
1114 me.reExpander.show();
1116 me.collapsed = true;
1119 me.doComponentLayout();
1123 me.resizer.disable();
1126 // If me Panel was configured with a collapse tool in its header, flip it's type
1127 if (me.collapseTool) {
1128 me.collapseTool.setType('expand-' + me.expandDirection);
1131 me.fireEvent('collapse', me);
1134 // Re-enable the toggle tool after an animated collapse
1135 if (animated && me.collapseTool) {
1136 me.collapseTool.enable();
1140 <span id='Ext-panel-Panel-method-expand'> /**
1141 </span> * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
1142 * cancel the expand action if it returns false.
1143 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1144 * {@link #animCollapse} panel config)
1145 * @return {Ext.panel.Panel} this
1147 expand: function(animate) {
1148 if (!this.collapsed || this.fireEvent('beforeexpand', this, animate) === false) {
1152 // EXTJSIV-1937 (would like to use setCalculateSize)
1153 if (this.uncollapsedSize) {
1154 Ext.Object.each(this.uncollapsedSize, function (name, value) {
1155 if (Ext.isDefined(value)) {
1161 delete this.uncollapsedSize;
1166 l = me.hiddenDocked.length,
1167 direction = me.expandDirection,
1168 height = me.getHeight(),
1169 width = me.getWidth(),
1170 pos, anim, satisfyJSLint;
1172 // Disable toggle tool during animated expand
1173 if (animate && me.collapseTool) {
1174 me.collapseTool.disable();
1177 // Show any docked items that we hid on collapse
1178 // And hide the injected reExpander Header
1179 for (; i < l; i++) {
1180 me.hiddenDocked[i].hidden = false;
1181 me.hiddenDocked[i].el.show();
1183 if (me.reExpander) {
1184 if (me.reExpander.temporary) {
1185 me.reExpander.hide();
1187 me.reExpander.removeClsWithUI(me.collapsedCls);
1188 me.reExpander.removeClsWithUI(me.collapsedCls + '-' + me.reExpander.dock);
1189 if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
1190 me.reExpander.removeClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
1192 me.reExpander.updateFrame();
1196 // If me Panel was configured with a collapse tool in its header, flip it's type
1197 if (me.collapseTool) {
1198 me.collapseTool.setType('collapse-' + me.collapseDirection);
1201 // Unset the flag before the potential call to calculateChildBox to calculate our newly flexed size
1202 me.collapsed = false;
1204 // Collapsed means body element was hidden
1207 // Remove any collapsed styling before any animation begins
1208 me.removeClsWithUI(me.collapsedCls);
1209 // if (me.border === false) {
1210 // me.removeClsWithUI(me.collapsedCls + '-noborder');
1221 afteranimate: me.afterExpand,
1226 if ((direction == Ext.Component.DIRECTION_TOP) || (direction == Ext.Component.DIRECTION_BOTTOM)) {
1228 // If autoHeight, measure the height now we have shown the body element.
1229 if (me.autoHeight) {
1230 me.setCalculatedSize(me.width, null);
1231 anim.to.height = me.getHeight();
1233 // Must size back down to collapsed for the animation.
1234 me.setCalculatedSize(me.width, anim.from.height);
1236 // If we were flexed, then we can't just restore to the saved size.
1237 // We must restore to the currently correct, flexed size, so we much ask the Box layout what that is.
1238 else if (me.savedFlex) {
1239 me.flex = me.savedFlex;
1240 anim.to.height = me.ownerCt.layout.calculateChildBox(me).height;
1243 // Else, restore to saved height
1245 anim.to.height = me.expandedSize;
1248 // top needs animating upwards
1249 if (direction == Ext.Component.DIRECTION_TOP) {
1250 pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
1251 anim.from.top = pos;
1252 anim.to.top = pos - (anim.to.height - height);
1254 } else if ((direction == Ext.Component.DIRECTION_LEFT) || (direction == Ext.Component.DIRECTION_RIGHT)) {
1256 // If autoWidth, measure the width now we have shown the body element.
1258 me.setCalculatedSize(null, me.height);
1259 anim.to.width = me.getWidth();
1261 // Must size back down to collapsed for the animation.
1262 me.setCalculatedSize(anim.from.width, me.height);
1264 // If we were flexed, then we can't just restore to the saved size.
1265 // We must restore to the currently correct, flexed size, so we much ask the Box layout what that is.
1266 else if (me.savedFlex) {
1267 me.flex = me.savedFlex;
1268 anim.to.width = me.ownerCt.layout.calculateChildBox(me).width;
1271 // Else, restore to saved width
1273 anim.to.width = me.expandedSize;
1276 // left needs animating leftwards
1277 if (direction == Ext.Component.DIRECTION_LEFT) {
1278 pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
1279 anim.from.left = pos;
1280 anim.to.left = pos - (anim.to.width - width);
1287 me.setSize(anim.to.width, anim.to.height);
1289 me.setLeft(anim.to.x);
1292 me.setTop(anim.to.y);
1294 me.afterExpand(false);
1300 afterExpand: function(animated) {
1302 me.setAutoScroll(me.initialConfig.autoScroll);
1304 // Restored to a calculated flex. Delete the set width and height properties so that flex works from now on.
1306 me.flex = me.savedFlex;
1307 delete me.savedFlex;
1312 // Reinstate layout out after Panel has re-expanded
1313 delete me.suspendLayout;
1314 if (animated && me.ownerCt) {
1315 me.ownerCt.doLayout();
1319 me.resizer.enable();
1322 me.fireEvent('expand', me);
1324 // Re-enable the toggle tool after an animated expand
1325 if (animated && me.collapseTool) {
1326 me.collapseTool.enable();
1330 <span id='Ext-panel-Panel-method-toggleCollapse'> /**
1331 </span> * Shortcut for performing an {@link #expand} or {@link #collapse} based on the current state of the panel.
1332 * @return {Ext.panel.Panel} this
1334 toggleCollapse: function() {
1335 if (this.collapsed) {
1336 this.expand(this.animCollapse);
1338 this.collapse(this.collapseDirection, this.animCollapse);
1344 getKeyMap : function(){
1346 this.keyMap = Ext.create('Ext.util.KeyMap', this.el, this.keys);
1352 initDraggable : function(){
1353 <span id='Ext-panel-Panel-property-dd'> /**
1354 </span> * <p>If this Panel is configured {@link #draggable}, this property will contain
1355 * an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
1356 * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
1357 * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
1358 * @type Ext.dd.DragSource.
1361 this.dd = Ext.create('Ext.panel.DD', this, Ext.isBoolean(this.draggable) ? null : this.draggable);
1364 // private - helper function for ghost
1365 ghostTools : function() {
1367 origTools = this.initialConfig.tools;
1370 Ext.each(origTools, function(tool) {
1371 // Some tools can be full components, and copying them into the ghost
1372 // actually removes them from the owning panel. You could also potentially
1373 // end up with duplicate DOM ids as well. To avoid any issues we just make
1374 // a simple bare-minimum clone of each tool for ghosting purposes.
1388 // private - used for dragging
1389 ghost: function(cls) {
1391 ghostPanel = me.ghostPanel,
1395 ghostPanel = Ext.create('Ext.panel.Panel', {
1396 renderTo: document.body,
1400 frame: Ext.supports.CSS3BorderRadius ? me.frame : false,
1402 overlapHeader: me.overlapHeader,
1403 headerPosition: me.headerPosition,
1404 width: me.getWidth(),
1405 height: me.getHeight(),
1406 iconCls: me.iconCls,
1407 baseCls: me.baseCls,
1408 tools: me.ghostTools(),
1409 cls: me.baseCls + '-ghost ' + (cls ||'')
1411 me.ghostPanel = ghostPanel;
1413 ghostPanel.floatParent = me.floatParent;
1415 ghostPanel.setZIndex(Ext.Number.from(me.el.getStyle('zIndex'), 0));
1417 ghostPanel.toFront();
1419 ghostPanel.el.show();
1420 ghostPanel.setPosition(box.x, box.y);
1421 ghostPanel.setSize(box.width, box.height);
1423 if (me.floatingItems) {
1424 me.floatingItems.hide();
1430 unghost: function(show, matchPosition) {
1432 if (!me.ghostPanel) {
1435 if (show !== false) {
1437 if (matchPosition !== false) {
1438 me.setPosition(me.ghostPanel.getPosition());
1440 if (me.floatingItems) {
1441 me.floatingItems.show();
1443 Ext.defer(me.focus, 10, me);
1445 me.ghostPanel.el.hide();
1448 initResizable: function(resizable) {
1449 if (this.collapsed) {
1450 resizable.disabled = true;
1452 this.callParent([resizable]);