3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.Panel"></div>/**
10 * @extends Ext.Container
11 * <p>Panel is a container that has specific functionality and structural components that make
12 * it the perfect building block for application-oriented user interfaces.</p>
13 * <p>Panels are, by virtue of their inheritance from {@link Ext.Container}, capable
14 * of being configured with a {@link Ext.Container#layout layout}, and containing child Components.</p>
15 * <p>When either specifying child {@link Ext.Component#items items} of a Panel, or dynamically {@link Ext.Container#add adding} Components
16 * to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether
17 * those child elements need to be sized using one of Ext's built-in <tt><b>{@link Ext.Container#layout layout}</b></tt> schemes. By
18 * default, Panels use the {@link Ext.layout.ContainerLayout ContainerLayout} scheme. This simply renders
19 * child components, appending them one after the other inside the Container, and <b>does not apply any sizing</b>
21 * <p>A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate
22 * {@link #header}, {@link #footer} and {@link #body} sections (see {@link #frame} for additional
24 * <p>Panel also provides built-in {@link #collapsible expandable and collapsible behavior}, along with
25 * a variety of {@link #tools prebuilt tool buttons} that can be wired up to provide other customized
26 * behavior. Panels can be easily dropped into any {@link Ext.Container Container} or layout, and the
27 * layout and rendering pipeline is {@link Ext.Container#add completely managed by the framework}.</p>
29 * @param {Object} config The config object
32 Ext.Panel = Ext.extend(Ext.Container, {
33 <div id="prop-Ext.Panel-header"></div>/**
34 * The Panel's header {@link Ext.Element Element}. Read-only.
35 * <p>This Element is used to house the {@link #title} and {@link #tools}</p>
36 * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
40 <div id="prop-Ext.Panel-body"></div>/**
41 * The Panel's body {@link Ext.Element Element} which may be used to contain HTML content.
42 * The content may be specified in the {@link #html} config, or it may be loaded using the
43 * {@link autoLoad} config, or through the Panel's {@link #getUpdater Updater}. Read-only.
44 * <p>If this is used to load visible HTML elements in either way, then
45 * the Panel may not be used as a Layout for hosting nested Panels.</p>
46 * <p>If this Panel is intended to be used as the host of a Layout (See {@link #layout}
47 * then the body Element must not be loaded or changed - it is under the control
48 * of the Panel's Layout.
49 * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
53 <div id="prop-Ext.Panel-bwrap"></div>/**
54 * The Panel's bwrap {@link Ext.Element Element} used to contain other Panel elements
55 * (tbar, body, bbar, footer). See {@link #bodyCfg}. Read-only.
59 <div id="prop-Ext.Panel-collapsed"></div>/**
60 * True if this panel is collapsed. Read-only.
64 <div id="cfg-Ext.Panel-bodyCfg"></div>/**
65 * @cfg {Object} bodyCfg
66 * <p>A {@link Ext.DomHelper DomHelper} element specification object may be specified for any
68 * <p>By default, the Default element in the table below will be used for the html markup to
69 * create a child element with the commensurate Default class name (<tt>baseCls</tt> will be
70 * replaced by <tt>{@link #baseCls}</tt>):</p>
72 * Panel Default Default Custom Additional Additional
73 * Element element class element class style
74 * ======== ========================== ========= ============== ===========
75 * {@link #header} div {@link #baseCls}+'-header' {@link #headerCfg} headerCssClass headerStyle
76 * {@link #bwrap} div {@link #baseCls}+'-bwrap' {@link #bwrapCfg} bwrapCssClass bwrapStyle
77 * + tbar div {@link #baseCls}+'-tbar' {@link #tbarCfg} tbarCssClass tbarStyle
78 * + {@link #body} div {@link #baseCls}+'-body' {@link #bodyCfg} {@link #bodyCssClass} {@link #bodyStyle}
79 * + bbar div {@link #baseCls}+'-bbar' {@link #bbarCfg} bbarCssClass bbarStyle
80 * + {@link #footer} div {@link #baseCls}+'-footer' {@link #footerCfg} footerCssClass footerStyle
82 * <p>Configuring a Custom element may be used, for example, to force the {@link #body} Element
83 * to use a different form of markup than is created by default. An example of this might be
84 * to {@link Ext.Element#createChild create a child} Panel containing a custom content, such as
85 * a header, or forcing centering of all Panel content by having the body be a <center>
89 title: 'Message Title',
90 renderTo: Ext.getBody(),
91 width: 200, height: 130,
94 cls: 'x-panel-body', // Default class not applied if Custom element specified
99 cls: 'x-panel-footer' // same as the Default class
102 footerCssClass: 'custom-footer', // additional css class, see {@link Ext.element#addClass addClass}
103 footerStyle: 'background-color:red' // see {@link #bodyStyle}
106 * <p>The example above also explicitly creates a <tt>{@link #footer}</tt> with custom markup and
107 * styling applied.</p>
109 <div id="cfg-Ext.Panel-headerCfg"></div>/**
110 * @cfg {Object} headerCfg
111 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
112 * of this Panel's {@link #header} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
114 <div id="cfg-Ext.Panel-bwrapCfg"></div>/**
115 * @cfg {Object} bwrapCfg
116 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
117 * of this Panel's {@link #bwrap} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
119 <div id="cfg-Ext.Panel-tbarCfg"></div>/**
120 * @cfg {Object} tbarCfg
121 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
122 * of this Panel's {@link #tbar} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
124 <div id="cfg-Ext.Panel-bbarCfg"></div>/**
125 * @cfg {Object} bbarCfg
126 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
127 * of this Panel's {@link #bbar} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
129 <div id="cfg-Ext.Panel-footerCfg"></div>/**
130 * @cfg {Object} footerCfg
131 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
132 * of this Panel's {@link #footer} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
134 <div id="cfg-Ext.Panel-closable"></div>/**
135 * @cfg {Boolean} closable
136 * Panels themselves do not directly support being closed, but some Panel subclasses do (like
137 * {@link Ext.Window}) or a Panel Class within an {@link Ext.TabPanel}. Specify <tt>true</tt>
138 * to enable closing in such situations. Defaults to <tt>false</tt>.
140 <div id="prop-Ext.Panel-footer"></div>/**
141 * The Panel's footer {@link Ext.Element Element}. Read-only.
142 * <p>This Element is used to house the Panel's <tt>{@link #buttons}</tt> or <tt>{@link #fbar}</tt>.</p>
143 * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
147 <div id="cfg-Ext.Panel-applyTo"></div>/**
148 * @cfg {Mixed} applyTo
149 * <p>The id of the node, a DOM node or an existing Element corresponding to a DIV that is already present in
150 * the document that specifies some panel-specific structural markup. When <tt>applyTo</tt> is used,
151 * constituent parts of the panel can be specified by CSS class name within the main element, and the panel
152 * will automatically create those components from that markup. Any required components not specified in the
153 * markup will be autogenerated if necessary.</p>
154 * <p>The following class names are supported (baseCls will be replaced by {@link #baseCls}):</p>
155 * <ul><li>baseCls + '-header'</li>
156 * <li>baseCls + '-header-text'</li>
157 * <li>baseCls + '-bwrap'</li>
158 * <li>baseCls + '-tbar'</li>
159 * <li>baseCls + '-body'</li>
160 * <li>baseCls + '-bbar'</li>
161 * <li>baseCls + '-footer'</li></ul>
162 * <p>Using this config, a call to render() is not required. If applyTo is specified, any value passed for
163 * {@link #renderTo} will be ignored and the target element's parent node will automatically be used as the
164 * panel's container.</p>
166 <div id="cfg-Ext.Panel-tbar"></div>/**
167 * @cfg {Object/Array} tbar
168 * <p>The top toolbar of the panel. This can be a {@link Ext.Toolbar} object, a toolbar config, or an array of
169 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
170 * To access the top toolbar after render, use {@link #getTopToolbar}.</p>
171 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> be updated by a load
172 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
173 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
174 * submission parameters are collected from the DOM tree.</p>
176 <div id="cfg-Ext.Panel-bbar"></div>/**
177 * @cfg {Object/Array} bbar
178 * <p>The bottom toolbar of the panel. This can be a {@link Ext.Toolbar} object, a toolbar config, or an array of
179 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
180 * To access the bottom toolbar after render, use {@link #getBottomToolbar}.</p>
181 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not<b> be updated by a load
182 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
183 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
184 * submission parameters are collected from the DOM tree.</p>
186 <div id="cfg-Ext.Panel-fbar"></div>/** @cfg {Object/Array} fbar
187 * <p>A {@link Ext.Toolbar Toolbar} object, a Toolbar config, or an array of
188 * {@link Ext.Button Button}s/{@link Ext.Button Button} configs, describing a {@link Ext.Toolbar Toolbar} to be rendered into this Panel's footer element.</p>
189 * <p>After render, the <code>fbar</code> property will be an {@link Ext.Toolbar Toolbar} instance.</p>
190 * <p>If <tt>{@link #buttons}</tt> are specified, they will supersede the <tt>fbar</tt> configuration property.</p>
191 * The Panel's <tt>{@link #buttonAlign}</tt> configuration affects the layout of these items, for example:
193 var w = new Ext.Window({
196 bbar: new Ext.Toolbar({
203 {@link #buttonAlign}: 'left', // anything but 'center' or 'right' and you can use "-", and "->"
204 // to control the alignment of fbar items
212 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not<b> be updated by a load
213 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
214 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
215 * submission parameters are collected from the DOM tree.</p>
217 <div id="cfg-Ext.Panel-header"></div>/**
218 * @cfg {Boolean} header
219 * <tt>true</tt> to create the Panel's header element explicitly, <tt>false</tt> to skip creating
220 * it. If a <tt>{@link #title}</tt> is set the header will be created automatically, otherwise it will not.
221 * If a <tt>{@link #title}</tt> is set but <tt>header</tt> is explicitly set to <tt>false</tt>, the header
222 * will not be rendered.
224 <div id="cfg-Ext.Panel-footer"></div>/**
225 * @cfg {Boolean} footer
226 * <tt>true</tt> to create the footer element explicitly, false to skip creating it. The footer
227 * will be created automatically if <tt>{@link #buttons}</tt> or a <tt>{@link #fbar}</tt> have
228 * been configured. See <tt>{@link #bodyCfg}</tt> for an example.
230 <div id="cfg-Ext.Panel-title"></div>/**
231 * @cfg {String} title
232 * The title text to be used as innerHTML (html tags are accepted) to display in the panel
233 * <tt>{@link #header}</tt> (defaults to ''). When a <tt>title</tt> is specified the
234 * <tt>{@link #header}</tt> element will automatically be created and displayed unless
235 * {@link #header} is explicitly set to <tt>false</tt>. If you do not want to specify a
236 * <tt>title</tt> at config time, but you may want one later, you must either specify a non-empty
237 * <tt>title</tt> (a blank space ' ' will do) or <tt>header:true</tt> so that the container
238 * element will get created.
240 <div id="cfg-Ext.Panel-buttons"></div>/**
241 * @cfg {Array} buttons
242 * <tt>buttons</tt> will be used as <tt>{@link Ext.Container#items items}</tt> for the toolbar in
243 * the footer (<tt>{@link #fbar}</tt>). Typically the value of this configuration property will be
244 * an array of {@link Ext.Button}s or {@link Ext.Button} configuration objects.
245 * If an item is configured with <tt>minWidth</tt> or the Panel is configured with <tt>minButtonWidth</tt>,
246 * that width will be applied to the item.
248 <div id="cfg-Ext.Panel-autoLoad"></div>/**
249 * @cfg {Object/String/Function} autoLoad
250 * A valid url spec according to the Updater {@link Ext.Updater#update} method.
251 * If autoLoad is not null, the panel will attempt to load its contents
252 * immediately upon render.<p>
253 * The URL will become the default URL for this panel's {@link #body} element,
254 * so it may be {@link Ext.Element#refresh refresh}ed at any time.</p>
256 <div id="cfg-Ext.Panel-frame"></div>/**
257 * @cfg {Boolean} frame
258 * <tt>false</tt> by default to render with plain 1px square borders. <tt>true</tt> to render with
259 * 9 elements, complete with custom rounded corners (also see {@link Ext.Element#boxWrap}).
260 * <p>The template generated for each condition is depicted below:</p><pre><code>
263 <div id="developer-specified-id-goes-here" class="x-panel">
265 <div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:false)</span></div>
267 <div class="x-panel-bwrap">
268 <div class="x-panel-body"><p>html value goes here</p></div>
272 // frame = true (create 9 elements)
273 <div id="developer-specified-id-goes-here" class="x-panel">
274 <div class="x-panel-tl"><div class="x-panel-tr"><div class="x-panel-tc">
275 <div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:true)</span></div>
276 </div></div></div>
278 <div class="x-panel-bwrap">
279 <div class="x-panel-ml"><div class="x-panel-mr"><div class="x-panel-mc">
280 <div class="x-panel-body"><p>html value goes here</p></div>
281 </div></div></div>
283 <div class="x-panel-bl"><div class="x-panel-br"><div class="x-panel-bc"/>
284 </div></div></div>
288 <div id="cfg-Ext.Panel-border"></div>/**
289 * @cfg {Boolean} border
290 * True to display the borders of the panel's body element, false to hide them (defaults to true). By default,
291 * the border is a 2px wide inset border, but this can be further altered by setting {@link #bodyBorder} to false.
293 <div id="cfg-Ext.Panel-bodyBorder"></div>/**
294 * @cfg {Boolean} bodyBorder
295 * True to display an interior border on the body element of the panel, false to hide it (defaults to true).
296 * This only applies when {@link #border} == true. If border == true and bodyBorder == false, the border will display
297 * as a 1px wide inset border, giving the entire body element an inset appearance.
299 <div id="cfg-Ext.Panel-bodyCssClass"></div>/**
300 * @cfg {String/Object/Function} bodyCssClass
301 * Additional css class selector to be applied to the {@link #body} element in the format expected by
302 * {@link Ext.Element#addClass} (defaults to null). See {@link #bodyCfg}.
304 <div id="cfg-Ext.Panel-bodyStyle"></div>/**
305 * @cfg {String/Object/Function} bodyStyle
306 * Custom CSS styles to be applied to the {@link #body} element in the format expected by
307 * {@link Ext.Element#applyStyles} (defaults to null). See {@link #bodyCfg}.
309 <div id="cfg-Ext.Panel-iconCls"></div>/**
310 * @cfg {String} iconCls
311 * The CSS class selector that specifies a background image to be used as the header icon (defaults to '').
312 * <p>An example of specifying a custom icon class would be something like:
314 // specify the property in the config for the class:
318 // css class that specifies background image to be used as the icon image:
319 .my-icon { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
322 <div id="cfg-Ext.Panel-collapsible"></div>/**
323 * @cfg {Boolean} collapsible
324 * True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into
325 * the header tool button area, false to keep the panel statically sized with no button (defaults to false).
327 <div id="cfg-Ext.Panel-tools"></div>/**
329 * An array of tool button configs to be added to the header tool area. When rendered, each tool is
330 * stored as an {@link Ext.Element Element} referenced by a public property called <tt><b></b>tools.<i><tool-type></i></tt>
331 * <p>Each tool config may contain the following properties:
332 * <div class="mdetail-params"><ul>
333 * <li><b>id</b> : String<div class="sub-desc"><b>Required.</b> The type
334 * of tool to create. By default, this assigns a CSS class of the form <tt>x-tool-<i><tool-type></i></tt> to the
335 * resulting tool Element. Ext provides CSS rules, and an icon sprite containing images for the tool types listed below.
336 * The developer may implement custom tools by supplying alternate CSS rules and background images:
338 * <div class="x-tool x-tool-toggle" style="float:left; margin-right:5;"> </div><div><tt> toggle</tt> (Created by default when {@link #collapsible} is <tt>true</tt>)</div>
339 * <div class="x-tool x-tool-close" style="float:left; margin-right:5;"> </div><div><tt> close</tt></div>
340 * <div class="x-tool x-tool-minimize" style="float:left; margin-right:5;"> </div><div><tt> minimize</tt></div>
341 * <div class="x-tool x-tool-maximize" style="float:left; margin-right:5;"> </div><div><tt> maximize</tt></div>
342 * <div class="x-tool x-tool-restore" style="float:left; margin-right:5;"> </div><div><tt> restore</tt></div>
343 * <div class="x-tool x-tool-gear" style="float:left; margin-right:5;"> </div><div><tt> gear</tt></div>
344 * <div class="x-tool x-tool-pin" style="float:left; margin-right:5;"> </div><div><tt> pin</tt></div>
345 * <div class="x-tool x-tool-unpin" style="float:left; margin-right:5;"> </div><div><tt> unpin</tt></div>
346 * <div class="x-tool x-tool-right" style="float:left; margin-right:5;"> </div><div><tt> right</tt></div>
347 * <div class="x-tool x-tool-left" style="float:left; margin-right:5;"> </div><div><tt> left</tt></div>
348 * <div class="x-tool x-tool-up" style="float:left; margin-right:5;"> </div><div><tt> up</tt></div>
349 * <div class="x-tool x-tool-down" style="float:left; margin-right:5;"> </div><div><tt> down</tt></div>
350 * <div class="x-tool x-tool-refresh" style="float:left; margin-right:5;"> </div><div><tt> refresh</tt></div>
351 * <div class="x-tool x-tool-minus" style="float:left; margin-right:5;"> </div><div><tt> minus</tt></div>
352 * <div class="x-tool x-tool-plus" style="float:left; margin-right:5;"> </div><div><tt> plus</tt></div>
353 * <div class="x-tool x-tool-help" style="float:left; margin-right:5;"> </div><div><tt> help</tt></div>
354 * <div class="x-tool x-tool-search" style="float:left; margin-right:5;"> </div><div><tt> search</tt></div>
355 * <div class="x-tool x-tool-save" style="float:left; margin-right:5;"> </div><div><tt> save</tt></div>
356 * <div class="x-tool x-tool-print" style="float:left; margin-right:5;"> </div><div><tt> print</tt></div>
358 * <li><b>handler</b> : Function<div class="sub-desc"><b>Required.</b> The function to
359 * call when clicked. Arguments passed are:<ul>
360 * <li><b>event</b> : Ext.EventObject<div class="sub-desc">The click event.</div></li>
361 * <li><b>toolEl</b> : Ext.Element<div class="sub-desc">The tool Element.</div></li>
362 * <li><b>panel</b> : Ext.Panel<div class="sub-desc">The host Panel</div></li>
363 * <li><b>tc</b> : Ext.Panel<div class="sub-desc">The tool configuration object</div></li>
365 * <li><b>stopEvent</b> : Boolean<div class="sub-desc">Defaults to true. Specify as false to allow click event to propagate.</div></li>
366 * <li><b>scope</b> : Object<div class="sub-desc">The scope in which to call the handler.</div></li>
367 * <li><b>qtip</b> : String/Object<div class="sub-desc">A tip string, or
368 * a config argument to {@link Ext.QuickTip#register}</div></li>
369 * <li><b>hidden</b> : Boolean<div class="sub-desc">True to initially render hidden.</div></li>
370 * <li><b>on</b> : Object<div class="sub-desc">A listener config object specifiying
371 * event listeners in the format of an argument to {@link #addListener}</div></li>
373 * <p>Note that, apart from the toggle tool which is provided when a panel is collapsible, these
374 * tools only provide the visual button. Any required functionality must be provided by adding
375 * handlers that implement the necessary behavior.</p>
376 * <p>Example usage:</p>
380 qtip: 'Refresh form Data',
382 handler: function(event, toolEl, panel){
389 handler: function(event, toolEl, panel){
394 * <p>For the custom id of <tt>'help'</tt> define two relevant css classes with a link to
397 .x-tool-help {background-image: url(images/help.png);}
398 .x-tool-help-over {background-image: url(images/help_over.png);}
399 // if using an image sprite:
400 .x-tool-help {background-image: url(images/help.png) no-repeat 0 0;}
401 .x-tool-help-over {background-position:-15px 0;}
404 <div id="cfg-Ext.Panel-toolTemplate"></div>/**
405 * @cfg {Ext.Template/Ext.XTemplate} toolTemplate
406 * <p>A Template used to create {@link #tools} in the {@link #header} Element. Defaults to:</p><pre><code>
407 new Ext.Template('<div class="x-tool x-tool-{id}">&#160;</div>')</code></pre>
408 * <p>This may may be overridden to provide a custom DOM structure for tools based upon a more
409 * complex XTemplate. The template's data is a single tool configuration object (Not the entire Array)
410 * as specified in {@link #tools}. In the following example an <a> tag is used to provide a
411 * visual indication when hovering over the tool:</p><pre><code>
412 var win = new Ext.Window({
415 href: '/MyPdfDoc.pdf'
417 toolTemplate: new Ext.XTemplate(
418 '<tpl if="id==\'download\'">',
419 '<a class="x-tool x-tool-pdf" href="{href}"></a>',
421 '<tpl if="id!=\'download\'">',
422 '<div class="x-tool x-tool-{id}">&#160;</div>',
429 * <p>Note that the CSS class "x-tool-pdf" should have an associated style rule which provides an
430 * appropriate background image, something like:</p>
432 a.x-tool-pdf {background-image: url(../shared/extjs/images/pdf.gif)!important;}
435 <div id="cfg-Ext.Panel-hideCollapseTool"></div>/**
436 * @cfg {Boolean} hideCollapseTool
437 * <tt>true</tt> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
438 * <tt>false</tt> to display it (defaults to <tt>false</tt>).
440 <div id="cfg-Ext.Panel-titleCollapse"></div>/**
441 * @cfg {Boolean} titleCollapse
442 * <tt>true</tt> to allow expanding and collapsing the panel (when <tt>{@link #collapsible} = true</tt>)
443 * by clicking anywhere in the header bar, <tt>false</tt>) to allow it only by clicking to tool button
444 * (defaults to <tt>false</tt>)). If this panel is a child item of a border layout also see the
445 * {@link Ext.layout.BorderLayout.Region BorderLayout.Region}
446 * <tt>{@link Ext.layout.BorderLayout.Region#floatable floatable}</tt> config option.
448 <div id="cfg-Ext.Panel-autoScroll"></div>/**
449 * @cfg {Boolean} autoScroll
450 * <tt>true</tt> to use overflow:'auto' on the panel's body element and show scroll bars automatically when
451 * necessary, <tt>false</tt> to clip any overflowing content (defaults to <tt>false</tt>).
453 <div id="cfg-Ext.Panel-floating"></div>/**
454 * @cfg {Mixed} floating
455 * <p>This property is used to configure the underlying {@link Ext.Layer}. Acceptable values for this
456 * configuration property are:</p><div class="mdetail-params"><ul>
457 * <li><b><tt>false</tt></b> : <b>Default.</b><div class="sub-desc">Display the panel inline where it is
458 * rendered.</div></li>
459 * <li><b><tt>true</tt></b> : <div class="sub-desc">Float the panel (absolute position it with automatic
460 * shimming and shadow).<ul>
461 * <div class="sub-desc">Setting floating to true will create an Ext.Layer for this panel and display the
462 * panel at negative offsets so that it is hidden.</div>
463 * <div class="sub-desc">Since the panel will be absolute positioned, the position must be set explicitly
464 * <i>after</i> render (e.g., <tt>myPanel.setPosition(100,100);</tt>).</div>
465 * <div class="sub-desc"><b>Note</b>: when floating a panel you should always assign a fixed width,
466 * otherwise it will be auto width and will expand to fill to the right edge of the viewport.</div>
468 * <li><b><tt>{@link Ext.Layer object}</tt></b> : <div class="sub-desc">The specified object will be used
469 * as the configuration object for the {@link Ext.Layer} that will be created.</div></li>
472 <div id="cfg-Ext.Panel-shadow"></div>/**
473 * @cfg {Boolean/String} shadow
474 * <tt>true</tt> (or a valid Ext.Shadow {@link Ext.Shadow#mode} value) to display a shadow behind the
475 * panel, <tt>false</tt> to display no shadow (defaults to <tt>'sides'</tt>). Note that this option
476 * only applies when <tt>{@link #floating} = true</tt>.
478 <div id="cfg-Ext.Panel-shadowOffset"></div>/**
479 * @cfg {Number} shadowOffset
480 * The number of pixels to offset the shadow if displayed (defaults to <tt>4</tt>). Note that this
481 * option only applies when <tt>{@link #floating} = true</tt>.
483 <div id="cfg-Ext.Panel-shim"></div>/**
484 * @cfg {Boolean} shim
485 * <tt>false</tt> to disable the iframe shim in browsers which need one (defaults to <tt>true</tt>).
486 * Note that this option only applies when <tt>{@link #floating} = true</tt>.
488 <div id="cfg-Ext.Panel-html"></div>/**
489 * @cfg {String/Object} html
490 * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the panel's body
491 * content (defaults to ''). The HTML content is added by the Panel's {@link #afterRender} method,
492 * and so the document will not contain this HTML at the time the {@link #render} event is fired.
493 * This content is inserted into the body <i>before</i> any configured {@link #contentEl} is appended.
495 <div id="cfg-Ext.Panel-contentEl"></div>/**
496 * @cfg {String} contentEl
497 * <p>Specify the <tt>id</tt> of an existing HTML node to use as the panel's body content
498 * (defaults to '').</p><div><ul>
499 * <li><b>Description</b> : <ul>
500 * <div class="sub-desc">This config option is used to take an existing HTML element and place it in the body
501 * of a new panel (it simply moves the specified DOM element into the body element of the Panel
502 * <i>when the Panel is rendered</i> to use as the content (it is not going to be the
503 * actual panel itself).</div>
505 * <li><b>Notes</b> : <ul>
506 * <div class="sub-desc">The specified HTML Element is appended to the Panel's {@link #body} Element by the
507 * Panel's {@link #afterRender} method <i>after any configured {@link #html HTML} has
508 * been inserted</i>, and so the document will not contain this HTML at the time the
509 * {@link #render} event is fired.</div>
510 * <div class="sub-desc">The specified HTML element used will not participate in any layout scheme that the
511 * Panel may use. It's just HTML. Layouts operate on child items.</div>
512 * <div class="sub-desc">Add either the <tt>x-hidden</tt> or the <tt>x-hide-display</tt> CSS class to
513 * prevent a brief flicker of the content before it is rendered to the panel.</div>
517 <div id="cfg-Ext.Panel-keys"></div>/**
518 * @cfg {Object/Array} keys
519 * A {@link Ext.KeyMap} config object (in the format expected by {@link Ext.KeyMap#addBinding}
520 * used to assign custom key handling to this panel (defaults to <tt>null</tt>).
522 <div id="cfg-Ext.Panel-draggable"></div>/**
523 * @cfg {Boolean/Object} draggable
524 * <p><tt>true</tt> to enable dragging of this Panel (defaults to <tt>false</tt>).</p>
525 * <p>For custom drag/drop implementations, an <b>Ext.Panel.DD</b> config could also be passed
526 * in this config instead of <tt>true</tt>. Ext.Panel.DD is an internal, undocumented class which
527 * moves a proxy Element around in place of the Panel's element, but provides no other behaviour
528 * during dragging or on drop. It is a subclass of {@link Ext.dd.DragSource}, so behaviour may be
529 * added by implementing the interface methods of {@link Ext.dd.DragDrop} e.g.:
535 renderTo: Ext.getBody(),
541 // Config option of Ext.Panel.DD class.
542 // It's a floating Panel, so do not show a placeholder proxy in the original position.
545 // Called for each mousemove event while dragging the DD object.
546 onDrag : function(e){
547 // Record the x,y position of the drag proxy so that we can
548 // position the Panel at end of drag.
549 var pel = this.proxy.getEl();
550 this.x = pel.getLeft(true);
551 this.y = pel.getTop(true);
553 // Keep the Shadow aligned if there is one.
554 var s = this.panel.getEl().shadow;
556 s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
560 // Called on the mouseup event.
561 endDrag : function(e){
562 this.panel.setPosition(this.x, this.y);
568 <div id="cfg-Ext.Panel-tabTip"></div>/**
569 * @cfg {String} tabTip
570 * A string to be used as innerHTML (html tags are accepted) to show in a tooltip when mousing over
571 * the tab of a Ext.Panel which is an item of a {@link Ext.TabPanel}. {@link Ext.QuickTips}.init()
572 * must be called in order for the tips to render.
574 <div id="cfg-Ext.Panel-disabled"></div>/**
575 * @cfg {Boolean} disabled
576 * Render this panel disabled (default is <tt>false</tt>). An important note when using the disabled
577 * config on panels is that IE will often fail to initialize the disabled mask element correectly if
578 * the panel's layout has not yet completed by the time the Panel is disabled during the render process.
579 * If you experience this issue, you may need to instead use the {@link #afterlayout} event to initialize
580 * the disabled state:
589 single: true // important, as many layouts can occur
595 <div id="cfg-Ext.Panel-autoHeight"></div>/**
596 * @cfg {Boolean} autoHeight
597 * <tt>true</tt> to use height:'auto', <tt>false</tt> to use fixed height (defaults to <tt>false</tt>).
598 * <b>Note</b>: Setting <tt>autoHeight:true</tt> means that the browser will manage the panel's height
599 * based on its contents, and that Ext will not manage it at all. If the panel is within a layout that
600 * manages dimensions (<tt>fit</tt>, <tt>border</tt>, etc.) then setting <tt>autoHeight:true</tt>
601 * can cause issues with scrolling and will not generally work as expected since the panel will take
602 * on the height of its contents rather than the height required by the Ext layout.
606 <div id="cfg-Ext.Panel-baseCls"></div>/**
607 * @cfg {String} baseCls
608 * The base CSS class to apply to this panel's element (defaults to <tt>'x-panel'</tt>).
609 * <p>Another option available by default is to specify <tt>'x-plain'</tt> which strips all styling
610 * except for required attributes for Ext layouts to function (e.g. overflow:hidden).
611 * See <tt>{@link #unstyled}</tt> also.</p>
614 <div id="cfg-Ext.Panel-collapsedCls"></div>/**
615 * @cfg {String} collapsedCls
616 * A CSS class to add to the panel's element after it has been collapsed (defaults to
617 * <tt>'x-panel-collapsed'</tt>).
619 collapsedCls : 'x-panel-collapsed',
620 <div id="cfg-Ext.Panel-maskDisabled"></div>/**
621 * @cfg {Boolean} maskDisabled
622 * <tt>true</tt> to mask the panel when it is {@link #disabled}, <tt>false</tt> to not mask it (defaults
623 * to <tt>true</tt>). Either way, the panel will always tell its contained elements to disable themselves
624 * when it is disabled, but masking the panel can provide an additional visual cue that the panel is
628 <div id="cfg-Ext.Panel-animCollapse"></div>/**
629 * @cfg {Boolean} animCollapse
630 * <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
631 * animation (defaults to <tt>true</tt> if the {@link Ext.Fx} class is available, otherwise <tt>false</tt>).
633 animCollapse : Ext.enableFx,
634 <div id="cfg-Ext.Panel-headerAsText"></div>/**
635 * @cfg {Boolean} headerAsText
636 * <tt>true</tt> to display the panel <tt>{@link #title}</tt> in the <tt>{@link #header}</tt>,
637 * <tt>false</tt> to hide it (defaults to <tt>true</tt>).
640 <div id="cfg-Ext.Panel-buttonAlign"></div>/**
641 * @cfg {String} buttonAlign
642 * The alignment of any {@link #buttons} added to this panel. Valid values are <tt>'right'</tt>,
643 * <tt>'left'</tt> and <tt>'center'</tt> (defaults to <tt>'right'</tt>).
645 buttonAlign : 'right',
646 <div id="cfg-Ext.Panel-collapsed"></div>/**
647 * @cfg {Boolean} collapsed
648 * <tt>true</tt> to render the panel collapsed, <tt>false</tt> to render it expanded (defaults to
652 <div id="cfg-Ext.Panel-collapseFirst"></div>/**
653 * @cfg {Boolean} collapseFirst
654 * <tt>true</tt> to make sure the collapse/expand toggle button always renders first (to the left of)
655 * any other tools in the panel's title bar, <tt>false</tt> to render it last (defaults to <tt>true</tt>).
657 collapseFirst : true,
658 <div id="cfg-Ext.Panel-minButtonWidth"></div>/**
659 * @cfg {Number} minButtonWidth
660 * Minimum width in pixels of all {@link #buttons} in this panel (defaults to <tt>75</tt>)
663 <div id="cfg-Ext.Panel-unstyled"></div>/**
664 * @cfg {Boolean} unstyled
665 * Overrides the <tt>{@link #baseCls}</tt> setting to <tt>{@link #baseCls} = 'x-plain'</tt> which renders
666 * the panel unstyled except for required attributes for Ext layouts to function (e.g. overflow:hidden).
668 <div id="cfg-Ext.Panel-elements"></div>/**
669 * @cfg {String} elements
670 * A comma-delimited list of panel elements to initialize when the panel is rendered. Normally, this list will be
671 * generated automatically based on the items added to the panel at config time, but sometimes it might be useful to
672 * make sure a structural element is rendered even if not specified at config time (for example, you may want
673 * to add a button or toolbar dynamically after the panel has been rendered). Adding those elements to this
674 * list will allocate the required placeholders in the panel when it is rendered. Valid values are<div class="mdetail-params"><ul>
675 * <li><tt>header</tt></li>
676 * <li><tt>tbar</tt> (top bar)</li>
677 * <li><tt>body</tt></li>
678 * <li><tt>bbar</tt> (bottom bar)</li>
679 * <li><tt>footer</tt></li>
681 * Defaults to '<tt>body</tt>'.
684 <div id="cfg-Ext.Panel-preventBodyReset"></div>/**
685 * @cfg {Boolean} preventBodyReset
686 * Defaults to <tt>false</tt>. When set to <tt>true</tt>, an extra css class <tt>'x-panel-normal'</tt>
687 * will be added to the panel's element, effectively applying css styles suggested by the W3C
688 * (see http://www.w3.org/TR/CSS21/sample.html) to the Panel's <b>body</b> element (not the header,
691 preventBodyReset : false,
693 // protected - these could be used to customize the behavior of the window,
694 // but changing them would not be useful without further mofifications and
695 // could lead to unexpected or undesirable results.
696 toolTarget : 'header',
697 collapseEl : 'bwrap',
701 // private, notify box this class will handle heights
713 initComponent : function(){
714 Ext.Panel.superclass.initComponent.call(this);
717 <div id="event-Ext.Panel-bodyresize"></div>/**
719 * Fires after the Panel has been resized.
720 * @param {Ext.Panel} p the Panel which has been resized.
721 * @param {Number} width The Panel's new width.
722 * @param {Number} height The Panel's new height.
725 <div id="event-Ext.Panel-titlechange"></div>/**
727 * Fires after the Panel title has been {@link #title set} or {@link #setTitle changed}.
728 * @param {Ext.Panel} p the Panel which has had its title changed.
729 * @param {String} The new title.
732 <div id="event-Ext.Panel-iconchange"></div>/**
734 * Fires after the Panel icon class has been {@link #iconCls set} or {@link #setIconClass changed}.
735 * @param {Ext.Panel} p the Panel which has had its {@link #iconCls icon class} changed.
736 * @param {String} The new icon class.
737 * @param {String} The old icon class.
740 <div id="event-Ext.Panel-collapse"></div>/**
742 * Fires after the Panel has been collapsed.
743 * @param {Ext.Panel} p the Panel that has been collapsed.
746 <div id="event-Ext.Panel-expand"></div>/**
748 * Fires after the Panel has been expanded.
749 * @param {Ext.Panel} p The Panel that has been expanded.
752 <div id="event-Ext.Panel-beforecollapse"></div>/**
753 * @event beforecollapse
754 * Fires before the Panel is collapsed. A handler can return false to cancel the collapse.
755 * @param {Ext.Panel} p the Panel being collapsed.
756 * @param {Boolean} animate True if the collapse is animated, else false.
759 <div id="event-Ext.Panel-beforeexpand"></div>/**
760 * @event beforeexpand
761 * Fires before the Panel is expanded. A handler can return false to cancel the expand.
762 * @param {Ext.Panel} p The Panel being expanded.
763 * @param {Boolean} animate True if the expand is animated, else false.
766 <div id="event-Ext.Panel-beforeclose"></div>/**
768 * Fires before the Panel is closed. Note that Panels do not directly support being closed, but some
769 * Panel subclasses do (like {@link Ext.Window}) or a Panel within a Ext.TabPanel. This event only
770 * applies to such subclasses.
771 * A handler can return false to cancel the close.
772 * @param {Ext.Panel} p The Panel being closed.
775 <div id="event-Ext.Panel-close"></div>/**
777 * Fires after the Panel is closed. Note that Panels do not directly support being closed, but some
778 * Panel subclasses do (like {@link Ext.Window}) or a Panel within a Ext.TabPanel.
779 * @param {Ext.Panel} p The Panel that has been closed.
782 <div id="event-Ext.Panel-activate"></div>/**
784 * Fires after the Panel has been visually activated.
785 * Note that Panels do not directly support being activated, but some Panel subclasses
786 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
787 * activate and deactivate events under the control of the TabPanel.
788 * @param {Ext.Panel} p The Panel that has been activated.
791 <div id="event-Ext.Panel-deactivate"></div>/**
793 * Fires after the Panel has been visually deactivated.
794 * Note that Panels do not directly support being deactivated, but some Panel subclasses
795 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
796 * activate and deactivate events under the control of the TabPanel.
797 * @param {Ext.Panel} p The Panel that has been deactivated.
803 this.baseCls = 'x-plain';
808 this.elements += ',tbar';
809 if(Ext.isObject(this.tbar)){
810 this.topToolbar = this.tbar;
815 this.elements += ',bbar';
816 if(Ext.isObject(this.bbar)){
817 this.bottomToolbar = this.bbar;
822 if(this.header === true){
823 this.elements += ',header';
825 }else if(this.headerCfg || (this.title && this.header !== false)){
826 this.elements += ',header';
829 if(this.footerCfg || this.footer === true){
830 this.elements += ',footer';
835 this.elements += ',footer';
836 var btns = this.buttons;
837 <div id="prop-Ext.Panel-buttons"></div>/**
838 * This Panel's Array of buttons as created from the <tt>{@link #buttons}</tt>
839 * config property. Read only.
844 for(var i = 0, len = btns.length; i < len; i++) {
845 if(btns[i].render){ // button instance
846 this.buttons.push(btns[i]);
847 }else if(btns[i].xtype){
848 this.buttons.push(Ext.create(btns[i], 'button'));
850 this.addButton(btns[i]);
855 this.elements += ',footer';
858 this.on('render', this.doAutoLoad, this, {delay:10});
863 createElement : function(name, pnode){
865 pnode.appendChild(this[name].dom);
869 if(name === 'bwrap' || this.elements.indexOf(name) != -1){
870 if(this[name+'Cfg']){
871 this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
873 var el = document.createElement('div');
874 el.className = this[name+'Cls'];
875 this[name] = Ext.get(pnode.appendChild(el));
877 if(this[name+'CssClass']){
878 this[name].addClass(this[name+'CssClass']);
880 if(this[name+'Style']){
881 this[name].applyStyles(this[name+'Style']);
887 onRender : function(ct, position){
888 Ext.Panel.superclass.onRender.call(this, ct, position);
889 this.createClasses();
894 el.addClass(this.baseCls);
895 if(d.firstChild){ // existing markup
896 this.header = el.down('.'+this.headerCls);
897 this.bwrap = el.down('.'+this.bwrapCls);
898 var cp = this.bwrap ? this.bwrap : el;
899 this.tbar = cp.down('.'+this.tbarCls);
900 this.body = cp.down('.'+this.bodyCls);
901 this.bbar = cp.down('.'+this.bbarCls);
902 this.footer = cp.down('.'+this.footerCls);
903 this.fromMarkup = true;
905 if (this.preventBodyReset === true) {
906 el.addClass('x-panel-reset');
909 el.addClass(this.cls);
913 this.elements += ',footer';
916 // This block allows for maximum flexibility and performance when using existing markup
918 // framing requires special markup
920 el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
922 this.createElement('header', d.firstChild.firstChild.firstChild);
923 this.createElement('bwrap', d);
925 // append the mid and bottom frame to the bwrap
927 var ml = d.childNodes[1], bl = d.childNodes[2];
931 var mc = bw.firstChild.firstChild.firstChild;
932 this.createElement('tbar', mc);
933 this.createElement('body', mc);
934 this.createElement('bbar', mc);
935 this.createElement('footer', bw.lastChild.firstChild.firstChild);
938 this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
941 this.createElement('header', d);
942 this.createElement('bwrap', d);
944 // append the mid and bottom frame to the bwrap
946 this.createElement('tbar', bw);
947 this.createElement('body', bw);
948 this.createElement('bbar', bw);
949 this.createElement('footer', bw);
952 this.body.addClass(this.bodyCls + '-noheader');
954 this.tbar.addClass(this.tbarCls + '-noheader');
959 if(this.padding !== undefined) {
960 this.body.setStyle('padding', this.body.addUnits(this.padding));
963 if(this.border === false){
964 this.el.addClass(this.baseCls + '-noborder');
965 this.body.addClass(this.bodyCls + '-noborder');
967 this.header.addClass(this.headerCls + '-noborder');
970 this.footer.addClass(this.footerCls + '-noborder');
973 this.tbar.addClass(this.tbarCls + '-noborder');
976 this.bbar.addClass(this.bbarCls + '-noborder');
980 if(this.bodyBorder === false){
981 this.body.addClass(this.bodyCls + '-noborder');
984 this.bwrap.enableDisplayMode('block');
987 this.header.unselectable();
989 // for tools, we need to wrap any existing header markup
990 if(this.headerAsText){
991 this.header.dom.innerHTML =
992 '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
995 this.setIconClass(this.iconCls);
1001 this.makeFloating(this.floating);
1004 if(this.collapsible){
1005 this.tools = this.tools ? this.tools.slice(0) : [];
1006 if(!this.hideCollapseTool){
1007 this.tools[this.collapseFirst?'unshift':'push']({
1009 handler : this.toggleCollapse,
1013 if(this.titleCollapse && this.header){
1014 this.mon(this.header, 'click', this.toggleCollapse, this);
1015 this.header.setStyle('cursor', 'pointer');
1019 var ts = this.tools;
1021 this.addTool.apply(this, ts);
1026 if(this.buttons && this.buttons.length > 0){
1027 this.fbar = new Ext.Toolbar({
1028 items: this.buttons,
1029 toolbarCls: 'x-panel-fbar'
1034 this.fbar = Ext.create(this.fbar, 'toolbar');
1035 this.fbar.enableOverflow = false;
1036 if(this.fbar.items){
1037 this.fbar.items.each(function(c){
1038 c.minWidth = c.minWidth || this.minButtonWidth;
1041 this.fbar.toolbarCls = 'x-panel-fbar';
1043 var bct = this.footer.createChild({cls: 'x-panel-btns x-panel-btns-'+this.buttonAlign});
1044 this.fbar.ownerCt = this;
1045 this.fbar.render(bct);
1046 bct.createChild({cls:'x-clear'});
1047 this.toolbars.push(this.fbar);
1050 if(this.tbar && this.topToolbar){
1051 if(Ext.isArray(this.topToolbar)){
1052 this.topToolbar = new Ext.Toolbar(this.topToolbar);
1053 }else if(!this.topToolbar.events){
1054 this.topToolbar = Ext.create(this.topToolbar, 'toolbar');
1056 this.topToolbar.ownerCt = this;
1057 this.topToolbar.render(this.tbar);
1058 this.toolbars.push(this.topToolbar);
1060 if(this.bbar && this.bottomToolbar){
1061 if(Ext.isArray(this.bottomToolbar)){
1062 this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
1063 }else if(!this.bottomToolbar.events){
1064 this.bottomToolbar = Ext.create(this.bottomToolbar, 'toolbar');
1066 this.bottomToolbar.ownerCt = this;
1067 this.bottomToolbar.render(this.bbar);
1068 this.toolbars.push(this.bottomToolbar);
1070 Ext.each(this.toolbars, function(tb){
1073 afterlayout: this.syncHeight,
1074 remove: this.syncHeight
1079 <div id="method-Ext.Panel-setIconClass"></div>/**
1080 * Sets the CSS class that provides the icon image for this panel. This method will replace any existing
1081 * icon class if one has already been set and fire the {@link #iconchange} event after completion.
1082 * @param {String} cls The new CSS class name
1084 setIconClass : function(cls){
1085 var old = this.iconCls;
1087 if(this.rendered && this.header){
1089 this.header.addClass('x-panel-icon');
1090 this.header.replaceClass(old, this.iconCls);
1092 var hd = this.header.dom;
1093 var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null;
1095 Ext.fly(img).replaceClass(old, this.iconCls);
1097 Ext.DomHelper.insertBefore(hd.firstChild, {
1098 tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
1103 this.fireEvent('iconchange', this, cls, old);
1107 makeFloating : function(cfg){
1108 this.floating = true;
1109 this.el = new Ext.Layer(
1110 Ext.isObject(cfg) ? cfg : {
1111 shadow: this.shadow !== undefined ? this.shadow : 'sides',
1112 shadowOffset: this.shadowOffset,
1114 shim: this.shim === false ? false : undefined
1119 <div id="method-Ext.Panel-getTopToolbar"></div>/**
1120 * Returns the {@link Ext.Toolbar toolbar} from the top (<tt>{@link #tbar}</tt>) section of the panel.
1121 * @return {Ext.Toolbar} The toolbar
1123 getTopToolbar : function(){
1124 return this.topToolbar;
1127 <div id="method-Ext.Panel-getBottomToolbar"></div>/**
1128 * Returns the {@link Ext.Toolbar toolbar} from the bottom (<tt>{@link #bbar}</tt>) section of the panel.
1129 * @return {Ext.Toolbar} The toolbar
1131 getBottomToolbar : function(){
1132 return this.bottomToolbar;
1135 <div id="method-Ext.Panel-addButton"></div>/**
1136 * Adds a button to this panel. Note that this method must be called prior to rendering. The preferred
1137 * approach is to add buttons via the {@link #buttons} config.
1138 * @param {String/Object} config A valid {@link Ext.Button} config. A string will become the text for a default
1139 * button config, an object will be treated as a button config object.
1140 * @param {Function} handler The function to be called on button {@link Ext.Button#click}
1141 * @param {Object} scope The scope to use for the button handler function
1142 * @return {Ext.Button} The button that was added
1144 addButton : function(config, handler, scope){
1148 minWidth: this.minButtonWidth,
1151 if(typeof config == "string"){
1154 Ext.apply(bc, config);
1156 var btn = new Ext.Button(bc);
1160 this.buttons.push(btn);
1165 addTool : function(){
1166 if(!this[this.toolTarget]) { // no where to render tools!
1169 if(!this.toolTemplate){
1170 // initialize the global tool template on first use
1171 var tt = new Ext.Template(
1172 '<div class="x-tool x-tool-{id}"> </div>'
1174 tt.disableFormats = true;
1176 Ext.Panel.prototype.toolTemplate = tt;
1178 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
1180 if(!this.tools[tc.id]){
1181 var overCls = 'x-tool-'+tc.id+'-over';
1182 var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
1183 this.tools[tc.id] = t;
1184 t.enableDisplayMode('block');
1185 this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
1193 if(Ext.isObject(tc.qtip)){
1194 Ext.QuickTips.register(Ext.apply({
1198 t.dom.qtip = tc.qtip;
1201 t.addClassOnOver(overCls);
1206 onLayout : function(){
1207 if(this.toolbars.length > 0){
1208 this.duringLayout = true;
1209 Ext.each(this.toolbars, function(tb){
1212 delete this.duringLayout;
1217 syncHeight : function(){
1218 if(!(this.autoHeight || this.duringLayout)){
1219 var last = this.lastSize;
1220 if(last && !Ext.isEmpty(last.height)){
1221 var old = last.height, h = this.el.getHeight();
1222 if(old != 'auto' && old != h){
1223 var bd = this.body, bdh = bd.getHeight();
1224 h = Math.max(bdh + old - h, 0);
1225 if(bdh > 0 && bdh != h){
1227 if(Ext.isIE && h <= 0){
1230 var sz = bd.getSize();
1231 this.fireEvent('bodyresize', sz.width, sz.height);
1239 onShow : function(){
1241 return this.el.show();
1243 Ext.Panel.superclass.onShow.call(this);
1247 onHide : function(){
1249 return this.el.hide();
1251 Ext.Panel.superclass.onHide.call(this);
1255 createToolHandler : function(t, tc, overCls, panel){
1257 t.removeClass(overCls);
1258 if(tc.stopEvent !== false){
1262 tc.handler.call(tc.scope || t, e, t, panel, tc);
1268 afterRender : function(){
1269 if(this.floating && !this.hidden){
1273 this.setTitle(this.title);
1275 this.setAutoScroll();
1277 this.body.update(Ext.isObject(this.html) ?
1278 Ext.DomHelper.markup(this.html) :
1283 var ce = Ext.getDom(this.contentEl);
1284 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
1285 this.body.dom.appendChild(ce);
1288 this.collapsed = false;
1289 this.collapse(false);
1291 Ext.Panel.superclass.afterRender.call(this); // do sizing calcs last
1296 setAutoScroll : function(){
1297 if(this.rendered && this.autoScroll){
1298 var el = this.body || this.el;
1300 el.setOverflow('auto');
1306 getKeyMap : function(){
1308 this.keyMap = new Ext.KeyMap(this.el, this.keys);
1314 initEvents : function(){
1319 this.initDraggable();
1324 initDraggable : function(){
1325 <div id="prop-Ext.Panel-dd"></div>/**
1326 * <p>If this Panel is configured {@link #draggable}, this property will contain
1327 * an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
1328 * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
1329 * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
1330 * @type Ext.dd.DragSource.
1333 this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
1337 beforeEffect : function(){
1339 this.el.beforeAction();
1341 this.el.addClass('x-panel-animated');
1345 afterEffect : function(){
1347 this.el.removeClass('x-panel-animated');
1350 // private - wraps up an animation param with internal callbacks
1351 createEffect : function(a, cb, scope){
1359 }else if(!a.callback){
1361 }else { // wrap it up
1362 o.callback = function(){
1364 Ext.callback(a.callback, a.scope);
1367 return Ext.applyIf(o, a);
1370 <div id="method-Ext.Panel-collapse"></div>/**
1371 * Collapses the panel body so that it becomes hidden. Fires the {@link #beforecollapse} event which will
1372 * cancel the collapse action if it returns false.
1373 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1374 * {@link #animCollapse} panel config)
1375 * @return {Ext.Panel} this
1377 collapse : function(animate){
1378 if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
1381 var doAnim = animate === true || (animate !== false && this.animCollapse);
1382 this.beforeEffect();
1383 this.onCollapse(doAnim, animate);
1388 onCollapse : function(doAnim, animArg){
1390 this[this.collapseEl].slideOut(this.slideAnchor,
1391 Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
1392 this.collapseDefaults));
1394 this[this.collapseEl].hide();
1395 this.afterCollapse();
1400 afterCollapse : function(){
1401 this.collapsed = true;
1402 this.el.addClass(this.collapsedCls);
1404 this.fireEvent('collapse', this);
1407 <div id="method-Ext.Panel-expand"></div>/**
1408 * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
1409 * cancel the expand action if it returns false.
1410 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1411 * {@link #animCollapse} panel config)
1412 * @return {Ext.Panel} this
1414 expand : function(animate){
1415 if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
1418 var doAnim = animate === true || (animate !== false && this.animCollapse);
1419 this.el.removeClass(this.collapsedCls);
1420 this.beforeEffect();
1421 this.onExpand(doAnim, animate);
1426 onExpand : function(doAnim, animArg){
1428 this[this.collapseEl].slideIn(this.slideAnchor,
1429 Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
1430 this.expandDefaults));
1432 this[this.collapseEl].show();
1438 afterExpand : function(){
1439 this.collapsed = false;
1441 if(this.deferLayout !== undefined){
1442 this.doLayout(true);
1444 this.fireEvent('expand', this);
1447 <div id="method-Ext.Panel-toggleCollapse"></div>/**
1448 * Shortcut for performing an {@link #expand} or {@link #collapse} based on the current state of the panel.
1449 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1450 * {@link #animCollapse} panel config)
1451 * @return {Ext.Panel} this
1453 toggleCollapse : function(animate){
1454 this[this.collapsed ? 'expand' : 'collapse'](animate);
1459 onDisable : function(){
1460 if(this.rendered && this.maskDisabled){
1463 Ext.Panel.superclass.onDisable.call(this);
1467 onEnable : function(){
1468 if(this.rendered && this.maskDisabled){
1471 Ext.Panel.superclass.onEnable.call(this);
1475 onResize : function(w, h){
1476 if(w !== undefined || h !== undefined){
1477 if(!this.collapsed){
1478 if(typeof w == 'number'){
1479 w = this.adjustBodyWidth(w - this.getFrameWidth());
1481 this.tbar.setWidth(w);
1482 if(this.topToolbar){
1483 this.topToolbar.setSize(w);
1487 this.bbar.setWidth(w);
1488 if(this.bottomToolbar){
1489 this.bottomToolbar.setSize(w);
1495 strict = Ext.isStrict;
1496 if(this.buttonAlign == 'left'){
1497 fWidth = w - f.container.getFrameWidth('lr');
1499 //center/right alignment off in webkit
1500 if(Ext.isIE || Ext.isWebKit){
1501 //center alignment ok on webkit.
1502 //right broken in both, center on IE
1503 if(!(this.buttonAlign == 'center' && Ext.isWebKit) && (!strict || (!Ext.isIE8 && strict))){
1505 f.setWidth(f.getEl().child('.x-toolbar-ct').getWidth());
1516 this.body.setWidth(w);
1517 }else if(w == 'auto'){
1518 this.body.setWidth(w);
1521 if(typeof h == 'number'){
1522 h = Math.max(0, this.adjustBodyHeight(h - this.getFrameHeight()));
1523 this.body.setHeight(h);
1524 }else if(h == 'auto'){
1525 this.body.setHeight(h);
1528 if(this.disabled && this.el._mask){
1529 this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
1532 this.queuedBodySize = {width: w, height: h};
1533 if(!this.queuedExpand && this.allowQueuedExpand !== false){
1534 this.queuedExpand = true;
1535 this.on('expand', function(){
1536 delete this.queuedExpand;
1537 this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
1539 }, this, {single:true});
1542 this.fireEvent('bodyresize', this, w, h);
1548 adjustBodyHeight : function(h){
1553 adjustBodyWidth : function(w){
1558 onPosition : function(){
1562 <div id="method-Ext.Panel-getFrameWidth"></div>/**
1563 * Returns the width in pixels of the framing elements of this panel (not including the body width). To
1564 * retrieve the body width see {@link #getInnerWidth}.
1565 * @return {Number} The frame width
1567 getFrameWidth : function(){
1568 var w = this.el.getFrameWidth('lr')+this.bwrap.getFrameWidth('lr');
1571 var l = this.bwrap.dom.firstChild;
1572 w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
1573 var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
1574 w += Ext.fly(mc).getFrameWidth('lr');
1579 <div id="method-Ext.Panel-getFrameHeight"></div>/**
1580 * Returns the height in pixels of the framing elements of this panel (including any top and bottom bars and
1581 * header and footer elements, but not including the body height). To retrieve the body height see {@link #getInnerHeight}.
1582 * @return {Number} The frame height
1584 getFrameHeight : function(){
1585 var h = this.el.getFrameWidth('tb')+this.bwrap.getFrameWidth('tb');
1586 h += (this.tbar ? this.tbar.getHeight() : 0) +
1587 (this.bbar ? this.bbar.getHeight() : 0);
1590 var hd = this.el.dom.firstChild;
1591 var ft = this.bwrap.dom.lastChild;
1592 h += (hd.offsetHeight + ft.offsetHeight);
1593 var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
1594 h += Ext.fly(mc).getFrameWidth('tb');
1596 h += (this.header ? this.header.getHeight() : 0) +
1597 (this.footer ? this.footer.getHeight() : 0);
1602 <div id="method-Ext.Panel-getInnerWidth"></div>/**
1603 * Returns the width in pixels of the body element (not including the width of any framing elements).
1604 * For the frame width see {@link #getFrameWidth}.
1605 * @return {Number} The body width
1607 getInnerWidth : function(){
1608 return this.getSize().width - this.getFrameWidth();
1611 <div id="method-Ext.Panel-getInnerHeight"></div>/**
1612 * Returns the height in pixels of the body element (not including the height of any framing elements).
1613 * For the frame height see {@link #getFrameHeight}.
1614 * @return {Number} The body height
1616 getInnerHeight : function(){
1617 return this.getSize().height - this.getFrameHeight();
1621 syncShadow : function(){
1628 getLayoutTarget : function(){
1632 <div id="method-Ext.Panel-setTitle"></div>/**
1633 * <p>Sets the title text for the panel and optionally the {@link #iconCls icon class}.</p>
1634 * <p>In order to be able to set the title, a header element must have been created
1635 * for the Panel. This is triggered either by configuring the Panel with a non-blank <tt>{@link #title}</tt>,
1636 * or configuring it with <tt><b>{@link #header}: true</b></tt>.</p>
1637 * @param {String} title The title text to set
1638 * @param {String} iconCls (optional) {@link #iconCls iconCls} A user-defined CSS class that provides the icon image for this panel
1640 setTitle : function(title, iconCls){
1642 if(this.header && this.headerAsText){
1643 this.header.child('span').update(title);
1646 this.setIconClass(iconCls);
1648 this.fireEvent('titlechange', this, title);
1652 <div id="method-Ext.Panel-getUpdater"></div>/**
1653 * Get the {@link Ext.Updater} for this panel. Enables you to perform Ajax updates of this panel's body.
1654 * @return {Ext.Updater} The Updater
1656 getUpdater : function(){
1657 return this.body.getUpdater();
1660 <div id="method-Ext.Panel-load"></div>/**
1661 * Loads this content panel immediately with content returned from an XHR call.
1662 * @param {Object/String/Function} config A config object containing any of the following options:
1665 url: "your-url.php",
1666 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
1667 callback: yourFunction,
1668 scope: yourObject, // optional scope for the callback
1676 * The only required property is url. The optional properties nocache, text and scripts
1677 * are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
1678 * associated property on this panel Updater instance.
1679 * @return {Ext.Panel} this
1682 var um = this.body.getUpdater();
1683 um.update.apply(um, arguments);
1688 beforeDestroy : function(){
1690 this.header.removeAllListeners();
1691 if(this.headerAsText){
1692 Ext.Element.uncache(this.header.child('span'));
1695 Ext.Element.uncache(
1704 for(var k in this.tools){
1705 Ext.destroy(this.tools[k]);
1709 for(var b in this.buttons){
1710 Ext.destroy(this.buttons[b]);
1713 Ext.destroy(this.toolbars);
1714 Ext.Panel.superclass.beforeDestroy.call(this);
1718 createClasses : function(){
1719 this.headerCls = this.baseCls + '-header';
1720 this.headerTextCls = this.baseCls + '-header-text';
1721 this.bwrapCls = this.baseCls + '-bwrap';
1722 this.tbarCls = this.baseCls + '-tbar';
1723 this.bodyCls = this.baseCls + '-body';
1724 this.bbarCls = this.baseCls + '-bbar';
1725 this.footerCls = this.baseCls + '-footer';
1729 createGhost : function(cls, useShim, appendTo){
1730 var el = document.createElement('div');
1731 el.className = 'x-panel-ghost ' + (cls ? cls : '');
1733 el.appendChild(this.el.dom.firstChild.cloneNode(true));
1735 Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
1736 el.style.width = this.el.dom.offsetWidth + 'px';;
1738 this.container.dom.appendChild(el);
1740 Ext.getDom(appendTo).appendChild(el);
1742 if(useShim !== false && this.el.useShim !== false){
1743 var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
1747 return new Ext.Element(el);
1752 doAutoLoad : function(){
1753 var u = this.body.getUpdater();
1755 u.setRenderer(this.renderer);
1757 u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
1760 <div id="method-Ext.Panel-getTool"></div>/**
1761 * Retrieve a tool by id.
1762 * @param {String} id
1763 * @return {Object} tool
1765 getTool : function(id) {
1766 return this.tools[id];
1769 <div id="cfg-Ext.Panel-autoEl"></div>/**
1770 * @cfg {String} autoEl @hide
1773 Ext.reg('panel', Ext.Panel);