📄 panel.js
字号:
/*
* Ext JS Library 2.0 Beta 1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
/** * @class Ext.Panel * @extends Ext.Container * Panel is a container that has specific functionality and structural components that make it the perfect building * block for application-oriented user interfaces. The Panel contains bottom and top toolbars, along with separate * header, footer and body sections. It also provides built-in expandable and collapsible behavior, along with a * variety of prebuilt tool buttons that can be wired up to provide other customized behavior. Panels can be easily * dropped into any Container or layout, and the layout and rendering pipeline is completely managed by the framework. * @constructor * @param {Object} config The config object */Ext.Panel = Ext.extend(Ext.Container, { /** * The Panel's header {@link Ext.Element Element}. Read-only. * @type Ext.Element * @property header */ /** * The Panel's body {@link Ext.Element Element} which may be used either to contain HTML content, * or to house a Layout. Read-only. * @type Ext.Element * @property body */ /** * The Panel's footer {@link Ext.Element Element}. Read-only. * @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 {@link #baseCls}): * <ul><li>baseCls + '-header'</li> * <li>baseCls + '-header-text'</li> * <li>baseCls + '-bwrap'</li> * <li>baseCls + '-tbar'</li> * <li>baseCls + '-body'</li> * <li>baseCls + '-bbar'</li> * <li>baseCls + '-footer'</li></ul> * Using this config, a call to render() is not required. If applyTo is specified, any value passed for * {@link #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 {@link 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 {@link #getTopToolbar}. */ /** * @cfg {Object/Array} bbar * The bottom toolbar of the panel. This can be a {@link 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 {@link #getBottomToolbar}. */ /** * @cfg {Boolean} header * True to create the header element explicitly, false to skip creating it. By default, when header is not * specified, if a {@link #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. By default, when footer is not * specified, if one or more buttons have been added to the panel the footer will be created automatically, * otherwise it will not. */ /** * @cfg {String} title * The title text to display in the panel header (defaults to ''). When a title is specified the header * element will automatically be created and displayed unless {@link #header} is explicitly set to false. */ /** * @cfg {Array} buttons * An array of {@link Ext.Button} instances (or valid button configs) to add to the footer of this panel */ /** * @cfg {Object/String/Function} autoLoad * A valid url spec according to the Updater {@link Ext.Updater#update} method. If autoLoad is not null, * the panel will attempt to load its contents immediately upon render. */ /** * @cfg {Boolean} frame * True to render the panel with custom rounded borders, false to render with plain 1px square borders (defaults to false). */ /** * @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 {@link #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 {@link #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 {Boolean} bodyStyle * Custom CSS styles to be applied to the body element in the format expected by {@link Ext.Element#applyStyles} * (defaults to null). */ /** * @cfg {String} iconCls * A CSS class that will provide a background image to be used as the panel header icon (defaults to ''). */ /** * @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. Each tool config should contain the id * of the tool, and can also contain an 'on' event handler config containing one or more event handlers to assign * to this tool. The optional property 'hidden:true' can be included to hide the tool by default. Example usage: * <pre><code>tools:[{ id:'refresh', // hidden:true, on:{ click: function(){ // refresh logic } }}]</code></pre> * A valid tool id should correspond to the CSS classes 'x-tool-{id}' (normal) and 'x-tool-{id}-over' (mouseover). * By default, the following tools are provided: toggle (default when collapsible = true), close, minimize, * maximize, restore, gear, pin, unpin, right, left, up, down, refresh, minus, plus, help, search and save. Note that * these tool classes only provide the visual button -- any required functionality must be provided by adding * event handlers that implement the necessary behavior. */ /** * @cfg {Boolean} hideCollapseTool * True to hide the expand/collapse toggle button when {@link #collapsible} = true, false to display it (defaults to false). */ /** * @cfg {Boolean} titleCollapse * True to allow expanding and collapsing the panel (when {@link #collapsible} = true) by clicking anywhere in the * header bar, false to allow it only by clicking to tool button (defaults to false). */ /** * @cfg {Boolean} autoScroll * True to use overflow:'auto' on the panel's body element and show scroll bars automatically when necessary, * false to clip any overflowing content (defaults to false). */ /** * @cfg {Boolean} floating * True to float the panel (absolute position it with automatic shimming and shadow), false to display it * inline where it is rendered (defaults to false). Note that by default, setting floating to true will cause the * panel to display at negative offsets so that it is hidden -- because the panel is absolute positioned, the * position must be set explicitly after render (e.g., myPanel.setPosition(100,100);). Also, 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. */ /** * @cfg {Boolean/String} shadow * True (or a valid Ext.Shadow {@link 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 {Boolean} shim * False to disable the iframe shim in browsers which need one (defaults to true). Note that this option * opnly applies when floating = true. */ /** * @cfg {String/Object} html * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use * as the panel's body content (defaults to ''). */ /** * @cfg {String} contentEl * The id of an existing HTML node to use as the panel's body content (defaults to ''). */ /** * @cfg {Object/Array} keys * A KeyMap config object (in the format expected by {@link Ext.KeyMap#addBinding} used to assign custom key * handling to this panel (defaults to null). */ /** * @cfg {String} baseCls * The base CSS class to apply to this panel's element (defaults to 'x-panel'). */ 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 {@link 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 {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,' * 'body,' 'footer,' 'tbar' (top bar) abd 'bbar' (bottom bar) - defaults to 'body.' */ elements : 'body', // protected - these could both be used to customize the behavior of the window, // but changing them would not be useful without further mofifications and could // lead to unexpected or undesirable results. toolTarget : 'header', collapseEl : 'bwrap', slideAnchor : 't', // private, notify box this class will handle heights deferHeight: true, // private expandDefaults: { duration:.25 }, // private collapseDefaults: { duration:.25 }, // private initComponent : function(){ Ext.Panel.superclass.initComponent.call(this); this.addEvents({ /** * @event bodyresize * Fires after the panel has been resized. * @param {Ext.Panel} this * @param {Number} width The panel's new width * @param {Number} height The panel's new height */ bodyresize : true, /** * @event titlechange * Fires after the panel title has been set or changed. * @param {Ext.Panel} this * @param {String} The new title */ titlechange: true, /** * @event collapse * Fires after the panel has been collapsed. * @param {Ext.Panel} this */ collapse : true, /** * @event expand * Fires after the panel has been expanded. * @param {Ext.Panel} this */ expand:true, /** * @event beforecollapse * Fires before the panel is collapsed. A handler can return false to cancel the collapse. * @param {Ext.Panel} this * @param {Boolean} animate True if the collapse is animated, else false */ beforecollapse : true, /** * @event beforeexpand * Fires before the panel is expanded. A handler can return false to cancel the expand. * @param {Ext.Panel} this * @param {Boolean} animate True if the expand is animated, else false */ beforeexpand:true, /** * @event beforeclose * Fires before the panel is closed. Note that panels do not directly support being closed, but some * panel subclasses do (like {@link Ext.Window}). This event only applies to such subclasses. * A handler can return false to cancel the close. * @param {Ext.Panel} this */ beforeclose: true, /** * @event close * Fires after the panel is closed. Note that panels do not directly support being closed, but some * panel subclasses do (like {@link Ext.Window}). * @param {Ext.Panel} this */ close: true, /** * @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 {@link Ext.Window}). * @param {Ext.Panel} this */ activate: true, /** * @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 {@link Ext.Window}). * @param {Ext.Panel} this */ deactivate: true }); // shortcuts if(this.tbar){ this.elements += ',tbar'; if(typeof this.tbar == 'object'){ this.topToolbar = this.tbar; } delete this.tbar; } if(this.bbar){ this.elements += ',bbar'; if(typeof this.bbar == 'object'){ this.bottomToolbar = this.bbar; } delete this.bbar; } if(this.header === true){ this.elements += ',header'; delete this.header; }else if(this.title && this.header !== false){ this.elements += ',header'; } if(this.footer === true){ this.elements += ',footer'; delete this.footer; } if(this.buttons){ var btns = this.buttons; delete this.buttons; for(var i = 0, len = btns.length; i < len; i++) { this.addButton(btns[i]); } } if(this.autoLoad){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -