/*!
- * Ext JS Library 3.0.0
+ * Ext JS Library 3.0.3
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
* {@link Ext.Component#id id} (see {@link #get}, or the convenience method {@link Ext#getCmp Ext.getCmp}).</p>
* <p>This object also provides a registry of available Component <i>classes</i>
* indexed by a mnemonic code known as the Component's {@link Ext.Component#xtype xtype}.
- * The <tt>{@link Ext.Component#xtype xtype}</tt> provides a way to avoid instantiating child Components
+ * The <code>{@link Ext.Component#xtype xtype}</code> provides a way to avoid instantiating child Components
* when creating a full, nested config object for a complete Ext page.</p>
* <p>A child Component may be specified simply as a <i>config object</i>
- * as long as the correct <tt>{@link Ext.Component#xtype xtype}</tt> is specified so that if and when the Component
+ * as long as the correct <code>{@link Ext.Component#xtype xtype}</code> is specified so that if and when the Component
* needs rendering, the correct type can be looked up for lazy instantiation.</p>
- * <p>For a list of all available <tt>{@link Ext.Component#xtype xtypes}</tt>, see {@link Ext.Component}.</p>
+ * <p>For a list of all available <code>{@link Ext.Component#xtype xtypes}</code>, see {@link Ext.Component}.</p>
* @singleton
*/
Ext.ComponentMgr = function(){
* Returns a component by {@link Ext.Component#id id}.
* For additional details see {@link Ext.util.MixedCollection#get}.
* @param {String} id The component {@link Ext.Component#id id}
- * @return Ext.Component The Component, <tt>undefined</tt> if not found, or <tt>null</tt> if a
+ * @return Ext.Component The Component, <code>undefined</code> if not found, or <code>null</code> if a
* Class was found.
*/
get : function(id){
* config object's {@link Ext.component#xtype xtype} to determine the class to instantiate.
* @param {Object} config A configuration object for the Component you wish to create.
* @param {Constructor} defaultType The constructor to provide the default Component type if
- * the config object does not contain a <tt>xtype</tt>. (Optional if the config contains a <tt>xtype</tt>).
+ * the config object does not contain a <code>xtype</code>. (Optional if the config contains a <code>xtype</code>).
* @return {Ext.Component} The newly instantiated Component.
*/
create : function(config, defaultType){
* config object's {@link Ext.component#ptype ptype} to determine the class to instantiate.
* @param {Object} config A configuration object for the Plugin you wish to create.
* @param {Constructor} defaultType The constructor to provide the default Plugin type if
- * the config object does not contain a <tt>ptype</tt>. (Optional if the config contains a <tt>ptype</tt>).
+ * the config object does not contain a <code>ptype</code>. (Optional if the config contains a <code>ptype</code>).
* @return {Ext.Component} The newly instantiated Plugin.
*/
createPlugin : function(config, defaultType){
* @method preg
*/
Ext.preg = Ext.ComponentMgr.registerPlugin;
-Ext.create = Ext.ComponentMgr.create;
/**
+ * Shorthand for {@link Ext.ComponentMgr#create}
+ * Creates a new Component from the specified config object using the
+ * config object's {@link Ext.component#xtype xtype} to determine the class to instantiate.
+ * @param {Object} config A configuration object for the Component you wish to create.
+ * @param {Constructor} defaultType The constructor to provide the default Component type if
+ * the config object does not contain a <code>xtype</code>. (Optional if the config contains a <code>xtype</code>).
+ * @return {Ext.Component} The newly instantiated Component.
+ * @member Ext
+ * @method create
+ */
+Ext.create = Ext.ComponentMgr.create;/**
* @class Ext.Component
* @extends Ext.util.Observable
* <p>Base class for all Ext components. All subclasses of Component may participate in the automated
Ext.Component.AUTO_ID = 1000;
Ext.extend(Ext.Component, Ext.util.Observable, {
- // Configs below are used for all Components when rendered by FormLayout.
+ // Configs below are used for all Components when rendered by FormLayout.
/**
* @cfg {String} fieldLabel <p>The label text to display next to this Component (defaults to '').</p>
* <br><p><b>Note</b>: this config is only used when this Component is rendered by a Container which
* <p>See {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} also.</p>
*/
/**
- * @cfg {String} itemCls <p>An additional CSS class to apply to the div wrapping the form item
+ * @cfg {String} itemCls
+ * <p><b>Note</b>: this config is only used when this Component is rendered by a Container which
+ * has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout manager (e.g.
+ * {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>).</p><br>
+ * <p>An additional CSS class to apply to the div wrapping the form item
* element of this field. If supplied, <tt>itemCls</tt> at the <b>field</b> level will override
* the default <tt>itemCls</tt> supplied at the <b>container</b> level. The value specified for
* <tt>itemCls</tt> will be added to the default class (<tt>'x-form-item'</tt>).</p>
* any other element within the markup for the field.</p>
* <br><p><b>Note</b>: see the note for <tt>{@link #fieldLabel}</tt>.</p><br>
* Example use:<pre><code>
-// Apply a style to the field's label:
+// Apply a style to the field's label:
<style>
.required .x-form-item-label {font-weight:bold;color:red;}
</style>
new Ext.FormPanel({
- height: 100,
- renderTo: Ext.getBody(),
- items: [{
- xtype: 'textfield',
- fieldLabel: 'Name',
- itemCls: 'required' //this label will be styled
- },{
- xtype: 'textfield',
- fieldLabel: 'Favorite Color'
- }]
+ height: 100,
+ renderTo: Ext.getBody(),
+ items: [{
+ xtype: 'textfield',
+ fieldLabel: 'Name',
+ itemCls: 'required' //this label will be styled
+ },{
+ xtype: 'textfield',
+ fieldLabel: 'Favorite Color'
+ }]
});
</code></pre>
*/
- // Configs below are used for all Components when rendered by AnchorLayout.
+ // Configs below are used for all Components when rendered by AnchorLayout.
/**
* @cfg {String} anchor <p><b>Note</b>: this config is only used when this Component is rendered
* by a Container which has been configured to use an <b>{@link Ext.layout.AnchorLayout AnchorLayout}</b>
* @property el
*/
/**
- * The component's owner {@link Ext.Container} (defaults to undefined, and is set automatically when
- * the component is added to a container). Read-only.
- * <p><b>Note</b>: to access items within the container see <tt>{@link #itemId}</tt>.</p>
+ * This Component's owner {@link Ext.Container Container} (defaults to undefined, and is set automatically when
+ * this Component is added to a Container). Read-only.
+ * <p><b>Note</b>: to access items within the Container see <tt>{@link #itemId}</tt>.</p>
* @type Ext.Container
* @property ownerCt
*/
/**
* True if this component is hidden. Read-only.
* @type Boolean
- * @property
+ * @property hidden
*/
/**
* True if this component is disabled. Read-only.
* @type Boolean
- * @property
+ * @property disabled
*/
/**
* True if this component has been rendered. Read-only.
* @type Boolean
- * @property
+ * @property rendered
*/
rendered : false,
},
// private
- applyState : function(state, config){
+ applyState : function(state){
if(state){
Ext.apply(this, state);
}
*
*/
destroy : function(){
- if(this.fireEvent('beforedestroy', this) !== false){
- this.beforeDestroy();
- if(this.rendered){
- this.el.removeAllListeners();
- this.el.remove();
- if(this.actionMode == 'container' || this.removeMode == 'container'){
- this.container.remove();
+ if(!this.isDestroyed){
+ if(this.fireEvent('beforedestroy', this) !== false){
+ this.beforeDestroy();
+ if(this.rendered){
+ this.el.removeAllListeners();
+ this.el.remove();
+ if(this.actionMode == 'container' || this.removeMode == 'container'){
+ this.container.remove();
+ }
}
+ this.onDestroy();
+ Ext.ComponentMgr.unregister(this);
+ this.fireEvent('destroy', this);
+ this.purgeListeners();
+ this.isDestroyed = true;
}
- this.onDestroy();
- Ext.ComponentMgr.unregister(this);
- this.fireEvent('destroy', this);
- this.purgeListeners();
}
},
// private
onShow : function(){
- this.getVisibiltyEl().removeClass('x-hide-' + this.hideMode);
+ this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
},
/**
// private
onHide : function(){
- this.getVisibiltyEl().addClass('x-hide-' + this.hideMode);
+ this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
},
// private
- getVisibiltyEl : function(){
+ getVisibilityEl : function(){
return this.hideParent ? this.container : this.getActionEl();
},
* @return {Boolean} True if this component is visible, false otherwise.
*/
isVisible : function(){
- return this.rendered && this.getVisibiltyEl().isVisible();
+ return this.rendered && this.getVisibilityEl().isVisible();
},
/**
}, this);
this.mons = [];
},
-
- // internal function for auto removal of assigned event handlers on destruction
- mon : function(item, ename, fn, scope, opt){
+
+ // private
+ createMons: function(){
if(!this.mons){
this.mons = [];
this.on('beforedestroy', this.clearMons, this, {single: true});
}
+ },
+ // internal function for auto removal of assigned event handlers on destruction
+ mon : function(item, ename, fn, scope, opt){
+ this.createMons();
if(Ext.isObject(ename)){
- var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
+ var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
var o = ename;
for(var e in o){
}
if(Ext.isFunction(o[e])){
// shared options
- this.mons.push({
- item: item, ename: e, fn: o[e], scope: o.scope
- });
- item.on(e, o[e], o.scope, o);
+ this.mons.push({
+ item: item, ename: e, fn: o[e], scope: o.scope
+ });
+ item.on(e, o[e], o.scope, o);
}else{
// individual options
- this.mons.push({
- item: item, ename: e, fn: o[e], scope: o.scope
- });
- item.on(e, o[e]);
+ this.mons.push({
+ item: item, ename: e, fn: o[e], scope: o.scope
+ });
+ item.on(e, o[e]);
}
}
return;
}
-
this.mons.push({
item: item, ename: ename, fn: fn, scope: scope
});
// protected, opposite of mon
mun : function(item, ename, fn, scope){
var found, mon;
+ this.createMons();
for(var i = 0, len = this.mons.length; i < len; ++i){
mon = this.mons[i];
if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
*/
Ext.BoxComponent = Ext.extend(Ext.Component, {
+ // tabTip config is used when a BoxComponent is a child of a TabPanel
+ /**
+ * @cfg {String} tabTip
+ * <p><b>Note</b>: this config is only used when this BoxComponent is a child item of a TabPanel.</p>
+ * A string to be used as innerHTML (html tags are accepted) to show in a tooltip when mousing over
+ * the associated tab selector element. {@link Ext.QuickTips}.init()
+ * must be called in order for the tips to render.
+ */
// Configs below are used for all Components when rendered by BorderLayout.
/**
* @cfg {String} region <p><b>Note</b>: this config is only used when this BoxComponent is rendered
},
// private
- onRender : function(ct, position){
- Ext.BoxComponent.superclass.onRender.call(this, ct, position);
+ afterRender : function(){
+ Ext.BoxComponent.superclass.afterRender.call(this);
if(this.resizeEl){
this.resizeEl = Ext.get(this.resizeEl);
}
if(this.positionEl){
this.positionEl = Ext.get(this.positionEl);
}
- },
-
- // private
- afterRender : function(){
- Ext.BoxComponent.superclass.afterRender.call(this);
this.boxReady = true;
this.setSize(this.width, this.height);
if(this.x || this.y){
* @type Number\r
*/\r
Ext.SplitBar.BOTTOM = 4;\r
-/**
- * @class Ext.Container
- * @extends Ext.BoxComponent
- * <p>Base class for any {@link Ext.BoxComponent} that may contain other Components. Containers handle the
- * basic behavior of containing items, namely adding, inserting and removing items.</p>
- *
- * <p>The most commonly used Container classes are {@link Ext.Panel}, {@link Ext.Window} and {@link Ext.TabPanel}.
- * If you do not need the capabilities offered by the aforementioned classes you can create a lightweight
- * Container to be encapsulated by an HTML element to your specifications by using the
- * <tt><b>{@link Ext.Component#autoEl autoEl}</b></tt> config option. This is a useful technique when creating
- * embedded {@link Ext.layout.ColumnLayout column} layouts inside {@link Ext.form.FormPanel FormPanels}
- * for example.</p>
- *
- * <p>The code below illustrates both how to explicitly create a Container, and how to implicitly
- * create one using the <b><tt>'container'</tt></b> xtype:<pre><code>
-// explicitly create a Container
-var embeddedColumns = new Ext.Container({
- autoEl: 'div', // This is the default
- layout: 'column',
- defaults: {
- // implicitly create Container by specifying xtype
- xtype: 'container',
- autoEl: 'div', // This is the default.
- layout: 'form',
- columnWidth: 0.5,
- style: {
- padding: '10px'
- }
- },
-// The two items below will be Ext.Containers, each encapsulated by a <DIV> element.
- items: [{
- items: {
- xtype: 'datefield',
- name: 'startDate',
- fieldLabel: 'Start date'
- }
- }, {
- items: {
- xtype: 'datefield',
- name: 'endDate',
- fieldLabel: 'End date'
- }
- }]
-});</code></pre></p>
- *
- * <p><u><b>Layout</b></u></p>
- * <p>Container classes delegate the rendering of child Components to a layout
- * manager class which must be configured into the Container using the
- * <code><b>{@link #layout}</b></code> configuration property.</p>
- * <p>When either specifying child <code>{@link #items}</code> of a Container,
- * or dynamically {@link #add adding} Components to a Container, remember to
- * consider how you wish the Container to arrange those child elements, and
- * whether those child elements need to be sized using one of Ext's built-in
- * <b><code>{@link #layout}</code></b> schemes. By default, Containers use the
- * {@link Ext.layout.ContainerLayout ContainerLayout} scheme which only
- * renders child components, appending them one after the other inside the
- * Container, and <b>does not apply any sizing</b> at all.</p>
- * <p>A common mistake is when a developer neglects to specify a
- * <b><code>{@link #layout}</code></b> (e.g. widgets like GridPanels or
- * TreePanels are added to Containers for which no <tt><b>{@link #layout}</b></tt>
- * has been specified). If a Container is left to use the default
- * {@link Ext.layout.ContainerLayout ContainerLayout} scheme, none of its
- * child components will be resized, or changed in any way when the Container
- * is resized.</p>
- * <p>Certain layout managers allow dynamic addition of child components.
- * Those that do include {@link Ext.layout.CardLayout},
- * {@link Ext.layout.AnchorLayout}, {@link Ext.layout.FormLayout}, and
- * {@link Ext.layout.TableLayout}. For example:<pre><code>
-// Create the GridPanel.
-var myNewGrid = new Ext.grid.GridPanel({
- store: myStore,
- columns: myColumnModel,
- title: 'Results', // the title becomes the title of the tab
-});
-
-myTabPanel.add(myNewGrid); // {@link Ext.TabPanel} implicitly uses {@link Ext.layout.CardLayout CardLayout}
-myTabPanel.{@link Ext.TabPanel#setActiveTab setActiveTab}(myNewGrid);
- * </code></pre></p>
- * <p>The example above adds a newly created GridPanel to a TabPanel. Note that
- * a TabPanel uses {@link Ext.layout.CardLayout} as its layout manager which
- * means all its child items are sized to {@link Ext.layout.FitLayout fit}
- * exactly into its client area.
- * <p><b><u>Overnesting is a common problem</u></b>.
- * An example of overnesting occurs when a GridPanel is added to a TabPanel
- * by wrapping the GridPanel <i>inside</i> a wrapping Panel (that has no
- * <tt><b>{@link #layout}</b></tt> specified) and then add that wrapping Panel
- * to the TabPanel. The point to realize is that a GridPanel <b>is</b> a
- * Component which can be added directly to a Container. If the wrapping Panel
- * has no <tt><b>{@link #layout}</b></tt> configuration, then the overnested
- * GridPanel will not be sized as expected.<p>
-</code></pre>
- *
- * <p><u><b>Adding via remote configuration</b></u></p>
- *
- * <p>A server side script can be used to add Components which are generated dynamically on the server.
- * An example of adding a GridPanel to a TabPanel where the GridPanel is generated by the server
- * based on certain parameters:
- * </p><pre><code>
-// execute an Ajax request to invoke server side script:
-Ext.Ajax.request({
- url: 'gen-invoice-grid.php',
- // send additional parameters to instruct server script
- params: {
- startDate: Ext.getCmp('start-date').getValue(),
- endDate: Ext.getCmp('end-date').getValue()
- },
- // process the response object to add it to the TabPanel:
- success: function(xhr) {
- var newComponent = eval(xhr.responseText); // see discussion below
- myTabPanel.add(newComponent); // add the component to the TabPanel
- myTabPanel.setActiveTab(newComponent);
- },
- failure: function() {
- Ext.Msg.alert("Grid create failed", "Server communication failure");
- }
-});
-</code></pre>
- * <p>The server script needs to return an executable Javascript statement which, when processed
- * using <tt>eval()</tt>, will return either a config object with an {@link Ext.Component#xtype xtype},
- * or an instantiated Component. The server might return this for example:</p><pre><code>
-(function() {
- function formatDate(value){
- return value ? value.dateFormat('M d, Y') : '';
- };
-
- var store = new Ext.data.Store({
- url: 'get-invoice-data.php',
- baseParams: {
- startDate: '01/01/2008',
- endDate: '01/31/2008'
- },
- reader: new Ext.data.JsonReader({
- record: 'transaction',
- idProperty: 'id',
- totalRecords: 'total'
- }, [
- 'customer',
- 'invNo',
- {name: 'date', type: 'date', dateFormat: 'm/d/Y'},
- {name: 'value', type: 'float'}
- ])
- });
-
- var grid = new Ext.grid.GridPanel({
- title: 'Invoice Report',
- bbar: new Ext.PagingToolbar(store),
- store: store,
- columns: [
- {header: "Customer", width: 250, dataIndex: 'customer', sortable: true},
- {header: "Invoice Number", width: 120, dataIndex: 'invNo', sortable: true},
- {header: "Invoice Date", width: 100, dataIndex: 'date', renderer: formatDate, sortable: true},
- {header: "Value", width: 120, dataIndex: 'value', renderer: 'usMoney', sortable: true}
- ],
- });
- store.load();
- return grid; // return instantiated component
-})();
-</code></pre>
- * <p>When the above code fragment is passed through the <tt>eval</tt> function in the success handler
- * of the Ajax request, the code is executed by the Javascript processor, and the anonymous function
- * runs, and returns the instantiated grid component.</p>
- * <p>Note: since the code above is <i>generated</i> by a server script, the <tt>baseParams</tt> for
- * the Store, the metadata to allow generation of the Record layout, and the ColumnModel
- * can all be generated into the code since these are all known on the server.</p>
- *
- * @xtype container
- */
-Ext.Container = Ext.extend(Ext.BoxComponent, {
- /**
- * @cfg {Boolean} monitorResize
- * True to automatically monitor window resize events to handle anything that is sensitive to the current size
- * of the viewport. This value is typically managed by the chosen <code>{@link #layout}</code> and should not need
- * to be set manually.
- */
- /**
- * @cfg {String/Object} layout
- * When creating complex UIs, it is important to remember that sizing and
- * positioning of child items is the responsibility of the Container's
- * layout manager. If you expect child items to be sized in response to
- * user interactions, <b>you must specify a layout manager</b> which
- * creates and manages the type of layout you have in mind. For example:<pre><code>
-new Ext.Window({
- width:300, height: 300,
- layout: 'fit', // explicitly set layout manager: override the default (layout:'auto')
- items: [{
- title: 'Panel inside a Window'
- }]
-}).show();
- * </code></pre>
- * <p>Omitting the {@link #layout} config means that the
- * {@link Ext.layout.ContainerLayout default layout manager} will be used which does
- * nothing but render child components sequentially into the Container (no sizing or
- * positioning will be performed in this situation).</p>
- * <p>The layout manager class for this container may be specified as either as an
- * Object or as a String:</p>
- * <div><ul class="mdetail-params">
- *
- * <li><u>Specify as an Object</u></li>
- * <div><ul class="mdetail-params">
- * <li>Example usage:</li>
-<pre><code>
-layout: {
- type: 'vbox',
- padding: '5',
- align: 'left'
-}
-</code></pre>
- *
- * <li><tt><b>type</b></tt></li>
- * <br/><p>The layout type to be used for this container. If not specified,
- * a default {@link Ext.layout.ContainerLayout} will be created and used.</p>
- * <br/><p>Valid layout <tt>type</tt> values are:</p>
- * <div class="sub-desc"><ul class="mdetail-params">
- * <li><tt><b>{@link Ext.layout.AbsoluteLayout absolute}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.AccordionLayout accordion}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.AnchorLayout anchor}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.ContainerLayout auto}</b></tt> <b>Default</b></li>
- * <li><tt><b>{@link Ext.layout.BorderLayout border}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.CardLayout card}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.ColumnLayout column}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.FitLayout fit}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.FormLayout form}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.HBoxLayout hbox}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.MenuLayout menu}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.TableLayout table}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.ToolbarLayout toolbar}</b></tt></li>
- * <li><tt><b>{@link Ext.layout.VBoxLayout vbox}</b></tt></li>
- * </ul></div>
- *
- * <li>Layout specific configuration properties</li>
- * <br/><p>Additional layout specific configuration properties may also be
- * specified. For complete details regarding the valid config options for
- * each layout type, see the layout class corresponding to the <tt>type</tt>
- * specified.</p>
- *
- * </ul></div>
- *
- * <li><u>Specify as a String</u></li>
- * <div><ul class="mdetail-params">
- * <li>Example usage:</li>
-<pre><code>
-layout: 'vbox',
-layoutConfig: {
- padding: '5',
- align: 'left'
-}
-</code></pre>
- * <li><tt><b>layout</b></tt></li>
- * <br/><p>The layout <tt>type</tt> to be used for this container (see list
- * of valid layout type values above).</p><br/>
- * <li><tt><b>{@link #layoutConfig}</b></tt></li>
- * <br/><p>Additional layout specific configuration properties. For complete
- * details regarding the valid config options for each layout type, see the
- * layout class corresponding to the <tt>layout</tt> specified.</p>
- * </ul></div></ul></div>
- */
- /**
- * @cfg {Object} layoutConfig
- * This is a config object containing properties specific to the chosen
- * <b><code>{@link #layout}</code></b> if <b><code>{@link #layout}</code></b>
- * has been specified as a <i>string</i>.</p>
- */
- /**
- * @cfg {Boolean/Number} bufferResize
- * When set to true (100 milliseconds) or a number of milliseconds, the layout assigned for this container will buffer
- * the frequency it calculates and does a re-layout of components. This is useful for heavy containers or containers
- * with a large quantity of sub-components for which frequent layout calls would be expensive.
- */
- bufferResize: 100,
-
- /**
- * @cfg {String/Number} activeItem
- * A string component id or the numeric index of the component that should be initially activated within the
- * container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first
- * item in the container's collection). activeItem only applies to layout styles that can display
- * items one at a time (like {@link Ext.layout.AccordionLayout}, {@link Ext.layout.CardLayout} and
- * {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.
- */
- /**
- * @cfg {Object/Array} items
- * <pre><b>** IMPORTANT</b>: be sure to specify a <b><code>{@link #layout}</code> ! **</b></pre>
- * <p>A single item, or an array of child Components to be added to this container,
- * for example:</p>
- * <pre><code>
-// specifying a single item
-items: {...},
-layout: 'fit', // specify a layout!
-
-// specifying multiple items
-items: [{...}, {...}],
-layout: 'anchor', // specify a layout!
- * </code></pre>
- * <p>Each item may be:</p>
- * <div><ul class="mdetail-params">
- * <li>any type of object based on {@link Ext.Component}</li>
- * <li>a fully instanciated object or</li>
- * <li>an object literal that:</li>
- * <div><ul class="mdetail-params">
- * <li>has a specified <code>{@link Ext.Component#xtype xtype}</code></li>
- * <li>the {@link Ext.Component#xtype} specified is associated with the Component
- * desired and should be chosen from one of the available xtypes as listed
- * in {@link Ext.Component}.</li>
- * <li>If an <code>{@link Ext.Component#xtype xtype}</code> is not explicitly
- * specified, the {@link #defaultType} for that Container is used.</li>
- * <li>will be "lazily instanciated", avoiding the overhead of constructing a fully
- * instanciated Component object</li>
- * </ul></div></ul></div>
- * <p><b>Notes</b>:</p>
- * <div><ul class="mdetail-params">
- * <li>Ext uses lazy rendering. Child Components will only be rendered
- * should it become necessary. Items are automatically laid out when they are first
- * shown (no sizing is done while hidden), or in response to a {@link #doLayout} call.</li>
- * <li>Do not specify <code>{@link Ext.Panel#contentEl contentEl}</code>/
- * <code>{@link Ext.Panel#html html}</code> with <code>items</code>.</li>
- * </ul></div>
- */
- /**
- * @cfg {Object} defaults
- * <p>A config object that will be applied to all components added to this container either via the {@link #items}
- * config or via the {@link #add} or {@link #insert} methods. The <tt>defaults</tt> config can contain any
- * number of name/value property pairs to be added to each item, and should be valid for the types of items
- * being added to the container. For example, to automatically apply padding to the body of each of a set of
- * contained {@link Ext.Panel} items, you could pass: <tt>defaults: {bodyStyle:'padding:15px'}</tt>.</p><br/>
- * <p><b>Note</b>: <tt>defaults</tt> will not be applied to config objects if the option is already specified.
- * For example:</p><pre><code>
-defaults: { // defaults are applied to items, not the container
- autoScroll:true
-},
-items: [
- {
- xtype: 'panel', // defaults <b>do not</b> have precedence over
- id: 'panel1', // options in config objects, so the defaults
- autoScroll: false // will not be applied here, panel1 will be autoScroll:false
- },
- new Ext.Panel({ // defaults <b>do</b> have precedence over options
- id: 'panel2', // options in components, so the defaults
- autoScroll: false // will be applied here, panel2 will be autoScroll:true.
- })
-]
- * </code></pre>
- */
-
-
- /** @cfg {Boolean} autoDestroy
- * If true the container will automatically destroy any contained component that is removed from it, else
- * destruction must be handled manually (defaults to true).
- */
- autoDestroy : true,
-
- /** @cfg {Boolean} forceLayout
- * If true the container will force a layout initially even if hidden or collapsed. This option
- * is useful for forcing forms to render in collapsed or hidden containers. (defaults to false).
- */
- forceLayout: false,
-
- /** @cfg {Boolean} hideBorders
- * True to hide the borders of each contained component, false to defer to the component's existing
- * border settings (defaults to false).
- */
- /** @cfg {String} defaultType
- * <p>The default {@link Ext.Component xtype} of child Components to create in this Container when
- * a child item is specified as a raw configuration object, rather than as an instantiated Component.</p>
- * <p>Defaults to <tt>'panel'</tt>, except {@link Ext.menu.Menu} which defaults to <tt>'menuitem'</tt>,
- * and {@link Ext.Toolbar} and {@link Ext.ButtonGroup} which default to <tt>'button'</tt>.</p>
- */
- defaultType : 'panel',
-
- // private
- initComponent : function(){
- Ext.Container.superclass.initComponent.call(this);
-
- this.addEvents(
- /**
- * @event afterlayout
- * Fires when the components in this container are arranged by the associated layout manager.
- * @param {Ext.Container} this
- * @param {ContainerLayout} layout The ContainerLayout implementation for this container
- */
- 'afterlayout',
- /**
- * @event beforeadd
- * Fires before any {@link Ext.Component} is added or inserted into the container.
- * A handler can return false to cancel the add.
- * @param {Ext.Container} this
- * @param {Ext.Component} component The component being added
- * @param {Number} index The index at which the component will be added to the container's items collection
- */
- 'beforeadd',
- /**
- * @event beforeremove
- * Fires before any {@link Ext.Component} is removed from the container. A handler can return
- * false to cancel the remove.
- * @param {Ext.Container} this
- * @param {Ext.Component} component The component being removed
- */
- 'beforeremove',
- /**
- * @event add
- * @bubbles
- * Fires after any {@link Ext.Component} is added or inserted into the container.
- * @param {Ext.Container} this
- * @param {Ext.Component} component The component that was added
- * @param {Number} index The index at which the component was added to the container's items collection
- */
- 'add',
- /**
- * @event remove
- * @bubbles
- * Fires after any {@link Ext.Component} is removed from the container.
- * @param {Ext.Container} this
- * @param {Ext.Component} component The component that was removed
- */
- 'remove'
- );
-
- this.enableBubble('add', 'remove');
-
- /**
- * The collection of components in this container as a {@link Ext.util.MixedCollection}
- * @type MixedCollection
- * @property items
- */
- var items = this.items;
- if(items){
- delete this.items;
- if(Ext.isArray(items) && items.length > 0){
- this.add.apply(this, items);
- }else{
- this.add(items);
- }
- }
- },
-
- // private
- initItems : function(){
- if(!this.items){
- this.items = new Ext.util.MixedCollection(false, this.getComponentId);
- this.getLayout(); // initialize the layout
- }
- },
-
- // private
- setLayout : function(layout){
- if(this.layout && this.layout != layout){
- this.layout.setContainer(null);
- }
- this.initItems();
- this.layout = layout;
- layout.setContainer(this);
- },
-
- // private
- render : function(){
- Ext.Container.superclass.render.apply(this, arguments);
- if(this.layout){
- if(Ext.isObject(this.layout) && !this.layout.layout){
- this.layoutConfig = this.layout;
- this.layout = this.layoutConfig.type;
- }
- if(typeof this.layout == 'string'){
- this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
- }
- this.setLayout(this.layout);
-
- if(this.activeItem !== undefined){
- var item = this.activeItem;
- delete this.activeItem;
- this.layout.setActiveItem(item);
- }
- }
- if(!this.ownerCt){
- // force a layout if no ownerCt is set
- this.doLayout(false, true);
- }
- if(this.monitorResize === true){
- Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
- }
- },
-
- /**
- * <p>Returns the Element to be used to contain the child Components of this Container.</p>
- * <p>An implementation is provided which returns the Container's {@link #getEl Element}, but
- * if there is a more complex structure to a Container, this may be overridden to return
- * the element into which the {@link #layout layout} renders child Components.</p>
- * @return {Ext.Element} The Element to render child Components into.
- */
- getLayoutTarget : function(){
- return this.el;
- },
-
- // private - used as the key lookup function for the items collection
- getComponentId : function(comp){
- return comp.getItemId();
- },
-
- /**
- * <p>Adds {@link Ext.Component Component}(s) to this Container.</p>
- * <br><p><b>Description</b></u> :
- * <div><ul class="mdetail-params">
- * <li>Fires the {@link #beforeadd} event before adding</li>
- * <li>The Container's {@link #defaults default config values} will be applied
- * accordingly (see <code>{@link #defaults}</code> for details).</li>
- * <li>Fires the {@link #add} event after the component has been added.</li>
- * </ul></div>
- * <br><p><b>Notes</b></u> :
- * <div><ul class="mdetail-params">
- * <li>If the Container is <i>already rendered</i> when <tt>add</tt>
- * is called, you may need to call {@link #doLayout} to refresh the view which causes
- * any unrendered child Components to be rendered. This is required so that you can
- * <tt>add</tt> multiple child components if needed while only refreshing the layout
- * once. For example:<pre><code>
-var tb = new {@link Ext.Toolbar}();
-tb.render(document.body); // toolbar is rendered
-tb.add({text:'Button 1'}); // add multiple items ({@link #defaultType} for {@link Ext.Toolbar Toolbar} is 'button')
-tb.add({text:'Button 2'});
-tb.{@link #doLayout}(); // refresh the layout
- * </code></pre></li>
- * <li><i>Warning:</i> Containers directly managed by the BorderLayout layout manager
- * may not be removed or added. See the Notes for {@link Ext.layout.BorderLayout BorderLayout}
- * for more details.</li>
- * </ul></div>
- * @param {Object/Array} component
- * <p>Either a single component or an Array of components to add. See
- * <code>{@link #items}</code> for additional information.</p>
- * @param {Object} (Optional) component_2
- * @param {Object} (Optional) component_n
- * @return {Ext.Component} component The Component (or config object) that was added.
- */
- add : function(comp){
- this.initItems();
- var args = arguments.length > 1;
- if(args || Ext.isArray(comp)){
- Ext.each(args ? arguments : comp, function(c){
- this.add(c);
- }, this);
- return;
- }
- var c = this.lookupComponent(this.applyDefaults(comp));
- var pos = this.items.length;
- if(this.fireEvent('beforeadd', this, c, pos) !== false && this.onBeforeAdd(c) !== false){
- this.items.add(c);
- c.ownerCt = this;
- this.fireEvent('add', this, c, pos);
- }
- return c;
- },
-
- /**
- * Inserts a Component into this Container at a specified index. Fires the
- * {@link #beforeadd} event before inserting, then fires the {@link #add} event after the
- * Component has been inserted.
- * @param {Number} index The index at which the Component will be inserted
- * into the Container's items collection
- * @param {Ext.Component} component The child Component to insert.<br><br>
- * Ext uses lazy rendering, and will only render the inserted Component should
- * it become necessary.<br><br>
- * A Component config object may be passed in order to avoid the overhead of
- * constructing a real Component object if lazy rendering might mean that the
- * inserted Component will not be rendered immediately. To take advantage of
- * this 'lazy instantiation', set the {@link Ext.Component#xtype} config
- * property to the registered type of the Component wanted.<br><br>
- * For a list of all available xtypes, see {@link Ext.Component}.
- * @return {Ext.Component} component The Component (or config object) that was
- * inserted with the Container's default config values applied.
- */
- insert : function(index, comp){
- this.initItems();
- var a = arguments, len = a.length;
- if(len > 2){
- for(var i = len-1; i >= 1; --i) {
- this.insert(index, a[i]);
- }
- return;
- }
- var c = this.lookupComponent(this.applyDefaults(comp));
-
- if(c.ownerCt == this && this.items.indexOf(c) < index){
- --index;
- }
-
- if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
- this.items.insert(index, c);
- c.ownerCt = this;
- this.fireEvent('add', this, c, index);
- }
- return c;
- },
-
- // private
- applyDefaults : function(c){
- if(this.defaults){
- if(typeof c == 'string'){
- c = Ext.ComponentMgr.get(c);
- Ext.apply(c, this.defaults);
- }else if(!c.events){
- Ext.applyIf(c, this.defaults);
- }else{
- Ext.apply(c, this.defaults);
- }
- }
- return c;
- },
-
- // private
- onBeforeAdd : function(item){
- if(item.ownerCt){
- item.ownerCt.remove(item, false);
- }
- if(this.hideBorders === true){
- item.border = (item.border === true);
- }
- },
-
- /**
- * Removes a component from this container. Fires the {@link #beforeremove} event before removing, then fires
- * the {@link #remove} event after the component has been removed.
- * @param {Component/String} component The component reference or id to remove.
- * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.
- * Defaults to the value of this Container's {@link #autoDestroy} config.
- * @return {Ext.Component} component The Component that was removed.
- */
- remove : function(comp, autoDestroy){
- this.initItems();
- var c = this.getComponent(comp);
- if(c && this.fireEvent('beforeremove', this, c) !== false){
- this.items.remove(c);
- delete c.ownerCt;
- if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
- c.destroy();
- }
- if(this.layout && this.layout.activeItem == c){
- delete this.layout.activeItem;
- }
- this.fireEvent('remove', this, c);
- }
- return c;
- },
-
- /**
- * Removes all components from this container.
- * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.
- * Defaults to the value of this Container's {@link #autoDestroy} config.
- * @return {Array} Array of the destroyed components
- */
- removeAll: function(autoDestroy){
- this.initItems();
- var item, rem = [], items = [];
- this.items.each(function(i){
- rem.push(i);
- });
- for (var i = 0, len = rem.length; i < len; ++i){
- item = rem[i];
- this.remove(item, autoDestroy);
- if(item.ownerCt !== this){
- items.push(item);
- }
- }
- return items;
- },
-
- /**
- * Examines this container's <code>{@link #items}</code> <b>property</b>
- * and gets a direct child component of this container.
- * @param {String/Number} comp This parameter may be any of the following:
- * <div><ul class="mdetail-params">
- * <li>a <b><tt>String</tt></b> : representing the <code>{@link Ext.Component#itemId itemId}</code>
- * or <code>{@link Ext.Component#id id}</code> of the child component </li>
- * <li>a <b><tt>Number</tt></b> : representing the position of the child component
- * within the <code>{@link #items}</code> <b>property</b></li>
- * </ul></div>
- * <p>For additional information see {@link Ext.util.MixedCollection#get}.
- * @return Ext.Component The component (if found).
- */
- getComponent : function(comp){
- if(Ext.isObject(comp)){
- return comp;
- }
- return this.items.get(comp);
- },
-
- // private
- lookupComponent : function(comp){
- if(typeof comp == 'string'){
- return Ext.ComponentMgr.get(comp);
- }else if(!comp.events){
- return this.createComponent(comp);
- }
- return comp;
- },
-
- // private
- createComponent : function(config){
- return Ext.create(config, this.defaultType);
- },
-
- /**
- * Force this container's layout to be recalculated. A call to this function is required after adding a new component
- * to an already rendered container, or possibly after changing sizing/position properties of child components.
- * @param {Boolean} shallow (optional) True to only calc the layout of this component, and let child components auto
- * calc layouts as required (defaults to false, which calls doLayout recursively for each subcontainer)
- * @param {Boolean} force (optional) True to force a layout to occur, even if the item is hidden.
- * @return {Ext.Container} this
- */
- doLayout: function(shallow, force){
- var rendered = this.rendered,
- forceLayout = this.forceLayout;
-
- if(!this.isVisible() || this.collapsed){
- this.deferLayout = this.deferLayout || !shallow;
- if(!(force || forceLayout)){
- return;
- }
- shallow = shallow && !this.deferLayout;
- } else {
- delete this.deferLayout;
- }
- if(rendered && this.layout){
- this.layout.layout();
- }
- if(shallow !== true && this.items){
- var cs = this.items.items;
- for(var i = 0, len = cs.length; i < len; i++){
- var c = cs[i];
- if(c.doLayout){
- c.forceLayout = forceLayout;
- c.doLayout();
- }
- }
- }
- if(rendered){
- this.onLayout(shallow, force);
- }
- delete this.forceLayout;
- },
-
- //private
- onLayout : Ext.emptyFn,
-
- onShow : function(){
- Ext.Container.superclass.onShow.call(this);
- if(this.deferLayout !== undefined){
- this.doLayout(true);
- }
- },
-
- /**
- * Returns the layout currently in use by the container. If the container does not currently have a layout
- * set, a default {@link Ext.layout.ContainerLayout} will be created and set as the container's layout.
- * @return {ContainerLayout} layout The container's layout
- */
- getLayout : function(){
- if(!this.layout){
- var layout = new Ext.layout.ContainerLayout(this.layoutConfig);
- this.setLayout(layout);
- }
- return this.layout;
- },
-
- // private
- beforeDestroy : function(){
- if(this.items){
- Ext.destroy.apply(Ext, this.items.items);
- }
- if(this.monitorResize){
- Ext.EventManager.removeResizeListener(this.doLayout, this);
- }
- Ext.destroy(this.layout);
- Ext.Container.superclass.beforeDestroy.call(this);
- },
-
- /**
- * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope (<i>this</i>) of
- * function call will be the scope provided or the current component. The arguments to the function
- * will be the args provided or the current component. If the function returns false at any point,
- * the bubble is stopped.
- * @param {Function} fn The function to call
- * @param {Object} scope (optional) The scope of the function (defaults to current node)
- * @param {Array} args (optional) The args to call the function with (default to passing the current component)
- * @return {Ext.Container} this
- */
- bubble : function(fn, scope, args){
- var p = this;
- while(p){
- if(fn.apply(scope || p, args || [p]) === false){
- break;
- }
- p = p.ownerCt;
- }
- return this;
- },
-
- /**
- * Cascades down the component/container heirarchy from this component (called first), calling the specified function with
- * each component. The scope (<i>this</i>) of
- * function call will be the scope provided or the current component. The arguments to the function
- * will be the args provided or the current component. If the function returns false at any point,
- * the cascade is stopped on that branch.
- * @param {Function} fn The function to call
- * @param {Object} scope (optional) The scope of the function (defaults to current component)
- * @param {Array} args (optional) The args to call the function with (defaults to passing the current component)
- * @return {Ext.Container} this
- */
- cascade : function(fn, scope, args){
- if(fn.apply(scope || this, args || [this]) !== false){
- if(this.items){
- var cs = this.items.items;
- for(var i = 0, len = cs.length; i < len; i++){
- if(cs[i].cascade){
- cs[i].cascade(fn, scope, args);
- }else{
- fn.apply(scope || cs[i], args || [cs[i]]);
- }
- }
- }
- }
- return this;
- },
-
- /**
- * Find a component under this container at any level by id
- * @param {String} id
- * @return Ext.Component
- */
- findById : function(id){
- var m, ct = this;
- this.cascade(function(c){
- if(ct != c && c.id === id){
- m = c;
- return false;
- }
- });
- return m || null;
- },
-
- /**
- * Find a component under this container at any level by xtype or class
- * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
- * @param {Boolean} shallow (optional) False to check whether this Component is descended from the xtype (this is
- * the default), or true to check whether this Component is directly of the specified xtype.
- * @return {Array} Array of Ext.Components
- */
- findByType : function(xtype, shallow){
- return this.findBy(function(c){
- return c.isXType(xtype, shallow);
- });
- },
-
- /**
- * Find a component under this container at any level by property
- * @param {String} prop
- * @param {String} value
- * @return {Array} Array of Ext.Components
- */
- find : function(prop, value){
- return this.findBy(function(c){
- return c[prop] === value;
- });
- },
-
- /**
- * Find a component under this container at any level by a custom function. If the passed function returns
- * true, the component will be included in the results. The passed function is called with the arguments (component, this container).
- * @param {Function} fn The function to call
- * @param {Object} scope (optional)
- * @return {Array} Array of Ext.Components
- */
- findBy : function(fn, scope){
- var m = [], ct = this;
- this.cascade(function(c){
- if(ct != c && fn.call(scope || c, c, ct) === true){
- m.push(c);
- }
- });
- return m;
- },
-
- /**
- * Get a component contained by this container (alias for items.get(key))
- * @param {String/Number} key The index or id of the component
- * @return {Ext.Component} Ext.Component
- */
- get : function(key){
- return this.items.get(key);
- }
-});
-
-Ext.Container.LAYOUTS = {};
-Ext.reg('container', Ext.Container);
+/**\r
+ * @class Ext.Container\r
+ * @extends Ext.BoxComponent\r
+ * <p>Base class for any {@link Ext.BoxComponent} that may contain other Components. Containers handle the\r
+ * basic behavior of containing items, namely adding, inserting and removing items.</p>\r
+ *\r
+ * <p>The most commonly used Container classes are {@link Ext.Panel}, {@link Ext.Window} and {@link Ext.TabPanel}.\r
+ * If you do not need the capabilities offered by the aforementioned classes you can create a lightweight\r
+ * Container to be encapsulated by an HTML element to your specifications by using the\r
+ * <tt><b>{@link Ext.Component#autoEl autoEl}</b></tt> config option. This is a useful technique when creating\r
+ * embedded {@link Ext.layout.ColumnLayout column} layouts inside {@link Ext.form.FormPanel FormPanels}\r
+ * for example.</p>\r
+ *\r
+ * <p>The code below illustrates both how to explicitly create a Container, and how to implicitly\r
+ * create one using the <b><tt>'container'</tt></b> xtype:<pre><code>\r
+// explicitly create a Container\r
+var embeddedColumns = new Ext.Container({\r
+ autoEl: 'div', // This is the default\r
+ layout: 'column',\r
+ defaults: {\r
+ // implicitly create Container by specifying xtype\r
+ xtype: 'container',\r
+ autoEl: 'div', // This is the default.\r
+ layout: 'form',\r
+ columnWidth: 0.5,\r
+ style: {\r
+ padding: '10px'\r
+ }\r
+ },\r
+// The two items below will be Ext.Containers, each encapsulated by a <DIV> element.\r
+ items: [{\r
+ items: {\r
+ xtype: 'datefield',\r
+ name: 'startDate',\r
+ fieldLabel: 'Start date'\r
+ }\r
+ }, {\r
+ items: {\r
+ xtype: 'datefield',\r
+ name: 'endDate',\r
+ fieldLabel: 'End date'\r
+ }\r
+ }]\r
+});</code></pre></p>\r
+ *\r
+ * <p><u><b>Layout</b></u></p>\r
+ * <p>Container classes delegate the rendering of child Components to a layout\r
+ * manager class which must be configured into the Container using the\r
+ * <code><b>{@link #layout}</b></code> configuration property.</p>\r
+ * <p>When either specifying child <code>{@link #items}</code> of a Container,\r
+ * or dynamically {@link #add adding} Components to a Container, remember to\r
+ * consider how you wish the Container to arrange those child elements, and\r
+ * whether those child elements need to be sized using one of Ext's built-in\r
+ * <b><code>{@link #layout}</code></b> schemes. By default, Containers use the\r
+ * {@link Ext.layout.ContainerLayout ContainerLayout} scheme which only\r
+ * renders child components, appending them one after the other inside the\r
+ * Container, and <b>does not apply any sizing</b> at all.</p>\r
+ * <p>A common mistake is when a developer neglects to specify a\r
+ * <b><code>{@link #layout}</code></b> (e.g. widgets like GridPanels or\r
+ * TreePanels are added to Containers for which no <tt><b>{@link #layout}</b></tt>\r
+ * has been specified). If a Container is left to use the default\r
+ * {@link Ext.layout.ContainerLayout ContainerLayout} scheme, none of its\r
+ * child components will be resized, or changed in any way when the Container\r
+ * is resized.</p>\r
+ * <p>Certain layout managers allow dynamic addition of child components.\r
+ * Those that do include {@link Ext.layout.CardLayout},\r
+ * {@link Ext.layout.AnchorLayout}, {@link Ext.layout.FormLayout}, and\r
+ * {@link Ext.layout.TableLayout}. For example:<pre><code>\r
+// Create the GridPanel.\r
+var myNewGrid = new Ext.grid.GridPanel({\r
+ store: myStore,\r
+ columns: myColumnModel,\r
+ title: 'Results', // the title becomes the title of the tab\r
+});\r
+\r
+myTabPanel.add(myNewGrid); // {@link Ext.TabPanel} implicitly uses {@link Ext.layout.CardLayout CardLayout}\r
+myTabPanel.{@link Ext.TabPanel#setActiveTab setActiveTab}(myNewGrid);\r
+ * </code></pre></p>\r
+ * <p>The example above adds a newly created GridPanel to a TabPanel. Note that\r
+ * a TabPanel uses {@link Ext.layout.CardLayout} as its layout manager which\r
+ * means all its child items are sized to {@link Ext.layout.FitLayout fit}\r
+ * exactly into its client area.\r
+ * <p><b><u>Overnesting is a common problem</u></b>.\r
+ * An example of overnesting occurs when a GridPanel is added to a TabPanel\r
+ * by wrapping the GridPanel <i>inside</i> a wrapping Panel (that has no\r
+ * <tt><b>{@link #layout}</b></tt> specified) and then add that wrapping Panel\r
+ * to the TabPanel. The point to realize is that a GridPanel <b>is</b> a\r
+ * Component which can be added directly to a Container. If the wrapping Panel\r
+ * has no <tt><b>{@link #layout}</b></tt> configuration, then the overnested\r
+ * GridPanel will not be sized as expected.<p>\r
+ *\r
+ * <p><u><b>Adding via remote configuration</b></u></p>\r
+ *\r
+ * <p>A server side script can be used to add Components which are generated dynamically on the server.\r
+ * An example of adding a GridPanel to a TabPanel where the GridPanel is generated by the server\r
+ * based on certain parameters:\r
+ * </p><pre><code>\r
+// execute an Ajax request to invoke server side script:\r
+Ext.Ajax.request({\r
+ url: 'gen-invoice-grid.php',\r
+ // send additional parameters to instruct server script\r
+ params: {\r
+ startDate: Ext.getCmp('start-date').getValue(),\r
+ endDate: Ext.getCmp('end-date').getValue()\r
+ },\r
+ // process the response object to add it to the TabPanel:\r
+ success: function(xhr) {\r
+ var newComponent = eval(xhr.responseText); // see discussion below\r
+ myTabPanel.add(newComponent); // add the component to the TabPanel\r
+ myTabPanel.setActiveTab(newComponent);\r
+ },\r
+ failure: function() {\r
+ Ext.Msg.alert("Grid create failed", "Server communication failure");\r
+ }\r
+});\r
+</code></pre>\r
+ * <p>The server script needs to return an executable Javascript statement which, when processed\r
+ * using <tt>eval()</tt>, will return either a config object with an {@link Ext.Component#xtype xtype},\r
+ * or an instantiated Component. The server might return this for example:</p><pre><code>\r
+(function() {\r
+ function formatDate(value){\r
+ return value ? value.dateFormat('M d, Y') : '';\r
+ };\r
+\r
+ var store = new Ext.data.Store({\r
+ url: 'get-invoice-data.php',\r
+ baseParams: {\r
+ startDate: '01/01/2008',\r
+ endDate: '01/31/2008'\r
+ },\r
+ reader: new Ext.data.JsonReader({\r
+ record: 'transaction',\r
+ idProperty: 'id',\r
+ totalRecords: 'total'\r
+ }, [\r
+ 'customer',\r
+ 'invNo',\r
+ {name: 'date', type: 'date', dateFormat: 'm/d/Y'},\r
+ {name: 'value', type: 'float'}\r
+ ])\r
+ });\r
+\r
+ var grid = new Ext.grid.GridPanel({\r
+ title: 'Invoice Report',\r
+ bbar: new Ext.PagingToolbar(store),\r
+ store: store,\r
+ columns: [\r
+ {header: "Customer", width: 250, dataIndex: 'customer', sortable: true},\r
+ {header: "Invoice Number", width: 120, dataIndex: 'invNo', sortable: true},\r
+ {header: "Invoice Date", width: 100, dataIndex: 'date', renderer: formatDate, sortable: true},\r
+ {header: "Value", width: 120, dataIndex: 'value', renderer: 'usMoney', sortable: true}\r
+ ],\r
+ });\r
+ store.load();\r
+ return grid; // return instantiated component\r
+})();\r
+</code></pre>\r
+ * <p>When the above code fragment is passed through the <tt>eval</tt> function in the success handler\r
+ * of the Ajax request, the code is executed by the Javascript processor, and the anonymous function\r
+ * runs, and returns the instantiated grid component.</p>\r
+ * <p>Note: since the code above is <i>generated</i> by a server script, the <tt>baseParams</tt> for\r
+ * the Store, the metadata to allow generation of the Record layout, and the ColumnModel\r
+ * can all be generated into the code since these are all known on the server.</p>\r
+ *\r
+ * @xtype container\r
+ */\r
+Ext.Container = Ext.extend(Ext.BoxComponent, {\r
+ /**\r
+ * @cfg {Boolean} monitorResize\r
+ * True to automatically monitor window resize events to handle anything that is sensitive to the current size\r
+ * of the viewport. This value is typically managed by the chosen <code>{@link #layout}</code> and should not need\r
+ * to be set manually.\r
+ */\r
+ /**\r
+ * @cfg {String/Object} layout\r
+ * <p><b>*Important</b>: In order for child items to be correctly sized and\r
+ * positioned, typically a layout manager <b>must</b> be specified through\r
+ * the <code>layout</code> configuration option.</p>\r
+ * <br><p>The sizing and positioning of child {@link items} is the responsibility of\r
+ * the Container's layout manager which creates and manages the type of layout\r
+ * you have in mind. For example:</p><pre><code>\r
+new Ext.Window({\r
+ width:300, height: 300,\r
+ layout: 'fit', // explicitly set layout manager: override the default (layout:'auto')\r
+ items: [{\r
+ title: 'Panel inside a Window'\r
+ }]\r
+}).show();\r
+ * </code></pre>\r
+ * <p>If the {@link #layout} configuration is not explicitly specified for\r
+ * a general purpose container (e.g. Container or Panel) the\r
+ * {@link Ext.layout.ContainerLayout default layout manager} will be used\r
+ * which does nothing but render child components sequentially into the\r
+ * Container (no sizing or positioning will be performed in this situation).\r
+ * Some container classes implicitly specify a default layout\r
+ * (e.g. FormPanel specifies <code>layout:'form'</code>). Other specific\r
+ * purpose classes internally specify/manage their internal layout (e.g.\r
+ * GridPanel, TabPanel, TreePanel, Toolbar, Menu, etc.).</p>\r
+ * <br><p><b><code>layout</code></b> may be specified as either as an Object or\r
+ * as a String:</p><div><ul class="mdetail-params">\r
+ *\r
+ * <li><u>Specify as an Object</u></li>\r
+ * <div><ul class="mdetail-params">\r
+ * <li>Example usage:</li>\r
+<pre><code>\r
+layout: {\r
+ type: 'vbox',\r
+ padding: '5',\r
+ align: 'left'\r
+}\r
+</code></pre>\r
+ *\r
+ * <li><tt><b>type</b></tt></li>\r
+ * <br/><p>The layout type to be used for this container. If not specified,\r
+ * a default {@link Ext.layout.ContainerLayout} will be created and used.</p>\r
+ * <br/><p>Valid layout <tt>type</tt> values are:</p>\r
+ * <div class="sub-desc"><ul class="mdetail-params">\r
+ * <li><tt><b>{@link Ext.layout.AbsoluteLayout absolute}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.AccordionLayout accordion}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.AnchorLayout anchor}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.ContainerLayout auto}</b></tt> <b>Default</b></li>\r
+ * <li><tt><b>{@link Ext.layout.BorderLayout border}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.CardLayout card}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.ColumnLayout column}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.FitLayout fit}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.FormLayout form}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.HBoxLayout hbox}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.MenuLayout menu}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.TableLayout table}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.ToolbarLayout toolbar}</b></tt></li>\r
+ * <li><tt><b>{@link Ext.layout.VBoxLayout vbox}</b></tt></li>\r
+ * </ul></div>\r
+ *\r
+ * <li>Layout specific configuration properties</li>\r
+ * <br/><p>Additional layout specific configuration properties may also be\r
+ * specified. For complete details regarding the valid config options for\r
+ * each layout type, see the layout class corresponding to the <tt>type</tt>\r
+ * specified.</p>\r
+ *\r
+ * </ul></div>\r
+ *\r
+ * <li><u>Specify as a String</u></li>\r
+ * <div><ul class="mdetail-params">\r
+ * <li>Example usage:</li>\r
+<pre><code>\r
+layout: 'vbox',\r
+layoutConfig: {\r
+ padding: '5',\r
+ align: 'left'\r
+}\r
+</code></pre>\r
+ * <li><tt><b>layout</b></tt></li>\r
+ * <br/><p>The layout <tt>type</tt> to be used for this container (see list\r
+ * of valid layout type values above).</p><br/>\r
+ * <li><tt><b>{@link #layoutConfig}</b></tt></li>\r
+ * <br/><p>Additional layout specific configuration properties. For complete\r
+ * details regarding the valid config options for each layout type, see the\r
+ * layout class corresponding to the <tt>layout</tt> specified.</p>\r
+ * </ul></div></ul></div>\r
+ */\r
+ /**\r
+ * @cfg {Object} layoutConfig\r
+ * This is a config object containing properties specific to the chosen\r
+ * <b><code>{@link #layout}</code></b> if <b><code>{@link #layout}</code></b>\r
+ * has been specified as a <i>string</i>.</p>\r
+ */\r
+ /**\r
+ * @cfg {Boolean/Number} bufferResize\r
+ * When set to true (50 milliseconds) or a number of milliseconds, the layout assigned for this container will buffer\r
+ * the frequency it calculates and does a re-layout of components. This is useful for heavy containers or containers\r
+ * with a large quantity of sub-components for which frequent layout calls would be expensive. Defaults to <tt>50</tt>.\r
+ */\r
+ bufferResize: 50,\r
+\r
+ /**\r
+ * @cfg {String/Number} activeItem\r
+ * A string component id or the numeric index of the component that should be initially activated within the\r
+ * container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first\r
+ * item in the container's collection). activeItem only applies to layout styles that can display\r
+ * items one at a time (like {@link Ext.layout.AccordionLayout}, {@link Ext.layout.CardLayout} and\r
+ * {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.\r
+ */\r
+ /**\r
+ * @cfg {Object/Array} items\r
+ * <pre><b>** IMPORTANT</b>: be sure to <b>{@link #layout specify a <code>layout</code>} if needed ! **</b></pre>\r
+ * <p>A single item, or an array of child Components to be added to this container,\r
+ * for example:</p>\r
+ * <pre><code>\r
+// specifying a single item\r
+items: {...},\r
+layout: 'fit', // specify a layout!\r
+\r
+// specifying multiple items\r
+items: [{...}, {...}],\r
+layout: 'anchor', // specify a layout!\r
+ * </code></pre>\r
+ * <p>Each item may be:</p>\r
+ * <div><ul class="mdetail-params">\r
+ * <li>any type of object based on {@link Ext.Component}</li>\r
+ * <li>a fully instanciated object or</li>\r
+ * <li>an object literal that:</li>\r
+ * <div><ul class="mdetail-params">\r
+ * <li>has a specified <code>{@link Ext.Component#xtype xtype}</code></li>\r
+ * <li>the {@link Ext.Component#xtype} specified is associated with the Component\r
+ * desired and should be chosen from one of the available xtypes as listed\r
+ * in {@link Ext.Component}.</li>\r
+ * <li>If an <code>{@link Ext.Component#xtype xtype}</code> is not explicitly\r
+ * specified, the {@link #defaultType} for that Container is used.</li>\r
+ * <li>will be "lazily instanciated", avoiding the overhead of constructing a fully\r
+ * instanciated Component object</li>\r
+ * </ul></div></ul></div>\r
+ * <p><b>Notes</b>:</p>\r
+ * <div><ul class="mdetail-params">\r
+ * <li>Ext uses lazy rendering. Child Components will only be rendered\r
+ * should it become necessary. Items are automatically laid out when they are first\r
+ * shown (no sizing is done while hidden), or in response to a {@link #doLayout} call.</li>\r
+ * <li>Do not specify <code>{@link Ext.Panel#contentEl contentEl}</code>/\r
+ * <code>{@link Ext.Panel#html html}</code> with <code>items</code>.</li>\r
+ * </ul></div>\r
+ */\r
+ /**\r
+ * @cfg {Object} defaults\r
+ * <p>A config object that will be applied to all components added to this container either via the {@link #items}\r
+ * config or via the {@link #add} or {@link #insert} methods. The <tt>defaults</tt> config can contain any\r
+ * number of name/value property pairs to be added to each item, and should be valid for the types of items\r
+ * being added to the container. For example, to automatically apply padding to the body of each of a set of\r
+ * contained {@link Ext.Panel} items, you could pass: <tt>defaults: {bodyStyle:'padding:15px'}</tt>.</p><br/>\r
+ * <p><b>Note</b>: <tt>defaults</tt> will not be applied to config objects if the option is already specified.\r
+ * For example:</p><pre><code>\r
+defaults: { // defaults are applied to items, not the container\r
+ autoScroll:true\r
+},\r
+items: [\r
+ {\r
+ xtype: 'panel', // defaults <b>do not</b> have precedence over\r
+ id: 'panel1', // options in config objects, so the defaults\r
+ autoScroll: false // will not be applied here, panel1 will be autoScroll:false\r
+ },\r
+ new Ext.Panel({ // defaults <b>do</b> have precedence over options\r
+ id: 'panel2', // options in components, so the defaults\r
+ autoScroll: false // will be applied here, panel2 will be autoScroll:true.\r
+ })\r
+]\r
+ * </code></pre>\r
+ */\r
+\r
+\r
+ /** @cfg {Boolean} autoDestroy\r
+ * If true the container will automatically destroy any contained component that is removed from it, else\r
+ * destruction must be handled manually (defaults to true).\r
+ */\r
+ autoDestroy : true,\r
+\r
+ /** @cfg {Boolean} forceLayout\r
+ * If true the container will force a layout initially even if hidden or collapsed. This option\r
+ * is useful for forcing forms to render in collapsed or hidden containers. (defaults to false).\r
+ */\r
+ forceLayout: false,\r
+\r
+ /** @cfg {Boolean} hideBorders\r
+ * True to hide the borders of each contained component, false to defer to the component's existing\r
+ * border settings (defaults to false).\r
+ */\r
+ /** @cfg {String} defaultType\r
+ * <p>The default {@link Ext.Component xtype} of child Components to create in this Container when\r
+ * a child item is specified as a raw configuration object, rather than as an instantiated Component.</p>\r
+ * <p>Defaults to <tt>'panel'</tt>, except {@link Ext.menu.Menu} which defaults to <tt>'menuitem'</tt>,\r
+ * and {@link Ext.Toolbar} and {@link Ext.ButtonGroup} which default to <tt>'button'</tt>.</p>\r
+ */\r
+ defaultType : 'panel',\r
+\r
+ /** @cfg {String} resizeEvent\r
+ * The event to listen to for resizing in layouts. Defaults to <tt>'resize'</tt>.\r
+ */\r
+ resizeEvent: 'resize',\r
+ \r
+ /**\r
+ * @cfg {Array} bubbleEvents\r
+ * <p>An array of events that, when fired, should be bubbled to any parent container.\r
+ * Defaults to <tt>['add', 'remove']</tt>.\r
+ */\r
+ bubbleEvents: ['add', 'remove'],\r
+\r
+ // private\r
+ initComponent : function(){\r
+ Ext.Container.superclass.initComponent.call(this);\r
+\r
+ this.addEvents(\r
+ /**\r
+ * @event afterlayout\r
+ * Fires when the components in this container are arranged by the associated layout manager.\r
+ * @param {Ext.Container} this\r
+ * @param {ContainerLayout} layout The ContainerLayout implementation for this container\r
+ */\r
+ 'afterlayout',\r
+ /**\r
+ * @event beforeadd\r
+ * Fires before any {@link Ext.Component} is added or inserted into the container.\r
+ * A handler can return false to cancel the add.\r
+ * @param {Ext.Container} this\r
+ * @param {Ext.Component} component The component being added\r
+ * @param {Number} index The index at which the component will be added to the container's items collection\r
+ */\r
+ 'beforeadd',\r
+ /**\r
+ * @event beforeremove\r
+ * Fires before any {@link Ext.Component} is removed from the container. A handler can return\r
+ * false to cancel the remove.\r
+ * @param {Ext.Container} this\r
+ * @param {Ext.Component} component The component being removed\r
+ */\r
+ 'beforeremove',\r
+ /**\r
+ * @event add\r
+ * @bubbles\r
+ * Fires after any {@link Ext.Component} is added or inserted into the container.\r
+ * @param {Ext.Container} this\r
+ * @param {Ext.Component} component The component that was added\r
+ * @param {Number} index The index at which the component was added to the container's items collection\r
+ */\r
+ 'add',\r
+ /**\r
+ * @event remove\r
+ * @bubbles\r
+ * Fires after any {@link Ext.Component} is removed from the container.\r
+ * @param {Ext.Container} this\r
+ * @param {Ext.Component} component The component that was removed\r
+ */\r
+ 'remove'\r
+ );\r
+\r
+ this.enableBubble(this.bubbleEvents);\r
+\r
+ /**\r
+ * The collection of components in this container as a {@link Ext.util.MixedCollection}\r
+ * @type MixedCollection\r
+ * @property items\r
+ */\r
+ var items = this.items;\r
+ if(items){\r
+ delete this.items;\r
+ this.add(items);\r
+ }\r
+ },\r
+\r
+ // private\r
+ initItems : function(){\r
+ if(!this.items){\r
+ this.items = new Ext.util.MixedCollection(false, this.getComponentId);\r
+ this.getLayout(); // initialize the layout\r
+ }\r
+ },\r
+\r
+ // private\r
+ setLayout : function(layout){\r
+ if(this.layout && this.layout != layout){\r
+ this.layout.setContainer(null);\r
+ }\r
+ this.initItems();\r
+ this.layout = layout;\r
+ layout.setContainer(this);\r
+ },\r
+\r
+ afterRender: function(){\r
+ Ext.Container.superclass.afterRender.call(this);\r
+ if(!this.layout){\r
+ this.layout = 'auto';\r
+ }\r
+ if(Ext.isObject(this.layout) && !this.layout.layout){\r
+ this.layoutConfig = this.layout;\r
+ this.layout = this.layoutConfig.type;\r
+ }\r
+ if(Ext.isString(this.layout)){\r
+ this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);\r
+ }\r
+ this.setLayout(this.layout);\r
+\r
+ if(this.activeItem !== undefined){\r
+ var item = this.activeItem;\r
+ delete this.activeItem;\r
+ this.layout.setActiveItem(item);\r
+ }\r
+ if(!this.ownerCt){\r
+ // force a layout if no ownerCt is set\r
+ this.doLayout(false, true);\r
+ }\r
+ if(this.monitorResize === true){\r
+ Ext.EventManager.onWindowResize(this.doLayout, this, [false]);\r
+ }\r
+ },\r
+\r
+ /**\r
+ * <p>Returns the Element to be used to contain the child Components of this Container.</p>\r
+ * <p>An implementation is provided which returns the Container's {@link #getEl Element}, but\r
+ * if there is a more complex structure to a Container, this may be overridden to return\r
+ * the element into which the {@link #layout layout} renders child Components.</p>\r
+ * @return {Ext.Element} The Element to render child Components into.\r
+ */\r
+ getLayoutTarget : function(){\r
+ return this.el;\r
+ },\r
+\r
+ // private - used as the key lookup function for the items collection\r
+ getComponentId : function(comp){\r
+ return comp.getItemId();\r
+ },\r
+\r
+ /**\r
+ * <p>Adds {@link Ext.Component Component}(s) to this Container.</p>\r
+ * <br><p><b>Description</b></u> :\r
+ * <div><ul class="mdetail-params">\r
+ * <li>Fires the {@link #beforeadd} event before adding</li>\r
+ * <li>The Container's {@link #defaults default config values} will be applied\r
+ * accordingly (see <code>{@link #defaults}</code> for details).</li>\r
+ * <li>Fires the {@link #add} event after the component has been added.</li>\r
+ * </ul></div>\r
+ * <br><p><b>Notes</b></u> :\r
+ * <div><ul class="mdetail-params">\r
+ * <li>If the Container is <i>already rendered</i> when <tt>add</tt>\r
+ * is called, you may need to call {@link #doLayout} to refresh the view which causes\r
+ * any unrendered child Components to be rendered. This is required so that you can\r
+ * <tt>add</tt> multiple child components if needed while only refreshing the layout\r
+ * once. For example:<pre><code>\r
+var tb = new {@link Ext.Toolbar}();\r
+tb.render(document.body); // toolbar is rendered\r
+tb.add({text:'Button 1'}); // add multiple items ({@link #defaultType} for {@link Ext.Toolbar Toolbar} is 'button')\r
+tb.add({text:'Button 2'});\r
+tb.{@link #doLayout}(); // refresh the layout\r
+ * </code></pre></li>\r
+ * <li><i>Warning:</i> Containers directly managed by the BorderLayout layout manager\r
+ * may not be removed or added. See the Notes for {@link Ext.layout.BorderLayout BorderLayout}\r
+ * for more details.</li>\r
+ * </ul></div>\r
+ * @param {Object/Array} component\r
+ * <p>Either a single component or an Array of components to add. See\r
+ * <code>{@link #items}</code> for additional information.</p>\r
+ * @param {Object} (Optional) component_2\r
+ * @param {Object} (Optional) component_n\r
+ * @return {Ext.Component} component The Component (or config object) that was added.\r
+ */\r
+ add : function(comp){\r
+ this.initItems();\r
+ var args = arguments.length > 1;\r
+ if(args || Ext.isArray(comp)){\r
+ Ext.each(args ? arguments : comp, function(c){\r
+ this.add(c);\r
+ }, this);\r
+ return;\r
+ }\r
+ var c = this.lookupComponent(this.applyDefaults(comp));\r
+ var pos = this.items.length;\r
+ if(this.fireEvent('beforeadd', this, c, pos) !== false && this.onBeforeAdd(c) !== false){\r
+ this.items.add(c);\r
+ c.ownerCt = this;\r
+ this.onAdd(c);\r
+ this.fireEvent('add', this, c, pos);\r
+ }\r
+ return c;\r
+ },\r
+\r
+ onAdd : function(c){\r
+ // Empty template method\r
+ },\r
+\r
+ /**\r
+ * Inserts a Component into this Container at a specified index. Fires the\r
+ * {@link #beforeadd} event before inserting, then fires the {@link #add} event after the\r
+ * Component has been inserted.\r
+ * @param {Number} index The index at which the Component will be inserted\r
+ * into the Container's items collection\r
+ * @param {Ext.Component} component The child Component to insert.<br><br>\r
+ * Ext uses lazy rendering, and will only render the inserted Component should\r
+ * it become necessary.<br><br>\r
+ * A Component config object may be passed in order to avoid the overhead of\r
+ * constructing a real Component object if lazy rendering might mean that the\r
+ * inserted Component will not be rendered immediately. To take advantage of\r
+ * this 'lazy instantiation', set the {@link Ext.Component#xtype} config\r
+ * property to the registered type of the Component wanted.<br><br>\r
+ * For a list of all available xtypes, see {@link Ext.Component}.\r
+ * @return {Ext.Component} component The Component (or config object) that was\r
+ * inserted with the Container's default config values applied.\r
+ */\r
+ insert : function(index, comp){\r
+ this.initItems();\r
+ var a = arguments, len = a.length;\r
+ if(len > 2){\r
+ for(var i = len-1; i >= 1; --i) {\r
+ this.insert(index, a[i]);\r
+ }\r
+ return;\r
+ }\r
+ var c = this.lookupComponent(this.applyDefaults(comp));\r
+ index = Math.min(index, this.items.length);\r
+ if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){\r
+ if(c.ownerCt == this){\r
+ this.items.remove(c);\r
+ }\r
+ this.items.insert(index, c);\r
+ c.ownerCt = this;\r
+ this.onAdd(c);\r
+ this.fireEvent('add', this, c, index);\r
+ }\r
+ return c;\r
+ },\r
+\r
+ // private\r
+ applyDefaults : function(c){\r
+ if(this.defaults){\r
+ if(Ext.isString(c)){\r
+ c = Ext.ComponentMgr.get(c);\r
+ Ext.apply(c, this.defaults);\r
+ }else if(!c.events){\r
+ Ext.applyIf(c, this.defaults);\r
+ }else{\r
+ Ext.apply(c, this.defaults);\r
+ }\r
+ }\r
+ return c;\r
+ },\r
+\r
+ // private\r
+ onBeforeAdd : function(item){\r
+ if(item.ownerCt){\r
+ item.ownerCt.remove(item, false);\r
+ }\r
+ if(this.hideBorders === true){\r
+ item.border = (item.border === true);\r
+ }\r
+ },\r
+\r
+ /**\r
+ * Removes a component from this container. Fires the {@link #beforeremove} event before removing, then fires\r
+ * the {@link #remove} event after the component has been removed.\r
+ * @param {Component/String} component The component reference or id to remove.\r
+ * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.\r
+ * Defaults to the value of this Container's {@link #autoDestroy} config.\r
+ * @return {Ext.Component} component The Component that was removed.\r
+ */\r
+ remove : function(comp, autoDestroy){\r
+ this.initItems();\r
+ var c = this.getComponent(comp);\r
+ if(c && this.fireEvent('beforeremove', this, c) !== false){\r
+ delete c.ownerCt;\r
+ if(this.layout && this.rendered){\r
+ this.layout.onRemove(c);\r
+ }\r
+ this.onRemove(c);\r
+ this.items.remove(c);\r
+ if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){\r
+ c.destroy();\r
+ }\r
+ this.fireEvent('remove', this, c);\r
+ }\r
+ return c;\r
+ },\r
+\r
+ onRemove: function(c){\r
+ // Empty template method\r
+ },\r
+\r
+ /**\r
+ * Removes all components from this container.\r
+ * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.\r
+ * Defaults to the value of this Container's {@link #autoDestroy} config.\r
+ * @return {Array} Array of the destroyed components\r
+ */\r
+ removeAll: function(autoDestroy){\r
+ this.initItems();\r
+ var item, rem = [], items = [];\r
+ this.items.each(function(i){\r
+ rem.push(i);\r
+ });\r
+ for (var i = 0, len = rem.length; i < len; ++i){\r
+ item = rem[i];\r
+ this.remove(item, autoDestroy);\r
+ if(item.ownerCt !== this){\r
+ items.push(item);\r
+ }\r
+ }\r
+ return items;\r
+ },\r
+\r
+ /**\r
+ * Examines this container's <code>{@link #items}</code> <b>property</b>\r
+ * and gets a direct child component of this container.\r
+ * @param {String/Number} comp This parameter may be any of the following:\r
+ * <div><ul class="mdetail-params">\r
+ * <li>a <b><tt>String</tt></b> : representing the <code>{@link Ext.Component#itemId itemId}</code>\r
+ * or <code>{@link Ext.Component#id id}</code> of the child component </li>\r
+ * <li>a <b><tt>Number</tt></b> : representing the position of the child component\r
+ * within the <code>{@link #items}</code> <b>property</b></li>\r
+ * </ul></div>\r
+ * <p>For additional information see {@link Ext.util.MixedCollection#get}.\r
+ * @return Ext.Component The component (if found).\r
+ */\r
+ getComponent : function(comp){\r
+ if(Ext.isObject(comp)){\r
+ comp = comp.getItemId();\r
+ }\r
+ return this.items.get(comp);\r
+ },\r
+\r
+ // private\r
+ lookupComponent : function(comp){\r
+ if(Ext.isString(comp)){\r
+ return Ext.ComponentMgr.get(comp);\r
+ }else if(!comp.events){\r
+ return this.createComponent(comp);\r
+ }\r
+ return comp;\r
+ },\r
+\r
+ // private\r
+ createComponent : function(config){\r
+ return Ext.create(config, this.defaultType);\r
+ },\r
+\r
+ // private\r
+ canLayout: function() {\r
+ var el = this.getVisibilityEl();\r
+ return el && !el.isStyle("display", "none");\r
+ },\r
+\r
+\r
+ /**\r
+ * Force this container's layout to be recalculated. A call to this function is required after adding a new component\r
+ * to an already rendered container, or possibly after changing sizing/position properties of child components.\r
+ * @param {Boolean} shallow (optional) True to only calc the layout of this component, and let child components auto\r
+ * calc layouts as required (defaults to false, which calls doLayout recursively for each subcontainer)\r
+ * @param {Boolean} force (optional) True to force a layout to occur, even if the item is hidden.\r
+ * @return {Ext.Container} this\r
+ */\r
+ doLayout: function(shallow, force){\r
+ var rendered = this.rendered;\r
+ forceLayout = force || this.forceLayout;\r
+\r
+ if(!this.canLayout() || this.collapsed){\r
+ this.deferLayout = this.deferLayout || !shallow;\r
+ if(!forceLayout){\r
+ return;\r
+ }\r
+ shallow = shallow && !this.deferLayout;\r
+ } else {\r
+ delete this.deferLayout;\r
+ }\r
+ if(rendered && this.layout){\r
+ this.layout.layout();\r
+ }\r
+ if(shallow !== true && this.items){\r
+ var cs = this.items.items;\r
+ for(var i = 0, len = cs.length; i < len; i++){\r
+ var c = cs[i];\r
+ if(c.doLayout){\r
+ c.doLayout(false, forceLayout);\r
+ }\r
+ }\r
+ }\r
+ if(rendered){\r
+ this.onLayout(shallow, forceLayout);\r
+ }\r
+ // Initial layout completed\r
+ this.hasLayout = true;\r
+ delete this.forceLayout;\r
+ },\r
+\r
+ //private\r
+ onLayout : Ext.emptyFn,\r
+\r
+ // private\r
+ shouldBufferLayout: function(){\r
+ /*\r
+ * Returns true if the container should buffer a layout.\r
+ * This is true only if the container has previously been laid out\r
+ * and has a parent container that is pending a layout.\r
+ */\r
+ var hl = this.hasLayout;\r
+ if(this.ownerCt){\r
+ // Only ever buffer if we've laid out the first time and we have one pending.\r
+ return hl ? !this.hasLayoutPending() : false;\r
+ }\r
+ // Never buffer initial layout\r
+ return hl;\r
+ },\r
+\r
+ // private\r
+ hasLayoutPending: function(){\r
+ // Traverse hierarchy to see if any parent container has a pending layout.\r
+ var pending = false;\r
+ this.ownerCt.bubble(function(c){\r
+ if(c.layoutPending){\r
+ pending = true;\r
+ return false;\r
+ }\r
+ });\r
+ return pending;\r
+ },\r
+\r
+ onShow : function(){\r
+ Ext.Container.superclass.onShow.call(this);\r
+ if(this.deferLayout !== undefined){\r
+ this.doLayout(true);\r
+ }\r
+ },\r
+\r
+ /**\r
+ * Returns the layout currently in use by the container. If the container does not currently have a layout\r
+ * set, a default {@link Ext.layout.ContainerLayout} will be created and set as the container's layout.\r
+ * @return {ContainerLayout} layout The container's layout\r
+ */\r
+ getLayout : function(){\r
+ if(!this.layout){\r
+ var layout = new Ext.layout.ContainerLayout(this.layoutConfig);\r
+ this.setLayout(layout);\r
+ }\r
+ return this.layout;\r
+ },\r
+\r
+ // private\r
+ beforeDestroy : function(){\r
+ if(this.items){\r
+ Ext.destroy.apply(Ext, this.items.items);\r
+ }\r
+ if(this.monitorResize){\r
+ Ext.EventManager.removeResizeListener(this.doLayout, this);\r
+ }\r
+ Ext.destroy(this.layout);\r
+ Ext.Container.superclass.beforeDestroy.call(this);\r
+ },\r
+\r
+ /**\r
+ * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope (<i>this</i>) of\r
+ * function call will be the scope provided or the current component. The arguments to the function\r
+ * will be the args provided or the current component. If the function returns false at any point,\r
+ * the bubble is stopped.\r
+ * @param {Function} fn The function to call\r
+ * @param {Object} scope (optional) The scope of the function (defaults to current node)\r
+ * @param {Array} args (optional) The args to call the function with (default to passing the current component)\r
+ * @return {Ext.Container} this\r
+ */\r
+ bubble : function(fn, scope, args){\r
+ var p = this;\r
+ while(p){\r
+ if(fn.apply(scope || p, args || [p]) === false){\r
+ break;\r
+ }\r
+ p = p.ownerCt;\r
+ }\r
+ return this;\r
+ },\r
+\r
+ /**\r
+ * Cascades down the component/container heirarchy from this component (called first), calling the specified function with\r
+ * each component. The scope (<i>this</i>) of\r
+ * function call will be the scope provided or the current component. The arguments to the function\r
+ * will be the args provided or the current component. If the function returns false at any point,\r
+ * the cascade is stopped on that branch.\r
+ * @param {Function} fn The function to call\r
+ * @param {Object} scope (optional) The scope of the function (defaults to current component)\r
+ * @param {Array} args (optional) The args to call the function with (defaults to passing the current component)\r
+ * @return {Ext.Container} this\r
+ */\r
+ cascade : function(fn, scope, args){\r
+ if(fn.apply(scope || this, args || [this]) !== false){\r
+ if(this.items){\r
+ var cs = this.items.items;\r
+ for(var i = 0, len = cs.length; i < len; i++){\r
+ if(cs[i].cascade){\r
+ cs[i].cascade(fn, scope, args);\r
+ }else{\r
+ fn.apply(scope || cs[i], args || [cs[i]]);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return this;\r
+ },\r
+\r
+ /**\r
+ * Find a component under this container at any level by id\r
+ * @param {String} id\r
+ * @return Ext.Component\r
+ */\r
+ findById : function(id){\r
+ var m, ct = this;\r
+ this.cascade(function(c){\r
+ if(ct != c && c.id === id){\r
+ m = c;\r
+ return false;\r
+ }\r
+ });\r
+ return m || null;\r
+ },\r
+\r
+ /**\r
+ * Find a component under this container at any level by xtype or class\r
+ * @param {String/Class} xtype The xtype string for a component, or the class of the component directly\r
+ * @param {Boolean} shallow (optional) False to check whether this Component is descended from the xtype (this is\r
+ * the default), or true to check whether this Component is directly of the specified xtype.\r
+ * @return {Array} Array of Ext.Components\r
+ */\r
+ findByType : function(xtype, shallow){\r
+ return this.findBy(function(c){\r
+ return c.isXType(xtype, shallow);\r
+ });\r
+ },\r
+\r
+ /**\r
+ * Find a component under this container at any level by property\r
+ * @param {String} prop\r
+ * @param {String} value\r
+ * @return {Array} Array of Ext.Components\r
+ */\r
+ find : function(prop, value){\r
+ return this.findBy(function(c){\r
+ return c[prop] === value;\r
+ });\r
+ },\r
+\r
+ /**\r
+ * Find a component under this container at any level by a custom function. If the passed function returns\r
+ * true, the component will be included in the results. The passed function is called with the arguments (component, this container).\r
+ * @param {Function} fn The function to call\r
+ * @param {Object} scope (optional)\r
+ * @return {Array} Array of Ext.Components\r
+ */\r
+ findBy : function(fn, scope){\r
+ var m = [], ct = this;\r
+ this.cascade(function(c){\r
+ if(ct != c && fn.call(scope || c, c, ct) === true){\r
+ m.push(c);\r
+ }\r
+ });\r
+ return m;\r
+ },\r
+\r
+ /**\r
+ * Get a component contained by this container (alias for items.get(key))\r
+ * @param {String/Number} key The index or id of the component\r
+ * @return {Ext.Component} Ext.Component\r
+ */\r
+ get : function(key){\r
+ return this.items.get(key);\r
+ }\r
+});\r
+\r
+Ext.Container.LAYOUTS = {};\r
+Ext.reg('container', Ext.Container);\r
/**
* @class Ext.layout.ContainerLayout
* <p>The ContainerLayout class is the default layout manager delegated by {@link Ext.Container} to
c.render(target, position);
this.configureItem(c, position);
}else if(c && !this.isValidParent(c, target)){
- if(typeof position == 'number'){
+ if(Ext.isNumber(position)){
position = target.dom.childNodes[position];
}
target.dom.insertBefore(c.getDomPositionEl().dom, position || null);
if (this.renderHidden && c != this.activeItem) {
c.hide();
}
- if(c.doLayout){
- c.doLayout(false, this.forceLayout);
+ if(c.doLayout && this.forceLayout){
+ c.doLayout(false, true);
+ }
+ },
+
+ onRemove: function(c){
+ if(this.activeItem == c){
+ delete this.activeItem;
+ }
+ if(c.rendered && this.extraCls){
+ var t = c.getPositionEl ? c.getPositionEl() : c;
+ t.removeClass(this.extraCls);
}
},
// private
onResize: function(){
- if(this.container.collapsed){
+ var ct = this.container,
+ b;
+
+ if(ct.collapsed){
return;
}
- var b = this.container.bufferResize;
- if(b){
- if(!this.resizeTask){
- this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
- this.resizeBuffer = typeof b == 'number' ? b : 100;
+ if(b = ct.bufferResize){
+ // Only allow if we should buffer the layout
+ if(ct.shouldBufferLayout()){
+ if(!this.resizeTask){
+ this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
+ this.resizeBuffer = Ext.isNumber(b) ? b : 50;
+ }
+ ct.layoutPending = true;
+ this.resizeTask.delay(this.resizeBuffer);
}
- this.resizeTask.delay(this.resizeBuffer);
}else{
- this.runLayout();
+ ct.doLayout();
}
},
// private
runLayout: function(){
- this.layout();
- this.container.onLayout();
+ var ct = this.container;
+ ct.doLayout();
+ delete ct.layoutPending;
},
// private
setContainer : function(ct){
if(this.monitorResize && ct != this.container){
- if(this.container){
- this.container.un('resize', this.onResize, this);
- this.container.un('bodyresize', this.onResize, this);
+ var old = this.container;
+ if(old){
+ old.un(old.resizeEvent, this.onResize, this);
}
if(ct){
- ct.on({
- scope: this,
- resize: this.onResize,
- bodyresize: this.onResize
- });
+ ct.on(ct.resizeEvent, this.onResize, this);
}
}
this.container = ct;
// private
parseMargins : function(v){
- if(typeof v == 'number'){
+ if(Ext.isNumber(v)){
v = v.toString();
}
var ms = v.split(' ');
},
/**
- * The {@link Template Ext.Template} used by Field rendering layout classes (such as
+ * The {@link Ext.Template Ext.Template} used by Field rendering layout classes (such as
* {@link Ext.layout.FormLayout}) to create the DOM structure of a fully wrapped,
* labeled and styled form Field. A default Template is supplied, but this may be
* overriden to create custom field structures. The template processes values returned from
if(this.activeItem){\r
this.activeItem.hide();\r
}\r
+ var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);\r
this.activeItem = item;\r
item.show();\r
- this.container.doLayout();\r
- if(this.layoutOnCardChange && item.doLayout){\r
+ this.layout();\r
+ if(layout){\r
item.doLayout();\r
}\r
}\r
}
c.collapsed = false;
if(!c.rendered){
- c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel';
c.render(target, i);
+ c.getDomPositionEl().addClass('x-border-panel');
}
this[pos] = pos != 'center' && c.split ?
new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
* @type String
* @property labelStyle
*/
+
+ /**
+ * @cfg {Boolean} trackLabels
+ * True to show/hide the field label when the field is hidden. Defaults to <tt>false</tt>.
+ */
+ trackLabels: false,
+
+ onRemove: function(c){
+ Ext.layout.FormLayout.superclass.onRemove.call(this, c);
+ if(this.trackLabels && !this.isHide(c)){
+ c.un('show', this.onFieldShow, this);
+ c.un('hide', this.onFieldHide, this);
+ }
+ // check for itemCt, since we may be removing a fieldset or something similar
+ var el = c.getPositionEl(),
+ ct = c.getItemCt && c.getItemCt();
+ if(c.rendered && ct){
+ el.insertAfter(ct);
+ Ext.destroy(ct);
+ Ext.destroyMembers(c, 'label', 'itemCt');
+ if(c.customItemCt){
+ Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
+ }
+ }
+ },
+
// private
setContainer : function(ct){
Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
}
if(ct.hideLabels){
- this.labelStyle = "display:none";
- this.elementStyle = "padding-left:0;";
- this.labelAdjust = 0;
+ Ext.apply(this, {
+ labelStyle: 'display:none',
+ elementStyle: 'padding-left:0;',
+ labelAdjust: 0
+ });
}else{
this.labelSeparator = ct.labelSeparator || this.labelSeparator;
ct.labelWidth = ct.labelWidth || 100;
- if(typeof ct.labelWidth == 'number'){
- var pad = (typeof ct.labelPad == 'number' ? ct.labelPad : 5);
- this.labelAdjust = ct.labelWidth+pad;
- this.labelStyle = "width:"+ct.labelWidth+"px;";
- this.elementStyle = "padding-left:"+(ct.labelWidth+pad)+'px';
+ if(Ext.isNumber(ct.labelWidth)){
+ var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
+ Ext.apply(this, {
+ labelAdjust: ct.labelWidth + pad,
+ labelStyle: 'width:' + ct.labelWidth + 'px;',
+ elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
+ });
}
if(ct.labelAlign == 'top'){
- this.labelStyle = "width:auto;";
- this.labelAdjust = 0;
- this.elementStyle = "padding-left:0;";
+ Ext.apply(this, {
+ labelStyle: 'width:auto;',
+ labelAdjust: 0,
+ elementStyle: 'padding-left:0;'
+ });
}
}
},
+
+ isHide: function(c){
+ return c.hideLabel || this.container.hideLabels;
+ },
+
+ onFieldShow: function(c){
+ c.getItemCt().removeClass('x-hide-' + c.hideMode);
+ },
+
+ onFieldHide: function(c){
+ c.getItemCt().addClass('x-hide-' + c.hideMode);
+ },
//private
getLabelStyle: function(s){
// private
renderItem : function(c, position, target){
- if(c && !c.rendered && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
+ if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
var args = this.getTemplateArgs(c);
- if(typeof position == 'number'){
+ if(Ext.isNumber(position)){
position = target.dom.childNodes[position] || null;
}
if(position){
- this.fieldTpl.insertBefore(position, args);
+ c.itemCt = this.fieldTpl.insertBefore(position, args, true);
}else{
- this.fieldTpl.append(target, args);
+ c.itemCt = this.fieldTpl.append(target, args, true);
+ }
+ if(!c.rendered){
+ c.render('x-form-el-' + c.id);
+ }else if(!this.isValidParent(c, target)){
+ Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
+ }
+ if(!c.getItemCt){
+ // Non form fields don't have getItemCt, apply it here
+ // This will get cleaned up in onRemove
+ Ext.apply(c, {
+ getItemCt: function(){
+ return c.itemCt;
+ },
+ customItemCt: true
+ });
+ }
+ c.label = c.getItemCt().child('label.x-form-item-label');
+ if(this.trackLabels && !this.isHide(c)){
+ if(c.hidden){
+ this.onFieldHide(c);
+ }
+ c.on({
+ scope: this,
+ show: this.onFieldShow,
+ hide: this.onFieldHide
+ });
}
- c.render('x-form-el-'+c.id);
+ this.configureItem(c);
}else {
Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
}
return {
id: field.id,
label: field.fieldLabel,
- labelStyle: field.labelStyle||this.labelStyle||'',
+ labelStyle: this.getLabelStyle(field.labelStyle),
elementStyle: this.elementStyle||'',
- labelSeparator: noLabelSep ? '' : (typeof field.labelSeparator == 'undefined' ? this.labelSeparator : field.labelSeparator),
+ labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator),
itemCls: (field.itemCls||this.container.itemCls||'') + (field.hideLabel ? ' x-hide-label' : ''),
clearCls: field.clearCls || 'x-form-clear-left'
};
},
// private
- adjustWidthAnchor : function(value, comp){
- return value - (comp.isFormField || comp.fieldLabel ? (comp.hideLabel ? 0 : this.labelAdjust) : 0);
+ adjustWidthAnchor: function(value, c){
+ if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
+ var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
+ return value - this.labelAdjust + (adjust ? -3 : 0);
+ }
+ return value;
+ },
+
+ adjustHeightAnchor : function(value, c){
+ if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
+ return value - c.label.getHeight();
+ }
+ return value;
},
// private
isValidParent : function(c, target){
- return true;
+ return target && this.container.getEl().contains(c.getDomPositionEl());
}
/**
Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;/**\r
* @class Ext.layout.AccordionLayout\r
* @extends Ext.layout.FitLayout\r
- * <p>This is a layout that contains multiple panels in an expandable accordion style such that only\r
- * <b>one panel can be open at any given time</b>. Each panel has built-in support for expanding and collapsing.\r
+ * <p>This is a layout that manages multiple Panels in an expandable accordion style such that only\r
+ * <b>one Panel can be expanded at any given time</b>. Each Panel has built-in support for expanding and collapsing.</p>\r
+ * <p>Note: Only Ext.Panels <b>and all subclasses of Ext.Panel</b> may be used in an accordion layout Container.</p>\r
* <p>This class is intended to be extended or created via the <tt><b>{@link Ext.Container#layout layout}</b></tt>\r
* configuration property. See <tt><b>{@link Ext.Container#layout}</b></tt> for additional details.</p>\r
* <p>Example usage:</p>\r
c.header.addClass('x-accordion-hd');\r
c.on('beforeexpand', this.beforeExpand, this);\r
},\r
+ \r
+ onRemove: function(c){\r
+ Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);\r
+ if(c.rendered){\r
+ c.header.removeClass('x-accordion-hd');\r
+ }\r
+ c.un('beforeexpand', this.beforeExpand, this);\r
+ },\r
\r
// private\r
beforeExpand : function(p, anim){\r
renderItem : function(c, position, target){\r
if(c && !c.rendered){\r
c.render(this.getNextCell(c));\r
- if(this.extraCls){\r
- var t = c.getPositionEl ? c.getPositionEl() : c;\r
- t.addClass(this.extraCls);\r
- }\r
+ this.configureItem(c, position);\r
+ }else if(c && !this.isValidParent(c, target)){\r
+ var container = this.getNextCell(c);\r
+ container.insertBefore(c.getDomPositionEl().dom, null);\r
+ c.container = Ext.get(container);\r
+ this.configureItem(c, position);\r
}\r
},\r
\r
// private\r
isValidParent : function(c, target){\r
- return true;\r
+ return c.getDomPositionEl().up('table', 5).dom.parentNode === (target.dom || target);\r
}\r
\r
/**\r
defaultMargins : {left:0,top:0,right:0,bottom:0},\r
/**\r
* @cfg {String} padding\r
- * Defaults to <tt>'0'</tt>. Sets the padding to be applied to all child items managed by this\r
- * container's layout. \r
+ * <p>Sets the padding to be applied to all child items managed by this layout.</p> \r
+ * <p>This property must be specified as a string containing\r
+ * space-separated, numeric padding values. The order of the sides associated\r
+ * with each value matches the way CSS processes padding values:</p>\r
+ * <div class="mdetail-params"><ul>\r
+ * <li>If there is only one value, it applies to all sides.</li>\r
+ * <li>If there are two values, the top and bottom borders are set to the\r
+ * first value and the right and left are set to the second.</li>\r
+ * <li>If there are three values, the top is set to the first value, the left\r
+ * and right are set to the second, and the bottom is set to the third.</li>\r
+ * <li>If there are four values, they apply to the top, right, bottom, and\r
+ * left, respectively.</li>\r
+ * </ul></div>\r
+ * <p>Defaults to: <code>"0"</code></p>\r
*/\r
padding : '0',\r
// documented in subclasses\r
extraCls : 'x-box-item',\r
ctCls : 'x-box-layout-ct',\r
innerCls : 'x-box-inner',\r
+ \r
+ constructor : function(config){\r
+ Ext.layout.BoxLayout.superclass.constructor.call(this, config);\r
+ if(Ext.isString(this.defaultMargins)){\r
+ this.defaultMargins = this.parseMargins(this.defaultMargins);\r
+ }\r
+ },\r
\r
// private\r
isValidParent : function(c, target){\r
\r
// private\r
renderItem : function(c){\r
- if(typeof c.margins == 'string'){\r
+ if(Ext.isString(c.margins)){\r
c.margins = this.parseMargins(c.margins);\r
}else if(!c.margins){\r
c.margins = this.defaultMargins;\r
/**\r
* @class Ext.layout.VBoxLayout\r
* @extends Ext.layout.BoxLayout\r
- * A layout that arranges items vertically\r
+ * <p>A layout that arranges items vertically down a Container. This layout optionally divides available vertical\r
+ * space between child items containing a numeric <code>flex</code> configuration.</p>\r
+ * This layout may also be used to set the widths of child items by configuring it with the {@link #align} option.\r
*/\r
Ext.layout.VBoxLayout = Ext.extend(Ext.layout.BoxLayout, {\r
/**\r
\r
var cs = this.getItems(ct), cm, ch, margin,\r
size = this.getTargetSize(target),\r
- w = size.width - target.getPadding('lr') - this.scrollOffset,\r
- h = size.height - target.getPadding('tb'),\r
+ w = size.width - target.getPadding('lr'),\r
+ h = size.height - target.getPadding('tb') - this.scrollOffset,\r
l = this.padding.left, t = this.padding.top,\r
isStart = this.pack == 'start',\r
isRestore = ['stretch', 'stretchmax'].indexOf(this.align) == -1,\r
/**\r
* @class Ext.layout.HBoxLayout\r
* @extends Ext.layout.BoxLayout\r
- * A layout that arranges items horizontally\r
+ * <p>A layout that arranges items horizontally across a Container. This layout optionally divides available horizontal\r
+ * space between child items containing a numeric <code>flex</code> configuration.</p>\r
+ * This layout may also be used to set the heights of child items by configuring it with the {@link #align} option.\r
*/\r
Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {\r
/**\r
* of being configured with a {@link Ext.Container#layout layout}, and containing child Components.</p>
* <p>When either specifying child {@link Ext.Component#items items} of a Panel, or dynamically {@link 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 <tt><b>{@link Ext.Container#layout layout}</b></tt> schemes. By
+ * those child elements need to be sized using one of Ext's built-in <code><b>{@link Ext.Container#layout layout}</b></code> schemes. By
* default, Panels use the {@link Ext.layout.ContainerLayout ContainerLayout} scheme. This simply renders
* child components, appending them one after the other inside the Container, and <b>does not apply any sizing</b>
* at all.</p>
/**
* The Panel's header {@link Ext.Element Element}. Read-only.
* <p>This Element is used to house the {@link #title} and {@link #tools}</p>
- * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
+ * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
* @type Ext.Element
* @property header
*/
* <p>If this Panel is intended to be used as the host of a Layout (See {@link #layout}
* then the body Element must not be loaded or changed - it is under the control
* of the Panel's Layout.
- * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
+ * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
* @type Ext.Element
* @property body
*/
* <p>A {@link Ext.DomHelper DomHelper} element specification object may be specified for any
* Panel Element.</p>
* <p>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 (<tt>baseCls</tt> will be
- * replaced by <tt>{@link #baseCls}</tt>):</p>
+ * create a child element with the commensurate Default class name (<code>baseCls</code> will be
+ * replaced by <code>{@link #baseCls}</code>):</p>
* <pre>
* Panel Default Default Custom Additional Additional
* Element element class element class style
footerStyle: 'background-color:red' // see {@link #bodyStyle}
});
* </code></pre>
- * <p>The example above also explicitly creates a <tt>{@link #footer}</tt> with custom markup and
+ * <p>The example above also explicitly creates a <code>{@link #footer}</code> with custom markup and
* styling applied.</p>
*/
/**
* @cfg {Object} headerCfg
* <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
- * of this Panel's {@link #header} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
+ * of this Panel's {@link #header} Element. See <code>{@link #bodyCfg}</code> also.</p>
*/
/**
* @cfg {Object} bwrapCfg
* <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
- * of this Panel's {@link #bwrap} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
+ * of this Panel's {@link #bwrap} Element. See <code>{@link #bodyCfg}</code> also.</p>
*/
/**
* @cfg {Object} tbarCfg
* <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
- * of this Panel's {@link #tbar} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
+ * of this Panel's {@link #tbar} Element. See <code>{@link #bodyCfg}</code> also.</p>
*/
/**
* @cfg {Object} bbarCfg
* <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
- * of this Panel's {@link #bbar} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
+ * of this Panel's {@link #bbar} Element. See <code>{@link #bodyCfg}</code> also.</p>
*/
/**
* @cfg {Object} footerCfg
* <p>A {@link Ext.DomHelper DomHelper} element specification object specifying the element structure
- * of this Panel's {@link #footer} Element. See <tt>{@link #bodyCfg}</tt> also.</p>
+ * of this Panel's {@link #footer} Element. See <code>{@link #bodyCfg}</code> also.</p>
*/
/**
* @cfg {Boolean} closable
* Panels themselves do not directly support being closed, but some Panel subclasses do (like
- * {@link Ext.Window}) or a Panel Class within an {@link Ext.TabPanel}. Specify <tt>true</tt>
- * to enable closing in such situations. Defaults to <tt>false</tt>.
+ * {@link Ext.Window}) or a Panel Class within an {@link Ext.TabPanel}. Specify <code>true</code>
+ * to enable closing in such situations. Defaults to <code>false</code>.
*/
/**
* The Panel's footer {@link Ext.Element Element}. Read-only.
- * <p>This Element is used to house the Panel's <tt>{@link #buttons}</tt> or <tt>{@link #fbar}</tt>.</p>
- * <br><p><b>Note</b>: see the Note for <tt>{@link Ext.Component#el el} also.</p>
+ * <p>This Element is used to house the Panel's <code>{@link #buttons}</code> or <code>{@link #fbar}</code>.</p>
+ * <br><p><b>Note</b>: see the Note for <code>{@link Ext.Component#el el}</code> also.</p>
* @type Ext.Element
* @property footer
*/
/**
* @cfg {Mixed} applyTo
* <p>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 <tt>applyTo</tt> is used,
+ * the document that specifies some panel-specific structural markup. When <code>applyTo</code> 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.</p>
* <p>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}.</p>
- * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not<b> be updated by a load
+ * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> 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 <b>will</b> be submitted because form
* submission parameters are collected from the DOM tree.</p>
* <p>A {@link Ext.Toolbar Toolbar} object, a Toolbar config, or an array of
* {@link Ext.Button Button}s/{@link Ext.Button Button} configs, describing a {@link Ext.Toolbar Toolbar} to be rendered into this Panel's footer element.</p>
* <p>After render, the <code>fbar</code> property will be an {@link Ext.Toolbar Toolbar} instance.</p>
- * <p>If <tt>{@link #buttons}</tt> are specified, they will supersede the <tt>fbar</tt> configuration property.</p>
- * The Panel's <tt>{@link #buttonAlign}</tt> configuration affects the layout of these items, for example:
+ * <p>If <code>{@link #buttons}</code> are specified, they will supersede the <code>fbar</code> configuration property.</p>
+ * The Panel's <code>{@link #buttonAlign}</code> configuration affects the layout of these items, for example:
* <pre><code>
var w = new Ext.Window({
height: 250,
text: 'bbar Right'
}]
}),
- {@link #buttonAlign}: 'left', // anything but 'center' or 'right' and you can use "-", and "->"
+ {@link #buttonAlign}: 'left', // anything but 'center' or 'right' and you can use '-', and '->'
// to control the alignment of fbar items
fbar: [{
text: 'fbar Left'
}]
}).show();
* </code></pre>
- * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not<b> be updated by a load
+ * <p><b>Note:</b> Although a Toolbar may contain Field components, these will <b>not</b> 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 <b>will</b> be submitted because form
* submission parameters are collected from the DOM tree.</p>
*/
/**
* @cfg {Boolean} header
- * <tt>true</tt> to create the Panel's header element explicitly, <tt>false</tt> to skip creating
- * it. If a <tt>{@link #title}</tt> is set the header will be created automatically, otherwise it will not.
- * If a <tt>{@link #title}</tt> is set but <tt>header</tt> is explicitly set to <tt>false</tt>, the header
+ * <code>true</code> to create the Panel's header element explicitly, <code>false</code> to skip creating
+ * it. If a <code>{@link #title}</code> is set the header will be created automatically, otherwise it will not.
+ * If a <code>{@link #title}</code> is set but <code>header</code> is explicitly set to <code>false</code>, the header
* will not be rendered.
*/
/**
* @cfg {Boolean} footer
- * <tt>true</tt> to create the footer element explicitly, false to skip creating it. The footer
- * will be created automatically if <tt>{@link #buttons}</tt> or a <tt>{@link #fbar}</tt> have
- * been configured. See <tt>{@link #bodyCfg}</tt> for an example.
+ * <code>true</code> to create the footer element explicitly, false to skip creating it. The footer
+ * will be created automatically if <code>{@link #buttons}</code> or a <code>{@link #fbar}</code> have
+ * been configured. See <code>{@link #bodyCfg}</code> for an example.
*/
/**
* @cfg {String} title
* The title text to be used as innerHTML (html tags are accepted) to display in the panel
- * <tt>{@link #header}</tt> (defaults to ''). When a <tt>title</tt> is specified the
- * <tt>{@link #header}</tt> element will automatically be created and displayed unless
- * {@link #header} is explicitly set to <tt>false</tt>. If you do not want to specify a
- * <tt>title</tt> at config time, but you may want one later, you must either specify a non-empty
- * <tt>title</tt> (a blank space ' ' will do) or <tt>header:true</tt> so that the container
+ * <code>{@link #header}</code> (defaults to ''). When a <code>title</code> is specified the
+ * <code>{@link #header}</code> element will automatically be created and displayed unless
+ * {@link #header} is explicitly set to <code>false</code>. If you do not want to specify a
+ * <code>title</code> at config time, but you may want one later, you must either specify a non-empty
+ * <code>title</code> (a blank space ' ' will do) or <code>header:true</code> so that the container
* element will get created.
*/
/**
* @cfg {Array} buttons
- * <tt>buttons</tt> will be used as <tt>{@link Ext.Container#items items}</tt> for the toolbar in
- * the footer (<tt>{@link #fbar}</tt>). Typically the value of this configuration property will be
+ * <code>buttons</code> will be used as <code>{@link Ext.Container#items items}</code> for the toolbar in
+ * the footer (<code>{@link #fbar}</code>). Typically the value of this configuration property will be
* an array of {@link Ext.Button}s or {@link Ext.Button} configuration objects.
- * If an item is configured with <tt>minWidth</tt> or the Panel is configured with <tt>minButtonWidth</tt>,
+ * If an item is configured with <code>minWidth</code> or the Panel is configured with <code>minButtonWidth</code>,
* that width will be applied to the item.
*/
/**
*/
/**
* @cfg {Boolean} frame
- * <tt>false</tt> by default to render with plain 1px square borders. <tt>true</tt> to render with
+ * <code>false</code> by default to render with plain 1px square borders. <code>true</code> to render with
* 9 elements, complete with custom rounded corners (also see {@link Ext.Element#boxWrap}).
* <p>The template generated for each condition is depicted below:</p><pre><code>
*
/**
* @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 {@link Ext.Element Element} referenced by a public property called <tt><b></b>tools.<i><tool-type></i></tt>
+ * stored as an {@link Ext.Element Element} referenced by a public property called <code><b></b>tools.<i><tool-type></i></code>
* <p>Each tool config may contain the following properties:
* <div class="mdetail-params"><ul>
* <li><b>id</b> : String<div class="sub-desc"><b>Required.</b> The type
- * of tool to create. By default, this assigns a CSS class of the form <tt>x-tool-<i><tool-type></i></tt> to the
+ * of tool to create. By default, this assigns a CSS class of the form <code>x-tool-<i><tool-type></i></code> 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:
* <ul>
- * <div class="x-tool x-tool-toggle" style="float:left; margin-right:5;"> </div><div><tt> toggle</tt> (Created by default when {@link #collapsible} is <tt>true</tt>)</div>
- * <div class="x-tool x-tool-close" style="float:left; margin-right:5;"> </div><div><tt> close</tt></div>
- * <div class="x-tool x-tool-minimize" style="float:left; margin-right:5;"> </div><div><tt> minimize</tt></div>
- * <div class="x-tool x-tool-maximize" style="float:left; margin-right:5;"> </div><div><tt> maximize</tt></div>
- * <div class="x-tool x-tool-restore" style="float:left; margin-right:5;"> </div><div><tt> restore</tt></div>
- * <div class="x-tool x-tool-gear" style="float:left; margin-right:5;"> </div><div><tt> gear</tt></div>
- * <div class="x-tool x-tool-pin" style="float:left; margin-right:5;"> </div><div><tt> pin</tt></div>
- * <div class="x-tool x-tool-unpin" style="float:left; margin-right:5;"> </div><div><tt> unpin</tt></div>
- * <div class="x-tool x-tool-right" style="float:left; margin-right:5;"> </div><div><tt> right</tt></div>
- * <div class="x-tool x-tool-left" style="float:left; margin-right:5;"> </div><div><tt> left</tt></div>
- * <div class="x-tool x-tool-up" style="float:left; margin-right:5;"> </div><div><tt> up</tt></div>
- * <div class="x-tool x-tool-down" style="float:left; margin-right:5;"> </div><div><tt> down</tt></div>
- * <div class="x-tool x-tool-refresh" style="float:left; margin-right:5;"> </div><div><tt> refresh</tt></div>
- * <div class="x-tool x-tool-minus" style="float:left; margin-right:5;"> </div><div><tt> minus</tt></div>
- * <div class="x-tool x-tool-plus" style="float:left; margin-right:5;"> </div><div><tt> plus</tt></div>
- * <div class="x-tool x-tool-help" style="float:left; margin-right:5;"> </div><div><tt> help</tt></div>
- * <div class="x-tool x-tool-search" style="float:left; margin-right:5;"> </div><div><tt> search</tt></div>
- * <div class="x-tool x-tool-save" style="float:left; margin-right:5;"> </div><div><tt> save</tt></div>
- * <div class="x-tool x-tool-print" style="float:left; margin-right:5;"> </div><div><tt> print</tt></div>
+ * <div class="x-tool x-tool-toggle" style="float:left; margin-right:5;"> </div><div><code> toggle</code> (Created by default when {@link #collapsible} is <code>true</code>)</div>
+ * <div class="x-tool x-tool-close" style="float:left; margin-right:5;"> </div><div><code> close</code></div>
+ * <div class="x-tool x-tool-minimize" style="float:left; margin-right:5;"> </div><div><code> minimize</code></div>
+ * <div class="x-tool x-tool-maximize" style="float:left; margin-right:5;"> </div><div><code> maximize</code></div>
+ * <div class="x-tool x-tool-restore" style="float:left; margin-right:5;"> </div><div><code> restore</code></div>
+ * <div class="x-tool x-tool-gear" style="float:left; margin-right:5;"> </div><div><code> gear</code></div>
+ * <div class="x-tool x-tool-pin" style="float:left; margin-right:5;"> </div><div><code> pin</code></div>
+ * <div class="x-tool x-tool-unpin" style="float:left; margin-right:5;"> </div><div><code> unpin</code></div>
+ * <div class="x-tool x-tool-right" style="float:left; margin-right:5;"> </div><div><code> right</code></div>
+ * <div class="x-tool x-tool-left" style="float:left; margin-right:5;"> </div><div><code> left</code></div>
+ * <div class="x-tool x-tool-up" style="float:left; margin-right:5;"> </div><div><code> up</code></div>
+ * <div class="x-tool x-tool-down" style="float:left; margin-right:5;"> </div><div><code> down</code></div>
+ * <div class="x-tool x-tool-refresh" style="float:left; margin-right:5;"> </div><div><code> refresh</code></div>
+ * <div class="x-tool x-tool-minus" style="float:left; margin-right:5;"> </div><div><code> minus</code></div>
+ * <div class="x-tool x-tool-plus" style="float:left; margin-right:5;"> </div><div><code> plus</code></div>
+ * <div class="x-tool x-tool-help" style="float:left; margin-right:5;"> </div><div><code> help</code></div>
+ * <div class="x-tool x-tool-search" style="float:left; margin-right:5;"> </div><div><code> search</code></div>
+ * <div class="x-tool x-tool-save" style="float:left; margin-right:5;"> </div><div><code> save</code></div>
+ * <div class="x-tool x-tool-print" style="float:left; margin-right:5;"> </div><div><code> print</code></div>
* </ul></div></li>
* <li><b>handler</b> : Function<div class="sub-desc"><b>Required.</b> The function to
* call when clicked. Arguments passed are:<ul>
}
}]
</code></pre>
- * <p>For the custom id of <tt>'help'</tt> define two relevant css classes with a link to
+ * <p>For the custom id of <code>'help'</code> define two relevant css classes with a link to
* a 15x15 image:</p>
* <pre><code>
.x-tool-help {background-image: url(images/help.png);}
height:300,
closeAction:'hide'
});</code></pre>
- * <p>Note that the CSS class "x-tool-pdf" should have an associated style rule which provides an
+ * <p>Note that the CSS class 'x-tool-pdf' should have an associated style rule which provides an
* appropriate background image, something like:</p>
<pre><code>
a.x-tool-pdf {background-image: url(../shared/extjs/images/pdf.gif)!important;}
*/
/**
* @cfg {Boolean} hideCollapseTool
- * <tt>true</tt> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
- * <tt>false</tt> to display it (defaults to <tt>false</tt>).
+ * <code>true</code> to hide the expand/collapse toggle button when <code>{@link #collapsible} == true</code>,
+ * <code>false</code> to display it (defaults to <code>false</code>).
*/
/**
* @cfg {Boolean} titleCollapse
- * <tt>true</tt> to allow expanding and collapsing the panel (when <tt>{@link #collapsible} = true</tt>)
- * by clicking anywhere in the header bar, <tt>false</tt>) to allow it only by clicking to tool button
- * (defaults to <tt>false</tt>)). If this panel is a child item of a border layout also see the
+ * <code>true</code> to allow expanding and collapsing the panel (when <code>{@link #collapsible} = true</code>)
+ * by clicking anywhere in the header bar, <code>false</code>) to allow it only by clicking to tool button
+ * (defaults to <code>false</code>)). If this panel is a child item of a border layout also see the
* {@link Ext.layout.BorderLayout.Region BorderLayout.Region}
- * <tt>{@link Ext.layout.BorderLayout.Region#floatable floatable}</tt> config option.
+ * <code>{@link Ext.layout.BorderLayout.Region#floatable floatable}</code> config option.
*/
/**
* @cfg {Boolean} autoScroll
- * <tt>true</tt> to use overflow:'auto' on the panel's body element and show scroll bars automatically when
- * necessary, <tt>false</tt> to clip any overflowing content (defaults to <tt>false</tt>).
+ * <code>true</code> to use overflow:'auto' on the panel's body element and show scroll bars automatically when
+ * necessary, <code>false</code> to clip any overflowing content (defaults to <code>false</code>).
*/
/**
* @cfg {Mixed} floating
* <p>This property is used to configure the underlying {@link Ext.Layer}. Acceptable values for this
* configuration property are:</p><div class="mdetail-params"><ul>
- * <li><b><tt>false</tt></b> : <b>Default.</b><div class="sub-desc">Display the panel inline where it is
+ * <li><b><code>false</code></b> : <b>Default.</b><div class="sub-desc">Display the panel inline where it is
* rendered.</div></li>
- * <li><b><tt>true</tt></b> : <div class="sub-desc">Float the panel (absolute position it with automatic
+ * <li><b><code>true</code></b> : <div class="sub-desc">Float the panel (absolute position it with automatic
* shimming and shadow).<ul>
* <div class="sub-desc">Setting floating to true will create an Ext.Layer for this panel and display the
* panel at negative offsets so that it is hidden.</div>
* <div class="sub-desc">Since the panel will be absolute positioned, the position must be set explicitly
- * <i>after</i> render (e.g., <tt>myPanel.setPosition(100,100);</tt>).</div>
+ * <i>after</i> render (e.g., <code>myPanel.setPosition(100,100);</code>).</div>
* <div class="sub-desc"><b>Note</b>: 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.</div>
* </ul></div></li>
- * <li><b><tt>{@link Ext.Layer object}</tt></b> : <div class="sub-desc">The specified object will be used
+ * <li><b><code>{@link Ext.Layer object}</code></b> : <div class="sub-desc">The specified object will be used
* as the configuration object for the {@link Ext.Layer} that will be created.</div></li>
* </ul></div>
*/
/**
* @cfg {Boolean/String} shadow
- * <tt>true</tt> (or a valid Ext.Shadow {@link Ext.Shadow#mode} value) to display a shadow behind the
- * panel, <tt>false</tt> to display no shadow (defaults to <tt>'sides'</tt>). Note that this option
- * only applies when <tt>{@link #floating} = true</tt>.
+ * <code>true</code> (or a valid Ext.Shadow {@link Ext.Shadow#mode} value) to display a shadow behind the
+ * panel, <code>false</code> to display no shadow (defaults to <code>'sides'</code>). Note that this option
+ * only applies when <code>{@link #floating} = true</code>.
*/
/**
* @cfg {Number} shadowOffset
- * The number of pixels to offset the shadow if displayed (defaults to <tt>4</tt>). Note that this
- * option only applies when <tt>{@link #floating} = true</tt>.
+ * The number of pixels to offset the shadow if displayed (defaults to <code>4</code>). Note that this
+ * option only applies when <code>{@link #floating} = true</code>.
*/
/**
* @cfg {Boolean} shim
- * <tt>false</tt> to disable the iframe shim in browsers which need one (defaults to <tt>true</tt>).
- * Note that this option only applies when <tt>{@link #floating} = true</tt>.
+ * <code>false</code> to disable the iframe shim in browsers which need one (defaults to <code>true</code>).
+ * Note that this option only applies when <code>{@link #floating} = true</code>.
*/
/**
* @cfg {String/Object} html
*/
/**
* @cfg {String} contentEl
- * <p>Specify the <tt>id</tt> of an existing HTML node to use as the panel's body content
- * (defaults to '').</p><div><ul>
- * <li><b>Description</b> : <ul>
+ * <p>Optional. Specify an existing HTML element, or the <code>id</code> of an existing HTML element to use as this Panel's
+ * <code><b>{@link #body}</b></code> content.</p>
+ * <ul>
+ * <li><b>Description</b> :
* <div class="sub-desc">This config option is used to take an existing HTML element and place it in the body
* of a new panel (it simply moves the specified DOM element into the body element of the Panel
- * <i>when the Panel is rendered</i> to use as the content (it is not going to be the
- * actual panel itself).</div>
- * </ul></li>
- * <li><b>Notes</b> : <ul>
- * <div class="sub-desc">The specified HTML Element is appended to the Panel's {@link #body} Element by the
- * Panel's {@link #afterRender} method <i>after any configured {@link #html HTML} has
- * been inserted</i>, and so the document will not contain this HTML at the time the
+ * <i>after the Panel is rendered</i> to use as the content (it is not going to be the actual panel itself).</div></li>
+ * <li><b>Notes</b> :
+ * <div class="sub-desc">The specified HTML element is appended to the Panel's {@link #body} Element by the
+ * Panel's <code>afterRender</code> method <i>after any configured {@link #html HTML} has
+ * been inserted</i>, and so the document will not contain this element at the time the
* {@link #render} event is fired.</div>
- * <div class="sub-desc">The specified HTML element used will not participate in any layout scheme that the
- * Panel may use. It's just HTML. Layouts operate on child items.</div>
- * <div class="sub-desc">Add either the <tt>x-hidden</tt> or the <tt>x-hide-display</tt> CSS class to
- * prevent a brief flicker of the content before it is rendered to the panel.</div>
- * </ul></li>
- * </ul></div>
+ * <div class="sub-desc">The specified HTML element used will not participate in any <code><b>{@link Ext.Container#layout layout}</b></code>
+ * scheme that the Panel may use. It is just HTML. Layouts operate on child <code><b>{@link Ext.Container#items items}</b></code>.</div>
+ * <div class="sub-desc">Add either the <code>x-hidden</code> or the <code>x-hide-display</code> CSS class to
+ * prevent a brief flicker of the content before it is rendered to the panel.</div></li>
+ * </ul>
*/
/**
* @cfg {Object/Array} keys
* A {@link Ext.KeyMap} config object (in the format expected by {@link Ext.KeyMap#addBinding}
- * used to assign custom key handling to this panel (defaults to <tt>null</tt>).
+ * used to assign custom key handling to this panel (defaults to <code>null</code>).
*/
/**
* @cfg {Boolean/Object} draggable
- * <p><tt>true</tt> to enable dragging of this Panel (defaults to <tt>false</tt>).</p>
+ * <p><code>true</code> to enable dragging of this Panel (defaults to <code>false</code>).</p>
* <p>For custom drag/drop implementations, an <b>Ext.Panel.DD</b> config could also be passed
- * in this config instead of <tt>true</tt>. Ext.Panel.DD is an internal, undocumented class which
+ * in this config instead of <code>true</code>. 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 {@link Ext.dd.DragSource}, so behaviour may be
* added by implementing the interface methods of {@link Ext.dd.DragDrop} e.g.:
}).show();
</code></pre>
*/
- /**
- * @cfg {String} tabTip
- * A string to be used as innerHTML (html tags are accepted) to show in a tooltip when mousing over
- * the tab of a Ext.Panel which is an item of a {@link Ext.TabPanel}. {@link Ext.QuickTips}.init()
- * must be called in order for the tips to render.
- */
/**
* @cfg {Boolean} disabled
- * Render this panel disabled (default is <tt>false</tt>). An important note when using the disabled
+ * Render this panel disabled (default is <code>false</code>). An important note when using the disabled
* config on panels is that IE will often fail to initialize the disabled mask element correectly 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 {@link #afterlayout} event to initialize
*/
/**
* @cfg {Boolean} autoHeight
- * <tt>true</tt> to use height:'auto', <tt>false</tt> to use fixed height (defaults to <tt>false</tt>).
- * <b>Note</b>: Setting <tt>autoHeight:true</tt> means that the browser will manage the panel's height
+ * <code>true</code> to use height:'auto', <code>false</code> to use fixed height (defaults to <code>false</code>).
+ * <b>Note</b>: Setting <code>autoHeight: true</code> 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 (<tt>fit</tt>, <tt>border</tt>, etc.) then setting <tt>autoHeight:true</tt>
+ * manages dimensions (<code>fit</code>, <code>border</code>, etc.) then setting <code>autoHeight: true</code>
* 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 <tt>'x-panel'</tt>).
- * <p>Another option available by default is to specify <tt>'x-plain'</tt> which strips all styling
+ * The base CSS class to apply to this panel's element (defaults to <code>'x-panel'</code>).
+ * <p>Another option available by default is to specify <code>'x-plain'</code> which strips all styling
* except for required attributes for Ext layouts to function (e.g. overflow:hidden).
- * See <tt>{@link #unstyled}</tt> also.</p>
+ * See <code>{@link #unstyled}</code> also.</p>
*/
baseCls : 'x-panel',
/**
* @cfg {String} collapsedCls
* A CSS class to add to the panel's element after it has been collapsed (defaults to
- * <tt>'x-panel-collapsed'</tt>).
+ * <code>'x-panel-collapsed'</code>).
*/
collapsedCls : 'x-panel-collapsed',
/**
* @cfg {Boolean} maskDisabled
- * <tt>true</tt> to mask the panel when it is {@link #disabled}, <tt>false</tt> to not mask it (defaults
- * to <tt>true</tt>). Either way, the panel will always tell its contained elements to disable themselves
+ * <code>true</code> to mask the panel when it is {@link #disabled}, <code>false</code> to not mask it (defaults
+ * to <code>true</code>). 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
- * <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
- * animation (defaults to <tt>true</tt> if the {@link Ext.Fx} class is available, otherwise <tt>false</tt>).
+ * <code>true</code> to animate the transition when the panel is collapsed, <code>false</code> to skip the
+ * animation (defaults to <code>true</code> if the {@link Ext.Fx} class is available, otherwise <code>false</code>).
*/
animCollapse : Ext.enableFx,
/**
* @cfg {Boolean} headerAsText
- * <tt>true</tt> to display the panel <tt>{@link #title}</tt> in the <tt>{@link #header}</tt>,
- * <tt>false</tt> to hide it (defaults to <tt>true</tt>).
+ * <code>true</code> to display the panel <code>{@link #title}</code> in the <code>{@link #header}</code>,
+ * <code>false</code> to hide it (defaults to <code>true</code>).
*/
headerAsText : true,
/**
* @cfg {String} buttonAlign
- * The alignment of any {@link #buttons} added to this panel. Valid values are <tt>'right'</tt>,
- * <tt>'left'</tt> and <tt>'center'</tt> (defaults to <tt>'right'</tt>).
+ * The alignment of any {@link #buttons} added to this panel. Valid values are <code>'right'</code>,
+ * <code>'left'</code> and <code>'center'</code> (defaults to <code>'right'</code>).
*/
buttonAlign : 'right',
/**
* @cfg {Boolean} collapsed
- * <tt>true</tt> to render the panel collapsed, <tt>false</tt> to render it expanded (defaults to
- * <tt>false</tt>).
+ * <code>true</code> to render the panel collapsed, <code>false</code> to render it expanded (defaults to
+ * <code>false</code>).
*/
collapsed : false,
/**
* @cfg {Boolean} collapseFirst
- * <tt>true</tt> to make sure the collapse/expand toggle button always renders first (to the left of)
- * any other tools in the panel's title bar, <tt>false</tt> to render it last (defaults to <tt>true</tt>).
+ * <code>true</code> to make sure the collapse/expand toggle button always renders first (to the left of)
+ * any other tools in the panel's title bar, <code>false</code> to render it last (defaults to <code>true</code>).
*/
collapseFirst : true,
/**
* @cfg {Number} minButtonWidth
- * Minimum width in pixels of all {@link #buttons} in this panel (defaults to <tt>75</tt>)
+ * Minimum width in pixels of all {@link #buttons} in this panel (defaults to <code>75</code>)
*/
minButtonWidth : 75,
/**
* @cfg {Boolean} unstyled
- * Overrides the <tt>{@link #baseCls}</tt> setting to <tt>{@link #baseCls} = 'x-plain'</tt> which renders
+ * Overrides the <code>{@link #baseCls}</code> setting to <code>{@link #baseCls} = 'x-plain'</code> which renders
* the panel unstyled except for required attributes for Ext layouts to function (e.g. overflow:hidden).
*/
/**
* 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<div class="mdetail-params"><ul>
- * <li><tt>header</tt></li>
- * <li><tt>tbar</tt> (top bar)</li>
- * <li><tt>body</tt></li>
- * <li><tt>bbar</tt> (bottom bar)</li>
- * <li><tt>footer</tt></li>
+ * <li><code>header</code></li>
+ * <li><code>tbar</code> (top bar)</li>
+ * <li><code>body</code></li>
+ * <li><code>bbar</code> (bottom bar)</li>
+ * <li><code>footer</code></li>
* </ul></div>
- * Defaults to '<tt>body</tt>'.
+ * Defaults to '<code>body</code>'.
*/
elements : 'body',
/**
* @cfg {Boolean} preventBodyReset
- * Defaults to <tt>false</tt>. When set to <tt>true</tt>, an extra css class <tt>'x-panel-normal'</tt>
+ * Defaults to <code>false</code>. When set to <code>true</code>, an extra css class <code>'x-panel-normal'</code>
* 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 <b>body</b> element (not the header,
* footer, etc.).
*/
preventBodyReset : false,
+
+ /** @cfg {String} resizeEvent
+ * The event to listen to for resizing in layouts. Defaults to <tt>'bodyresize'</tt>.
+ */
+ resizeEvent: 'bodyresize',
// protected - these could be used to customize the behavior of the window,
// but changing them would not be useful without further mofifications and
this.elements += ',footer';
var btns = this.buttons;
/**
- * This Panel's Array of buttons as created from the <tt>{@link #buttons}</tt>
+ * This Panel's Array of buttons as created from the <code>{@link #buttons}</code>
* config property. Read only.
* @type Array
* @property buttons
*/
this.buttons = [];
- for(var i = 0, len = btns.length; i < len; i++) {
- if(btns[i].render){ // button instance
- this.buttons.push(btns[i]);
- }else if(btns[i].xtype){
- this.buttons.push(Ext.create(btns[i], 'button'));
+ Ext.each(btns, function(btn){
+ if(btn.render){ // button instance
+ this.buttons.push(btn);
+ }else if(btn.xtype){
+ this.buttons.push(Ext.create(btn, 'button'));
}else{
- this.addButton(btns[i]);
+ this.addButton(btn);
}
- }
+ }, this);
}
if(this.fbar){
this.elements += ',footer';
var el = this.el,
d = el.dom,
- bw;
+ 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);
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(this.bwrap.dom.firstChild.firstChild.firstChild);
}else{
this.createElement('header', d);
this.createElement('bwrap', d);
}
}
- if(this.padding !== undefined) {
+ if(Ext.isDefined(this.padding)){
this.body.setStyle('padding', this.body.addUnits(this.padding));
}
this.makeFloating(this.floating);
}
- if(this.collapsible){
- this.tools = this.tools ? this.tools.slice(0) : [];
- if(!this.hideCollapseTool){
- this.tools[this.collapseFirst?'unshift':'push']({
- id: 'toggle',
- handler : this.toggleCollapse,
- scope: this
- });
- }
- if(this.titleCollapse && this.header){
- this.mon(this.header, 'click', this.toggleCollapse, this);
- this.header.setStyle('cursor', 'pointer');
- }
+ if(this.collapsible && this.titleCollapse && this.header){
+ this.mon(this.header, 'click', this.toggleCollapse, this);
+ this.header.setStyle('cursor', 'pointer');
}
- if(this.tools){
- var ts = this.tools;
- this.tools = {};
+ if(ts){
this.addTool.apply(this, ts);
- }else{
- this.tools = {};
}
if(this.buttons && this.buttons.length > 0){
this.bottomToolbar.render(this.bbar);
this.toolbars.push(this.bottomToolbar);
}
- Ext.each(this.toolbars, function(tb){
- tb.on({
- scope: this,
- afterlayout: this.syncHeight,
- remove: this.syncHeight
- });
- }, this);
},
/**
this.header.addClass('x-panel-icon');
this.header.replaceClass(old, this.iconCls);
}else{
- var hd = this.header.dom;
- var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null;
+ var hd = this.header,
+ img = hd.child('img.x-panel-inline-icon');
if(img){
Ext.fly(img).replaceClass(old, this.iconCls);
}else{
- Ext.DomHelper.insertBefore(hd.firstChild, {
+ Ext.DomHelper.insertBefore(hd.dom.firstChild, {
tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
});
}
this.floating = true;
this.el = new Ext.Layer(
Ext.isObject(cfg) ? cfg : {
- shadow: this.shadow !== undefined ? this.shadow : 'sides',
+ shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
shadowOffset: this.shadowOffset,
constrain:false,
shim: this.shim === false ? false : undefined
},
/**
- * Returns the {@link Ext.Toolbar toolbar} from the top (<tt>{@link #tbar}</tt>) section of the panel.
+ * Returns the {@link Ext.Toolbar toolbar} from the top (<code>{@link #tbar}</code>) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getTopToolbar : function(){
},
/**
- * Returns the {@link Ext.Toolbar toolbar} from the bottom (<tt>{@link #bbar}</tt>) section of the panel.
+ * Returns the {@link Ext.Toolbar toolbar} from the bottom (<code>{@link #bbar}</code>) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getBottomToolbar : function(){
minWidth: this.minButtonWidth,
hideParent:true
};
- if(typeof config == "string"){
+ if(Ext.isString(config)){
bc.text = config;
}else{
Ext.apply(bc, config);
// private
addTool : function(){
- if(!this[this.toolTarget]) { // no where to render tools!
+ 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){
}
},
- onLayout : function(){
- if(this.toolbars.length > 0){
- this.duringLayout = true;
+ onLayout : function(shallow, force){
+ if(this.hasLayout && this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
- tb.doLayout();
+ tb.doLayout(undefined, force);
});
- delete this.duringLayout;
this.syncHeight();
}
},
syncHeight : function(){
- if(!(this.autoHeight || this.duringLayout)){
- var last = this.lastSize;
- if(last && !Ext.isEmpty(last.height)){
- var old = last.height, h = this.el.getHeight();
- if(old != 'auto' && old != h){
- var bd = this.body, bdh = bd.getHeight();
- h = Math.max(bdh + old - h, 0);
- if(bdh > 0 && bdh != h){
- bd.setHeight(h);
- if(Ext.isIE && h <= 0){
- return;
- }
- var sz = bd.getSize();
- this.fireEvent('bodyresize', sz.width, sz.height);
- }
- }
- }
+ var h = this.toolbarHeight,
+ bd = this.body,
+ lsh = this.lastSize.height;
+
+ if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
+ return;
+ }
+
+
+ if(h != this.getToolbarHeight()){
+ h = Math.max(0, this.adjustBodyHeight(lsh - this.getFrameHeight()));
+ bd.setHeight(h);
+ sz = bd.getSize();
+ this.toolbarHeight = this.getToolbarHeight();
+ this.onBodyResize(sz.width, sz.height);
}
},
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);
+ if(!this.ownerCt){
+ this.syncHeight();
+ }
+ }
},
// private
* @type Ext.dd.DragSource.
* @property dd
*/
- this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
+ this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
},
// private
- beforeEffect : function(){
+ beforeEffect : function(anim){
if(this.floating){
this.el.beforeAction();
}
- this.el.addClass('x-panel-animated');
+ if(anim !== false){
+ this.el.addClass('x-panel-animated');
+ }
},
// private
- afterEffect : function(){
+ afterEffect : function(anim){
this.syncShadow();
- this.el.removeClass('x-panel-animated');
+ if(anim !== false){
+ this.el.removeClass('x-panel-animated');
+ }
},
// private - wraps up an animation param with internal callbacks
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
- this.beforeEffect();
+ this.beforeEffect(doAnim);
this.onCollapse(doAnim, animate);
return this;
},
this.collapseDefaults));
}else{
this[this.collapseEl].hide();
- this.afterCollapse();
+ this.afterCollapse(false);
}
},
// private
- afterCollapse : function(){
+ afterCollapse : function(anim){
this.collapsed = true;
this.el.addClass(this.collapsedCls);
- this.afterEffect();
+ this.afterEffect(anim);
this.fireEvent('collapse', this);
},
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.el.removeClass(this.collapsedCls);
- this.beforeEffect();
+ this.beforeEffect(doAnim);
this.onExpand(doAnim, animate);
return this;
},
this.expandDefaults));
}else{
this[this.collapseEl].show();
- this.afterExpand();
+ this.afterExpand(false);
}
},
// private
- afterExpand : function(){
+ afterExpand : function(anim){
this.collapsed = false;
- this.afterEffect();
- if(this.deferLayout !== undefined){
+ this.afterEffect(anim);
+ if(Ext.isDefined(this.deferLayout)){
this.doLayout(true);
}
this.fireEvent('expand', this);
// private
onResize : function(w, h){
- if(w !== undefined || h !== undefined){
+ if(Ext.isDefined(w) || Ext.isDefined(h)){
if(!this.collapsed){
- if(typeof w == 'number'){
+ if(Ext.isNumber(w)){
w = this.adjustBodyWidth(w - this.getFrameWidth());
if(this.tbar){
this.tbar.setWidth(w);
this.body.setWidth(w);
}
- if(typeof h == 'number'){
+ if(Ext.isNumber(h)){
h = Math.max(0, this.adjustBodyHeight(h - this.getFrameHeight()));
this.body.setHeight(h);
}else if(h == 'auto'){
}, this, {single:true});
}
}
- this.fireEvent('bodyresize', this, w, h);
+ this.onBodyResize(w, h);
}
this.syncShadow();
},
+
+ // 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;
+ },
// private
adjustBodyHeight : function(h){
* @return {Number} The frame width
*/
getFrameWidth : function(){
- var w = this.el.getFrameWidth('lr')+this.bwrap.getFrameWidth('lr');
+ 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'));
- var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
- w += Ext.fly(mc).getFrameWidth('lr');
+ w += this.mc.getFrameWidth('lr');
}
return w;
},
* @return {Number} The frame height
*/
getFrameHeight : function(){
- var h = this.el.getFrameWidth('tb')+this.bwrap.getFrameWidth('tb');
+ 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){
- var hd = this.el.dom.firstChild;
- var ft = this.bwrap.dom.lastChild;
- h += (hd.offsetHeight + ft.offsetHeight);
- var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
- h += Ext.fly(mc).getFrameWidth('tb');
+ 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);
/**
* <p>Sets the title text for the panel and optionally the {@link #iconCls icon class}.</p>
* <p>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 <tt>{@link #title}</tt>,
- * or configuring it with <tt><b>{@link #header}: true</b></tt>.</p>
+ * for the Panel. This is triggered either by configuring the Panel with a non-blank <code>{@link #title}</code>,
+ * or configuring it with <code><b>{@link #header}: true</b></code>.</p>
* @param {String} title The title text to set
* @param {String} iconCls (optional) {@link #iconCls iconCls} A user-defined CSS class that provides the icon image for this panel
*/
* @param {Object/String/Function} config A config object containing any of the following options:
<pre><code>
panel.load({
- url: "your-url.php",
- params: {param1: "foo", param2: "bar"}, // or a URL encoded string
+ 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...",
+ text: 'Loading...',
timeout: 30,
scripts: false
});
}
}
Ext.Element.uncache(
+ this.ft,
+ this.mc,
this.header,
this.tbar,
this.bbar,
Ext.destroy(this.buttons[b]);
}
}
- Ext.destroy(this.toolbars);
+ if(this.rendered){
+ Ext.destroy(this.toolbars);
+ }else{
+ Ext.destroy(this.topToolbar, this.bottomToolbar);
+ }
Ext.Panel.superclass.beforeDestroy.call(this);
},
*/
/**
* @cfg {Boolean/String} autoSize
- * True for the editor to automatically adopt the size of the element being edited, "width" to adopt the width only,
- * or "height" to adopt the height only (defaults to false)
+ * True for the editor to automatically adopt the size of the underlying field, "width" to adopt the width only,
+ * or "height" to adopt the height only, "none" to always use the field dimensions. (defaults to false)
*/
/**
* @cfg {Boolean} revertInvalid
*/
swallowKeys : true,
/**
- * @cfg {Boolean} completeOnEnter True to complete the edit when the enter key is pressed (defaults to false)
+ * @cfg {Boolean} completeOnEnter True to complete the edit when the enter key is pressed. Defaults to <tt>true</tt>.
*/
- completeOnEnter : false,
+ completeOnEnter : true,
/**
- * @cfg {Boolean} cancelOnEsc True to cancel the edit when the escape key is pressed (defaults to false)
+ * @cfg {Boolean} cancelOnEsc True to cancel the edit when the escape key is pressed. Defaults to <tt>true</tt>.
*/
- cancelOnEsc : false,
+ cancelOnEsc : true,
/**
* @cfg {Boolean} updateEl True to update the innerHTML of the bound element when the update completes (defaults to false)
*/
this.field.msgTarget = 'qtip';
}
this.field.inEditor = true;
- this.field.render(this.el);
- if(Ext.isGecko){
- this.field.el.dom.setAttribute('autocomplete', 'off');
+ this.mon(this.field, {
+ scope: this,
+ blur: this.onBlur,
+ specialkey: this.onSpecialKey
+ });
+ if(this.field.grow){
+ this.mon(this.field, "autosize", this.el.sync, this.el, {delay:1});
}
- this.mon(this.field, "specialkey", this.onSpecialKey, this);
+ this.field.render(this.el).show();
+ this.field.getEl().dom.name = '';
if(this.swallowKeys){
- this.field.el.swallowEvent(['keydown','keypress']);
- }
- this.field.show();
- this.mon(this.field, "blur", this.onBlur, this);
- if(this.field.grow){
- this.mon(this.field, "autosize", this.el.sync, this.el, {delay:1});
+ this.field.el.swallowEvent([
+ 'keypress', // *** Opera
+ 'keydown' // *** all other browsers
+ ]);
}
},
// private
onSpecialKey : function(field, e){
- var key = e.getKey();
- if(this.completeOnEnter && key == e.ENTER){
+ var key = e.getKey(),
+ complete = this.completeOnEnter && key == e.ENTER,
+ cancel = this.cancelOnEsc && key == e.ESC;
+ if(complete || cancel){
e.stopEvent();
- this.completeEdit();
- }else if(this.cancelOnEsc && key == e.ESC){
- this.cancelEdit();
- }else{
- this.fireEvent('specialkey', field, e);
- }
- if(this.field.triggerBlur && (key == e.ENTER || key == e.ESC || key == e.TAB)){
- this.field.triggerBlur();
+ if(complete){
+ this.completeEdit();
+ }else{
+ this.cancelEdit();
+ }
+ if(field.triggerBlur){
+ field.triggerBlur();
+ }
}
+ this.fireEvent('specialkey', field, e);
},
/**
if(!this.rendered){
this.render(this.parentEl || document.body);
}
- if(this.fireEvent("beforestartedit", this, this.boundEl, v) === false){
- return;
+ if(this.fireEvent("beforestartedit", this, this.boundEl, v) !== false){
+ this.startValue = v;
+ this.field.setValue(v);
+ this.doAutoSize();
+ this.el.alignTo(this.boundEl, this.alignment);
+ this.editing = true;
+ this.show();
}
- this.startValue = v;
- this.field.setValue(v);
- this.doAutoSize();
- this.el.alignTo(this.boundEl, this.alignment);
- this.editing = true;
- this.show();
},
// private
doAutoSize : function(){
if(this.autoSize){
- var sz = this.boundEl.getSize();
+ var sz = this.boundEl.getSize(),
+ fs = this.field.getSize();
+
switch(this.autoSize){
case "width":
- this.setSize(sz.width, "");
- break;
+ this.setSize(sz.width, fs.height);
+ break;
case "height":
- this.setSize("", sz.height);
- break;
+ this.setSize(fs.width, sz.height);
+ break;
+ case "none":
+ this.setSize(fs.width, fs.height);
+ break;
default:
- this.setSize(sz.width, sz.height);
+ this.setSize(sz.width, sz.height);
}
}
},
if(this.hideEl !== false){
this.boundEl.hide();
}
- this.field.show();
- if(Ext.isIE && !this.fixIEFocus){ // IE has problems with focusing the first time
- this.fixIEFocus = true;
- this.deferredFocus.defer(50, this);
- }else{
- this.field.focus();
- }
+ this.field.show().focus(false, true);
this.fireEvent("startedit", this.boundEl, this.startValue);
},
- deferredFocus : function(){
- if(this.editing){
- this.field.focus();
- }
- },
-
/**
* Cancels the editing process and hides the editor without persisting any changes. The field value will be
* reverted to the original starting value.
);
if(this.handler){
- this.on("select", this.handler, this.scope, true);
+ this.on('select', this.handler, this.scope, true);
}
};
Ext.extend(Ext.ColorPalette, Ext.Component, {
*/
/**
* @cfg {String} itemCls
- * The CSS class to apply to the containing element (defaults to "x-color-palette")
+ * The CSS class to apply to the containing element (defaults to 'x-color-palette')
*/
- itemCls : "x-color-palette",
+ itemCls : 'x-color-palette',
/**
* @cfg {String} value
* The initial color to highlight (should be a valid 6-digit color hex code without the # symbol). Note that
* the hex codes are case-sensitive.
*/
value : null,
- clickEvent:'click',
+ clickEvent :'click',
// private
- ctype: "Ext.ColorPalette",
+ ctype : 'Ext.ColorPalette',
/**
* @cfg {Boolean} allowReselect If set to true then reselecting a color that is already selected fires the {@link #select} event
* <p>You can override individual colors if needed:</p>
* <pre><code>
var cp = new Ext.ColorPalette();
-cp.colors[0] = "FF0000"; // change the first box to red
+cp.colors[0] = 'FF0000'; // change the first box to red
</code></pre>
Or you can provide a custom array of your own for complete control:
<pre><code>
var cp = new Ext.ColorPalette();
-cp.colors = ["000000", "993300", "333300"];
+cp.colors = ['000000', '993300', '333300'];
</code></pre>
* @type Array
*/
colors : [
- "000000", "993300", "333300", "003300", "003366", "000080", "333399", "333333",
- "800000", "FF6600", "808000", "008000", "008080", "0000FF", "666699", "808080",
- "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF", "800080", "969696",
- "FF00FF", "FFCC00", "FFFF00", "00FF00", "00FFFF", "00CCFF", "993366", "C0C0C0",
- "FF99CC", "FFCC99", "FFFF99", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF"
+ '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
+ '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
+ 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
+ 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
+ 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
],
+ /**
+ * @cfg {Function} handler
+ * Optional. A function that will handle the select event of this palette.
+ * The handler is passed the following parameters:<div class="mdetail-params"><ul>
+ * <li><code>palette</code> : ColorPalette<div class="sub-desc">The {@link #palette Ext.ColorPalette}.</div></li>
+ * <li><code>color</code> : String<div class="sub-desc">The 6-digit color hex code (without the # symbol).</div></li>
+ * </ul></div>
+ */
+ /**
+ * @cfg {Object} scope
+ * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
+ * function will be called. Defaults to this ColorPalette instance.
+ */
+
// private
onRender : function(container, position){
var t = this.tpl || new Ext.XTemplate(
'<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'
);
- var el = document.createElement("div");
+ var el = document.createElement('div');
el.id = this.getId();
el.className = this.itemCls;
t.overwrite(el, this.colors);
* @param {String} color A valid 6-digit color hex code (# will be stripped if included)
*/
select : function(color){
- color = color.replace("#", "");
+ color = color.replace('#', '');
if(color != this.value || this.allowReselect){
var el = this.el;
if(this.value){
- el.child("a.color-"+this.value).removeClass("x-color-palette-sel");
+ el.child('a.color-'+this.value).removeClass('x-color-palette-sel');
}
- el.child("a.color-"+color).addClass("x-color-palette-sel");
+ el.child('a.color-'+color).addClass('x-color-palette-sel');
this.value = color;
- this.fireEvent("select", this, color);
+ this.fireEvent('select', this, color);
}
}
* @cfg {String} autoEl @hide
*/
});
-Ext.reg('colorpalette', Ext.ColorPalette);/**\r
+Ext.reg('colorpalette', Ext.ColorPalette);
+/**\r
* @class Ext.DatePicker\r
* @extends Ext.Component\r
* Simple date picker class.\r
* The text to display on the cancel button (defaults to <tt>'Cancel'</tt>)\r
*/\r
cancelText : 'Cancel',\r
+ /**\r
+ * @cfg {Function} handler\r
+ * Optional. A function that will handle the select event of this picker.\r
+ * The handler is passed the following parameters:<div class="mdetail-params"><ul>\r
+ * <li><code>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>\r
+ * <li><code>date</code> : Date<div class="sub-desc">The selected date.</div></li>\r
+ * </ul></div>\r
+ */\r
+ /**\r
+ * @cfg {Object} scope\r
+ * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>\r
+ * function will be called. Defaults to this DatePicker instance.\r
+ */ \r
/**\r
* @cfg {String} todayTip\r
* The tooltip to display for the button that selects the current date (defaults to <tt>'{current date} (Spacebar)'</tt>)\r
Ext.DatePicker.superclass.initComponent.call(this);\r
\r
this.value = this.value ?\r
- this.value.clearTime() : new Date().clearTime();\r
+ this.value.clearTime(true) : new Date().clearTime();\r
\r
this.addEvents(\r
/**\r
* @param {Date} value The date to set\r
*/\r
setValue : function(value){\r
- var old = this.value;\r
this.value = value.clearTime(true);\r
- if(this.el){\r
- this.update(this.value);\r
- }\r
+ this.update(this.value);\r
},\r
\r
/**\r
\r
// private\r
focus : function(){\r
- if(this.el){\r
- this.update(this.activeDate);\r
- }\r
+ this.update(this.activeDate);\r
},\r
\r
// private\r
},\r
\r
// private\r
- onDisable: function(){\r
+ onDisable : function(){\r
Ext.DatePicker.superclass.onDisable.call(this); \r
this.doDisabled(true);\r
if(Ext.isIE && !Ext.isIE8){\r
},\r
\r
// private\r
- doDisabled: function(disabled){\r
+ doDisabled : function(disabled){\r
this.keyNav.setDisabled(disabled);\r
this.prevRepeater.setDisabled(disabled);\r
this.nextRepeater.setDisabled(disabled);\r
\r
// private\r
update : function(date, forceRefresh){\r
- var vd = this.activeDate, vis = this.isVisible();\r
- this.activeDate = date;\r
- if(!forceRefresh && vd && this.el){\r
- var t = date.getTime();\r
- if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){\r
- this.cells.removeClass('x-date-selected');\r
- this.cells.each(function(c){\r
- if(c.dom.firstChild.dateValue == t){\r
- c.addClass('x-date-selected');\r
- if(vis){\r
- Ext.fly(c.dom.firstChild).focus(50);\r
- }\r
- return false;\r
- }\r
- });\r
- return;\r
- }\r
- }\r
- var days = date.getDaysInMonth();\r
- var firstOfMonth = date.getFirstDateOfMonth();\r
- var startingPos = firstOfMonth.getDay()-this.startDay;\r
-\r
- if(startingPos <= this.startDay){\r
- startingPos += 7;\r
- }\r
-\r
- var pm = date.add('mo', -1);\r
- var prevStart = pm.getDaysInMonth()-startingPos;\r
-\r
- var cells = this.cells.elements;\r
- var textEls = this.textNodes;\r
- days += startingPos;\r
-\r
- // convert everything to numbers so it's fast\r
- var day = 86400000;\r
- var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();\r
- var today = new Date().clearTime().getTime();\r
- var sel = date.clearTime().getTime();\r
- var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;\r
- var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;\r
- var ddMatch = this.disabledDatesRE;\r
- var ddText = this.disabledDatesText;\r
- var ddays = this.disabledDays ? this.disabledDays.join('') : false;\r
- var ddaysText = this.disabledDaysText;\r
- var format = this.format;\r
-\r
- if(this.showToday){\r
- var td = new Date().clearTime();\r
- var disable = (td < min || td > max ||\r
- (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||\r
- (ddays && ddays.indexOf(td.getDay()) != -1));\r
-\r
- if(!this.disabled){\r
- this.todayBtn.setDisabled(disable);\r
- this.todayKeyListener[disable ? 'disable' : 'enable']();\r
- }\r
- }\r
-\r
- var setCellClass = function(cal, cell){\r
- cell.title = '';\r
- var t = d.getTime();\r
- cell.firstChild.dateValue = t;\r
- if(t == today){\r
- cell.className += ' x-date-today';\r
- cell.title = cal.todayText;\r
- }\r
- if(t == sel){\r
- cell.className += ' x-date-selected';\r
- if(vis){\r
- Ext.fly(cell.firstChild).focus(50);\r
- }\r
- }\r
- // disabling\r
- if(t < min) {\r
- cell.className = ' x-date-disabled';\r
- cell.title = cal.minText;\r
- return;\r
- }\r
- if(t > max) {\r
- cell.className = ' x-date-disabled';\r
- cell.title = cal.maxText;\r
- return;\r
- }\r
- if(ddays){\r
- if(ddays.indexOf(d.getDay()) != -1){\r
- cell.title = ddaysText;\r
- cell.className = ' x-date-disabled';\r
- }\r
- }\r
- if(ddMatch && format){\r
- var fvalue = d.dateFormat(format);\r
- if(ddMatch.test(fvalue)){\r
- cell.title = ddText.replace('%0', fvalue);\r
- cell.className = ' x-date-disabled';\r
- }\r
- }\r
- };\r
-\r
- var i = 0;\r
- for(; i < startingPos; i++) {\r
- textEls[i].innerHTML = (++prevStart);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-prevday';\r
- setCellClass(this, cells[i]);\r
- }\r
- for(; i < days; i++){\r
- var intDay = i - startingPos + 1;\r
- textEls[i].innerHTML = (intDay);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-active';\r
- setCellClass(this, cells[i]);\r
- }\r
- var extraDays = 0;\r
- for(; i < 42; i++) {\r
- textEls[i].innerHTML = (++extraDays);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-nextday';\r
- setCellClass(this, cells[i]);\r
- }\r
-\r
- this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());\r
-\r
- if(!this.internalRender){\r
- var main = this.el.dom.firstChild;\r
- var w = main.offsetWidth;\r
- this.el.setWidth(w + this.el.getBorderWidth('lr'));\r
- Ext.fly(main).setWidth(w);\r
- this.internalRender = true;\r
- // opera does not respect the auto grow header center column\r
- // then, after it gets a width opera refuses to recalculate\r
- // without a second pass\r
- if(Ext.isOpera && !this.secondPass){\r
- main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';\r
- this.secondPass = true;\r
- this.update.defer(10, this, [date]);\r
- }\r
+ if(this.rendered){\r
+ var vd = this.activeDate, vis = this.isVisible();\r
+ this.activeDate = date;\r
+ if(!forceRefresh && vd && this.el){\r
+ var t = date.getTime();\r
+ if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){\r
+ this.cells.removeClass('x-date-selected');\r
+ this.cells.each(function(c){\r
+ if(c.dom.firstChild.dateValue == t){\r
+ c.addClass('x-date-selected');\r
+ if(vis){\r
+ Ext.fly(c.dom.firstChild).focus(50);\r
+ }\r
+ return false;\r
+ }\r
+ });\r
+ return;\r
+ }\r
+ }\r
+ var days = date.getDaysInMonth(),\r
+ firstOfMonth = date.getFirstDateOfMonth(),\r
+ startingPos = firstOfMonth.getDay()-this.startDay;\r
+ \r
+ if(startingPos < 0){\r
+ startingPos += 7;\r
+ }\r
+ days += startingPos;\r
+ \r
+ var pm = date.add('mo', -1),\r
+ prevStart = pm.getDaysInMonth()-startingPos,\r
+ cells = this.cells.elements,\r
+ textEls = this.textNodes,\r
+ // convert everything to numbers so it's fast\r
+ day = 86400000,\r
+ d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(),\r
+ today = new Date().clearTime().getTime(),\r
+ sel = date.clearTime(true).getTime(),\r
+ min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,\r
+ max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,\r
+ ddMatch = this.disabledDatesRE,\r
+ ddText = this.disabledDatesText,\r
+ ddays = this.disabledDays ? this.disabledDays.join('') : false,\r
+ ddaysText = this.disabledDaysText,\r
+ format = this.format;\r
+ \r
+ if(this.showToday){\r
+ var td = new Date().clearTime(),\r
+ disable = (td < min || td > max ||\r
+ (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||\r
+ (ddays && ddays.indexOf(td.getDay()) != -1));\r
+ \r
+ if(!this.disabled){\r
+ this.todayBtn.setDisabled(disable);\r
+ this.todayKeyListener[disable ? 'disable' : 'enable']();\r
+ }\r
+ }\r
+ \r
+ var setCellClass = function(cal, cell){\r
+ cell.title = '';\r
+ var t = d.getTime();\r
+ cell.firstChild.dateValue = t;\r
+ if(t == today){\r
+ cell.className += ' x-date-today';\r
+ cell.title = cal.todayText;\r
+ }\r
+ if(t == sel){\r
+ cell.className += ' x-date-selected';\r
+ if(vis){\r
+ Ext.fly(cell.firstChild).focus(50);\r
+ }\r
+ }\r
+ // disabling\r
+ if(t < min) {\r
+ cell.className = ' x-date-disabled';\r
+ cell.title = cal.minText;\r
+ return;\r
+ }\r
+ if(t > max) {\r
+ cell.className = ' x-date-disabled';\r
+ cell.title = cal.maxText;\r
+ return;\r
+ }\r
+ if(ddays){\r
+ if(ddays.indexOf(d.getDay()) != -1){\r
+ cell.title = ddaysText;\r
+ cell.className = ' x-date-disabled';\r
+ }\r
+ }\r
+ if(ddMatch && format){\r
+ var fvalue = d.dateFormat(format);\r
+ if(ddMatch.test(fvalue)){\r
+ cell.title = ddText.replace('%0', fvalue);\r
+ cell.className = ' x-date-disabled';\r
+ }\r
+ }\r
+ };\r
+ \r
+ var i = 0;\r
+ for(; i < startingPos; i++) {\r
+ textEls[i].innerHTML = (++prevStart);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-prevday';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ for(; i < days; i++){\r
+ var intDay = i - startingPos + 1;\r
+ textEls[i].innerHTML = (intDay);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-active';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ var extraDays = 0;\r
+ for(; i < 42; i++) {\r
+ textEls[i].innerHTML = (++extraDays);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-nextday';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ \r
+ this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());\r
+ \r
+ if(!this.internalRender){\r
+ var main = this.el.dom.firstChild,\r
+ w = main.offsetWidth;\r
+ this.el.setWidth(w + this.el.getBorderWidth('lr'));\r
+ Ext.fly(main).setWidth(w);\r
+ this.internalRender = true;\r
+ // opera does not respect the auto grow header center column\r
+ // then, after it gets a width opera refuses to recalculate\r
+ // without a second pass\r
+ if(Ext.isOpera && !this.secondPass){\r
+ main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';\r
+ this.secondPass = true;\r
+ this.update.defer(10, this, [date]);\r
+ }\r
+ }\r
}\r
},\r
\r
this.waitTimer = Ext.TaskMgr.start({\r
run: function(i){\r
var inc = o.increment || 10;\r
+ i -= 1;\r
this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);\r
},\r
interval: o.interval || 1000,\r