3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.Panel"></div>/**
16 * @extends Ext.Container
17 * <p>Panel is a container that has specific functionality and structural components that make
18 * it the perfect building block for application-oriented user interfaces.</p>
19 * <p>Panels are, by virtue of their inheritance from {@link Ext.Container}, capable
20 * of being configured with a {@link Ext.Container#layout layout}, and containing child Components.</p>
21 * <p>When either specifying child {@link Ext.Component#items items} of a Panel, or dynamically {@link Ext.Container#add adding} Components
22 * to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether
23 * those child elements need to be sized using one of Ext's built-in <code><b>{@link Ext.Container#layout layout}</b></code> schemes. By
24 * default, Panels use the {@link Ext.layout.ContainerLayout ContainerLayout} scheme. This simply renders
25 * child components, appending them one after the other inside the Container, and <b>does not apply any sizing</b>
27 * <p>A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate
28 * {@link #header}, {@link #footer} and {@link #body} sections (see {@link #frame} for additional
30 * <p>Panel also provides built-in {@link #collapsible expandable and collapsible behavior}, along with
31 * a variety of {@link #tools prebuilt tool buttons} that can be wired up to provide other customized
32 * behavior. Panels can be easily dropped into any {@link Ext.Container Container} or layout, and the
33 * layout and rendering pipeline is {@link Ext.Container#add completely managed by the framework}.</p>
35 * @param {Object} config The config object
38 Ext.Panel = Ext.extend(Ext.Container, {
39 <div id="prop-Ext.Panel-header"></div>/**
40 * The Panel's header {@link Ext.Element Element}. Read-only.
41 * <p>This Element is used to house the {@link #title} and {@link #tools}</p>
42 * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
46 <div id="prop-Ext.Panel-body"></div>/**
47 * The Panel's body {@link Ext.Element Element} which may be used to contain HTML content.
48 * The content may be specified in the {@link #html} config, or it may be loaded using the
49 * {@link autoLoad} config, or through the Panel's {@link #getUpdater Updater}. Read-only.
50 * <p>If this is used to load visible HTML elements in either way, then
51 * the Panel may not be used as a Layout for hosting nested Panels.</p>
52 * <p>If this Panel is intended to be used as the host of a Layout (See {@link #layout}
53 * then the body Element must not be loaded or changed - it is under the control
54 * of the Panel's Layout.
55 * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
59 <div id="prop-Ext.Panel-bwrap"></div>/**
60 * The Panel's bwrap {@link Ext.Element Element} used to contain other Panel elements
61 * (tbar, body, bbar, footer). See {@link #bodyCfg}. Read-only.
65 <div id="prop-Ext.Panel-collapsed"></div>/**
66 * True if this panel is collapsed. Read-only.
70 <div id="cfg-Ext.Panel-bodyCfg"></div>/**
71 * @cfg {Object} bodyCfg
72 * <p>A {@link Ext.DomHelper DomHelper} element specification object may be specified for any
74 * <p>By default, the Default element in the table below will be used for the html markup to
75 * create a child element with the commensurate Default class name (<code>baseCls</code> will be
76 * replaced by <code>{@link #baseCls}</code>):</p>
78 * Panel Default Default Custom Additional Additional
79 * Element element class element class style
80 * ======== ========================== ========= ============== ===========
81 * {@link #header} div {@link #baseCls}+'-header' {@link #headerCfg} headerCssClass headerStyle
82 * {@link #bwrap} div {@link #baseCls}+'-bwrap' {@link #bwrapCfg} bwrapCssClass bwrapStyle
83 * + tbar div {@link #baseCls}+'-tbar' {@link #tbarCfg} tbarCssClass tbarStyle
84 * + {@link #body} div {@link #baseCls}+'-body' {@link #bodyCfg} {@link #bodyCssClass} {@link #bodyStyle}
85 * + bbar div {@link #baseCls}+'-bbar' {@link #bbarCfg} bbarCssClass bbarStyle
86 * + {@link #footer} div {@link #baseCls}+'-footer' {@link #footerCfg} footerCssClass footerStyle
88 * <p>Configuring a Custom element may be used, for example, to force the {@link #body} Element
89 * to use a different form of markup than is created by default. An example of this might be
90 * to {@link Ext.Element#createChild create a child} Panel containing a custom content, such as
91 * a header, or forcing centering of all Panel content by having the body be a <center>
95 title: 'Message Title',
96 renderTo: Ext.getBody(),
97 width: 200, height: 130,
100 cls: 'x-panel-body', // Default class not applied if Custom element specified
105 cls: 'x-panel-footer' // same as the Default class
108 footerCssClass: 'custom-footer', // additional css class, see {@link Ext.element#addClass addClass}
109 footerStyle: 'background-color:red' // see {@link #bodyStyle}
112 * <p>The example above also explicitly creates a <code>{@link #footer}</code> with custom markup and
113 * styling applied.</p>
115 <div id="cfg-Ext.Panel-headerCfg"></div>/**
116 * @cfg {Object} headerCfg
117 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
118 * of this Panel's {@link #header} Element. See <code>{@link #bodyCfg}</code> also.</p>
120 <div id="cfg-Ext.Panel-bwrapCfg"></div>/**
121 * @cfg {Object} bwrapCfg
122 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
123 * of this Panel's {@link #bwrap} Element. See <code>{@link #bodyCfg}</code> also.</p>
125 <div id="cfg-Ext.Panel-tbarCfg"></div>/**
126 * @cfg {Object} tbarCfg
127 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
128 * of this Panel's {@link #tbar} Element. See <code>{@link #bodyCfg}</code> also.</p>
130 <div id="cfg-Ext.Panel-bbarCfg"></div>/**
131 * @cfg {Object} bbarCfg
132 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
133 * of this Panel's {@link #bbar} Element. See <code>{@link #bodyCfg}</code> also.</p>
135 <div id="cfg-Ext.Panel-footerCfg"></div>/**
136 * @cfg {Object} footerCfg
137 * <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
138 * of this Panel's {@link #footer} Element. See <code>{@link #bodyCfg}</code> also.</p>
140 <div id="cfg-Ext.Panel-closable"></div>/**
141 * @cfg {Boolean} closable
142 * Panels themselves do not directly support being closed, but some Panel subclasses do (like
143 * {@link Ext.Window}) or a Panel Class within an {@link Ext.TabPanel}. Specify <code>true</code>
144 * to enable closing in such situations. Defaults to <code>false</code>.
146 <div id="prop-Ext.Panel-footer"></div>/**
147 * The Panel's footer {@link Ext.Element Element}. Read-only.
148 * <p>This Element is used to house the Panel's <code>{@link #buttons}</code> or <code>{@link #fbar}</code>.</p>
149 * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
153 <div id="cfg-Ext.Panel-applyTo"></div>/**
154 * @cfg {Mixed} applyTo
155 * <p>The id of the node, a DOM node or an existing Element corresponding to a DIV that is already present in
156 * the document that specifies some panel-specific structural markup. When <code>applyTo</code> is used,
157 * constituent parts of the panel can be specified by CSS class name within the main element, and the panel
158 * will automatically create those components from that markup. Any required components not specified in the
159 * markup will be autogenerated if necessary.</p>
160 * <p>The following class names are supported (baseCls will be replaced by {@link #baseCls}):</p>
161 * <ul><li>baseCls + '-header'</li>
162 * <li>baseCls + '-header-text'</li>
163 * <li>baseCls + '-bwrap'</li>
164 * <li>baseCls + '-tbar'</li>
165 * <li>baseCls + '-body'</li>
166 * <li>baseCls + '-bbar'</li>
167 * <li>baseCls + '-footer'</li></ul>
168 * <p>Using this config, a call to render() is not required. If applyTo is specified, any value passed for
169 * {@link #renderTo} will be ignored and the target element's parent node will automatically be used as the
170 * panel's container.</p>
172 <div id="cfg-Ext.Panel-tbar"></div>/**
173 * @cfg {Object/Array} tbar
174 * <p>The top toolbar of the panel. This can be a {@link Ext.Toolbar} object, a toolbar config, or an array of
175 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
176 * To access the top toolbar after render, use {@link #getTopToolbar}.</p>
177 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> be updated by a load
178 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
179 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
180 * submission parameters are collected from the DOM tree.</p>
182 <div id="cfg-Ext.Panel-bbar"></div>/**
183 * @cfg {Object/Array} bbar
184 * <p>The bottom toolbar of the panel. This can be a {@link Ext.Toolbar} object, a toolbar config, or an array of
185 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
186 * To access the bottom toolbar after render, use {@link #getBottomToolbar}.</p>
187 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> be updated by a load
188 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
189 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
190 * submission parameters are collected from the DOM tree.</p>
192 <div id="cfg-Ext.Panel-fbar"></div>/** @cfg {Object/Array} fbar
193 * <p>A {@link Ext.Toolbar Toolbar} object, a Toolbar config, or an array of
194 * {@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>
195 * <p>After render, the <code>fbar</code> property will be an {@link Ext.Toolbar Toolbar} instance.</p>
196 * <p>If <code>{@link #buttons}</code> are specified, they will supersede the <code>fbar</code> configuration property.</p>
197 * The Panel's <code>{@link #buttonAlign}</code> configuration affects the layout of these items, for example:
199 var w = new Ext.Window({
202 bbar: new Ext.Toolbar({
209 {@link #buttonAlign}: 'left', // anything but 'center' or 'right' and you can use '-', and '->'
210 // to control the alignment of fbar items
218 * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> be updated by a load
219 * of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
220 * so are not scanned to collect form items. However, the values <b>will</b> be submitted because form
221 * submission parameters are collected from the DOM tree.</p>
223 <div id="cfg-Ext.Panel-header"></div>/**
224 * @cfg {Boolean} header
225 * <code>true</code> to create the Panel's header element explicitly, <code>false</code> to skip creating
226 * it. If a <code>{@link #title}</code> is set the header will be created automatically, otherwise it will not.
227 * If a <code>{@link #title}</code> is set but <code>header</code> is explicitly set to <code>false</code>, the header
228 * will not be rendered.
230 <div id="cfg-Ext.Panel-footer"></div>/**
231 * @cfg {Boolean} footer
232 * <code>true</code> to create the footer element explicitly, false to skip creating it. The footer
233 * will be created automatically if <code>{@link #buttons}</code> or a <code>{@link #fbar}</code> have
234 * been configured. See <code>{@link #bodyCfg}</code> for an example.
236 <div id="cfg-Ext.Panel-title"></div>/**
237 * @cfg {String} title
238 * The title text to be used as innerHTML (html tags are accepted) to display in the panel
239 * <code>{@link #header}</code> (defaults to ''). When a <code>title</code> is specified the
240 * <code>{@link #header}</code> element will automatically be created and displayed unless
241 * {@link #header} is explicitly set to <code>false</code>. If you do not want to specify a
242 * <code>title</code> at config time, but you may want one later, you must either specify a non-empty
243 * <code>title</code> (a blank space ' ' will do) or <code>header:true</code> so that the container
244 * element will get created.
246 <div id="cfg-Ext.Panel-buttons"></div>/**
247 * @cfg {Array} buttons
248 * <code>buttons</code> will be used as <code>{@link Ext.Container#items items}</code> for the toolbar in
249 * the footer (<code>{@link #fbar}</code>). Typically the value of this configuration property will be
250 * an array of {@link Ext.Button}s or {@link Ext.Button} configuration objects.
251 * If an item is configured with <code>minWidth</code> or the Panel is configured with <code>minButtonWidth</code>,
252 * that width will be applied to the item.
254 <div id="cfg-Ext.Panel-autoLoad"></div>/**
255 * @cfg {Object/String/Function} autoLoad
256 * A valid url spec according to the Updater {@link Ext.Updater#update} method.
257 * If autoLoad is not null, the panel will attempt to load its contents
258 * immediately upon render.<p>
259 * The URL will become the default URL for this panel's {@link #body} element,
260 * so it may be {@link Ext.Element#refresh refresh}ed at any time.</p>
262 <div id="cfg-Ext.Panel-frame"></div>/**
263 * @cfg {Boolean} frame
264 * <code>false</code> by default to render with plain 1px square borders. <code>true</code> to render with
265 * 9 elements, complete with custom rounded corners (also see {@link Ext.Element#boxWrap}).
266 * <p>The template generated for each condition is depicted below:</p><pre><code>
269 <div id="developer-specified-id-goes-here" class="x-panel">
271 <div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:false)</span></div>
273 <div class="x-panel-bwrap">
274 <div class="x-panel-body"><p>html value goes here</p></div>
278 // frame = true (create 9 elements)
279 <div id="developer-specified-id-goes-here" class="x-panel">
280 <div class="x-panel-tl"><div class="x-panel-tr"><div class="x-panel-tc">
281 <div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:true)</span></div>
282 </div></div></div>
284 <div class="x-panel-bwrap">
285 <div class="x-panel-ml"><div class="x-panel-mr"><div class="x-panel-mc">
286 <div class="x-panel-body"><p>html value goes here</p></div>
287 </div></div></div>
289 <div class="x-panel-bl"><div class="x-panel-br"><div class="x-panel-bc"/>
290 </div></div></div>
294 <div id="cfg-Ext.Panel-border"></div>/**
295 * @cfg {Boolean} border
296 * True to display the borders of the panel's body element, false to hide them (defaults to true). By default,
297 * the border is a 2px wide inset border, but this can be further altered by setting {@link #bodyBorder} to false.
299 <div id="cfg-Ext.Panel-bodyBorder"></div>/**
300 * @cfg {Boolean} bodyBorder
301 * True to display an interior border on the body element of the panel, false to hide it (defaults to true).
302 * This only applies when {@link #border} == true. If border == true and bodyBorder == false, the border will display
303 * as a 1px wide inset border, giving the entire body element an inset appearance.
305 <div id="cfg-Ext.Panel-bodyCssClass"></div>/**
306 * @cfg {String/Object/Function} bodyCssClass
307 * Additional css class selector to be applied to the {@link #body} element in the format expected by
308 * {@link Ext.Element#addClass} (defaults to null). See {@link #bodyCfg}.
310 <div id="cfg-Ext.Panel-bodyStyle"></div>/**
311 * @cfg {String/Object/Function} bodyStyle
312 * Custom CSS styles to be applied to the {@link #body} element in the format expected by
313 * {@link Ext.Element#applyStyles} (defaults to null). See {@link #bodyCfg}.
315 <div id="cfg-Ext.Panel-iconCls"></div>/**
316 * @cfg {String} iconCls
317 * The CSS class selector that specifies a background image to be used as the header icon (defaults to '').
318 * <p>An example of specifying a custom icon class would be something like:
320 // specify the property in the config for the class:
324 // css class that specifies background image to be used as the icon image:
325 .my-icon { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
328 <div id="cfg-Ext.Panel-collapsible"></div>/**
329 * @cfg {Boolean} collapsible
330 * True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into
331 * the header tool button area, false to keep the panel statically sized with no button (defaults to false).
333 <div id="cfg-Ext.Panel-tools"></div>/**
335 * An array of tool button configs to be added to the header tool area. When rendered, each tool is
336 * stored as an {@link Ext.Element Element} referenced by a public property called <code><b></b>tools.<i><tool-type></i></code>
337 * <p>Each tool config may contain the following properties:
338 * <div class="mdetail-params"><ul>
339 * <li><b>id</b> : String<div class="sub-desc"><b>Required.</b> The type
340 * of tool to create. By default, this assigns a CSS class of the form <code>x-tool-<i><tool-type></i></code> to the
341 * resulting tool Element. Ext provides CSS rules, and an icon sprite containing images for the tool types listed below.
342 * The developer may implement custom tools by supplying alternate CSS rules and background images:
344 * <div class="x-tool x-tool-toggle" style="float:left; margin-right:5;"> </div><div><code> toggle</code> (Created by default when {@link #collapsible} is <code>true</code>)</div>
345 * <div class="x-tool x-tool-close" style="float:left; margin-right:5;"> </div><div><code> close</code></div>
346 * <div class="x-tool x-tool-minimize" style="float:left; margin-right:5;"> </div><div><code> minimize</code></div>
347 * <div class="x-tool x-tool-maximize" style="float:left; margin-right:5;"> </div><div><code> maximize</code></div>
348 * <div class="x-tool x-tool-restore" style="float:left; margin-right:5;"> </div><div><code> restore</code></div>
349 * <div class="x-tool x-tool-gear" style="float:left; margin-right:5;"> </div><div><code> gear</code></div>
350 * <div class="x-tool x-tool-pin" style="float:left; margin-right:5;"> </div><div><code> pin</code></div>
351 * <div class="x-tool x-tool-unpin" style="float:left; margin-right:5;"> </div><div><code> unpin</code></div>
352 * <div class="x-tool x-tool-right" style="float:left; margin-right:5;"> </div><div><code> right</code></div>
353 * <div class="x-tool x-tool-left" style="float:left; margin-right:5;"> </div><div><code> left</code></div>
354 * <div class="x-tool x-tool-up" style="float:left; margin-right:5;"> </div><div><code> up</code></div>
355 * <div class="x-tool x-tool-down" style="float:left; margin-right:5;"> </div><div><code> down</code></div>
356 * <div class="x-tool x-tool-refresh" style="float:left; margin-right:5;"> </div><div><code> refresh</code></div>
357 * <div class="x-tool x-tool-minus" style="float:left; margin-right:5;"> </div><div><code> minus</code></div>
358 * <div class="x-tool x-tool-plus" style="float:left; margin-right:5;"> </div><div><code> plus</code></div>
359 * <div class="x-tool x-tool-help" style="float:left; margin-right:5;"> </div><div><code> help</code></div>
360 * <div class="x-tool x-tool-search" style="float:left; margin-right:5;"> </div><div><code> search</code></div>
361 * <div class="x-tool x-tool-save" style="float:left; margin-right:5;"> </div><div><code> save</code></div>
362 * <div class="x-tool x-tool-print" style="float:left; margin-right:5;"> </div><div><code> print</code></div>
364 * <li><b>handler</b> : Function<div class="sub-desc"><b>Required.</b> The function to
365 * call when clicked. Arguments passed are:<ul>
366 * <li><b>event</b> : Ext.EventObject<div class="sub-desc">The click event.</div></li>
367 * <li><b>toolEl</b> : Ext.Element<div class="sub-desc">The tool Element.</div></li>
368 * <li><b>panel</b> : Ext.Panel<div class="sub-desc">The host Panel</div></li>
369 * <li><b>tc</b> : Ext.Panel<div class="sub-desc">The tool configuration object</div></li>
371 * <li><b>stopEvent</b> : Boolean<div class="sub-desc">Defaults to true. Specify as false to allow click event to propagate.</div></li>
372 * <li><b>scope</b> : Object<div class="sub-desc">The scope in which to call the handler.</div></li>
373 * <li><b>qtip</b> : String/Object<div class="sub-desc">A tip string, or
374 * a config argument to {@link Ext.QuickTip#register}</div></li>
375 * <li><b>hidden</b> : Boolean<div class="sub-desc">True to initially render hidden.</div></li>
376 * <li><b>on</b> : Object<div class="sub-desc">A listener config object specifiying
377 * event listeners in the format of an argument to {@link #addListener}</div></li>
379 * <p>Note that, apart from the toggle tool which is provided when a panel is collapsible, these
380 * tools only provide the visual button. Any required functionality must be provided by adding
381 * handlers that implement the necessary behavior.</p>
382 * <p>Example usage:</p>
386 qtip: 'Refresh form Data',
388 handler: function(event, toolEl, panel){
395 handler: function(event, toolEl, panel){
400 * <p>For the custom id of <code>'help'</code> define two relevant css classes with a link to
403 .x-tool-help {background-image: url(images/help.png);}
404 .x-tool-help-over {background-image: url(images/help_over.png);}
405 // if using an image sprite:
406 .x-tool-help {background-image: url(images/help.png) no-repeat 0 0;}
407 .x-tool-help-over {background-position:-15px 0;}
410 <div id="cfg-Ext.Panel-toolTemplate"></div>/**
411 * @cfg {Ext.Template/Ext.XTemplate} toolTemplate
412 * <p>A Template used to create {@link #tools} in the {@link #header} Element. Defaults to:</p><pre><code>
413 new Ext.Template('<div class="x-tool x-tool-{id}">&#160;</div>')</code></pre>
414 * <p>This may may be overridden to provide a custom DOM structure for tools based upon a more
415 * complex XTemplate. The template's data is a single tool configuration object (Not the entire Array)
416 * as specified in {@link #tools}. In the following example an <a> tag is used to provide a
417 * visual indication when hovering over the tool:</p><pre><code>
418 var win = new Ext.Window({
421 href: '/MyPdfDoc.pdf'
423 toolTemplate: new Ext.XTemplate(
424 '<tpl if="id==\'download\'">',
425 '<a class="x-tool x-tool-pdf" href="{href}"></a>',
427 '<tpl if="id!=\'download\'">',
428 '<div class="x-tool x-tool-{id}">&#160;</div>',
435 * <p>Note that the CSS class 'x-tool-pdf' should have an associated style rule which provides an
436 * appropriate background image, something like:</p>
438 a.x-tool-pdf {background-image: url(../shared/extjs/images/pdf.gif)!important;}
441 <div id="cfg-Ext.Panel-hideCollapseTool"></div>/**
442 * @cfg {Boolean} hideCollapseTool
443 * <code>true</code> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
444 * <code>false</code> to display it (defaults to <code>false</code>).
446 <div id="cfg-Ext.Panel-titleCollapse"></div>/**
447 * @cfg {Boolean} titleCollapse
448 * <code>true</code> to allow expanding and collapsing the panel (when <code>{@link #collapsible} = true</code>)
449 * by clicking anywhere in the header bar, <code>false</code>) to allow it only by clicking to tool button
450 * (defaults to <code>false</code>)). If this panel is a child item of a border layout also see the
451 * {@link Ext.layout.BorderLayout.Region BorderLayout.Region}
452 * <code>{@link Ext.layout.BorderLayout.Region#floatable floatable}</code> config option.
454 <div id="cfg-Ext.Panel-autoScroll"></div>/**
455 * @cfg {Boolean} autoScroll
456 * <code>true</code> to use overflow:'auto' on the panel's body element and show scroll bars automatically when
457 * necessary, <code>false</code> to clip any overflowing content (defaults to <code>false</code>).
459 <div id="cfg-Ext.Panel-floating"></div>/**
460 * @cfg {Mixed} floating
461 * <p>This property is used to configure the underlying {@link Ext.Layer}. Acceptable values for this
462 * configuration property are:</p><div class="mdetail-params"><ul>
463 * <li><b><code>false</code></b> : <b>Default.</b><div class="sub-desc">Display the panel inline where it is
464 * rendered.</div></li>
465 * <li><b><code>true</code></b> : <div class="sub-desc">Float the panel (absolute position it with automatic
466 * shimming and shadow).<ul>
467 * <div class="sub-desc">Setting floating to true will create an Ext.Layer for this panel and display the
468 * panel at negative offsets so that it is hidden.</div>
469 * <div class="sub-desc">Since the panel will be absolute positioned, the position must be set explicitly
470 * <i>after</i> render (e.g., <code>myPanel.setPosition(100,100);</code>).</div>
471 * <div class="sub-desc"><b>Note</b>: when floating a panel you should always assign a fixed width,
472 * otherwise it will be auto width and will expand to fill to the right edge of the viewport.</div>
474 * <li><b><code>{@link Ext.Layer object}</code></b> : <div class="sub-desc">The specified object will be used
475 * as the configuration object for the {@link Ext.Layer} that will be created.</div></li>
478 <div id="cfg-Ext.Panel-shadow"></div>/**
479 * @cfg {Boolean/String} shadow
480 * <code>true</code> (or a valid Ext.Shadow {@link Ext.Shadow#mode} value) to display a shadow behind the
481 * panel, <code>false</code> to display no shadow (defaults to <code>'sides'</code>). Note that this option
482 * only applies when <code>{@link #floating} = true</code>.
484 <div id="cfg-Ext.Panel-shadowOffset"></div>/**
485 * @cfg {Number} shadowOffset
486 * The number of pixels to offset the shadow if displayed (defaults to <code>4</code>). Note that this
487 * option only applies when <code>{@link #floating} = true</code>.
489 <div id="cfg-Ext.Panel-shim"></div>/**
490 * @cfg {Boolean} shim
491 * <code>false</code> to disable the iframe shim in browsers which need one (defaults to <code>true</code>).
492 * Note that this option only applies when <code>{@link #floating} = true</code>.
494 <div id="cfg-Ext.Panel-html"></div>/**
495 * @cfg {String/Object} html
496 * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the panel's body
497 * content (defaults to ''). The HTML content is added by the Panel's {@link #afterRender} method,
498 * and so the document will not contain this HTML at the time the {@link #render} event is fired.
499 * This content is inserted into the body <i>before</i> any configured {@link #contentEl} is appended.
501 <div id="cfg-Ext.Panel-contentEl"></div>/**
502 * @cfg {String} contentEl
503 * <p>Optional. Specify an existing HTML element, or the <code>id</code> of an existing HTML element to use as this Panel's
504 * <code><b>{@link #body}</b></code> content.</p>
506 * <li><b>Description</b> :
507 * <div class="sub-desc">This config option is used to take an existing HTML element and place it in the body
508 * of a new panel (it simply moves the specified DOM element into the body element of the Panel
509 * <i>after the Panel is rendered</i> to use as the content (it is not going to be the actual panel itself).</div></li>
511 * <div class="sub-desc">The specified HTML element is appended to the Panel's {@link #body} Element by the
512 * Panel's <code>afterRender</code> method <i>after any configured {@link #html HTML} has
513 * been inserted</i>, and so the document will not contain this element at the time the
514 * {@link #render} event is fired.</div>
515 * <div class="sub-desc">The specified HTML element used will not participate in any <code><b>{@link Ext.Container#layout layout}</b></code>
516 * scheme that the Panel may use. It is just HTML. Layouts operate on child <code><b>{@link Ext.Container#items items}</b></code>.</div>
517 * <div class="sub-desc">Add either the <code>x-hidden</code> or the <code>x-hide-display</code> CSS class to
518 * prevent a brief flicker of the content before it is rendered to the panel.</div></li>
521 <div id="cfg-Ext.Panel-keys"></div>/**
522 * @cfg {Object/Array} keys
523 * A {@link Ext.KeyMap} config object (in the format expected by {@link Ext.KeyMap#addBinding}
524 * used to assign custom key handling to this panel (defaults to <code>null</code>).
526 <div id="cfg-Ext.Panel-draggable"></div>/**
527 * @cfg {Boolean/Object} draggable
528 * <p><code>true</code> to enable dragging of this Panel (defaults to <code>false</code>).</p>
529 * <p>For custom drag/drop implementations, an <b>Ext.Panel.DD</b> config could also be passed
530 * in this config instead of <code>true</code>. Ext.Panel.DD is an internal, undocumented class which
531 * moves a proxy Element around in place of the Panel's element, but provides no other behaviour
532 * during dragging or on drop. It is a subclass of {@link Ext.dd.DragSource}, so behaviour may be
533 * added by implementing the interface methods of {@link Ext.dd.DragDrop} e.g.:
539 renderTo: Ext.getBody(),
545 // Config option of Ext.Panel.DD class.
546 // It's a floating Panel, so do not show a placeholder proxy in the original position.
549 // Called for each mousemove event while dragging the DD object.
550 onDrag : function(e){
551 // Record the x,y position of the drag proxy so that we can
552 // position the Panel at end of drag.
553 var pel = this.proxy.getEl();
554 this.x = pel.getLeft(true);
555 this.y = pel.getTop(true);
557 // Keep the Shadow aligned if there is one.
558 var s = this.panel.getEl().shadow;
560 s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
564 // Called on the mouseup event.
565 endDrag : function(e){
566 this.panel.setPosition(this.x, this.y);
572 <div id="cfg-Ext.Panel-disabled"></div>/**
573 * @cfg {Boolean} disabled
574 * Render this panel disabled (default is <code>false</code>). An important note when using the disabled
575 * config on panels is that IE will often fail to initialize the disabled mask element correectly if
576 * the panel's layout has not yet completed by the time the Panel is disabled during the render process.
577 * If you experience this issue, you may need to instead use the {@link #afterlayout} event to initialize
578 * the disabled state:
587 single: true // important, as many layouts can occur
593 <div id="cfg-Ext.Panel-autoHeight"></div>/**
594 * @cfg {Boolean} autoHeight
595 * <code>true</code> to use height:'auto', <code>false</code> to use fixed height (defaults to <code>false</code>).
596 * <b>Note</b>: Setting <code>autoHeight: true</code> means that the browser will manage the panel's height
597 * based on its contents, and that Ext will not manage it at all. If the panel is within a layout that
598 * manages dimensions (<code>fit</code>, <code>border</code>, etc.) then setting <code>autoHeight: true</code>
599 * can cause issues with scrolling and will not generally work as expected since the panel will take
600 * on the height of its contents rather than the height required by the Ext layout.
604 <div id="cfg-Ext.Panel-baseCls"></div>/**
605 * @cfg {String} baseCls
606 * The base CSS class to apply to this panel's element (defaults to <code>'x-panel'</code>).
607 * <p>Another option available by default is to specify <code>'x-plain'</code> which strips all styling
608 * except for required attributes for Ext layouts to function (e.g. overflow:hidden).
609 * See <code>{@link #unstyled}</code> also.</p>
612 <div id="cfg-Ext.Panel-collapsedCls"></div>/**
613 * @cfg {String} collapsedCls
614 * A CSS class to add to the panel's element after it has been collapsed (defaults to
615 * <code>'x-panel-collapsed'</code>).
617 collapsedCls : 'x-panel-collapsed',
618 <div id="cfg-Ext.Panel-maskDisabled"></div>/**
619 * @cfg {Boolean} maskDisabled
620 * <code>true</code> to mask the panel when it is {@link #disabled}, <code>false</code> to not mask it (defaults
621 * to <code>true</code>). Either way, the panel will always tell its contained elements to disable themselves
622 * when it is disabled, but masking the panel can provide an additional visual cue that the panel is
626 <div id="cfg-Ext.Panel-animCollapse"></div>/**
627 * @cfg {Boolean} animCollapse
628 * <code>true</code> to animate the transition when the panel is collapsed, <code>false</code> to skip the
629 * animation (defaults to <code>true</code> if the {@link Ext.Fx} class is available, otherwise <code>false</code>).
631 animCollapse : Ext.enableFx,
632 <div id="cfg-Ext.Panel-headerAsText"></div>/**
633 * @cfg {Boolean} headerAsText
634 * <code>true</code> to display the panel <code>{@link #title}</code> in the <code>{@link #header}</code>,
635 * <code>false</code> to hide it (defaults to <code>true</code>).
638 <div id="cfg-Ext.Panel-buttonAlign"></div>/**
639 * @cfg {String} buttonAlign
640 * The alignment of any {@link #buttons} added to this panel. Valid values are <code>'right'</code>,
641 * <code>'left'</code> and <code>'center'</code> (defaults to <code>'right'</code>).
643 buttonAlign : 'right',
644 <div id="cfg-Ext.Panel-collapsed"></div>/**
645 * @cfg {Boolean} collapsed
646 * <code>true</code> to render the panel collapsed, <code>false</code> to render it expanded (defaults to
647 * <code>false</code>).
650 <div id="cfg-Ext.Panel-collapseFirst"></div>/**
651 * @cfg {Boolean} collapseFirst
652 * <code>true</code> to make sure the collapse/expand toggle button always renders first (to the left of)
653 * any other tools in the panel's title bar, <code>false</code> to render it last (defaults to <code>true</code>).
655 collapseFirst : true,
656 <div id="cfg-Ext.Panel-minButtonWidth"></div>/**
657 * @cfg {Number} minButtonWidth
658 * Minimum width in pixels of all {@link #buttons} in this panel (defaults to <code>75</code>)
661 <div id="cfg-Ext.Panel-unstyled"></div>/**
662 * @cfg {Boolean} unstyled
663 * Overrides the <code>{@link #baseCls}</code> setting to <code>{@link #baseCls} = 'x-plain'</code> which renders
664 * the panel unstyled except for required attributes for Ext layouts to function (e.g. overflow:hidden).
666 <div id="cfg-Ext.Panel-elements"></div>/**
667 * @cfg {String} elements
668 * A comma-delimited list of panel elements to initialize when the panel is rendered. Normally, this list will be
669 * generated automatically based on the items added to the panel at config time, but sometimes it might be useful to
670 * make sure a structural element is rendered even if not specified at config time (for example, you may want
671 * to add a button or toolbar dynamically after the panel has been rendered). Adding those elements to this
672 * list will allocate the required placeholders in the panel when it is rendered. Valid values are<div class="mdetail-params"><ul>
673 * <li><code>header</code></li>
674 * <li><code>tbar</code> (top bar)</li>
675 * <li><code>body</code></li>
676 * <li><code>bbar</code> (bottom bar)</li>
677 * <li><code>footer</code></li>
679 * Defaults to '<code>body</code>'.
682 <div id="cfg-Ext.Panel-preventBodyReset"></div>/**
683 * @cfg {Boolean} preventBodyReset
684 * Defaults to <code>false</code>. When set to <code>true</code>, an extra css class <code>'x-panel-normal'</code>
685 * will be added to the panel's element, effectively applying css styles suggested by the W3C
686 * (see http://www.w3.org/TR/CSS21/sample.html) to the Panel's <b>body</b> element (not the header,
689 preventBodyReset : false,
691 <div id="cfg-Ext.Panel-resizeEvent"></div>/** @cfg {String} resizeEvent
692 * The event to listen to for resizing in layouts. Defaults to <tt>'bodyresize'</tt>.
694 resizeEvent: 'bodyresize',
696 // protected - these could be used to customize the behavior of the window,
697 // but changing them would not be useful without further mofifications and
698 // could lead to unexpected or undesirable results.
699 toolTarget : 'header',
700 collapseEl : 'bwrap',
704 // private, notify box this class will handle heights
716 initComponent : function(){
717 Ext.Panel.superclass.initComponent.call(this);
720 <div id="event-Ext.Panel-bodyresize"></div>/**
722 * Fires after the Panel has been resized.
723 * @param {Ext.Panel} p the Panel which has been resized.
724 * @param {Number} width The Panel's new width.
725 * @param {Number} height The Panel's new height.
728 <div id="event-Ext.Panel-titlechange"></div>/**
730 * Fires after the Panel title has been {@link #title set} or {@link #setTitle changed}.
731 * @param {Ext.Panel} p the Panel which has had its title changed.
732 * @param {String} The new title.
735 <div id="event-Ext.Panel-iconchange"></div>/**
737 * Fires after the Panel icon class has been {@link #iconCls set} or {@link #setIconClass changed}.
738 * @param {Ext.Panel} p the Panel which has had its {@link #iconCls icon class} changed.
739 * @param {String} The new icon class.
740 * @param {String} The old icon class.
743 <div id="event-Ext.Panel-collapse"></div>/**
745 * Fires after the Panel has been collapsed.
746 * @param {Ext.Panel} p the Panel that has been collapsed.
749 <div id="event-Ext.Panel-expand"></div>/**
751 * Fires after the Panel has been expanded.
752 * @param {Ext.Panel} p The Panel that has been expanded.
755 <div id="event-Ext.Panel-beforecollapse"></div>/**
756 * @event beforecollapse
757 * Fires before the Panel is collapsed. A handler can return false to cancel the collapse.
758 * @param {Ext.Panel} p the Panel being collapsed.
759 * @param {Boolean} animate True if the collapse is animated, else false.
762 <div id="event-Ext.Panel-beforeexpand"></div>/**
763 * @event beforeexpand
764 * Fires before the Panel is expanded. A handler can return false to cancel the expand.
765 * @param {Ext.Panel} p The Panel being expanded.
766 * @param {Boolean} animate True if the expand is animated, else false.
769 <div id="event-Ext.Panel-beforeclose"></div>/**
771 * Fires before the Panel is closed. Note that Panels do not directly support being closed, but some
772 * Panel subclasses do (like {@link Ext.Window}) or a Panel within a Ext.TabPanel. This event only
773 * applies to such subclasses.
774 * A handler can return false to cancel the close.
775 * @param {Ext.Panel} p The Panel being closed.
778 <div id="event-Ext.Panel-close"></div>/**
780 * Fires after the Panel is closed. Note that Panels do not directly support being closed, but some
781 * Panel subclasses do (like {@link Ext.Window}) or a Panel within a Ext.TabPanel.
782 * @param {Ext.Panel} p The Panel that has been closed.
785 <div id="event-Ext.Panel-activate"></div>/**
787 * Fires after the Panel has been visually activated.
788 * Note that Panels do not directly support being activated, but some Panel subclasses
789 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
790 * activate and deactivate events under the control of the TabPanel.
791 * @param {Ext.Panel} p The Panel that has been activated.
794 <div id="event-Ext.Panel-deactivate"></div>/**
796 * Fires after the Panel has been visually deactivated.
797 * Note that Panels do not directly support being deactivated, but some Panel subclasses
798 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
799 * activate and deactivate events under the control of the TabPanel.
800 * @param {Ext.Panel} p The Panel that has been deactivated.
806 this.baseCls = 'x-plain';
811 this.elements += ',tbar';
812 if(Ext.isObject(this.tbar)){
813 this.topToolbar = this.tbar;
818 this.elements += ',bbar';
819 if(Ext.isObject(this.bbar)){
820 this.bottomToolbar = this.bbar;
825 if(this.header === true){
826 this.elements += ',header';
828 }else if(this.headerCfg || (this.title && this.header !== false)){
829 this.elements += ',header';
832 if(this.footerCfg || this.footer === true){
833 this.elements += ',footer';
838 this.elements += ',footer';
839 var btns = this.buttons;
840 <div id="prop-Ext.Panel-buttons"></div>/**
841 * This Panel's Array of buttons as created from the <code>{@link #buttons}</code>
842 * config property. Read only.
847 Ext.each(btns, function(btn){
848 if(btn.render){ // button instance
849 this.buttons.push(btn);
851 this.buttons.push(Ext.create(btn, 'button'));
858 this.elements += ',footer';
861 this.on('render', this.doAutoLoad, this, {delay:10});
866 createElement : function(name, pnode){
868 pnode.appendChild(this[name].dom);
872 if(name === 'bwrap' || this.elements.indexOf(name) != -1){
873 if(this[name+'Cfg']){
874 this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
876 var el = document.createElement('div');
877 el.className = this[name+'Cls'];
878 this[name] = Ext.get(pnode.appendChild(el));
880 if(this[name+'CssClass']){
881 this[name].addClass(this[name+'CssClass']);
883 if(this[name+'Style']){
884 this[name].applyStyles(this[name+'Style']);
890 onRender : function(ct, position){
891 Ext.Panel.superclass.onRender.call(this, ct, position);
892 this.createClasses();
900 if(this.collapsible && !this.hideCollapseTool){
901 this.tools = this.tools ? this.tools.slice(0) : [];
902 this.tools[this.collapseFirst?'unshift':'push']({
904 handler : this.toggleCollapse,
911 this.elements += (this.header !== false) ? ',header' : '';
915 el.addClass(this.baseCls);
916 if(d.firstChild){ // existing markup
917 this.header = el.down('.'+this.headerCls);
918 this.bwrap = el.down('.'+this.bwrapCls);
919 var cp = this.bwrap ? this.bwrap : el;
920 this.tbar = cp.down('.'+this.tbarCls);
921 this.body = cp.down('.'+this.bodyCls);
922 this.bbar = cp.down('.'+this.bbarCls);
923 this.footer = cp.down('.'+this.footerCls);
924 this.fromMarkup = true;
926 if (this.preventBodyReset === true) {
927 el.addClass('x-panel-reset');
930 el.addClass(this.cls);
934 this.elements += ',footer';
937 // This block allows for maximum flexibility and performance when using existing markup
939 // framing requires special markup
941 el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
943 this.createElement('header', d.firstChild.firstChild.firstChild);
944 this.createElement('bwrap', d);
946 // append the mid and bottom frame to the bwrap
948 var ml = d.childNodes[1], bl = d.childNodes[2];
952 var mc = bw.firstChild.firstChild.firstChild;
953 this.createElement('tbar', mc);
954 this.createElement('body', mc);
955 this.createElement('bbar', mc);
956 this.createElement('footer', bw.lastChild.firstChild.firstChild);
959 this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
962 * Store a reference to this element so:
963 * a) We aren't looking it up all the time
964 * b) The last element is reported incorrectly when using a loadmask
966 this.ft = Ext.get(this.bwrap.dom.lastChild);
967 this.mc = Ext.get(this.bwrap.dom.firstChild.firstChild.firstChild);
969 this.createElement('header', d);
970 this.createElement('bwrap', d);
972 // append the mid and bottom frame to the bwrap
974 this.createElement('tbar', bw);
975 this.createElement('body', bw);
976 this.createElement('bbar', bw);
977 this.createElement('footer', bw);
980 this.body.addClass(this.bodyCls + '-noheader');
982 this.tbar.addClass(this.tbarCls + '-noheader');
987 if(Ext.isDefined(this.padding)){
988 this.body.setStyle('padding', this.body.addUnits(this.padding));
991 if(this.border === false){
992 this.el.addClass(this.baseCls + '-noborder');
993 this.body.addClass(this.bodyCls + '-noborder');
995 this.header.addClass(this.headerCls + '-noborder');
998 this.footer.addClass(this.footerCls + '-noborder');
1001 this.tbar.addClass(this.tbarCls + '-noborder');
1004 this.bbar.addClass(this.bbarCls + '-noborder');
1008 if(this.bodyBorder === false){
1009 this.body.addClass(this.bodyCls + '-noborder');
1012 this.bwrap.enableDisplayMode('block');
1015 this.header.unselectable();
1017 // for tools, we need to wrap any existing header markup
1018 if(this.headerAsText){
1019 this.header.dom.innerHTML =
1020 '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
1023 this.setIconClass(this.iconCls);
1029 this.makeFloating(this.floating);
1032 if(this.collapsible && this.titleCollapse && this.header){
1033 this.mon(this.header, 'click', this.toggleCollapse, this);
1034 this.header.setStyle('cursor', 'pointer');
1037 this.addTool.apply(this, ts);
1040 if(this.buttons && this.buttons.length > 0){
1041 this.fbar = new Ext.Toolbar({
1042 items: this.buttons,
1043 toolbarCls: 'x-panel-fbar'
1048 this.fbar = Ext.create(this.fbar, 'toolbar');
1049 this.fbar.enableOverflow = false;
1050 if(this.fbar.items){
1051 this.fbar.items.each(function(c){
1052 c.minWidth = c.minWidth || this.minButtonWidth;
1055 this.fbar.toolbarCls = 'x-panel-fbar';
1057 var bct = this.footer.createChild({cls: 'x-panel-btns x-panel-btns-'+this.buttonAlign});
1058 this.fbar.ownerCt = this;
1059 this.fbar.render(bct);
1060 bct.createChild({cls:'x-clear'});
1061 this.toolbars.push(this.fbar);
1064 if(this.tbar && this.topToolbar){
1065 if(Ext.isArray(this.topToolbar)){
1066 this.topToolbar = new Ext.Toolbar(this.topToolbar);
1067 }else if(!this.topToolbar.events){
1068 this.topToolbar = Ext.create(this.topToolbar, 'toolbar');
1070 this.topToolbar.ownerCt = this;
1071 this.topToolbar.render(this.tbar);
1072 this.toolbars.push(this.topToolbar);
1074 if(this.bbar && this.bottomToolbar){
1075 if(Ext.isArray(this.bottomToolbar)){
1076 this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
1077 }else if(!this.bottomToolbar.events){
1078 this.bottomToolbar = Ext.create(this.bottomToolbar, 'toolbar');
1080 this.bottomToolbar.ownerCt = this;
1081 this.bottomToolbar.render(this.bbar);
1082 this.toolbars.push(this.bottomToolbar);
1086 <div id="method-Ext.Panel-setIconClass"></div>/**
1087 * Sets the CSS class that provides the icon image for this panel. This method will replace any existing
1088 * icon class if one has already been set and fire the {@link #iconchange} event after completion.
1089 * @param {String} cls The new CSS class name
1091 setIconClass : function(cls){
1092 var old = this.iconCls;
1094 if(this.rendered && this.header){
1096 this.header.addClass('x-panel-icon');
1097 this.header.replaceClass(old, this.iconCls);
1099 var hd = this.header,
1100 img = hd.child('img.x-panel-inline-icon');
1102 Ext.fly(img).replaceClass(old, this.iconCls);
1104 Ext.DomHelper.insertBefore(hd.dom.firstChild, {
1105 tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
1110 this.fireEvent('iconchange', this, cls, old);
1114 makeFloating : function(cfg){
1115 this.floating = true;
1116 this.el = new Ext.Layer(
1117 Ext.isObject(cfg) ? cfg : {
1118 shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
1119 shadowOffset: this.shadowOffset,
1121 shim: this.shim === false ? false : undefined
1126 <div id="method-Ext.Panel-getTopToolbar"></div>/**
1127 * Returns the {@link Ext.Toolbar toolbar} from the top (<code>{@link #tbar}</code>) section of the panel.
1128 * @return {Ext.Toolbar} The toolbar
1130 getTopToolbar : function(){
1131 return this.topToolbar;
1134 <div id="method-Ext.Panel-getBottomToolbar"></div>/**
1135 * Returns the {@link Ext.Toolbar toolbar} from the bottom (<code>{@link #bbar}</code>) section of the panel.
1136 * @return {Ext.Toolbar} The toolbar
1138 getBottomToolbar : function(){
1139 return this.bottomToolbar;
1142 <div id="method-Ext.Panel-addButton"></div>/**
1143 * Adds a button to this panel. Note that this method must be called prior to rendering. The preferred
1144 * approach is to add buttons via the {@link #buttons} config.
1145 * @param {String/Object} config A valid {@link Ext.Button} config. A string will become the text for a default
1146 * button config, an object will be treated as a button config object.
1147 * @param {Function} handler The function to be called on button {@link Ext.Button#click}
1148 * @param {Object} scope The scope to use for the button handler function
1149 * @return {Ext.Button} The button that was added
1151 addButton : function(config, handler, scope){
1155 minWidth: this.minButtonWidth,
1158 if(Ext.isString(config)){
1161 Ext.apply(bc, config);
1163 var btn = new Ext.Button(bc);
1167 this.buttons.push(btn);
1172 addTool : function(){
1177 Ext.each(arguments, function(arg){
1178 this.tools.push(arg)
1182 // nowhere to render tools!
1183 if(!this[this.toolTarget]){
1186 if(!this.toolTemplate){
1187 // initialize the global tool template on first use
1188 var tt = new Ext.Template(
1189 '<div class="x-tool x-tool-{id}"> </div>'
1191 tt.disableFormats = true;
1193 Ext.Panel.prototype.toolTemplate = tt;
1195 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
1197 if(!this.tools[tc.id]){
1198 var overCls = 'x-tool-'+tc.id+'-over';
1199 var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
1200 this.tools[tc.id] = t;
1201 t.enableDisplayMode('block');
1202 this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
1210 if(Ext.isObject(tc.qtip)){
1211 Ext.QuickTips.register(Ext.apply({
1215 t.dom.qtip = tc.qtip;
1218 t.addClassOnOver(overCls);
1223 onLayout : function(shallow, force){
1224 if(this.hasLayout && this.toolbars.length > 0){
1225 Ext.each(this.toolbars, function(tb){
1226 tb.doLayout(undefined, force);
1232 syncHeight : function(){
1233 var h = this.toolbarHeight,
1235 lsh = this.lastSize.height;
1237 if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
1242 if(h != this.getToolbarHeight()){
1243 h = Math.max(0, this.adjustBodyHeight(lsh - this.getFrameHeight()));
1246 this.toolbarHeight = this.getToolbarHeight();
1247 this.onBodyResize(sz.width, sz.height);
1252 onShow : function(){
1254 return this.el.show();
1256 Ext.Panel.superclass.onShow.call(this);
1260 onHide : function(){
1262 return this.el.hide();
1264 Ext.Panel.superclass.onHide.call(this);
1268 createToolHandler : function(t, tc, overCls, panel){
1270 t.removeClass(overCls);
1271 if(tc.stopEvent !== false){
1275 tc.handler.call(tc.scope || t, e, t, panel, tc);
1281 afterRender : function(){
1282 if(this.floating && !this.hidden){
1286 this.setTitle(this.title);
1288 this.setAutoScroll();
1290 this.body.update(Ext.isObject(this.html) ?
1291 Ext.DomHelper.markup(this.html) :
1296 var ce = Ext.getDom(this.contentEl);
1297 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
1298 this.body.dom.appendChild(ce);
1301 this.collapsed = false;
1302 this.collapse(false);
1304 Ext.Panel.superclass.afterRender.call(this); // do sizing calcs last
1309 setAutoScroll : function(){
1310 if(this.rendered && this.autoScroll){
1311 var el = this.body || this.el;
1313 el.setOverflow('auto');
1319 getKeyMap : function(){
1321 this.keyMap = new Ext.KeyMap(this.el, this.keys);
1327 initEvents : function(){
1332 this.initDraggable();
1334 if(this.toolbars.length > 0){
1335 Ext.each(this.toolbars, function(tb){
1339 afterlayout: this.syncHeight,
1340 remove: this.syncHeight
1350 initDraggable : function(){
1351 <div id="prop-Ext.Panel-dd"></div>/**
1352 * <p>If this Panel is configured {@link #draggable}, this property will contain
1353 * an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
1354 * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
1355 * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
1356 * @type Ext.dd.DragSource.
1359 this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
1363 beforeEffect : function(anim){
1365 this.el.beforeAction();
1368 this.el.addClass('x-panel-animated');
1373 afterEffect : function(anim){
1376 this.el.removeClass('x-panel-animated');
1380 // private - wraps up an animation param with internal callbacks
1381 createEffect : function(a, cb, scope){
1389 }else if(!a.callback){
1391 }else { // wrap it up
1392 o.callback = function(){
1394 Ext.callback(a.callback, a.scope);
1397 return Ext.applyIf(o, a);
1400 <div id="method-Ext.Panel-collapse"></div>/**
1401 * Collapses the panel body so that it becomes hidden. Fires the {@link #beforecollapse} event which will
1402 * cancel the collapse action if it returns false.
1403 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1404 * {@link #animCollapse} panel config)
1405 * @return {Ext.Panel} this
1407 collapse : function(animate){
1408 if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
1411 var doAnim = animate === true || (animate !== false && this.animCollapse);
1412 this.beforeEffect(doAnim);
1413 this.onCollapse(doAnim, animate);
1418 onCollapse : function(doAnim, animArg){
1420 this[this.collapseEl].slideOut(this.slideAnchor,
1421 Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
1422 this.collapseDefaults));
1424 this[this.collapseEl].hide();
1425 this.afterCollapse(false);
1430 afterCollapse : function(anim){
1431 this.collapsed = true;
1432 this.el.addClass(this.collapsedCls);
1433 this.afterEffect(anim);
1434 this.fireEvent('collapse', this);
1437 <div id="method-Ext.Panel-expand"></div>/**
1438 * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
1439 * cancel the expand action if it returns false.
1440 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1441 * {@link #animCollapse} panel config)
1442 * @return {Ext.Panel} this
1444 expand : function(animate){
1445 if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
1448 var doAnim = animate === true || (animate !== false && this.animCollapse);
1449 this.el.removeClass(this.collapsedCls);
1450 this.beforeEffect(doAnim);
1451 this.onExpand(doAnim, animate);
1456 onExpand : function(doAnim, animArg){
1458 this[this.collapseEl].slideIn(this.slideAnchor,
1459 Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
1460 this.expandDefaults));
1462 this[this.collapseEl].show();
1463 this.afterExpand(false);
1468 afterExpand : function(anim){
1469 this.collapsed = false;
1470 this.afterEffect(anim);
1471 if(Ext.isDefined(this.deferLayout)){
1472 this.doLayout(true);
1474 this.fireEvent('expand', this);
1477 <div id="method-Ext.Panel-toggleCollapse"></div>/**
1478 * Shortcut for performing an {@link #expand} or {@link #collapse} based on the current state of the panel.
1479 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
1480 * {@link #animCollapse} panel config)
1481 * @return {Ext.Panel} this
1483 toggleCollapse : function(animate){
1484 this[this.collapsed ? 'expand' : 'collapse'](animate);
1489 onDisable : function(){
1490 if(this.rendered && this.maskDisabled){
1493 Ext.Panel.superclass.onDisable.call(this);
1497 onEnable : function(){
1498 if(this.rendered && this.maskDisabled){
1501 Ext.Panel.superclass.onEnable.call(this);
1505 onResize : function(w, h){
1506 if(Ext.isDefined(w) || Ext.isDefined(h)){
1507 if(!this.collapsed){
1508 if(Ext.isNumber(w)){
1509 w = this.adjustBodyWidth(w - this.getFrameWidth());
1511 this.tbar.setWidth(w);
1512 if(this.topToolbar){
1513 this.topToolbar.setSize(w);
1517 this.bbar.setWidth(w);
1518 if(this.bottomToolbar){
1519 this.bottomToolbar.setSize(w);
1525 strict = Ext.isStrict;
1526 if(this.buttonAlign == 'left'){
1527 fWidth = w - f.container.getFrameWidth('lr');
1529 //center/right alignment off in webkit
1530 if(Ext.isIE || Ext.isWebKit){
1531 //center alignment ok on webkit.
1532 //right broken in both, center on IE
1533 if(!(this.buttonAlign == 'center' && Ext.isWebKit) && (!strict || (!Ext.isIE8 && strict))){
1535 f.setWidth(f.getEl().child('.x-toolbar-ct').getWidth());
1546 this.body.setWidth(w);
1547 }else if(w == 'auto'){
1548 this.body.setWidth(w);
1551 if(Ext.isNumber(h)){
1552 h = Math.max(0, this.adjustBodyHeight(h - this.getFrameHeight()));
1553 this.body.setHeight(h);
1554 }else if(h == 'auto'){
1555 this.body.setHeight(h);
1558 if(this.disabled && this.el._mask){
1559 this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
1562 this.queuedBodySize = {width: w, height: h};
1563 if(!this.queuedExpand && this.allowQueuedExpand !== false){
1564 this.queuedExpand = true;
1565 this.on('expand', function(){
1566 delete this.queuedExpand;
1567 this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
1569 }, this, {single:true});
1572 this.onBodyResize(w, h);
1578 onBodyResize: function(w, h){
1579 this.fireEvent('bodyresize', this, w, h);
1583 getToolbarHeight: function(){
1586 Ext.each(this.toolbars, function(tb){
1587 h += tb.getHeight();
1594 adjustBodyHeight : function(h){
1599 adjustBodyWidth : function(w){
1604 onPosition : function(){
1608 <div id="method-Ext.Panel-getFrameWidth"></div>/**
1609 * Returns the width in pixels of the framing elements of this panel (not including the body width). To
1610 * retrieve the body width see {@link #getInnerWidth}.
1611 * @return {Number} The frame width
1613 getFrameWidth : function(){
1614 var w = this.el.getFrameWidth('lr') + this.bwrap.getFrameWidth('lr');
1617 var l = this.bwrap.dom.firstChild;
1618 w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
1619 w += this.mc.getFrameWidth('lr');
1624 <div id="method-Ext.Panel-getFrameHeight"></div>/**
1625 * Returns the height in pixels of the framing elements of this panel (including any top and bottom bars and
1626 * header and footer elements, but not including the body height). To retrieve the body height see {@link #getInnerHeight}.
1627 * @return {Number} The frame height
1629 getFrameHeight : function(){
1630 var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
1631 h += (this.tbar ? this.tbar.getHeight() : 0) +
1632 (this.bbar ? this.bbar.getHeight() : 0);
1635 h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
1637 h += (this.header ? this.header.getHeight() : 0) +
1638 (this.footer ? this.footer.getHeight() : 0);
1643 <div id="method-Ext.Panel-getInnerWidth"></div>/**
1644 * Returns the width in pixels of the body element (not including the width of any framing elements).
1645 * For the frame width see {@link #getFrameWidth}.
1646 * @return {Number} The body width
1648 getInnerWidth : function(){
1649 return this.getSize().width - this.getFrameWidth();
1652 <div id="method-Ext.Panel-getInnerHeight"></div>/**
1653 * Returns the height in pixels of the body element (not including the height of any framing elements).
1654 * For the frame height see {@link #getFrameHeight}.
1655 * @return {Number} The body height
1657 getInnerHeight : function(){
1658 return this.getSize().height - this.getFrameHeight();
1662 syncShadow : function(){
1669 getLayoutTarget : function(){
1673 <div id="method-Ext.Panel-setTitle"></div>/**
1674 * <p>Sets the title text for the panel and optionally the {@link #iconCls icon class}.</p>
1675 * <p>In order to be able to set the title, a header element must have been created
1676 * for the Panel. This is triggered either by configuring the Panel with a non-blank <code>{@link #title}</code>,
1677 * or configuring it with <code><b>{@link #header}: true</b></code>.</p>
1678 * @param {String} title The title text to set
1679 * @param {String} iconCls (optional) {@link #iconCls iconCls} A user-defined CSS class that provides the icon image for this panel
1681 setTitle : function(title, iconCls){
1683 if(this.header && this.headerAsText){
1684 this.header.child('span').update(title);
1687 this.setIconClass(iconCls);
1689 this.fireEvent('titlechange', this, title);
1693 <div id="method-Ext.Panel-getUpdater"></div>/**
1694 * Get the {@link Ext.Updater} for this panel. Enables you to perform Ajax updates of this panel's body.
1695 * @return {Ext.Updater} The Updater
1697 getUpdater : function(){
1698 return this.body.getUpdater();
1701 <div id="method-Ext.Panel-load"></div>/**
1702 * Loads this content panel immediately with content returned from an XHR call.
1703 * @param {Object/String/Function} config A config object containing any of the following options:
1706 url: 'your-url.php',
1707 params: {param1: 'foo', param2: 'bar'}, // or a URL encoded string
1708 callback: yourFunction,
1709 scope: yourObject, // optional scope for the callback
1717 * The only required property is url. The optional properties nocache, text and scripts
1718 * are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
1719 * associated property on this panel Updater instance.
1720 * @return {Ext.Panel} this
1723 var um = this.body.getUpdater();
1724 um.update.apply(um, arguments);
1729 beforeDestroy : function(){
1731 this.header.removeAllListeners();
1732 if(this.headerAsText){
1733 Ext.Element.uncache(this.header.child('span'));
1736 Ext.Element.uncache(
1747 for(var k in this.tools){
1748 Ext.destroy(this.tools[k]);
1752 for(var b in this.buttons){
1753 Ext.destroy(this.buttons[b]);
1757 Ext.destroy(this.toolbars);
1759 Ext.destroy(this.topToolbar, this.bottomToolbar);
1761 Ext.Panel.superclass.beforeDestroy.call(this);
1765 createClasses : function(){
1766 this.headerCls = this.baseCls + '-header';
1767 this.headerTextCls = this.baseCls + '-header-text';
1768 this.bwrapCls = this.baseCls + '-bwrap';
1769 this.tbarCls = this.baseCls + '-tbar';
1770 this.bodyCls = this.baseCls + '-body';
1771 this.bbarCls = this.baseCls + '-bbar';
1772 this.footerCls = this.baseCls + '-footer';
1776 createGhost : function(cls, useShim, appendTo){
1777 var el = document.createElement('div');
1778 el.className = 'x-panel-ghost ' + (cls ? cls : '');
1780 el.appendChild(this.el.dom.firstChild.cloneNode(true));
1782 Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
1783 el.style.width = this.el.dom.offsetWidth + 'px';;
1785 this.container.dom.appendChild(el);
1787 Ext.getDom(appendTo).appendChild(el);
1789 if(useShim !== false && this.el.useShim !== false){
1790 var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
1794 return new Ext.Element(el);
1799 doAutoLoad : function(){
1800 var u = this.body.getUpdater();
1802 u.setRenderer(this.renderer);
1804 u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
1807 <div id="method-Ext.Panel-getTool"></div>/**
1808 * Retrieve a tool by id.
1809 * @param {String} id
1810 * @return {Object} tool
1812 getTool : function(id) {
1813 return this.tools[id];
1816 <div id="cfg-Ext.Panel-autoEl"></div>/**
1817 * @cfg {String} autoEl @hide
1820 Ext.reg('panel', Ext.Panel);