/*
* Ext JS Library 3.3.0
*/
/**
* @class Ext.Panel
* @extends Ext.Container
*
* panel作用:
* Panel is a container that has specific(特有的) functionality(功能) and structural(结构的) components that make
* it the perfect(完善的) building block for application-oriented(面向应用的) user interfaces.
*
* Panels are, by virtue of(由于、因为) their inheritance(继承) from Ext.Container, capable(有能力的)
* of being configured with a {Ext.Container#layout layout}, and containing child Components.
*
*When either specifying(指定) child {Ext.Component#items items} of a Panel, or dynamically(动态的)
*{Ext.Container#add adding} Components to a Panel, remember to consider how you wish the Panel to arrange those child
*elements, and whether those child elements need to be sized using one of Ext's built-in {Ext.Container#layout layout}
*schemes. By default, Panels use the {Ext.layout.ContainerLayout ContainerLayout} scheme. This simply renders
* child components, appending them one after the other inside the Container, and does not apply any sizing
* at all.
*
* A Panel may also contain {#bbar bottom} and {#tbar top} toolbars, along with separate
* {#header}, {#footer} and {#body} sections(零件) (see {#frame} for additional information).
*
* Panel also provides built-in(内置) {#collapsible expandable and collapsible behavior}, along with
* a variety of {#tools prebuilt tool buttons} that can be wired up to provide other customized(定制的)
* behavior. Panels can be easily dropped into any {Ext.Container Container} or layout, and the
* layout and rendering pipeline(通道) is {Ext.Container#add completely managed by the framework}.
* @constructor
* @param {Object} config_The config object
* @xtype panel
*/
Ext.Panel = Ext.extend(Ext.Container, {
/**
* The Panel's header {Ext.Element Element}. Read-only.
* This Element is used to house the {#title} and {#tools}
*
* Note: see the Note for {Ext.Component#el el} also.
* @type Ext.Element
* @property header
*/
/**
* The Panel's body {Ext.Element Element} which may be used to contain HTML content.
* The content may be specified(指定) in the {#html} config, or it may be loaded using the
* {autoLoad} config, or through the Panel's {#getUpdater Updater}. Read-only.
*
* If this is used to load visible HTML elements in either way, then
* the Panel may not be used as a Layout for hosting nested Panels.
*
* If this Panel is intended(计划) to be used as the host of a Layout (See {#layout}
* then the body Element must not be loaded or changed - it is under the control
* of the Panel's Layout.
*
* Note: see the Note for {Ext.Component#el el} also.
* @type Ext.Element
* @property body
*/
/**
* The Panel's bwrap {Ext.Element Element} used to contain other Panel elements
* (tbar, body, bbar, footer). See {#bodyCfg}. Read-only.
* @type Ext.Element
* @property bwrap
*/
/**
* True if this panel is collapsed. Read-only.
* @type Boolean
* @property collapsed
*/
/**
* @cfg {Object} bodyCfg
*
* A {Ext.DomHelper DomHelper} element specification object may be specified for any
* Panel Element.
*
* By default, the Default element in the table below will be used for the html markup to
* create a child element with the commensurate(相称的) Default class name (baseCls will be
* replaced by {#baseCls}):
*
* Panel Default Default Custom Additional Additional
* Element element class element class style
* ======== ========================== ========= ============== ===========
* {#header} div {#baseCls}+'-header' {#headerCfg} headerCssClass headerStyle
* {#bwrap} div {#baseCls}+'-bwrap' {#bwrapCfg} bwrapCssClass bwrapStyle
* + tbar div {#baseCls}+'-tbar' {#tbarCfg} tbarCssClass tbarStyle
* + {#body} div {#baseCls}+'-body' {#bodyCfg} {#bodyCssClass} {#bodyStyle}
* + bbar div {#baseCls}+'-bbar' {#bbarCfg} bbarCssClass bbarStyle
* + {#footer} div {#baseCls}+'-footer' {#footerCfg} footerCssClass footerStyle
*
* Configuring a Custom element may be used, for example, to force the {#body} Element
* to use a different form of markup than is created by default. An example of this might be
* to {Ext.Element#createChild create a child} Panel containing a custom content, such as
* a header, or forcing centering of all Panel content by having the body be a <center>
* element:
*
new Ext.Panel({
title: 'Message Title',
renderTo: Ext.getBody(),
width: 200, height: 130,
bodyCfg: {
tag: 'center',
cls: 'x-panel-body', // Default class not applied if Custom element specified
html: 'Message'
},
footerCfg: {
tag: 'h2',
cls: 'x-panel-footer', // same as the Default class
html: 'footer html'
},
footerCssClass: 'custom-footer', // additional css class, see {Ext.element#addClass addClass}
footerStyle: 'background-color:red' // see {#bodyStyle}
});
*
*
* The example above also explicitly(明白的) creates a {#footer} with custom markup and
* styling applied.
*/
/**
* @cfg {Object} headerCfg
*
* A {Ext.DomHelper DomHelper} element specification object specifying the element structure
* of this Panel's {#header} Element. See {#bodyCfg} also.
*/
/**
* @cfg {Object} bwrapCfg
*
* A {Ext.DomHelper DomHelper} element specification object specifying the element structure
* of this Panel's {#bwrap} Element. See {#bodyCfg} also.
*/
/**
* @cfg {Object} tbarCfg
*
* A {Ext.DomHelper DomHelper} element specification object specifying the element structure
* of this Panel's {#tbar} Element. See {#bodyCfg} also.
*/
/**
* @cfg {Object} bbarCfg
*
* A {Ext.DomHelper DomHelper} element specification object specifying the element structure
* of this Panel's {#bbar} Element. See {#bodyCfg} also.
*/
/**
* @cfg {Object} footerCfg
*
* A {Ext.DomHelper DomHelper} element specification object specifying the element structure
* of this Panel's {#footer} Element. See {#bodyCfg} also.
*/
/**
* @cfg {Boolean} closable(是否能关闭)
* Panels themselves do not directly support being closed, but some Panel subclasses do (like
* {Ext.Window}) or a Panel Class within an {Ext.TabPanel}. Specify true
* to enable closing in such situations. Defaults to false.
*/
/**
* The Panel's footer {Ext.Element Element}. Read-only.
*
* This Element is used to house the Panel's {#buttons} or {#fbar}.
*
* Note: see the Note for {Ext.Component#el el} also.
* @type Ext.Element
* @property footer
*/
/**
* @cfg {Mixed} applyTo
*
* The id of the node, a DOM node or an existing Element corresponding(相应的) to a DIV that is already present in
* the document that specifies some panel-specific structural markup. When applyTo is used,
* constituent(组成的) parts of the panel can be specified by CSS class name within the main element, and the panel
* will automatically create those components from that markup. Any required components not specified in the
* markup will be autogenerated if necessary.
*
* The following class names are supported (baseCls will be replaced by {#baseCls}):
baseCls + '-header'
baseCls + '-header-text'
baseCls + '-bwrap'
baseCls + '-tbar'
baseCls + '-body'
baseCls + '-bbar'
baseCls + '-footer'
*
* Using this config, a call to render() is not required. If applyTo is specified, any value passed for
* {#renderTo} will be ignored and the target element's parent node will automatically be used as the
* panel's container.
*/
/**
* @cfg {Object/Array} tbar
*
* The top toolbar of the panel. This can be a {Ext.Toolbar} object, a toolbar config, or an array of
* buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
* To access the top toolbar after render, use {#getTopToolbar}.
* 如果想在渲染之后访问顶部工具栏,请使用getTopToolbar()方法。
*
* Note: Although a Toolbar may contain Field components, these will not be updated by a load
* of an ancestor(祖先) FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
* so are not scanned to collect form items. However, the values will be submitted because form
* submission parameters are collected from the DOM tree.
*/
/**
* @cfg {Object/Array} bbar
*
* The bottom toolbar of the panel. This can be a {Ext.Toolbar} object, a toolbar config, or an array of
* buttons/button configs to be added to the toolbar. Note that this is not available as a property after render.
* To access the bottom toolbar after render, use {#getBottomToolbar}.
*
* Note: Although a Toolbar may contain Field components, these will not be updated by a load
* of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
* so are not scanned to collect form items. However, the values will be submitted because form
* submission parameters are collected from the DOM tree.
*/
/** @cfg {Object/Array} fbar
*
* A {Ext.Toolbar Toolbar} object, a Toolbar config, or an array of
* {Ext.Button Button}s/{Ext.Button Button} configs, describing a {Ext.Toolbar Toolbar} to be rendered into
* this Panel's footer element.
*
* After render, the fbar property will be an {Ext.Toolbar Toolbar} instance.
*
* If {#buttons} are specified, they will supersede(取代、接替) the fbar configuration property.
* The Panel's {#buttonAlign} configuration affects the layout of these items, for example:
* (示例:按钮位置)
var w = new Ext.Window({
height: 250,
width: 500,
bbar: new Ext.Toolbar({
items: [{
text: 'bbar Left'
},'->',{
text: 'bbar Right'
}]
}),
buttonAlign: 'left', // anything but 'center' or 'right' and you can use '-', and '->'
// to control the alignment of fbar items
fbar: [{
text: 'fbar Left'
},'->',{
text: 'fbar Right'
}]
}).show();
*
* Note: Although a Toolbar may contain Field components, these will not be updated by a load
* of an ancestor FormPanel. A Panel's toolbars are not part of the standard Container->Component hierarchy, and
* so are not scanned to collect form items. However, the values will be submitted because form
* submission parameters are collected from the DOM tree.
*/
/**
* @cfg {Boolean} header
* true to create the Panel's header element explicitly(明确的), false to skip(略过) creating
* it. If a title is set the header will be created automatically, otherwise it will not.
* If a title is set but header is explicitly set to false, the header will not be rendered.
*/
/**
* @cfg {Boolean} footer
* true to create the footer element explicitly, false to skip creating it. The footer
* will be created automatically if {buttons} or a {#fbar} have
* been configured. See {#bodyCfg} for an example.
*/
/**
* @cfg {String} title
* The title text to be used as innerHTML (html tags are accepted) to display in the panel
* {#header} (defaults to ''). When a title is specified the header element will automatically
* be created and displayed unless {header} is explicitly set to false. If you do not want to specify a
* title at config time, but you may want one later, you must either specify a non-empty
* title (a blank space ' ' will do) or header:true so that the container element will get created.
*/
/**
* @cfg {Array} buttons
* buttons will be used as {Ext.Container#items items} for the toolbar in
* the footer ({#fbar}). Typically(通常) the value of this configuration property will be
* an array of {Ext.Button}s or {Ext.Button} configuration objects.
* If an item is configured with minWidth or the Panel is configured with minButtonWidth,
* that width will be applied to the item.
*/
/**
* @cfg {Object/String/Function} autoLoad
* A valid url spec(规格) according to the Updater {Ext.Updater#update} method.
* If autoLoad is not null, the panel will attempt(试图) to load its contents
* immediately upon render.
* The URL will become the default URL for this panel's {body} element,
* so it may be {Ext.Element#refresh refresh}ed at any time.
*/
/**
* @cfg {Boolean} frame
* false by default to render with plain 1px square borders. true to render with
* 9 elements, complete with custom rounded corners (also see {Ext.Element#boxWrap}).
*
* The template generated for each condition is depicted(描绘) below:
// frame = false
<div id="developer-specified-id-goes-here" class="x-panel">
<div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:false)</span></div>
<div class="x-panel-bwrap">
<div class="x-panel-body"><p>html value goes here</p></div>
</div>
</div>
// frame = true (create 9 elements)
<div id="developer-specified-id-goes-here" class="x-panel">
<div class="x-panel-tl"><div class="x-panel-tr"><div class="x-panel-tc">
<div class="x-panel-header"><span class="x-panel-header-text">Title: (frame:true)</span></div>
</div></div></div>
<div class="x-panel-bwrap">
<div class="x-panel-ml"><div class="x-panel-mr"><div class="x-panel-mc">
<div class="x-panel-body"><p>html value goes here</p></div>
</div></div></div>
<div class="x-panel-bl"><div class="x-panel-br"><div class="x-panel-bc"/>
</div></div></div>
</div>
*/
/**
* @cfg {Boolean} border
* True to display the borders of the panel's body element, false to hide them (defaults to true). By default,
* the border is a 2px wide inset border, but this can be further altered by setting {#bodyBorder} to false.
*/
/**
* @cfg {Boolean} bodyBorder
* True to display an interior(内部、里边) border on the body element of the panel, false to hide it (defaults to true).
* This only applies when {#border} == true. If border == true and bodyBorder == false, the border will display
* as a 1px wide inset border, giving the entire body element an inset appearance.
*/
/**
* @cfg {String/Object/Function} bodyCssClass(bodycss样式)
* Additional css class selector to be applied to the {#body} element in the format expected by
* {Ext.Element#addClass} (defaults to null). See {#bodyCfg}.
*/
/**
* @cfg {String/Object/Function} bodyStyle
* Custom CSS styles to be applied to the {#body} element in the format expected by
* {Ext.Element#applyStyles} (defaults to null). See {#bodyCfg}.
*/
/**
* @cfg {String} iconCls(背景图片)
* The CSS class selector that specifies a background image to be used as the header icon (defaults to '').
*
* An example of specifying a custom icon class would be something like:
// specify the property in the config for the class:
...
iconCls: 'my-icon'
// css class that specifies background image to be used as the icon image:
.my-icon { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
*/
/**
* @cfg {Boolean} collapsible(伸缩性)
* True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into
* the header tool button area(头部工具栏区域);
* false to keep the panel statically(静态的) sized with no button (defaults to false).
*/
/**
* @cfg {Array} tools
* An array of tool button configs to be added to the header tool area. When rendered, each tool is
* stored as an {Ext.Element Element} referenced(引用的) by a public property called tools.<tool-type>
* Each tool config may contain the following properties:
=>id : String
Required. The type
* of tool to create. By default, this assigns a CSS class of the form x-tool-<tool-type> to the
* resulting tool Element. Ext provides CSS rules, and an icon sprite containing images for the tool
* types listed below. The developer may implement custom tools by supplying alternate CSS rules and
* background images:
toggle (Created by default when {#collapsible} is true)
close
minimize
maximize
restore(还原)
gear(齿轮)
pin(大头针图标)
unpin
right
left
up
down
refresh
minus
plus
help
search
save
*
=>handler : Function
Required. The function to call when clicked. Arguments passed are:
event : Ext.EventObject_The click event.
toolEl : Ext.Element_The tool Element.
panel : Ext.Panel_The host Panel
tc : Object_The tool configuration object
*
=>stopEvent : Boolean_Defaults to true. Specify as false to allow click event to propagate(普及).
*
=>scope : Object_The scope in which to call the handler.
*
=>qtip : String/Object
A tip string, or a config argument to {Ext.QuickTip#register}
*
=>hidden : Boolean_True to initially render hidden.
*
=>on : Object_A listener config object specifiying event listeners
in the format of an argument to {addListener}
*
* Note that, apart from the toggle tool which is provided when a panel is collapsible, these
* tools only provide the visual button. Any required functionality must be provided by adding
* handlers that implement the necessary behavior.
* Example usage(示例):
tools:[{
id:'refresh',
qtip: 'Refresh form Data',
// hidden:true,
handler: function(event, toolEl, panel){
// refresh logic(逻辑)
}
},
{
id:'help',
qtip: 'Get Help',
handler: function(event, toolEl, panel){
// whatever
}
}]
*
* For the custom id of 'help' define two relevant css classes with a link to a 15x15 image:
.x-tool-help {background-image: url(images/help.png);}
.x-tool-help-over {background-image: url(images/help_over.png);}
// if using an image sprite:
.x-tool-help {background-image: url(images/help.png) no-repeat 0 0;}
.x-tool-help-over {background-position:-15px 0;}
*/
/**
* @cfg {Ext.Template/Ext.XTemplate} toolTemplate
* A Template used to create {#tools} in the {#header} Element. Defaults to:
new Ext.Template('<div class="x-tool x-tool-{id}"> </div>')
*
* This may be overridden to provide a custom DOM structure for tools based upon a more
* complex XTemplate. The template's data is a single tool configuration object (Not the entire(全部的) Array)
* as specified in {#tools}. In the following example an <a> tag is used to provide a
* visual indication(标示) when hovering over the tool:
var win = new Ext.Window({
tools: [{
id: 'download',
href: '/MyPdfDoc.pdf'
}],
toolTemplate: new Ext.XTemplate(
'<tpl if="id==\'download\'">',
'<a class="x-tool x-tool-pdf" href="{href}"></a>',
'</tpl>',
'<tpl if="id!=\'download\'">',
'<div class="x-tool x-tool-{id}"> </div>',
'</tpl>'
),
width:500,
height:300,
closeAction:'hide'
});
*
* Note that the CSS class 'x-tool-pdf' should have an associated(有关联的) style rule which provides an
* appropriate(合适的) background image, something like:
a.x-tool-pdf {background-image: url(../shared/extjs/images/pdf.gif)!important;}
*/
/**
* @cfg {Boolean} hideCollapseTool
* true to hide the expand/collapse toggle button when {#collapsible} == true,
* false to display it (defaults to false).
*/
/**
* @cfg {Boolean} titleCollapse
* true to allow expanding and collapsing the panel (when {#collapsible} = true)
* by clicking anywhere in the header bar, false) to allow it only by clicking to tool button
* (defaults to false)). If this panel is a child item of a border layout also see the
* {Ext.layout.BorderLayout.Region BorderLayout.Region}
* {Ext.layout.BorderLayout.Region#floatable floatable} config option.
*/
/**
* @cfg {Mixed} floating
*
* This property is used to configure the underlying(下层的) {Ext.Layer}. Acceptable(可接受的) values for this
* configuration property are:
=>false : Default.
Display the panel inline where it is rendered.
*
=>true : Float the panel (absolute position it with automatic shimming(填补) and shadow).
*
* Setting floating to true will create an Ext.Layer for this panel and display the
* panel at negative offsets(负偏置) so that it is hidden.
*
* Since the panel will be absolute positioned, the position must be set explicitly(明确地)
* after render (e.g., myPanel.setPosition(100,100);).
*
* Note: when floating a panel you should always assign a fixed width,
* otherwise(否则) it will be auto width and will expand to fill to the right edge(边缘) of the viewport.
*
* {Ext.Layer object} :
* The specified object will be used as the configuration object for the {Ext.Layer} that will be created.
*/
/**
* @cfg {Boolean/String} shadow
* true (or a valid Ext.Shadow {Ext.Shadow#mode} value) to display a shadow behind the
* panel, false to display no shadow (defaults to 'sides'). Note that this option
* only applies when {#floating} = true.
*/
/**
* @cfg {Number} shadowOffset
* The number of pixels to offset the shadow if displayed (defaults to 4). Note that this
* option only applies when {#floating} = true.
*/
/**
* @cfg {Boolean} shim
* false to disable(禁用) the iframe shim in browsers which need one (defaults to true).
* Note that this option only applies when {#floating} = true.
*/
/**
* @cfg {Object/Array} keys
* A {Ext.KeyMap} config object (in the format expected by {Ext.KeyMap#addBinding}
* used to assign custom key handling to this panel (defaults to null).
*/
/**
* @cfg {Boolean/Object} draggable
* true to enable dragging of this Panel (defaults to false).
*
* For custom drag/drop implementations(执行操作), an Ext.Panel.DD config could also be passed
* in this config instead of true. Ext.Panel.DD is an internal, undocumented class which
* moves a proxy Element around in place of the Panel's element, but provides no other behaviour(行为)
* during dragging or on drop. It is a subclass of {Ext.dd.DragSource}, so behaviour may be
* added by implementing the interface methods of {Ext.dd.DragDrop} e.g.:
new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),
floating: true, //浮动
frame: true,
width: 400,
height: 200,
draggable: {
// Config option of Ext.Panel.DD class.
// It's a floating Panel(浮动面板), so do not show a placeholder proxy in the original(初始的) position.
insertProxy: false,
// Called for each mousemove event while dragging the DD object.
onDrag : function(e){
// Record the x,y position of the drag proxy so that we can
// position the Panel at end of drag.
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);
// Keep the Shadow aligned if there is one.
var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());//realign重新排列
}
},
// Called on the mouseup event.
endDrag : function(e){
this.panel.setPosition(this.x, this.y);
}
}
}).show();
*/
/**
* @cfg {Boolean} disabled(禁用)
* Render this panel disabled (default is false). An important note when using the disabled
* config on panels is that IE will often fail to initialize the disabled mask element correctly if
* the panel's layout has not yet completed by the time the Panel is disabled during the render process.
* If you experience this issue(问题), you may need to instead use the { #afterlayout} event to initialize
* the disabled state:
new Ext.Panel({
...
listeners: {
'afterlayout': {
fn: function(p){
p.disable();
},
single: true // important, as many layouts can occur
}
}
});
*/
/**
* @cfg {Boolean} autoHeight
* true to use height:'auto', false to use fixed height (defaults to false).
* Note: Setting autoHeight: true means that the browser will manage the panel's height
* based on its contents, and that Ext will not manage it at all. If the panel is within a layout that
* manages dimensions(尺寸) (fit, border, etc.) then setting autoHeight: true
* can cause issues with scrolling and will not generally work as expected since the panel will take
* on the height of its contents rather than the height required by the Ext layout.
*/
/**
* @cfg {String} baseCls
* The base CSS class to apply to this panel's element (defaults to 'x-panel').
*
* Another option available by default is to specify 'x-plain' which strips(剥夺) all styling
* except for required attributes for Ext layouts to function (e.g. overflow:hidden).
* See {#unstyled} also.
*/
baseCls : 'x-panel',
/**
* @cfg {String} collapsedCls
* A CSS class to add to the panel's element after it has been collapsed(收起) (defaults to
* 'x-panel-collapsed').
*/
collapsedCls : 'x-panel-collapsed',
/**
* @cfg {Boolean} maskDisabled
* true to mask the panel when it is {#disabled}, false to not mask it (defaults
* to true). Either way(没关系), the panel will always tell its contained elements to disable themselves
* when it is disabled, but masking the panel can provide an additional(额外的) visual cue(提示) that the panel is
* disabled.
*/
maskDisabled : true,
/**
* @cfg {Boolean} animCollapse
* true to animate(动态) the transition(过渡) when the panel is collapsed, false to skip(忽略) the
* animation (defaults to true if the {Ext.Fx} class is available(可用), otherwise(否则) false).
*/
animCollapse : Ext.enableFx,
/**
* @cfg {Boolean} headerAsText
* true to display the panel {#title} in the {#header},
* false to hide it (defaults to true).
*/
headerAsText : true,
/**
* @cfg {String} buttonAlign
* The alignment of any {#buttons} added to this panel. Valid values are 'right',
* 'left' and 'center' (defaults to 'right').
*/
buttonAlign : 'right',
/**
* @cfg {Boolean} collapsed(渲染时是否收取/初始时是否收起)
* true to render the panel collapsed, false to render it expanded (defaults to
* false).
*/
collapsed : false, //展开
/**
* @cfg {Boolean} collapseFirst
* true to make sure the collapse/expand toggle button always renders first (to the left of)
* any other tools in the panel's title bar, false to render it last (defaults to true).
*/
collapseFirst : true,
/**
* @cfg {Number} minButtonWidth
* Minimum width in pixels of all {#buttons} in this panel (defaults to 75)
*/
minButtonWidth : 75, //按钮最小的尺寸
/**
* @cfg {Boolean} unstyled
* Overrides the {#baseCls} setting to {#baseCls} = 'x-plain' which renders
* the panel unstyled except for required attributes for Ext layouts to function (e.g. overflow:hidden).
*/
/**
* @cfg {String} elements
* A comma-delimited list of panel elements to initialize when the panel is rendered. Normally(通常), this list will be
* generated automatically based on the items added to the panel at config time, but sometimes it might be useful to
* make sure a structural element is rendered even if not specified at config time (for example, you may want
* to add a button or toolbar dynamically after the panel has been rendered). Adding those elements to this
* list will allocate(分派) the required placeholders in the panel when it is rendered. Valid values are
header
tbar (top bar)
body
bbar (bottom bar)
footer
Defaults to 'body'.
*/
elements : 'body',
/**
* @cfg {Boolean} preventBodyReset
* Defaults to false. When set to true, an extra css class 'x-panel-normal'
* will be added to the panel's element, effectively(事实上) applying css styles suggested by the W3C
* (see http://www.w3.org/TR/CSS21/sample.html) to the Panel's body element (not the header,
* footer, etc.).
*/
preventBodyReset : false,
/**
* @cfg {Number/String} padding
* A shortcut for setting a padding style on the body element. The value can either be
* a number to be applied to all sides, or a normal css string describing padding.
* Defaults to undefined.
*/
padding: undefined,
/** @cfg {String} resizeEvent
* The event to listen to for resizing in layouts. Defaults to 'bodyresize'.
*/
resizeEvent: 'bodyresize',
// protected - these could be used to customize the behavior of the window,
// but changing them would not be useful without further modifications and
// could lead to unexpected or undesirable(讨厌的) results.
toolTarget : 'header',
collapseEl : 'bwrap',
slideAnchor : 't',
disabledClass : '',
// private(私有的), notify(通告) box this class will handle heights
deferHeight : true,
// private
expandDefaults: {
duration : 0.25 //duration;持续时间
},
// private
collapseDefaults : {
duration : 0.25
},
// private
initComponent : function(){
Ext.Panel.superclass.initComponent.call(this);
this.addEvents(
/**23
* @event bodyresize
* Fires after the Panel has been resized.
* @param {Ext.Panel} p_the Panel which has been resized.
* @param {Number} width_The Panel body's new width.
* @param {Number} height_The Panel body's new height.
*/
'bodyresize',
/**
* @event titlechange
* Fires after the Panel title has been {#title set} or {#setTitle changed}.
* @param {Ext.Panel} p_the Panel which has had its title changed.
* @param {String} The new title.
*/
'titlechange',
/**
* @event iconchange
* Fires after the Panel icon class has been {#iconCls set} or {#setIconClass changed}.
* @param {Ext.Panel} p_the Panel which has had its {#iconCls icon class} changed.
* @param {String} The new icon class.
* @param {String} The old icon class.
*/
'iconchange',
/**
* @event collapse(收起)
* Fires after the Panel has been collapsed.
* @param {Ext.Panel} p_the Panel that has been collapsed.
*/
'collapse',
/**
* @event expand
* Fires after the Panel has been expanded.
* @param {Ext.Panel} p_The Panel that has been expanded.
*/
'expand',
/**
* @event beforecollapse
* Fires before the Panel is collapsed. A handler can return false to cancel the collapse.
* @param {Ext.Panel} p_the Panel being collapsed.
* @param {Boolean} animate_True if the collapse is animated, else false.
*/
'beforecollapse',
/**
* @event beforeexpand
* Fires before the Panel is expanded. A handler can return false to cancel the expand.
* @param {Ext.Panel} p_The Panel being expanded.
* @param {Boolean} animate_True if the expand is animated, else false.
*/
'beforeexpand',
/**
* @event beforeclose
* Fires before the Panel is closed. Note that Panels do not directly support being closed, but some
* Panel subclasses do (like {Ext.Window}) or a Panel within(在里面) a Ext.TabPanel. This event only
* applies to such subclasses.
* A handler can return false to cancel the close.
* @param {Ext.Panel} p_The Panel being closed.
*/
'beforeclose',
/**
* @event close
* Fires after the Panel is closed. Note that Panels do not directly support being closed, but some
* Panel subclasses do (like {Ext.Window}) or a Panel within a Ext.TabPanel.
* @param {Ext.Panel} p_The Panel that has been closed.
*/
'close',
/**
* @event activate
* Fires after the Panel has been visually activated.
* Note that Panels do not directly support being activated, but some Panel subclasses
* do (like {Ext.Window}). Panels which are child Components of a TabPanel fire the
* activate and deactivate events under the control of the TabPanel.
* @param {Ext.Panel} p_The Panel that has been activated.
*/
'activate',
/**
* @event deactivate
* Fires after the Panel has been visually deactivated.
* Note that Panels do not directly support being deactivated, but some Panel subclasses
* do (like {Ext.Window}). Panels which are child Components of a TabPanel fire the
* activate and deactivate events under the control of the TabPanel.
* @param {Ext.Panel} p_The Panel that has been deactivated.
*/
'deactivate'
);
if(this.unstyled){
this.baseCls = 'x-plain';
}
this.toolbars = [];
// shortcuts
if(this.tbar){
this.elements += ',tbar';
this.topToolbar = this.createToolbar(this.tbar);
this.tbar = null;
}
if(this.bbar){
this.elements += ',bbar';
this.bottomToolbar = this.createToolbar(this.bbar);
this.bbar = null;
}
if(this.header === true){
this.elements += ',header';
this.header = null;
}else if(this.headerCfg || (this.title && this.header !== false)){
this.elements += ',header';
}
if(this.footerCfg || this.footer === true){
this.elements += ',footer';
this.footer = null;
}
if(this.buttons){
this.fbar = this.buttons;
this.buttons = null;
}
if(this.fbar){
this.createFbar(this.fbar);
}
if(this.autoLoad){
this.on('render', this.doAutoLoad, this, {delay:10});
}
},
// private
createFbar : function(fbar){
var min = this.minButtonWidth;
this.elements += ',footer';
this.fbar = this.createToolbar(fbar, {
buttonAlign: this.buttonAlign,
toolbarCls: 'x-panel-fbar',
enableOverflow: false,
defaults: function(c){
return {
minWidth: c.minWidth || min
};
}
});
// @compat(兼容性) addButton and buttons could possibly be removed
// @target 4.0
/**
* This Panel's Array of buttons as created from the {#buttons}
* config property. Read only.
* @type Array
* @property buttons
*/
this.fbar.items.each(function(c){
c.minWidth = c.minWidth || this.minButtonWidth;
}, this);
this.buttons = this.fbar.items.items;
},
// private
createToolbar: function(tb, options){
var result;
// Convert array to proper toolbar config
if(Ext.isArray(tb)){
tb = {
items: tb
};
}
result = tb.events ? Ext.apply(tb, options) : this.createComponent(Ext.apply({}, tb, options), 'toolbar');
this.toolbars.push(result);
return result;
},
// private
createElement : function(name, pnode){
if(this[name]){
pnode.appendChild(this[name].dom);
return;
}
if(name === 'bwrap' || this.elements.indexOf(name) != -1){
if(this[name+'Cfg']){
this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
}else{
var el = document.createElement('div');
el.className = this[name+'Cls'];
this[name] = Ext.get(pnode.appendChild(el));
}
if(this[name+'CssClass']){
this[name].addClass(this[name+'CssClass']);
}
if(this[name+'Style']){
this[name].applyStyles(this[name+'Style']);
}
}
},
// private
onRender : function(ct, position){
Ext.Panel.superclass.onRender.call(this, ct, position);
this.createClasses();
var el = this.el,
d = el.dom,
bw,
ts;
if(this.collapsible && !this.hideCollapseTool){
this.tools = this.tools ? this.tools.slice(0) : [];
this.tools[this.collapseFirst?'unshift':'push']({
id: 'toggle',
handler : this.toggleCollapse,
scope: this
});
}
if(this.tools){
ts = this.tools;
this.elements += (this.header !== false) ? ',header' : '';
}
this.tools = {};
el.addClass(this.baseCls);
if(d.firstChild){ // existing markup
this.header = el.down('.'+this.headerCls);
this.bwrap = el.down('.'+this.bwrapCls);
var cp = this.bwrap ? this.bwrap : el;
this.tbar = cp.down('.'+this.tbarCls);
this.body = cp.down('.'+this.bodyCls);
this.bbar = cp.down('.'+this.bbarCls);
this.footer = cp.down('.'+this.footerCls);
this.fromMarkup = true;
}
if (this.preventBodyReset === true) {
el.addClass('x-panel-reset');
}
if(this.cls){
el.addClass(this.cls);
}
if(this.buttons){
this.elements += ',footer';
}
// This block allows for maximum flexibility(灵活性) and performance(性能) when using existing markup
// framing requires special(专门的) markup
if(this.frame){
el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
this.createElement('header', d.firstChild.firstChild.firstChild);
this.createElement('bwrap', d);
// append the mid and bottom frame to the bwrap
bw = this.bwrap.dom;
var ml = d.childNodes[1], bl = d.childNodes[2];
bw.appendChild(ml);
bw.appendChild(bl);
var mc = bw.firstChild.firstChild.firstChild;
this.createElement('tbar', mc);
this.createElement('body', mc);
this.createElement('bbar', mc);
this.createElement('footer', bw.lastChild.firstChild.firstChild);
if(!this.footer){
this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
}
/*
* Store a reference to this element so:
* a) We aren't looking it up all the time
* b) The last element is reported incorrectly(错误的) when using a loadmask
*/
this.ft = Ext.get(this.bwrap.dom.lastChild);
this.mc = Ext.get(mc);
}else{
this.createElement('header', d);
this.createElement('bwrap', d);
// append the mid and bottom frame to the bwrap
bw = this.bwrap.dom;
this.createElement('tbar', bw);
this.createElement('body', bw);
this.createElement('bbar', bw);
this.createElement('footer', bw);
if(!this.header){
this.body.addClass(this.bodyCls + '-noheader');
if(this.tbar){
this.tbar.addClass(this.tbarCls + '-noheader');
}
}
}
if(Ext.isDefined(this.padding)){
this.body.setStyle('padding', this.body.addUnits(this.padding));
}
if(this.border === false){
this.el.addClass(this.baseCls + '-noborder');
this.body.addClass(this.bodyCls + '-noborder');
if(this.header){
this.header.addClass(this.headerCls + '-noborder');
}
if(this.footer){
this.footer.addClass(this.footerCls + '-noborder');
}
if(this.tbar){
this.tbar.addClass(this.tbarCls + '-noborder');
}
if(this.bbar){
this.bbar.addClass(this.bbarCls + '-noborder');
}
}
if(this.bodyBorder === false){
this.body.addClass(this.bodyCls + '-noborder');
}
this.bwrap.enableDisplayMode('block');
if(this.header){
this.header.unselectable();
// for tools, we need to wrap any existing header markup
if(this.headerAsText){
this.header.dom.innerHTML =
''+this.header.dom.innerHTML+'';
if(this.iconCls){
this.setIconClass(this.iconCls);
}
}
}
if(this.floating){
this.makeFloating(this.floating);
}
if(this.collapsible && this.titleCollapse && this.header){
this.mon(this.header, 'click', this.toggleCollapse, this);
this.header.setStyle('cursor', 'pointer');
}
if(ts){
this.addTool.apply(this, ts);
}
// Render Toolbars.
if(this.fbar){
this.footer.addClass('x-panel-btns');
this.fbar.ownerCt = this;
this.fbar.render(this.footer);
this.footer.createChild({cls:'x-clear'});
}
if(this.tbar && this.topToolbar){
this.topToolbar.ownerCt = this;
this.topToolbar.render(this.tbar);
}
if(this.bbar && this.bottomToolbar){
this.bottomToolbar.ownerCt = this;
this.bottomToolbar.render(this.bbar);
}
},
/**
* Sets the CSS class that provides the icon image for this panel. This method will replace any existing
* icon class if one has already been set and fire the {#iconchange} event after completion(完成、结束).
* @param {String} cls_The new CSS class name
*/
setIconClass : function(cls){
var old = this.iconCls;
this.iconCls = cls;
if(this.rendered && this.header){
if(this.frame){
this.header.addClass('x-panel-icon');
this.header.replaceClass(old, this.iconCls);
}else{
var hd = this.header,
img = hd.child('img.x-panel-inline-icon');
if(img){
Ext.fly(img).replaceClass(old, this.iconCls);
}else{
var hdspan = hd.child('span.' + this.headerTextCls);
if (hdspan) {
Ext.DomHelper.insertBefore(hdspan.dom, {
tag:'img', alt: '', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
});
}
}
}
}
this.fireEvent('iconchange', this, cls, old);
},
// private
makeFloating : function(cfg){
this.floating = true;
this.el = new Ext.Layer(Ext.apply({}, cfg, {
shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
shadowOffset: this.shadowOffset,
constrain:false,
shim: this.shim === false ? false : undefined
}), this.el);
},
/**
* Returns the {Ext.Toolbar toolbar} from the top ({#tbar}) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getTopToolbar : function(){
return this.topToolbar;
},
/**
* Returns the {Ext.Toolbar toolbar} from the bottom ({#bbar}) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getBottomToolbar : function(){
return this.bottomToolbar;
},
/**
* Returns the {Ext.Toolbar toolbar} from the footer ({#fbar}) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getFooterToolbar : function() {
return this.fbar;
},
/**
* Adds a button to this panel. Note that this method must be called prior(优先) to rendering. The preferred(优先的)
* approach(建议) is to add buttons via the {#buttons} config.
* @param {String/Object} config_A valid {Ext.Button} config. A string will become the text for a default
* button config, an object will be treated as a button config object.
* @param {Function} handler_The function to be called on button {Ext.Button#click}
* @param {Object} scope_The scope (this reference) in which the button handler function is executed.
* Defaults to the Button.
* @return {Ext.Button} The button that was added
*/
addButton : function(config, handler, scope){
if(!this.fbar){
this.createFbar([]);
}
if(handler){
if(Ext.isString(config)){
config = {text: config};
}
config = Ext.apply({
handler: handler,
scope: scope
}, config);
}
return this.fbar.add(config);
},
// private
addTool : function(){
if(!this.rendered){
if(!this.tools){
this.tools = [];
}
Ext.each(arguments, function(arg){
this.tools.push(arg);
}, this);
return;
}
// nowhere to render tools!
if(!this[this.toolTarget]){
return;
}
if(!this.toolTemplate){
// initialize the global tool template on first use
var tt = new Ext.Template(
''
);
tt.disableFormats = true;
tt.compile();
Ext.Panel.prototype.toolTemplate = tt;
}
for(var i = 0, a = arguments, len = a.length; i < len; i++) {
var tc = a[i];
if(!this.tools[tc.id]){
var overCls = 'x-tool-'+tc.id+'-over';
var t = this.toolTemplate.insertFirst(this[this.toolTarget], tc, true);
this.tools[tc.id] = t;
t.enableDisplayMode('block');
this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
if(tc.on){
this.mon(t, tc.on);
}
if(tc.hidden){
t.hide();
}
if(tc.qtip){
if(Ext.isObject(tc.qtip)){
Ext.QuickTips.register(Ext.apply({
target: t.id
}, tc.qtip));
} else {
t.dom.qtip = tc.qtip;
}
}
t.addClassOnOver(overCls);
}
}
},
onLayout : function(shallow, force){
Ext.Panel.superclass.onLayout.apply(this, arguments);
if(this.hasLayout && this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.doLayout(undefined, force);
});
this.syncHeight();
}
},
syncHeight : function(){
var h = this.toolbarHeight,
bd = this.body,
lsh = this.lastSize.height,
sz;
if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
return;
}
if(h != this.getToolbarHeight()){
h = Math.max(0, lsh - this.getFrameHeight());
bd.setHeight(h);
sz = bd.getSize();
this.toolbarHeight = this.getToolbarHeight();
this.onBodyResize(sz.width, sz.height);
}
},
// private
onShow : function(){
if(this.floating){
return this.el.show();
}
Ext.Panel.superclass.onShow.call(this);
},
// private
onHide : function(){
if(this.floating){
return this.el.hide();
}
Ext.Panel.superclass.onHide.call(this);
},
// private
createToolHandler : function(t, tc, overCls, panel){
return function(e){
t.removeClass(overCls);
if(tc.stopEvent !== false){
e.stopEvent();
}
if(tc.handler){
tc.handler.call(tc.scope || t, e, t, panel, tc);
}
};
},
// private
afterRender : function(){
if(this.floating && !this.hidden){
this.el.show();
}
if(this.title){
this.setTitle(this.title);
}
Ext.Panel.superclass.afterRender.call(this); // do sizing calcs(计算) last
if (this.collapsed) {
this.collapsed = false;
this.collapse(false);
}
this.initEvents();
},
// private
getKeyMap : function(){
if(!this.keyMap){
this.keyMap = new Ext.KeyMap(this.el, this.keys);
}
return this.keyMap;
},
// private
initEvents : function(){
if(this.keys){
this.getKeyMap();
}
if(this.draggable){
this.initDraggable();
}
if(this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.doLayout();
tb.on({
scope: this,
afterlayout: this.syncHeight,
remove: this.syncHeight
});
}, this);
this.syncHeight();
}
},
// private
initDraggable : function(){
/**
*
* If this Panel is configured {#draggable}, this property will contain
* an instance of {Ext.dd.DragSource} which handles dragging the Panel.
* The developer must provide implementations(执行) of the abstract(抽象的) methods of {Ext.dd.DragSource}
* in order to supply behaviour for each stage(阶段) of the drag/drop process. See {#draggable}.
* @type Ext.dd.DragSource.
* @property dd
*/
this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
},
// private
beforeEffect : function(anim){
if(this.floating){
this.el.beforeAction();
}
if(anim !== false){
this.el.addClass('x-panel-animated');
}
},
// private
afterEffect : function(anim){
this.syncShadow();
this.el.removeClass('x-panel-animated');
},
//23 private - wraps up an animation param with internal callbacks
createEffect : function(a, cb, scope){
var o = {
scope:scope,
block:true
};
if(a === true){
o.callback = cb;
return o;
}else if(!a.callback){
o.callback = cb;
}else { // wrap it up
o.callback = function(){
cb.call(scope);
Ext.callback(a.callback, a.scope);
};
}
return Ext.applyIf(o, a);
},
/**
* Collapses the panel body so that it becomes hidden. Fires the {#beforecollapse} event which will
* cancel the collapse action if it returns false.
* @param {Boolean} animate_True to animate the transition(转变), else false (defaults to the value of the
* {#animCollapse} panel config)
* @return {Ext.Panel} this
*/
collapse : function(animate){
if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.beforeEffect(doAnim);
this.onCollapse(doAnim, animate);
return this;
},
// private
onCollapse : function(doAnim, animArg){
if(doAnim){
this[this.collapseEl].slideOut(this.slideAnchor,
Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
this.collapseDefaults));
}else{
this[this.collapseEl].hide(this.hideMode);
this.afterCollapse(false);
}
},
// private
afterCollapse : function(anim){
this.collapsed = true;
this.el.addClass(this.collapsedCls);
if(anim !== false){
this[this.collapseEl].hide(this.hideMode);
}
this.afterEffect(anim);
// Reset lastSize of all sub-components so they KNOW they are in a collapsed container
this.cascade(function(c) {
if (c.lastSize) {
c.lastSize = { width: undefined, height: undefined };
}
});
this.fireEvent('collapse', this);
},
/**
* Expands the panel body so that it becomes visible. Fires the {#beforeexpand} event which will
* cancel the expand action if it returns false.
* @param {Boolean} animate_True to animate the transition, else false (defaults to the value of the
* {#animCollapse} panel config)
* @return {Ext.Panel} this
*/
expand : function(animate){
if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.el.removeClass(this.collapsedCls);
this.beforeEffect(doAnim);
this.onExpand(doAnim, animate);
return this;
},
// private
onExpand : function(doAnim, animArg){
if(doAnim){
this[this.collapseEl].slideIn(this.slideAnchor,
Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
this.expandDefaults));
}else{
this[this.collapseEl].show(this.hideMode);
this.afterExpand(false);
}
},
// private
afterExpand : function(anim){
this.collapsed = false;
if(anim !== false){
this[this.collapseEl].show(this.hideMode);
}
this.afterEffect(anim);
if (this.deferLayout) {
delete this.deferLayout;
this.doLayout(true);
}
this.fireEvent('expand', this);
},
/**
* Shortcut(捷径办法) for performing(履行的) an {#expand} or {#collapse} based on the current state of the panel.
* @param {Boolean} animate_True to animate the transition, else false (defaults to the value of the
* {#animCollapse} panel config)
* @return {Ext.Panel} this
*/
toggleCollapse : function(animate){
this[this.collapsed ? 'expand' : 'collapse'](animate);
return this;
},
// private
onDisable : function(){
if(this.rendered && this.maskDisabled){
this.el.mask();
}
Ext.Panel.superclass.onDisable.call(this);
},
// private
onEnable : function(){
if(this.rendered && this.maskDisabled){
this.el.unmask();
}
Ext.Panel.superclass.onEnable.call(this);
},
// private
onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
var w = adjWidth,
h = adjHeight;
if(Ext.isDefined(w) || Ext.isDefined(h)){
if(!this.collapsed){
// First, set the Panel's body width.
// If we have auto-widthed it, get the resulting full offset width so we can size the Toolbars to match
// The Toolbars must not buffer this resize operation because we need to know their heights.
if(Ext.isNumber(w)){
this.body.setWidth(w = this.adjustBodyWidth(w - this.getFrameWidth()));
} else if (w == 'auto') {
w = this.body.setWidth('auto').dom.offsetWidth;
} else {
w = this.body.dom.offsetWidth;
}
if(this.tbar){
this.tbar.setWidth(w);
if(this.topToolbar){
this.topToolbar.setSize(w);
}
}
if(this.bbar){
this.bbar.setWidth(w);
if(this.bottomToolbar){
this.bottomToolbar.setSize(w);
// The bbar does not move on resize without this.
if (Ext.isIE) {
this.bbar.setStyle('position', 'static');
this.bbar.setStyle('position', '');
}
}
}
if(this.footer){
this.footer.setWidth(w);
if(this.fbar){
this.fbar.setSize(Ext.isIE ? (w - this.footer.getFrameWidth('lr')) : 'auto');
}
}
// At this point, the Toolbars must be layed out for getFrameHeight to find a result.
if(Ext.isNumber(h)){
h = Math.max(0, h - this.getFrameHeight());
//h = Math.max(0, h - (this.getHeight() - this.body.getHeight()));
this.body.setHeight(h);
}else if(h == 'auto'){
this.body.setHeight(h);
}
if(this.disabled && this.el._mask){
this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
}
}else{
// Adds an event to set the correct height afterExpand.
// This accounts(帐目) for the deferHeight flag in panel
this.queuedBodySize = {width: w, height: h};
if(!this.queuedExpand && this.allowQueuedExpand !== false){
this.queuedExpand = true;
this.on('expand', function(){
delete this.queuedExpand;
this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
}, this, {single:true});
}
}
this.onBodyResize(w, h);
}
this.syncShadow();
Ext.Panel.superclass.onResize.call(this, adjWidth, adjHeight, rawWidth, rawHeight);
},
// private
onBodyResize: function(w, h){
this.fireEvent('bodyresize', this, w, h);
},
// private
getToolbarHeight: function(){
var h = 0;
if(this.rendered){
Ext.each(this.toolbars, function(tb){
h += tb.getHeight();
}, this);
}
return h;
},
// deprecate (不赞成)
adjustBodyHeight : function(h){
return h;
},
// private
adjustBodyWidth : function(w){
return w;
},
// private
onPosition : function(){
this.syncShadow();
},
/**
* Returns the width in pixels of the framing elements of this panel (not including the body width). To
* retrieve(取回) the body width see #getInnerWidth}.
* @return {Number} The frame width
*/
getFrameWidth : function(){
var w = this.el.getFrameWidth('lr') + this.bwrap.getFrameWidth('lr');
if(this.frame){
var l = this.bwrap.dom.firstChild;
w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
w += this.mc.getFrameWidth('lr');
}
return w;
},
/**
* Returns the height in pixels of the framing elements of this panel (including any top and bottom bars and
* header and footer elements, but not including the body height). To retrieve the body height see
* {#getInnerHeight}.
* @return {Number} The frame height
*/
getFrameHeight : function() {
var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
h += (this.tbar ? this.tbar.getHeight() : 0) +
(this.bbar ? this.bbar.getHeight() : 0);
if(this.frame){
h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
}else{
h += (this.header ? this.header.getHeight() : 0) +
(this.footer ? this.footer.getHeight() : 0);
}
return h;
},
/**
* Returns the width in pixels of the body element (not including the width of any framing elements).
* For the frame width see {#getFrameWidth}.
* @return {Number} The body width
*/
getInnerWidth : function(){
return this.getSize().width - this.getFrameWidth();
},
/**
* Returns the height in pixels of the body element (not including the height of any framing elements).
* For the frame height see {#getFrameHeight}.
* @return {Number} The body height
*/
getInnerHeight : function(){
return this.body.getHeight();
/* Deprecate
return this.getSize().height - this.getFrameHeight();
*/
},
// private
syncShadow : function(){
if(this.floating){
this.el.sync(true);
}
},
// private
getLayoutTarget : function(){
return this.body;
},
// private
getContentTarget : function(){
return this.body;
},
/**
* Sets the title text for the panel and optionally(随意的) the {#iconCls icon class}.
* In order to be able to set the title, a header element must have been created
* for the Panel. This is triggered(触发的) either by configuring the Panel with a non-blank {title},
* or configuring it with {#header}: true.
* @param {String} title_The title text to set
* @param {String} iconCls (optional)_{#iconCls iconCls} A user-defined CSS class that provides the icon image
* for this panel
*/
setTitle : function(title, iconCls){
this.title = title;
if(this.header && this.headerAsText){
this.header.child('span').update(title);
}
if(iconCls){
this.setIconClass(iconCls);
}
this.fireEvent('titlechange', this, title);
return this;
},
/**
* Get the {Ext.Updater} for this panel. Enables you to perform(执行) Ajax updates of this panel's body.
* @return {Ext.Updater} The Updater
*/
getUpdater : function(){
return this.body.getUpdater();
},
/**
* Loads this content panel immediately(直接地) with content returned from an XHR call.
* @param {Object/String/Function} config_A config object containing any of the following options:
panel.load({
url: 'your-url.php',
params: {param1: 'foo', param2: 'bar'}, // or a URL encoded string
callback: yourFunction,
scope: yourObject, // optional scope for the callback
discardUrl: false,
nocache: false,
text: 'Loading...',
timeout: 30,
scripts: false
});
* The only required property is url. The optional properties nocache, text and scripts
* are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
* associated(相关的) property on this panel Updater instance.
* @return {Ext.Panel} this
*/
load : function(){
var um = this.body.getUpdater();
um.update.apply(um, arguments);
return this;
},
// private
beforeDestroy : function(){
Ext.Panel.superclass.beforeDestroy.call(this);
if(this.header){
this.header.removeAllListeners();
}
if(this.tools){
for(var k in this.tools){
Ext.destroy(this.tools[k]);
}
}
if(this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.un('afterlayout', this.syncHeight, this);
tb.un('remove', this.syncHeight, this);
}, this);
}
if(Ext.isArray(this.buttons)){
while(this.buttons.length) {
Ext.destroy(this.buttons[0]);
}
}
if(this.rendered){
Ext.destroy(
this.ft,
this.header,
this.footer,
this.tbar,
this.bbar,
this.body,
this.mc,
this.bwrap,
this.dd
);
if (this.fbar) {
Ext.destroy(
this.fbar,
this.fbar.el
);
}
}
Ext.destroy(this.toolbars);
},
// private
createClasses : function(){
this.headerCls = this.baseCls + '-header';
this.headerTextCls = this.baseCls + '-header-text';
this.bwrapCls = this.baseCls + '-bwrap';
this.tbarCls = this.baseCls + '-tbar';
this.bodyCls = this.baseCls + '-body';
this.bbarCls = this.baseCls + '-bbar';
this.footerCls = this.baseCls + '-footer';
},
// private
createGhost : function(cls, useShim, appendTo){
var el = document.createElement('div');
el.className = 'x-panel-ghost ' + (cls ? cls : '');
if(this.header){
el.appendChild(this.el.dom.firstChild.cloneNode(true));
}
Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
el.style.width = this.el.dom.offsetWidth + 'px';;
if(!appendTo){
this.container.dom.appendChild(el);
}else{
Ext.getDom(appendTo).appendChild(el);
}
if(useShim !== false && this.el.useShim !== false){
var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
layer.show();
return layer;
}else{
return new Ext.Element(el);
}
},
// private
doAutoLoad : function(){
var u = this.body.getUpdater();
if(this.renderer){
u.setRenderer(this.renderer);
}
u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
},
/**
* Retrieve a tool by id.
* @param {String} id
* @return {Object} tool
*/
getTool : function(id) {
return this.tools[id];
}
/**
* @cfg {String} autoEl @hide
*/
});
Ext.reg('panel', Ext.Panel);