2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
11 * @extends Ext.Container
\r
12 * Panel is a container that has specific functionality and structural components that make it the perfect building
\r
13 * block for application-oriented user interfaces. The Panel contains bottom and top toolbars, along with separate
\r
14 * header, footer and body sections. It also provides built-in expandable and collapsible behavior, along with a
\r
15 * variety of prebuilt tool buttons that can be wired up to provide other customized behavior. Panels can be easily
\r
16 * dropped into any Container or layout, and the layout and rendering pipeline is completely managed by the framework.
\r
18 * @param {Object} config The config object
\r
20 Ext.Panel = Ext.extend(Ext.Container, {
\r
22 * The Panel's header {@link Ext.Element Element}. Read-only.
\r
23 * <p>This Element is used to house the {@link #title} and {@link #tools}</p>
\r
28 * The Panel's body {@link Ext.Element Element} which may be used to contain HTML content.
\r
29 * The content may be specified in the {@link #html} config, or it may be loaded using the
\r
30 * {@link autoLoad} config, or through the Panel's {@link #getUpdater Updater}. Read-only.
\r
31 * <p>If this is used to load visible HTML elements in either way, then
\r
32 * the Panel may not be used as a Layout for hosting nested Panels.</p>
\r
33 * <p>If this Panel is intended to be used as the host of a Layout (See {@link #layout}
\r
34 * then the body Element must not be loaded or changed - it is under the control
\r
35 * of the Panel's Layout.
\r
40 * @cfg {Object} bodyCfg
\r
41 * <p>A {@link Ext.DomHelper DomHelper} configuration object specifying the element structure
\r
42 * of this Panel's {@link #body} Element.</p>
\r
43 * <p>This may be used to force the body Element to use a different form of markup than
\r
44 * is created automatically. An example of this might be to create a child Panel containing
\r
45 * custom content, such as a header, or forcing centering of all Panel
\r
46 * content by having the body be a <center> element:</p><code><pre>
\r
48 title: 'New Message',
\r
50 renderTo: Ext.getBody(),
\r
59 bodyCfg: {tag: 'h2', html: 'Message'}
\r
64 marginBottom: '10px'
\r
71 marginBottom: '10px'
\r
78 * The Panel's footer {@link Ext.Element Element}. Read-only.
\r
79 * <p>This Element is used to house the Panel's {@link #buttons}.</p>
\r
84 * @cfg {Mixed} applyTo
\r
85 * The id of the node, a DOM node or an existing Element corresponding to a DIV that is already present in
\r
86 * the document that specifies some panel-specific structural markup. When applyTo is used, constituent parts of
\r
87 * the panel can be specified by CSS class name within the main element, and the panel will automatically create those
\r
88 * components from that markup. Any required components not specified in the markup will be autogenerated if necessary.
\r
89 * The following class names are supported (baseCls will be replaced by {@link #baseCls}):
\r
90 * <ul><li>baseCls + '-header'</li>
\r
91 * <li>baseCls + '-header-text'</li>
\r
92 * <li>baseCls + '-bwrap'</li>
\r
93 * <li>baseCls + '-tbar'</li>
\r
94 * <li>baseCls + '-body'</li>
\r
95 * <li>baseCls + '-bbar'</li>
\r
96 * <li>baseCls + '-footer'</li></ul>
\r
97 * Using this config, a call to render() is not required. If applyTo is specified, any value passed for
\r
98 * {@link #renderTo} will be ignored and the target element's parent node will automatically be used as the panel's container.
\r
101 * @cfg {Object/Array} tbar
\r
102 * The top toolbar of the panel. This can be either an {@link Ext.Toolbar} object or an array of
\r
103 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
\r
104 * To access the top toolbar after render, use {@link #getTopToolbar}.
\r
107 * @cfg {Object/Array} bbar
\r
108 * The bottom toolbar of the panel. This can be either an {@link Ext.Toolbar} object or an array of
\r
109 * buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
\r
110 * To access the bottom toolbar after render, use {@link #getBottomToolbar}.
\r
113 * @cfg {Boolean} header
\r
114 * True to create the header element explicitly, false to skip creating it. By default, when header is not
\r
115 * specified, if a {@link #title} is set the header will be created automatically, otherwise it will not. If
\r
116 * a title is set but header is explicitly set to false, the header will not be rendered.
\r
119 * @cfg {Boolean} footer
\r
120 * True to create the footer element explicitly, false to skip creating it. By default, when footer is not
\r
121 * specified, if one or more buttons have been added to the panel the footer will be created automatically,
\r
122 * otherwise it will not.
\r
125 * @cfg {String} title
\r
126 * The title text to display in the panel header (defaults to ''). When a title is specified the header
\r
127 * element will automatically be created and displayed unless {@link #header} is explicitly set to false. If
\r
128 * you don't want to specify a title at config time, but you may want one later, you must either specify a
\r
129 * non-empty title (a blank space ' ' will do) or header:true so that the container element will get created.
\r
132 * @cfg {Array} buttons
\r
133 * An array of {@link Ext.Button}s or {@link Ext.Button} configs used to add buttons to the footer of this panel.
\r
136 * @cfg {Object/String/Function} autoLoad
\r
137 * A valid url spec according to the Updater {@link Ext.Updater#update} method.
\r
138 * If autoLoad is not null, the panel will attempt to load its contents
\r
139 * immediately upon render.<p>
\r
140 * The URL will become the default URL for this panel's {@link #body} element,
\r
141 * so it may be {@link Ext.Element#refresh refresh}ed at any time.</p>
\r
144 * @cfg {Boolean} frame
\r
145 * True to render the panel with custom rounded borders, false to render with plain 1px square borders (defaults to false).
\r
148 * @cfg {Boolean} border
\r
149 * True to display the borders of the panel's body element, false to hide them (defaults to true). By default,
\r
150 * the border is a 2px wide inset border, but this can be further altered by setting {@link #bodyBorder} to false.
\r
153 * @cfg {Boolean} bodyBorder
\r
154 * True to display an interior border on the body element of the panel, false to hide it (defaults to true).
\r
155 * This only applies when {@link #border} == true. If border == true and bodyBorder == false, the border will display
\r
156 * as a 1px wide inset border, giving the entire body element an inset appearance.
\r
159 * @cfg {String/Object/Function} bodyStyle
\r
160 * Custom CSS styles to be applied to the body element in the format expected by {@link Ext.Element#applyStyles}
\r
161 * (defaults to null).
\r
164 * @cfg {String} iconCls
\r
165 * A CSS class that will provide a background image to be used as the header icon (defaults to ''). An example
\r
166 * custom icon class would be something like: .my-icon { background: url(../images/my-icon.gif) 0 6px no-repeat !important;}
\r
169 * @cfg {Boolean} collapsible
\r
170 * True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into
\r
171 * the header tool button area, false to keep the panel statically sized with no button (defaults to false).
\r
174 * @cfg {Array} tools
\r
175 * An array of tool button configs to be added to the header tool area. When rendered, each tool is
\r
176 * stored as an {@link Ext.Element Element} referenced by a public property called <tt><b></b>tools.<i><tool-type></i></tt>
\r
177 * <p>Each tool config may contain the following properties:
\r
178 * <div class="mdetail-params"><ul>
\r
179 * <li><b>id</b> : String<div class="sub-desc"><b>Required.</b> The type
\r
180 * of tool to create. Values may be<ul>
\r
181 * <li><tt>toggle</tt> (Created by default when {@link #collapsible} is <tt>true</tt>)</li>
\r
182 * <li><tt>close</tt></li>
\r
183 * <li><tt>minimize</tt></li>
\r
184 * <li><tt>maximize</tt></li>
\r
185 * <li><tt>restore</tt></li>
\r
186 * <li><tt>gear</tt></li>
\r
187 * <li><tt>pin</tt></li>
\r
188 * <li><tt>unpin</tt></li>
\r
189 * <li><tt>right</tt></li>
\r
190 * <li><tt>left</tt></li>
\r
191 * <li><tt>up</tt></li>
\r
192 * <li><tt>down</tt></li>
\r
193 * <li><tt>refresh</tt></li>
\r
194 * <li><tt>minus</tt></li>
\r
195 * <li><tt>plus</tt></li>
\r
196 * <li><tt>help</tt></li>
\r
197 * <li><tt>search</tt></li>
\r
198 * <li><tt>save</tt></li>
\r
199 * <li><tt>print</tt></li>
\r
201 * <li><b>handler</b> : Function<div class="sub-desc"><b>Required.</b> The function to
\r
202 * call when clicked. Arguments passed are:<ul>
\r
203 * <li><b>event</b> : Ext.EventObject<div class="sub-desc">The click event.</div></li>
\r
204 * <li><b>toolEl</b> : Ext.Element<div class="sub-desc">The tool Element.</div></li>
\r
205 * <li><b>Panel</b> : Ext.Panel<div class="sub-desc">The host Panel</div></li>
\r
207 * <li><b>scope</b> : Object<div class="sub-desc">The scope in which to call the handler.</div></li>
\r
208 * <li><b>qtip</b> : String/Object<div class="sub-desc">A tip string, or
\r
209 * a config argument to {@link Ext.QuickTip#register}</div></li>
\r
210 * <li><b>hidden</b> : Boolean<div class="sub-desc">True to initially render hidden.</div></li>
\r
211 * <li><b>on</b> : Object<div class="sub-desc">A listener config object specifiying
\r
212 * event listeners in the format of an argument to {@link #addListener}</div></li>
\r
218 qtip: 'Refresh form Data',
\r
220 handler: function(event, toolEl, panel){
\r
225 * Note that apart from the toggle tool which is provided when a panel is
\r
226 * collapsible, these tools only provide the visual button. Any required
\r
227 * functionality must be provided by adding handlers that implement the
\r
228 * necessary behavior.
\r
231 * @cfg {Boolean} hideCollapseTool
\r
232 * True to hide the expand/collapse toggle button when {@link #collapsible} = true, false to display it (defaults to false).
\r
235 * @cfg {Boolean} titleCollapse
\r
236 * True to allow expanding and collapsing the panel (when {@link #collapsible} = true) by clicking anywhere in the
\r
237 * header bar, false to allow it only by clicking to tool button (defaults to false).
\r
240 * @cfg {Boolean} autoScroll
\r
241 * True to use overflow:'auto' on the panel's body element and show scroll bars automatically when necessary,
\r
242 * false to clip any overflowing content (defaults to false).
\r
245 * @cfg {Boolean} floating
\r
246 * True to float the panel (absolute position it with automatic shimming and shadow), false to display it
\r
247 * inline where it is rendered (defaults to false). Note that by default, setting floating to true will cause the
\r
248 * panel to display at negative offsets so that it is hidden -- because the panel is absolute positioned, the
\r
249 * position must be set explicitly after render (e.g., myPanel.setPosition(100,100);). Also, when floating a
\r
250 * panel you should always assign a fixed width, otherwise it will be auto width and will expand to fill to the
\r
251 * right edge of the viewport.
\r
254 * @cfg {Boolean/String} shadow
\r
255 * True (or a valid Ext.Shadow {@link Ext.Shadow#mode} value) to display a shadow behind the panel, false to
\r
256 * display no shadow (defaults to 'sides'). Note that this option only applies when floating = true.
\r
259 * @cfg {Number} shadowOffset
\r
260 * The number of pixels to offset the shadow if displayed (defaults to 4). Note that this option only applies
\r
261 * when floating = true.
\r
264 * @cfg {Boolean} shim
\r
265 * False to disable the iframe shim in browsers which need one (defaults to true). Note that this option
\r
266 * only applies when floating = true.
\r
269 * @cfg {String/Object} html
\r
270 * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use
\r
271 * as the panel's body content (defaults to ''). The HTML content is added by the Panel's
\r
272 * afterRender method, and so the document will not contain this HTML at the time the render
\r
273 * event is fired. This content is inserted into the body <i>before</i> any configured
\r
274 * {@link #contentEl} is appended.
\r
277 * @cfg {String} contentEl
\r
278 * The id of an existing HTML node to use as the panel's body content (defaults to ''). The
\r
279 * specified Element is appended to the Panel's body Element by the Panel's afterRender method
\r
280 * <i>after any configured {@link #html HTML} has been inserted</i>, and so the document will
\r
281 * not contain this HTML at the time the render event is fired.
\r
284 * @cfg {Object/Array} keys
\r
285 * A KeyMap config object (in the format expected by {@link Ext.KeyMap#addBinding} used to assign custom key
\r
286 * handling to this panel (defaults to null).
\r
289 * @cfg {Boolean} draggable
\r
290 * <p>True to enable dragging of this Panel (defaults to false).</p>
\r
291 * <p>For custom drag/drop implementations, an Ext.Panel.DD
\r
292 * config could also be passed in this config instead of true. Ext.Panel.DD is an internal,
\r
293 * undocumented class which moves a proxy Element around in place of the Panel's element, but
\r
294 * provides no other behaviour during dragging or on drop. It is a subclass of
\r
295 * {@link Ext.dd.DragSource}, so behaviour may be added by implementing the interface methods
\r
296 * of {@link Ext.dd.DragDrop} eg:
\r
302 renderTo: Ext.getBody(),
\r
308 // Config option of Ext.Panel.DD class.
\r
309 // It's a floating Panel, so do not show a placeholder proxy in the original position.
\r
310 insertProxy: false,
\r
312 // Called for each mousemove event while dragging the DD object.
\r
313 onDrag : function(e){
\r
314 // Record the x,y position of the drag proxy so that we can
\r
315 // position the Panel at end of drag.
\r
316 var pel = this.proxy.getEl();
\r
317 this.x = pel.getLeft(true);
\r
318 this.y = pel.getTop(true);
\r
320 // Keep the Shadow aligned if there is one.
\r
321 var s = this.panel.getEl().shadow;
\r
323 s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
\r
327 // Called on the mouseup event.
\r
328 endDrag : function(e){
\r
329 this.panel.setPosition(this.x, this.y);
\r
336 * @cfg {String} tabTip
\r
337 * Adds a tooltip when mousing over the tab of a Ext.Panel which is an item of a Ext.TabPanel. Ext.QuickTips.init()
\r
338 * must be called in order for the tips to render.
\r
341 * @cfg {Boolean} disabled
\r
342 * Render this panel disabled (default is false). An important note when using the disabled config on panels is
\r
343 * that IE will often fail to initialize the disabled mask element correectly if the panel's layout has not yet
\r
344 * completed by the time the Panel is disabled during the render process. If you experience this issue, you may
\r
345 * need to instead use the {@link afterlayout} event to initialize the disabled state:
\r
354 single: true // important, as many layouts can occur
\r
361 * @cfg {Boolean} autoHeight
\r
362 * True to use height:'auto', false to use fixed height (defaults to false). <b>Note</b>: Setting autoHeight:true
\r
363 * means that the browser will manage the panel's height based on its contents, and that Ext will not manage it at
\r
364 * all. If the panel is within a layout that manages dimensions (fit, border, etc.) then setting autoHeight:true
\r
365 * can cause issues with scrolling and will not generally work as expected since the panel will take on the height
\r
366 * of its contents rather than the height required by the Ext layout.
\r
371 * @cfg {String} baseCls
\r
372 * The base CSS class to apply to this panel's element (defaults to 'x-panel').
\r
374 baseCls : 'x-panel',
\r
376 * @cfg {String} collapsedCls
\r
377 * A CSS class to add to the panel's element after it has been collapsed (defaults to 'x-panel-collapsed').
\r
379 collapsedCls : 'x-panel-collapsed',
\r
381 * @cfg {Boolean} maskDisabled
\r
382 * True to mask the panel when it is disabled, false to not mask it (defaults to true). Either way, the panel
\r
383 * will always tell its contained elements to disable themselves when it is disabled, but masking the panel
\r
384 * can provide an additional visual cue that the panel is disabled.
\r
386 maskDisabled: true,
\r
388 * @cfg {Boolean} animCollapse
\r
389 * True to animate the transition when the panel is collapsed, false to skip the animation (defaults to true
\r
390 * if the {@link Ext.Fx} class is available, otherwise false).
\r
392 animCollapse: Ext.enableFx,
\r
394 * @cfg {Boolean} headerAsText
\r
395 * True to display the panel title in the header, false to hide it (defaults to true).
\r
397 headerAsText: true,
\r
399 * @cfg {String} buttonAlign
\r
400 * The alignment of any buttons added to this panel. Valid values are 'right,' 'left' and 'center' (defaults to 'right').
\r
402 buttonAlign: 'right',
\r
404 * @cfg {Boolean} collapsed
\r
405 * True to render the panel collapsed, false to render it expanded (defaults to false).
\r
409 * @cfg {Boolean} collapseFirst
\r
410 * True to make sure the collapse/expand toggle button always renders first (to the left of) any other tools
\r
411 * in the panel's title bar, false to render it last (defaults to true).
\r
413 collapseFirst: true,
\r
415 * @cfg {Number} minButtonWidth
\r
416 * Minimum width in pixels of all buttons in this panel (defaults to 75)
\r
420 * @cfg {String} elements
\r
421 * A comma-delimited list of panel elements to initialize when the panel is rendered. Normally, this list will be
\r
422 * generated automatically based on the items added to the panel at config time, but sometimes it might be useful to
\r
423 * make sure a structural element is rendered even if not specified at config time (for example, you may want
\r
424 * to add a button or toolbar dynamically after the panel has been rendered). Adding those elements to this
\r
425 * list will allocate the required placeholders in the panel when it is rendered. Valid values are<ul>
\r
426 * <li><b>header</b></li>
\r
427 * <li><b>tbar</b> (top bar)</li>
\r
428 * <li><b>body</b> (required)</li>
\r
429 * <li><b>bbar</b> (bottom bar)</li>
\r
430 * <li><b>footer</b><li>
\r
432 * Defaults to 'body'.
\r
436 // protected - these could be used to customize the behavior of the window,
\r
437 // but changing them would not be useful without further mofifications and
\r
438 // could lead to unexpected or undesirable results.
\r
439 toolTarget : 'header',
\r
440 collapseEl : 'bwrap',
\r
444 // private, notify box this class will handle heights
\r
451 collapseDefaults: {
\r
456 initComponent : function(){
\r
457 Ext.Panel.superclass.initComponent.call(this);
\r
461 * @event bodyresize
\r
462 * Fires after the Panel has been resized.
\r
463 * @param {Ext.Panel} p the Panel which has been resized.
\r
464 * @param {Number} width The Panel's new width.
\r
465 * @param {Number} height The Panel's new height.
\r
469 * @event titlechange
\r
470 * Fires after the Panel title has been set or changed.
\r
471 * @param {Ext.Panel} p the Panel which has had its title changed.
\r
472 * @param {String} The new title.
\r
476 * @event iconchange
\r
477 * Fires after the Panel icon class has been set or changed.
\r
478 * @param {Ext.Panel} p the Panel which has had its icon class changed.
\r
479 * @param {String} The new icon class.
\r
480 * @param {String} The old icon class.
\r
485 * Fires after the Panel has been collapsed.
\r
486 * @param {Ext.Panel} p the Panel that has been collapsed.
\r
491 * Fires after the Panel has been expanded.
\r
492 * @param {Ext.Panel} p The Panel that has been expanded.
\r
496 * @event beforecollapse
\r
497 * Fires before the Panel is collapsed. A handler can return false to cancel the collapse.
\r
498 * @param {Ext.Panel} p the Panel being collapsed.
\r
499 * @param {Boolean} animate True if the collapse is animated, else false.
\r
503 * @event beforeexpand
\r
504 * Fires before the Panel is expanded. A handler can return false to cancel the expand.
\r
505 * @param {Ext.Panel} p The Panel being expanded.
\r
506 * @param {Boolean} animate True if the expand is animated, else false.
\r
510 * @event beforeclose
\r
511 * Fires before the Panel is closed. Note that Panels do not directly support being closed, but some
\r
512 * Panel subclasses do (like {@link Ext.Window}). This event only applies to such subclasses.
\r
513 * A handler can return false to cancel the close.
\r
514 * @param {Ext.Panel} p The Panel being closed.
\r
519 * Fires after the Panel is closed. Note that Panels do not directly support being closed, but some
\r
520 * Panel subclasses do (like {@link Ext.Window}).
\r
521 * @param {Ext.Panel} p The Panel that has been closed.
\r
526 * Fires after the Panel has been visually activated.
\r
527 * Note that Panels do not directly support being activated, but some Panel subclasses
\r
528 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
\r
529 * activate and deactivate events under the control of the TabPanel.
\r
530 * @param {Ext.Panel} p The Panel that has been activated.
\r
534 * @event deactivate
\r
535 * Fires after the Panel has been visually deactivated.
\r
536 * Note that Panels do not directly support being deactivated, but some Panel subclasses
\r
537 * do (like {@link Ext.Window}). Panels which are child Components of a TabPanel fire the
\r
538 * activate and deactivate events under the control of the TabPanel.
\r
539 * @param {Ext.Panel} p The Panel that has been deactivated.
\r
546 this.elements += ',tbar';
\r
547 if(typeof this.tbar == 'object'){
\r
548 this.topToolbar = this.tbar;
\r
553 this.elements += ',bbar';
\r
554 if(typeof this.bbar == 'object'){
\r
555 this.bottomToolbar = this.bbar;
\r
560 if(this.header === true){
\r
561 this.elements += ',header';
\r
562 delete this.header;
\r
563 }else if(this.title && this.header !== false){
\r
564 this.elements += ',header';
\r
567 if(this.footer === true){
\r
568 this.elements += ',footer';
\r
569 delete this.footer;
\r
573 var btns = this.buttons;
\r
575 * This Panel's Array of buttons as created from the <tt>buttons</tt>
\r
576 * config property. Read only.
\r
578 * @property buttons
\r
581 for(var i = 0, len = btns.length; i < len; i++) {
\r
582 if(btns[i].render){ // button instance
\r
583 btns[i].ownerCt = this;
\r
584 this.buttons.push(btns[i]);
\r
586 this.addButton(btns[i]);
\r
591 this.on('render', this.doAutoLoad, this, {delay:10});
\r
596 createElement : function(name, pnode){
\r
598 pnode.appendChild(this[name].dom);
\r
602 if(name === 'bwrap' || this.elements.indexOf(name) != -1){
\r
603 if(this[name+'Cfg']){
\r
604 this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
\r
606 var el = document.createElement('div');
\r
607 el.className = this[name+'Cls'];
\r
608 this[name] = Ext.get(pnode.appendChild(el));
\r
610 if(this[name+'CssClass']){
\r
611 this[name].addClass(this[name+'CssClass']);
\r
613 if(this[name+'Style']){
\r
614 this[name].applyStyles(this[name+'Style']);
\r
620 onRender : function(ct, position){
\r
621 Ext.Panel.superclass.onRender.call(this, ct, position);
\r
623 this.createClasses();
\r
625 if(this.el){ // existing markup
\r
626 this.el.addClass(this.baseCls);
\r
627 this.header = this.el.down('.'+this.headerCls);
\r
628 this.bwrap = this.el.down('.'+this.bwrapCls);
\r
629 var cp = this.bwrap ? this.bwrap : this.el;
\r
630 this.tbar = cp.down('.'+this.tbarCls);
\r
631 this.body = cp.down('.'+this.bodyCls);
\r
632 this.bbar = cp.down('.'+this.bbarCls);
\r
633 this.footer = cp.down('.'+this.footerCls);
\r
634 this.fromMarkup = true;
\r
636 this.el = ct.createChild({
\r
641 var el = this.el, d = el.dom;
\r
644 this.el.addClass(this.cls);
\r
648 this.elements += ',footer';
\r
651 // This block allows for maximum flexibility and performance when using existing markup
\r
653 // framing requires special markup
\r
655 el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
\r
657 this.createElement('header', d.firstChild.firstChild.firstChild);
\r
658 this.createElement('bwrap', d);
\r
660 // append the mid and bottom frame to the bwrap
\r
661 var bw = this.bwrap.dom;
\r
662 var ml = d.childNodes[1], bl = d.childNodes[2];
\r
663 bw.appendChild(ml);
\r
664 bw.appendChild(bl);
\r
666 var mc = bw.firstChild.firstChild.firstChild;
\r
667 this.createElement('tbar', mc);
\r
668 this.createElement('body', mc);
\r
669 this.createElement('bbar', mc);
\r
670 this.createElement('footer', bw.lastChild.firstChild.firstChild);
\r
673 this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
\r
676 this.createElement('header', d);
\r
677 this.createElement('bwrap', d);
\r
679 // append the mid and bottom frame to the bwrap
\r
680 var bw = this.bwrap.dom;
\r
681 this.createElement('tbar', bw);
\r
682 this.createElement('body', bw);
\r
683 this.createElement('bbar', bw);
\r
684 this.createElement('footer', bw);
\r
687 this.body.addClass(this.bodyCls + '-noheader');
\r
689 this.tbar.addClass(this.tbarCls + '-noheader');
\r
694 if(this.border === false){
\r
695 this.el.addClass(this.baseCls + '-noborder');
\r
696 this.body.addClass(this.bodyCls + '-noborder');
\r
698 this.header.addClass(this.headerCls + '-noborder');
\r
701 this.footer.addClass(this.footerCls + '-noborder');
\r
704 this.tbar.addClass(this.tbarCls + '-noborder');
\r
707 this.bbar.addClass(this.bbarCls + '-noborder');
\r
711 if(this.bodyBorder === false){
\r
712 this.body.addClass(this.bodyCls + '-noborder');
\r
715 this.bwrap.enableDisplayMode('block');
\r
718 this.header.unselectable();
\r
720 // for tools, we need to wrap any existing header markup
\r
721 if(this.headerAsText){
\r
722 this.header.dom.innerHTML =
\r
723 '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
\r
726 this.setIconClass(this.iconCls);
\r
732 this.makeFloating(this.floating);
\r
735 if(this.collapsible){
\r
736 this.tools = this.tools ? this.tools.slice(0) : [];
\r
737 if(!this.hideCollapseTool){
\r
738 this.tools[this.collapseFirst?'unshift':'push']({
\r
740 handler : this.toggleCollapse,
\r
744 if(this.titleCollapse && this.header){
\r
745 this.header.on('click', this.toggleCollapse, this);
\r
746 this.header.setStyle('cursor', 'pointer');
\r
750 var ts = this.tools;
\r
752 this.addTool.apply(this, ts);
\r
757 if(this.buttons && this.buttons.length > 0){
\r
758 // tables are required to maintain order and for correct IE layout
\r
759 var tb = this.footer.createChild({cls:'x-panel-btns-ct', cn: {
\r
760 cls:"x-panel-btns x-panel-btns-"+this.buttonAlign,
\r
761 html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
\r
763 var tr = tb.getElementsByTagName('tr')[0];
\r
764 for(var i = 0, len = this.buttons.length; i < len; i++) {
\r
765 var b = this.buttons[i];
\r
766 var td = document.createElement('td');
\r
767 td.className = 'x-panel-btn-td';
\r
768 b.render(tr.appendChild(td));
\r
772 if(this.tbar && this.topToolbar){
\r
773 if(Ext.isArray(this.topToolbar)){
\r
774 this.topToolbar = new Ext.Toolbar(this.topToolbar);
\r
776 this.topToolbar.render(this.tbar);
\r
777 this.topToolbar.ownerCt = this;
\r
779 if(this.bbar && this.bottomToolbar){
\r
780 if(Ext.isArray(this.bottomToolbar)){
\r
781 this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
\r
783 this.bottomToolbar.render(this.bbar);
\r
784 this.bottomToolbar.ownerCt = this;
\r
789 * Sets the CSS class that provides the icon image for this panel. This method will replace any existing
\r
790 * icon class if one has already been set.
\r
791 * @param {String} cls The new CSS class name
\r
793 setIconClass : function(cls){
\r
794 var old = this.iconCls;
\r
795 this.iconCls = cls;
\r
796 if(this.rendered && this.header){
\r
798 this.header.addClass('x-panel-icon');
\r
799 this.header.replaceClass(old, this.iconCls);
\r
801 var hd = this.header.dom;
\r
802 var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null;
\r
804 Ext.fly(img).replaceClass(old, this.iconCls);
\r
806 Ext.DomHelper.insertBefore(hd.firstChild, {
\r
807 tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
\r
812 this.fireEvent('iconchange', this, cls, old);
\r
816 makeFloating : function(cfg){
\r
817 this.floating = true;
\r
818 this.el = new Ext.Layer(
\r
819 typeof cfg == 'object' ? cfg : {
\r
820 shadow: this.shadow !== undefined ? this.shadow : 'sides',
\r
821 shadowOffset: this.shadowOffset,
\r
823 shim: this.shim === false ? false : undefined
\r
829 * Returns the toolbar from the top (tbar) section of the panel.
\r
830 * @return {Ext.Toolbar} The toolbar
\r
832 getTopToolbar : function(){
\r
833 return this.topToolbar;
\r
837 * Returns the toolbar from the bottom (bbar) section of the panel.
\r
838 * @return {Ext.Toolbar} The toolbar
\r
840 getBottomToolbar : function(){
\r
841 return this.bottomToolbar;
\r
845 * Adds a button to this panel. Note that this method must be called prior to rendering. The preferred
\r
846 * approach is to add buttons via the {@link #buttons} config.
\r
847 * @param {String/Object} config A valid {@link Ext.Button} config. A string will become the text for a default
\r
848 * button config, an object will be treated as a button config object.
\r
849 * @param {Function} handler The function to be called on button {@link Ext.Button#click}
\r
850 * @param {Object} scope The scope to use for the button handler function
\r
851 * @return {Ext.Button} The button that was added
\r
853 addButton : function(config, handler, scope){
\r
857 minWidth: this.minButtonWidth,
\r
860 if(typeof config == "string"){
\r
863 Ext.apply(bc, config);
\r
865 var btn = new Ext.Button(bc);
\r
866 btn.ownerCt = this;
\r
870 this.buttons.push(btn);
\r
875 addTool : function(){
\r
876 if(!this[this.toolTarget]) { // no where to render tools!
\r
879 if(!this.toolTemplate){
\r
880 // initialize the global tool template on first use
\r
881 var tt = new Ext.Template(
\r
882 '<div class="x-tool x-tool-{id}"> </div>'
\r
884 tt.disableFormats = true;
\r
886 Ext.Panel.prototype.toolTemplate = tt;
\r
888 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
\r
890 if(!this.tools[tc.id]){
\r
891 var overCls = 'x-tool-'+tc.id+'-over';
\r
892 var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
\r
893 this.tools[tc.id] = t;
\r
894 t.enableDisplayMode('block');
\r
895 t.on('click', this.createToolHandler(t, tc, overCls, this));
\r
903 if(typeof tc.qtip == 'object'){
\r
904 Ext.QuickTips.register(Ext.apply({
\r
908 t.dom.qtip = tc.qtip;
\r
911 t.addClassOnOver(overCls);
\r
917 onShow : function(){
\r
919 return this.el.show();
\r
921 Ext.Panel.superclass.onShow.call(this);
\r
925 onHide : function(){
\r
927 return this.el.hide();
\r
929 Ext.Panel.superclass.onHide.call(this);
\r
933 createToolHandler : function(t, tc, overCls, panel){
\r
934 return function(e){
\r
935 t.removeClass(overCls);
\r
938 tc.handler.call(tc.scope || t, e, t, panel);
\r
944 afterRender : function(){
\r
945 if(this.fromMarkup && this.height === undefined && !this.autoHeight){
\r
946 this.height = this.el.getHeight();
\r
948 if(this.floating && !this.hidden && !this.initHidden){
\r
952 this.setTitle(this.title);
\r
954 this.setAutoScroll();
\r
956 this.body.update(typeof this.html == 'object' ?
\r
957 Ext.DomHelper.markup(this.html) :
\r
961 if(this.contentEl){
\r
962 var ce = Ext.getDom(this.contentEl);
\r
963 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
\r
964 this.body.dom.appendChild(ce);
\r
966 if(this.collapsed){
\r
967 this.collapsed = false;
\r
968 this.collapse(false);
\r
970 Ext.Panel.superclass.afterRender.call(this); // do sizing calcs last
\r
975 setAutoScroll : function(){
\r
976 if(this.rendered && this.autoScroll){
\r
977 var el = this.body || this.el;
\r
979 el.setOverflow('auto');
\r
985 getKeyMap : function(){
\r
987 this.keyMap = new Ext.KeyMap(this.el, this.keys);
\r
989 return this.keyMap;
\r
993 initEvents : function(){
\r
997 if(this.draggable){
\r
998 this.initDraggable();
\r
1003 initDraggable : function(){
\r
1005 * <p>If this Panel is configured {@link #draggable}, this property will contain
\r
1006 * an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
\r
1007 * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
\r
1008 * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
\r
1009 * @type Ext.dd.DragSource.
\r
1012 this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
\r
1016 beforeEffect : function(){
\r
1017 if(this.floating){
\r
1018 this.el.beforeAction();
\r
1020 this.el.addClass('x-panel-animated');
\r
1024 afterEffect : function(){
\r
1025 this.syncShadow();
\r
1026 this.el.removeClass('x-panel-animated');
\r
1029 // private - wraps up an animation param with internal callbacks
\r
1030 createEffect : function(a, cb, scope){
\r
1038 }else if(!a.callback){
\r
1040 }else { // wrap it up
\r
1041 o.callback = function(){
\r
1043 Ext.callback(a.callback, a.scope);
\r
1046 return Ext.applyIf(o, a);
\r
1050 * Collapses the panel body so that it becomes hidden. Fires the {@link #beforecollapse} event which will
\r
1051 * cancel the collapse action if it returns false.
\r
1052 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
\r
1053 * {@link #animCollapse} panel config)
\r
1054 * @return {Ext.Panel} this
\r
1056 collapse : function(animate){
\r
1057 if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
\r
1060 var doAnim = animate === true || (animate !== false && this.animCollapse);
\r
1061 this.beforeEffect();
\r
1062 this.onCollapse(doAnim, animate);
\r
1067 onCollapse : function(doAnim, animArg){
\r
1069 this[this.collapseEl].slideOut(this.slideAnchor,
\r
1070 Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
\r
1071 this.collapseDefaults));
\r
1073 this[this.collapseEl].hide();
\r
1074 this.afterCollapse();
\r
1079 afterCollapse : function(){
\r
1080 this.collapsed = true;
\r
1081 this.el.addClass(this.collapsedCls);
\r
1082 this.afterEffect();
\r
1083 this.fireEvent('collapse', this);
\r
1087 * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
\r
1088 * cancel the expand action if it returns false.
\r
1089 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
\r
1090 * {@link #animCollapse} panel config)
\r
1091 * @return {Ext.Panel} this
\r
1093 expand : function(animate){
\r
1094 if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
\r
1097 var doAnim = animate === true || (animate !== false && this.animCollapse);
\r
1098 this.el.removeClass(this.collapsedCls);
\r
1099 this.beforeEffect();
\r
1100 this.onExpand(doAnim, animate);
\r
1105 onExpand : function(doAnim, animArg){
\r
1107 this[this.collapseEl].slideIn(this.slideAnchor,
\r
1108 Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
\r
1109 this.expandDefaults));
\r
1111 this[this.collapseEl].show();
\r
1112 this.afterExpand();
\r
1117 afterExpand : function(){
\r
1118 this.collapsed = false;
\r
1119 this.afterEffect();
\r
1120 this.fireEvent('expand', this);
\r
1124 * Shortcut for performing an {@link #expand} or {@link #collapse} based on the current state of the panel.
\r
1125 * @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
\r
1126 * {@link #animCollapse} panel config)
\r
1127 * @return {Ext.Panel} this
\r
1129 toggleCollapse : function(animate){
\r
1130 this[this.collapsed ? 'expand' : 'collapse'](animate);
\r
1135 onDisable : function(){
\r
1136 if(this.rendered && this.maskDisabled){
\r
1139 Ext.Panel.superclass.onDisable.call(this);
\r
1143 onEnable : function(){
\r
1144 if(this.rendered && this.maskDisabled){
\r
1147 Ext.Panel.superclass.onEnable.call(this);
\r
1151 onResize : function(w, h){
\r
1152 if(w !== undefined || h !== undefined){
\r
1153 if(!this.collapsed){
\r
1154 if(typeof w == 'number'){
\r
1155 this.body.setWidth(
\r
1156 this.adjustBodyWidth(w - this.getFrameWidth()));
\r
1157 }else if(w == 'auto'){
\r
1158 this.body.setWidth(w);
\r
1161 if(typeof h == 'number'){
\r
1162 this.body.setHeight(
\r
1163 this.adjustBodyHeight(h - this.getFrameHeight()));
\r
1164 }else if(h == 'auto'){
\r
1165 this.body.setHeight(h);
\r
1168 if(this.disabled && this.el._mask){
\r
1169 this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
\r
1172 this.queuedBodySize = {width: w, height: h};
\r
1173 if(!this.queuedExpand && this.allowQueuedExpand !== false){
\r
1174 this.queuedExpand = true;
\r
1175 this.on('expand', function(){
\r
1176 delete this.queuedExpand;
\r
1177 this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
\r
1179 }, this, {single:true});
\r
1182 this.fireEvent('bodyresize', this, w, h);
\r
1184 this.syncShadow();
\r
1188 adjustBodyHeight : function(h){
\r
1193 adjustBodyWidth : function(w){
\r
1198 onPosition : function(){
\r
1199 this.syncShadow();
\r
1203 * Returns the width in pixels of the framing elements of this panel (not including the body width). To
\r
1204 * retrieve the body width see {@link #getInnerWidth}.
\r
1205 * @return {Number} The frame width
\r
1207 getFrameWidth : function(){
\r
1208 var w = this.el.getFrameWidth('lr');
\r
1211 var l = this.bwrap.dom.firstChild;
\r
1212 w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
\r
1213 var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
\r
1214 w += Ext.fly(mc).getFrameWidth('lr');
\r
1220 * Returns the height in pixels of the framing elements of this panel (including any top and bottom bars and
\r
1221 * header and footer elements, but not including the body height). To retrieve the body height see {@link #getInnerHeight}.
\r
1222 * @return {Number} The frame height
\r
1224 getFrameHeight : function(){
\r
1225 var h = this.el.getFrameWidth('tb');
\r
1226 h += (this.tbar ? this.tbar.getHeight() : 0) +
\r
1227 (this.bbar ? this.bbar.getHeight() : 0);
\r
1230 var hd = this.el.dom.firstChild;
\r
1231 var ft = this.bwrap.dom.lastChild;
\r
1232 h += (hd.offsetHeight + ft.offsetHeight);
\r
1233 var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
\r
1234 h += Ext.fly(mc).getFrameWidth('tb');
\r
1236 h += (this.header ? this.header.getHeight() : 0) +
\r
1237 (this.footer ? this.footer.getHeight() : 0);
\r
1243 * Returns the width in pixels of the body element (not including the width of any framing elements).
\r
1244 * For the frame width see {@link #getFrameWidth}.
\r
1245 * @return {Number} The body width
\r
1247 getInnerWidth : function(){
\r
1248 return this.getSize().width - this.getFrameWidth();
\r
1252 * Returns the height in pixels of the body element (not including the height of any framing elements).
\r
1253 * For the frame height see {@link #getFrameHeight}.
\r
1254 * @return {Number} The body height
\r
1256 getInnerHeight : function(){
\r
1257 return this.getSize().height - this.getFrameHeight();
\r
1261 syncShadow : function(){
\r
1262 if(this.floating){
\r
1263 this.el.sync(true);
\r
1268 getLayoutTarget : function(){
\r
1273 * <p>Sets the title text for the panel and optionally the icon class.</p>
\r
1274 * <p>In order to be able to set the title, a header element must have been created
\r
1275 * for the Panel. This is triggered either by configuring the Panel with a non-blank title,
\r
1276 * or configuring it with <tt><b>{@link #header}: true</b></tt>.</p>
\r
1277 * @param {String} title The title text to set
\r
1278 * @param {String} iconCls (optional) iconCls A user-defined CSS class that provides the icon image for this panel
\r
1280 setTitle : function(title, iconCls){
\r
1281 this.title = title;
\r
1282 if(this.header && this.headerAsText){
\r
1283 this.header.child('span').update(title);
\r
1286 this.setIconClass(iconCls);
\r
1288 this.fireEvent('titlechange', this, title);
\r
1293 * Get the {@link Ext.Updater} for this panel. Enables you to perform Ajax updates of this panel's body.
\r
1294 * @return {Ext.Updater} The Updater
\r
1296 getUpdater : function(){
\r
1297 return this.body.getUpdater();
\r
1301 * Loads this content panel immediately with content returned from an XHR call.
\r
1302 * @param {Object/String/Function} config A config object containing any of the following options:
\r
1305 url: "your-url.php",
\r
1306 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
\r
1307 callback: yourFunction,
\r
1308 scope: yourObject, // optional scope for the callback
\r
1309 discardUrl: false,
\r
1311 text: "Loading...",
\r
1316 * The only required property is url. The optional properties nocache, text and scripts
\r
1317 * are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
\r
1318 * associated property on this panel Updater instance.
\r
1319 * @return {Ext.Panel} this
\r
1321 load : function(){
\r
1322 var um = this.body.getUpdater();
\r
1323 um.update.apply(um, arguments);
\r
1328 beforeDestroy : function(){
\r
1330 this.header.removeAllListeners();
\r
1331 if(this.headerAsText){
\r
1332 Ext.Element.uncache(this.header.child('span'));
\r
1335 Ext.Element.uncache(
\r
1344 for(var k in this.tools){
\r
1345 Ext.destroy(this.tools[k]);
\r
1349 for(var b in this.buttons){
\r
1350 Ext.destroy(this.buttons[b]);
\r
1355 this.bottomToolbar
\r
1357 Ext.Panel.superclass.beforeDestroy.call(this);
\r
1361 createClasses : function(){
\r
1362 this.headerCls = this.baseCls + '-header';
\r
1363 this.headerTextCls = this.baseCls + '-header-text';
\r
1364 this.bwrapCls = this.baseCls + '-bwrap';
\r
1365 this.tbarCls = this.baseCls + '-tbar';
\r
1366 this.bodyCls = this.baseCls + '-body';
\r
1367 this.bbarCls = this.baseCls + '-bbar';
\r
1368 this.footerCls = this.baseCls + '-footer';
\r
1372 createGhost : function(cls, useShim, appendTo){
\r
1373 var el = document.createElement('div');
\r
1374 el.className = 'x-panel-ghost ' + (cls ? cls : '');
\r
1376 el.appendChild(this.el.dom.firstChild.cloneNode(true));
\r
1378 Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
\r
1379 el.style.width = this.el.dom.offsetWidth + 'px';;
\r
1381 this.container.dom.appendChild(el);
\r
1383 Ext.getDom(appendTo).appendChild(el);
\r
1385 if(useShim !== false && this.el.useShim !== false){
\r
1386 var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
\r
1390 return new Ext.Element(el);
\r
1395 doAutoLoad : function(){
\r
1397 typeof this.autoLoad == 'object' ?
\r
1398 this.autoLoad : {url: this.autoLoad});
\r
1402 * Retrieve a tool by id.
\r
1403 * @param {String} id
\r
1404 * @return {Object} tool
\r
1406 getTool: function(id) {
\r
1407 return this.tools[id];
\r
1411 * @cfg {String} autoEl @hide
\r
1414 Ext.reg('panel', Ext.Panel);
\r