/** * @class Ext.AbstractComponent * Shared Component class *Base class for all Ext components. All subclasses of Component may participate in the automated * Ext component lifecycle of creation, rendering and destruction which is provided by the {@link Ext.Container Container} class. * Components may be added to a Container through the {@link Ext.Container#items items} config option at the time the Container is created, * or they may be added dynamically via the {@link Ext.Container#add add} method.
*The Component base class has built-in support for basic hide/show and enable/disable behavior.
*All Components are registered with the {@link Ext.ComponentMgr} on construction so that they can be referenced at any time via * {@link Ext#getCmp}, passing the {@link #id}.
*All user-developed visual widgets that are required to participate in automated lifecycle and size management should subclass Component (or * {@link Ext.BoxComponent} if managed box model handling is required, ie height and width management).
*See the Creating new UI controls tutorial for details on how * and to either extend or augment ExtJs base classes to create custom Components.
*Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:
*xtype Class ------------- ------------------ button {@link Ext.Button} buttongroup {@link Ext.ButtonGroup} colorpalette {@link Ext.ColorPalette} component {@link Ext.Component} container {@link Ext.Container} cycle {@link Ext.CycleButton} dataview {@link Ext.DataView} datepicker {@link Ext.DatePicker} editor {@link Ext.Editor} editorgrid {@link Ext.grid.EditorGridPanel} flash {@link Ext.FlashComponent} grid {@link Ext.grid.GridPanel} listview {@link Ext.ListView} multislider {@link Ext.slider.MultiSlider} panel {@link Ext.Panel} progress {@link Ext.ProgressBar} propertygrid {@link Ext.grid.PropertyGrid} slider {@link Ext.slider.SingleSlider} spacer {@link Ext.Spacer} splitbutton {@link Ext.SplitButton} tabpanel {@link Ext.TabPanel} treepanel {@link Ext.tree.TreePanel} viewport {@link Ext.ViewPort} window {@link Ext.Window} Toolbar components --------------------------------------- paging {@link Ext.PagingToolbar} toolbar {@link Ext.Toolbar} tbbutton {@link Ext.Toolbar.Button} (deprecated; use button) tbfill {@link Ext.Toolbar.Fill} tbitem {@link Ext.Toolbar.Item} tbseparator {@link Ext.Toolbar.Separator} tbspacer {@link Ext.Toolbar.Spacer} tbsplit {@link Ext.Toolbar.SplitButton} (deprecated; use splitbutton) tbtext {@link Ext.Toolbar.TextItem} Menu components --------------------------------------- menu {@link Ext.menu.Menu} colormenu {@link Ext.menu.ColorMenu} datemenu {@link Ext.menu.DateMenu} menubaseitem {@link Ext.menu.BaseItem} menucheckitem {@link Ext.menu.CheckItem} menuitem {@link Ext.menu.Item} menuseparator {@link Ext.menu.Separator} menutextitem {@link Ext.menu.TextItem} Form components --------------------------------------- form {@link Ext.form.FormPanel} checkbox {@link Ext.form.Checkbox} checkboxgroup {@link Ext.form.CheckboxGroup} combo {@link Ext.form.ComboBox} compositefield {@link Ext.form.CompositeField} datefield {@link Ext.form.DateField} displayfield {@link Ext.form.DisplayField} field {@link Ext.form.Field} fieldset {@link Ext.form.FieldSet} hidden {@link Ext.form.Hidden} htmleditor {@link Ext.form.HtmlEditor} label {@link Ext.form.Label} numberfield {@link Ext.form.NumberField} radio {@link Ext.form.Radio} radiogroup {@link Ext.form.RadioGroup} textarea {@link Ext.form.TextArea} textfield {@link Ext.form.TextField} timefield {@link Ext.form.TimeField} trigger {@link Ext.form.TriggerField} Chart components --------------------------------------- chart {@link Ext.chart.Chart} barchart {@link Ext.chart.BarChart} cartesianchart {@link Ext.chart.CartesianChart} columnchart {@link Ext.chart.ColumnChart} linechart {@link Ext.chart.LineChart} piechart {@link Ext.chart.PieChart} Store xtypes --------------------------------------- arraystore {@link Ext.data.ArrayStore} directstore {@link Ext.data.DirectStore} groupingstore {@link Ext.data.GroupingStore} jsonstore {@link Ext.data.JsonStore} simplestore {@link Ext.data.SimpleStore} (deprecated; use arraystore) store {@link Ext.data.Store} xmlstore {@link Ext.data.XmlStore}* @constructor * @param {Ext.Element/String/Object} config The configuration options may be specified as either: **/ Ext.define('Ext.AbstractComponent', { /* Begin Definitions */ mixins: { observable: 'Ext.util.Observable' }, requires: [ 'Ext.PluginMgr', 'Ext.ComponentMgr', 'Ext.core.Element', 'Ext.core.DomHelper', 'Ext.XTemplate', 'Ext.ComponentQuery', 'Ext.LoadMask', 'Ext.ComponentLoader', 'Ext.EventManager', 'Ext.layout.Manager', 'Ext.layout.component.Auto' ], // Please remember to add dependencies whenever you use it // I had to fix these many times already uses: [ 'Ext.ZIndexManager' ], statics: { AUTO_ID: 1000 }, /* End Definitions */ isComponent: true, getAutoId: function() { return ++Ext.AbstractComponent.AUTO_ID; }, /** * @cfg {String} id **
- an element : *
*it is set as the internal element and its id used as the component id
- a string : *
*it is assumed to be the id of an existing element and is used as the component id
- anything else : *
*it is assumed to be a standard config object and is applied to the component
The unique id of this component instance (defaults to an {@link #getId auto-assigned id}).
*It should not be necessary to use this configuration except for singleton objects in your application. * Components created with an id may be accessed globally using {@link Ext#getCmp Ext.getCmp}.
*Instead of using assigned ids, use the {@link #itemId} config, and {@link Ext.ComponentQuery ComponentQuery} which * provides selector-based searching for Sencha Components analogous to DOM querying. The {@link Ext.container.Container Container} * class contains {@link Ext.container.Container#down shortcut methods} to query its descendant Components by selector.
*Note that this id will also be used as the element id for the containing HTML element * that is rendered to the page for this component. This allows you to write id-based CSS * rules to style the specific instance of this component uniquely, and also to select * sub-elements using this component's id as the parent.
*Note: to avoid complications imposed by a unique id also see
*{@link #itemId}.Note: to access the container of a Component see
*/ /** * @cfg {String} itemId *{@link #ownerCt}.An itemId can be used as an alternative way to get a reference to a component * when no object reference is available. Instead of using an
*{@link #id}with * {@link Ext}.{@link Ext#getCmp getCmp}, useitemIdwith * {@link Ext.Container}.{@link Ext.Container#getComponent getComponent} which will retrieve *itemId's or {@link #id}'s. SinceitemId's are an index to the * container's internal MixedCollection, theitemIdis scoped locally to the container -- * avoiding potential conflicts with {@link Ext.ComponentMgr} which requires a unique *{@link #id}.*var c = new Ext.Panel({ // {@link Ext.Component#height height}: 300, {@link #renderTo}: document.body, {@link Ext.container.Container#layout layout}: 'auto', {@link Ext.container.Container#items items}: [ { itemId: 'p1', {@link Ext.panel.Panel#title title}: 'Panel 1', {@link Ext.Component#height height}: 150 }, { itemId: 'p2', {@link Ext.panel.Panel#title title}: 'Panel 2', {@link Ext.Component#height height}: 150 } ] }) p1 = c.{@link Ext.Container#getComponent getComponent}('p1'); // not the same as {@link Ext#getCmp Ext.getCmp()} p2 = p1.{@link #ownerCt}.{@link Ext.Container#getComponent getComponent}('p2'); // reference via a sibling *Also see {@link #id} and
*{@link #ref}.Note: to access the container of an item see {@link #ownerCt}.
*/ /** * This Component's owner {@link Ext.container.Container Container} (defaults to undefined, and is set automatically when * this Component is added to a Container). Read-only. *Note: to access items within the Container see {@link #itemId}.
* @type Ext.Container * @property ownerCt */ /** * @cfg {Mixed} autoEl *A tag name or {@link Ext.DomHelper DomHelper} spec used to create the {@link #getEl Element} which will * encapsulate this Component.
*You do not normally need to specify this. For the base classes {@link Ext.Component} and {@link Ext.container.Container}, * this defaults to 'div'. The more complex Sencha classes use a more complex * DOM structure specified by their own {@link #renderTpl}s.
*This is intended to allow the developer to create application-specific utility Components encapsulated by * different DOM elements. Example usage:
*/ /** * @cfg {Mixed} renderTpl *{ xtype: 'component', autoEl: { tag: 'img', src: 'http://www.example.com/example.jpg' } }, { xtype: 'component', autoEl: { tag: 'blockquote', html: 'autoEl is cool!' } }, { xtype: 'container', autoEl: 'ul', cls: 'ux-unordered-list', items: { xtype: 'component', autoEl: 'li', html: 'First list item' } }An {@link Ext.XTemplate XTemplate} used to create the internal structure inside this Component's * encapsulating {@link #getEl Element}.
*You do not normally need to specify this. For the base classes {@link Ext.Component} * and {@link Ext.container.Container}, this defaults to
*nullwhich means that they will be initially rendered * with no internal structure; they render their {@link #getEl Element} empty. The more specialized ExtJS and Touch classes * which use a more complex DOM structure, provide their own template definitions.This is intended to allow the developer to create application-specific utility Components with customized * internal structure.
*Upon rendering, any created child elements may be automatically imported into object properties using the * {@link #renderSelectors} option.
*/ renderTpl: null, /** * @cfg {Object} renderSelectors. *An object containing properties specifying {@link Ext.DomQuery DomQuery} selectors which identify child elements * created by the render process.
*After the Component's internal structure is rendered according to the {@link renderTpl}, this object is iterated through, * and the found Elements are added as properties to the Component using the
*renderSelectorproperty name.For example, a Component which rendered an image, and description into its element might use the following properties * coded into its prototype:
*renderTpl: '{description}', renderSelectors: { image: 'img.x-image-component-img', descEl: 'div.x-image-component-desc' }After rendering, the Component would have a property
*/ /** * @cfg {Mixed} renderTo *imagereferencing its childimgElement, * and a propertydescElreferencing thedivElement which contains the description.Specify the id of the element, a DOM element or an existing Element that this component * will be rendered into.
**
- Notes :
**
Do not use this option if the Component is to be a child item of * a {@link Ext.container.Container Container}. It is the responsibility of the * {@link Ext.container.Container Container}'s {@link Ext.container.Container#layout layout manager} * to render and manage its child items.*When using this config, a call to render() is not required.*See
*/ /** * @cfg {Boolean} frame *{@link #render}also.Specify as
*trueto have the Component inject framing elements within the Component at render time to * provide a graphical rounded frame around the Component content.This is only necessary when running on outdated, or non standard-compliant browsers such as Microsoft's Internet Explorer * prior to version 9 which do not support rounded corners natively.
*The extra space taken up by this framing is available from the read only property {@link #frameSize}.
*/ /** *Read-only property indicating the width of any framing elements which were added within the encapsulating element * to provide graphical, rounded borders. See the {@link #frame} config.
*This is an object containing the frame width in pixels for all four sides of the Component containing * the following properties:
* @property frameSize * @type {Object} */ /** * @cfg {String/Object} componentLayout **
- *
topThe width of the top framing element in pixels.- *
rightThe width of the right framing element in pixels.- *
bottomThe width of the bottom framing element in pixels.- *
leftThe width of the left framing element in pixels.The sizing and positioning of a Component's internal Elements is the responsibility of * the Component's layout manager which sizes a Component's internal structure in response to the Component being sized.
*Generally, developers will not use this configuration as all provided Components which need their internal * elements sizing (Such as {@link Ext.form.Field input fields}) come with their own componentLayout managers.
*The {@link Ext.layout.AutoComponentLayout default layout manager} will be used on instances of the base Ext.Component class * which simply sizes the Component's encapsulating element to the height and width specified in the {@link setSize} method.
*/ /** * @cfg {Mixed} tpl * An{@link Ext.Template} ,{@link Ext.XTemplate} * or an array of strings to form an Ext.XTemplate. * Used in conjunction with the{@link #data}and *{@link #tplWriteMode}configurations. */ /** * @cfg {Mixed} data * The initial set of data to apply to the{@link #tpl}to * update the content area of the Component. */ /** * @cfg {String} tplWriteMode The Ext.(X)Template method to use when * updating the content area of the Component. Defaults to'overwrite'* (see{@link Ext.XTemplate#overwrite}). */ tplWriteMode: 'overwrite', /** * @cfg {String} baseCls * The base CSS class to apply to this components's element. This will also be prepended to * elements within this component like Panel's body will get a class x-panel-body. This means * that if you create a subclass of Panel, and you want it to get all the Panels styling for the * element and the body, you leave the baseCls x-panel and use componentCls to add specific styling for this * component. */ baseCls: Ext.baseCSSPrefix + 'component', /** * @cfg {String} componentCls * CSS Class to be added to a components root level element to give distinction to it * via styling. */ /** * @cfg {String} cls * An optional extra CSS class that will be added to this component's Element (defaults to ''). This can be * useful for adding customized styles to the component or any of its children using standard CSS rules. */ /** * @cfg {String} overCls * An optional extra CSS class that will be added to this component's Element when the mouse moves * over the Element, and removed when the mouse moves out. (defaults to ''). This can be * useful for adding customized 'active' or 'hover' styles to the component or any of its children using standard CSS rules. */ /** * @cfg {String} disabledCls * CSS class to add when the Component is disabled. Defaults to 'x-item-disabled'. */ disabledCls: Ext.baseCSSPrefix + 'item-disabled', /** * @cfg {String} ui * A set of predefined ui styles for individual components. * * Most components support 'light' and 'dark'. * * Extra string added to the baseCls with an extra '-'. **new Ext.Panel({ title: 'Some Title', baseCls: 'x-component' ui: 'green' });The ui configuration in this example would add 'x-component-green' as an additional class.
*/ /** * @cfg {String} style * A custom style specification to be applied to this component's Element. Should be a valid argument to * {@link Ext.core.Element#applyStyles}. **/ /** * @cfg {Number} width * The width of this component in pixels. */ /** * @cfg {Number} height * The height of this component in pixels. */ /** * @cfg {Number/String} border * Specifies the border for this component. The border can be a single numeric value to apply to all sides or * it can be a CSS style specification for each style, for example: '10 5 3 10'. */ /** * @cfg {Number/String} padding * Specifies the padding for this component. The padding can be a single numeric value to apply to all sides or * it can be a CSS style specification for each style, for example: '10 5 3 10'. */ /** * @cfg {Number/String} margin * Specifies the margin for this component. The margin can be a single numeric value to apply to all sides or * it can be a CSS style specification for each style, for example: '10 5 3 10'. */ /** * @cfg {Boolean} hidden * Defaults to false. */ hidden: false, /** * @cfg {Boolean} disabled * Defaults to false. */ disabled: false, /** * @cfg {Boolean} draggable * Allows the component to be dragged via the touch event. */ /** * Read-only property indicating whether or not the component can be dragged * @property draggable * @type {Boolean} */ draggable: false, /** * @cfg {Boolean} floating * Create the Component as a floating and use absolute positioning. * Defaults to false. */ floating: false, /** * @cfg {String} hideMode * A String which specifies how this Component's encapsulating DOM element will be hidden. * Values may benew Ext.Panel({ title: 'Some Title', renderTo: Ext.getBody(), width: 400, height: 300, layout: 'form', items: [{ xtype: 'textarea', style: { width: '95%', marginBottom: '10px' } }, new Ext.Button({ text: 'Send', minWidth: '100', style: { marginBottom: '10px' } }) ] });* Defaults to*
- *
'display': The Component will be hidden using thedisplay: nonestyle.- *
'visibility': The Component will be hidden using thevisibility: hiddenstyle.'offsets': The Component will be hidden by absolutely positioning it out of the visible area of the document. This * is useful when a hidden Component must maintain measurable dimensions. Hiding usingdisplayresults * in a Component having zero dimensions.'display'. */ hideMode: 'display', /** * @cfg {String} contentEl *Optional. Specify an existing HTML element, or the
*idof an existing HTML element to use as the content * for this component.
{@link Ext.container.Container#layout layout}
* scheme that the Component may use. It is just HTML. Layouts operate on child {@link Ext.container.Container#items items}.x-hidden or the x-hide-display CSS class to
* prevent a brief flicker of the content before it is rendered to the panel.The minimum value in pixels which this Component will set its height to.
*Warning: This will override any size management applied by layout managers.
*/ /** * @cfg {Number} minWidth *The minimum value in pixels which this Component will set its width to.
*Warning: This will override any size management applied by layout managers.
*/ /** * @cfg {Number} maxHeight *The maximum value in pixels which this Component will set its height to.
*Warning: This will override any size management applied by layout managers.
*/ /** * @cfg {Number} maxWidth *The maximum value in pixels which this Component will set its width to.
*Warning: This will override any size management applied by layout managers.
*/ /** * @cfg {Ext.ComponentLoader/Object} loader * A configuration object or an instance of a {@link Ext.ComponentLoader} to load remote * content for this Component. */ // @private allowDomMove: true, autoShow: false, /** * @cfg {Mixed} autoRender *This config is intended mainly for {@link #floating} Components which may or may not be shown. Instead * of using {@link #renderTo} in the configuration, and rendering upon construction, this allows a Component * to render itself upon first {@link #show}.
*Specify as true to have this Component render to the document body upon first show.
Specify as an element, or the ID of an element to have this Component render to a specific element upon first show.
*This defaults to true for the {@link Ext.window.Window Window} class.
Fires after the component rendering is finished.
*The afterrender event is fired after this Component has been {@link #rendered}, been postprocesed * by any afterRender method defined for the Component, and, if {@link #stateful}, after state * has been restored.
* @param {Ext.Component} this */ 'afterrender', /** * @event beforedestroy * Fires before the component is {@link #destroy}ed. Return false from an event handler to stop the {@link #destroy}. * @param {Ext.Component} this */ 'beforedestroy', /** * @event destroy * Fires after the component is {@link #destroy}ed. * @param {Ext.Component} this */ 'destroy', /** * @event resize * Fires after the component is resized. * @param {Ext.Component} this * @param {Number} adjWidth The box-adjusted width that was set * @param {Number} adjHeight The box-adjusted height that was set */ 'resize', /** * @event move * Fires after the component is moved. * @param {Ext.Component} this * @param {Number} x The new x position * @param {Number} y The new y position */ 'move', 'beforestaterestore', 'staterestore', 'beforestatesave', 'statesave' ); me.getId(); me.mons = []; me.additionalCls = []; me.renderData = me.renderData || {}; me.renderSelectors = me.renderSelectors || {}; if (me.plugins) { me.plugins = [].concat(me.plugins); for (i = 0, len = me.plugins.length; i < len; i++) { me.plugins[i] = me.constructPlugin(me.plugins[i]); } } me.initComponent(); // ititComponent gets a chance to change the id property before registering Ext.ComponentMgr.register(me); // Dont pass the config so that it is not applied to 'this' again me.mixins.observable.constructor.call(me); // Move this into Observable? if (me.plugins) { me.plugins = [].concat(me.plugins); for (i = 0, len = me.plugins.length; i < len; i++) { me.plugins[i] = me.initPlugin(me.plugins[i]); } } me.loader = me.getLoader(); // This won't work in Touch if (me.applyTo) { me.applyToMarkup(me.applyTo); delete me.applyTo; } else if (me.renderTo) { me.render(me.renderTo); } //Finds the ancestor Container responsible for allocating zIndexes for the passed Component.
*That will be the outermost Container (a Container which has no ownerCt).
*If we have no ancestors, or we walk all the way up to the document body, there's no zIndexParent, * and the global Ext.WindowMgr will be used.
*/ getZIndexParent: function() { var p = this.ownerCt, c; if (p) { while (p) { c = p; p = p.ownerCt; } if (c.el.dom !== document.body) { return c; } } }, // @private render : function(container, position) { var me = this; if (!me.rendered && me.fireEvent('beforerender', me) !== false) { // If this.el is defined, we want to make sure we are dealing with // an Ext Element. if (me.el) { me.el = Ext.get(me.el); } // Floaters must register with a ZIndexManager at render time when the ownerCt chain is complete if (me.floating) { me.zIndexParent = me.getZIndexParent(); me.floatParent = me.ownerCt; delete me.ownerCt; // If a floating Component is configured to be constrained, but has no configured // constrainTo setting, set its constrainTo to be it's ownerCt before rendering. if ((me.constrain || me.constrainHeader) && !me.constrainTo) { me.constrainTo = me.floatParent ? me.floatParent.getTargetEl() : Ext.getBody(); } if (me.zIndexParent) { me.zIndexParent.registerFloatingItem(me); } else { Ext.WindowMgr.register(me); } } container = me.initContainer(container); me.onRender(container, position); // Tell the encapsulating element to hide itself in the way the Component is configured to hide // This means DISPLAY, VISIBILITY or OFFSETS. me.el.setVisibilityMode(Ext.core.Element[me.hideMode.toUpperCase()]); if(me.overCls){ me.el.addClsOnOver(me.overCls); } me.fireEvent('render', me); me.initContent(); me.afterRender(container); me.fireEvent('afterrender', me); me.initEvents(); if (me.autoShow) { me.show(); } if (me.hidden) { // call this so we don't fire initial hide events. me.onHide(false); // no animation after render } if (me.disabled) { // pass silent so the event doesn't fire the first time. me.disable(true); } } return me; }, // @private onRender : function(container, position) { var el = this.el, renderTpl, renderData; position = this.getInsertPosition(position); if (!el) { if (position) { el = Ext.core.DomHelper.insertBefore(position, this.getElConfig(), true); } else { el = Ext.core.DomHelper.append(container, this.getElConfig(), true); } } else if (this.allowDomMove !== false) { if (position) { container.dom.insertBefore(el.dom, position); } else { container.dom.appendChild(el.dom); } } el.addCls(this.initCls()); el.setStyle(this.initStyles()); // Here we check if the component has a height set through style or css. // If it does then we set the this.height to that value and it won't be // considered an auto height component // if (this.height === undefined) { // var height = el.getHeight(); // // This hopefully means that the panel has an explicit height set in style or css // if (height - el.getPadding('tb') - el.getBorderWidth('tb') > 0) { // this.height = height; // } // } this.el = el; if (!Ext.supports.CSS3BorderRadius) { this.initFrame(); } renderTpl = this.initRenderTpl(); if (renderTpl) { renderData = this.initRenderData(); renderTpl.append(this.getTargetEl(), renderData); } this.applyRenderSelectors(); this.rendered = true; }, // @private afterRender : function() { var me = this, pos, xy; me.getComponentLayout(); // Set the configured size. me.setSize(me.width, me.height); // For floaters, calculate x and y if they aren't defined by aligning // the sized element to the center of either the the container or the ownerCt if (me.floating && (me.x === undefined || me.y === undefined)) { if (me.floatParent) { xy = me.el.getAlignToXY(me.floatParent.getTargetEl(), 'c-c'); pos = me.floatParent.getTargetEl().translatePoints(xy[0], xy[1]); } else { xy = me.el.getAlignToXY(me.container, 'c-c'); pos = me.el.translatePoints(xy[0], xy[1]); } me.x = me.x === undefined ? pos.left: me.x; me.y = me.y === undefined ? pos.top: me.y; } if (me.x || me.y) { me.setPosition(me.x, me.y); } if (me.styleHtmlContent) { me.getTargetEl().addCls(me.styleHtmlCls); } }, frameCls: Ext.baseCSSPrefix + 'frame', frameTpl: [ 'Creates an array of class names from the configurations to add to this Component's el on render.
Private, but (possibly) used by ComponentQuery for selection by class name if Component is not rendered.
* @return {Array} An array of class names with which the Component's element will be rendered. * @private */ initCls: function() { var cls = [ this.baseCls ]; //Walks up the ownerCt axis looking for an ancestor Container which matches
* the passed simple selector.
Example:
var owningTabContainer = grid.up('tabcontainer');
* @param {String} selector Optional. The simple selector to test.
* @return {Ext.container.Container} The matching ancestor Container (or undefined if no match was found).
*/
up: function(selector) {
var result = this.ownerCt;
if (selector) {
for (; result; result = result.ownerCt) {
if (Ext.ComponentQuery.is(result, selector)) {
return result;
}
}
}
return result;
},
/**
* Returns the next sibling of this Component.
*Optionally selects the next sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery} selector.
*May also be refered to as prev()
Returns the previous sibling of this Component.
*Optionally selects the previous sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery} selector.
*May also be refered to as prev()
Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended * from the xtype (default) or whether it is directly of the xtype specified (shallow = true).
*If using your own subclasses, be aware that a Component must register its own xtype * to participate in determination of inherited xtypes.
*For a list of all available xtypes, see the {@link Ext.Component} header.
*Example usage:
*
var t = new Ext.form.Text();
var isText = t.isXType('textfield'); // true
var isBoxSubclass = t.isXType('field'); // true, descended from Ext.form.Field
var isBoxInstance = t.isXType('field', true); // false, not a direct Ext.form.Field instance
* @param {String} xtype The xtype to check for this Component
* @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 {Boolean} True if this component descends from the specified xtype, false otherwise.
*/
isXType: function(xtype, shallow) {
//assume a string by default
if (Ext.isFunction(xtype)) {
xtype = xtype.xtype;
//handle being passed the class, e.g. Ext.Component
} else if (Ext.isObject(xtype)) {
xtype = xtype.statics().xtype;
//handle being passed an instance
}
return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1: this.self.xtype == xtype;
},
/**
* Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all * available xtypes, see the {@link Ext.Component} header.
*If using your own subclasses, be aware that a Component must register its own xtype * to participate in determination of inherited xtypes.
*Example usage:
*
var t = new Ext.form.Text();
alert(t.getXTypes()); // alerts 'component/field/textfield'
* @return {String} The xtype hierarchy string
*/
getXTypes: function() {
var self = this.self,
xtypes = [],
parentPrototype = this,
xtype;
if (!self.xtypes) {
while (parentPrototype && Ext.getClass(parentPrototype)) {
xtype = Ext.getClass(parentPrototype).xtype;
if (xtype !== undefined) {
xtypes.unshift(xtype);
}
parentPrototype = parentPrototype.superclass;
}
self.xtypeChain = xtypes;
self.xtypes = xtypes.join('/');
}
return self.xtypes;
},
/**
* Update the content area of a component.
* @param {Mixed} htmlOrData
* If this component has been configured with a template via the tpl config
* then it will use this argument as data to populate the template.
* If this component was not configured with a template, the components
* content area will be updated via Ext.core.Element update
* @param {Boolean} loadScripts
* (optional) Only legitimate when using the html configuration. Defaults to false
* @param {Function} callback
* (optional) Only legitimate when using the html configuration. Callback to execute when scripts have finished loading
*/
update : function(htmlOrData, loadScripts, cb) {
if (this.tpl && !Ext.isString(htmlOrData)) {
this.data = htmlOrData;
if (this.rendered) {
this.tpl[this.tplWriteMode](this.getTargetEl(), htmlOrData || {});
}
}
else {
this.html = Ext.isObject(htmlOrData) ? Ext.core.DomHelper.markup(htmlOrData) : htmlOrData;
if (this.rendered) {
this.getTargetEl().update(this.html, loadScripts, cb);
}
}
if (this.rendered) {
this.doComponentLayout();
}
},
/**
* Convenience function to hide or show this component by boolean.
* @param {Boolean} visible True to show, false to hide
* @return {Ext.Component} this
*/
setVisible : function(visible) {
return this[visible ? 'show': 'hide']();
},
/**
* Returns true if this component is visible.
* @param {Boolean} deep. Optional. Pass true to interrogate the visibility status of all
* parent Containers to determine whether this Component is truly visible to the user.
Generally, to determine whether a Component is hidden, the no argument form is needed. For example * when creating dynamically laid out UIs in a hidden Container before showing them.
* @return {Boolean} True if this component is visible, false otherwise. */ isVisible: function(deep) { var me = this, child = me, visible = !me.hidden, ancestor = me.ownerCt; // Clear hiddenOwnerCt property me.hiddenAncestor = false; if (me.destroyed) { return false; } if (deep && visible && me.rendered && ancestor) { while (ancestor) { // If any ancestor is hidden, then this is hidden. // If an ancestor Panel (only Panels have a collapse method) is collapsed, // then its layoutTarget (body) is hidden, so this is hidden unless its within a // docked item; they are still visible when collapsed (Unless they themseves are hidden) if (ancestor.hidden || (ancestor.collapsed && !(ancestor.getDockedItems && Ext.Array.contains(ancestor.getDockedItems(), child)))) { // Store hiddenOwnerCt property if needed me.hiddenAncestor = ancestor; visible = false; break; } child = ancestor; ancestor = ancestor.ownerCt; } } return visible; }, /** * Enable the component * @param {Boolean} silent * Passing false will supress the 'enable' event from being fired. */ enable : function(silent) { if (this.rendered) { this.el.removeCls(this.disabledCls); this.el.dom.disabled = false; this.onEnable(); } this.disabled = false; if (silent !== true) { this.fireEvent('enable', this); } return this; }, /** * Disable the component. * @param {Boolean} silent * Passing true, will supress the 'disable' event from being fired. */ disable : function(silent) { if (this.rendered) { this.el.addCls(this.disabledCls); this.el.dom.disabled = true; this.onDisable(); } this.disabled = true; if (silent !== true) { this.fireEvent('disable', this); } return this; }, /** * Method to determine whether this Component is currently disabled. * @return {Boolean} the disabled state of this Component. */ isDisabled : function() { return this.disabled; }, /** * Enable or disable the component. * @param {Boolean} disabled */ setDisabled : function(disabled) { return this[disabled ? 'disable': 'enable'](); }, /** * Method to determine whether this Component is currently set to hidden. * @return {Boolean} the hidden state of this Component. */ isHidden : function() { return this.hidden; }, /** * Adds a CSS class to the top level element representing this component. * @returns {Ext.Component} Returns the Component to allow method chaining. */ addCls : function() { var me = this, args = Ext.Array.toArray(arguments); if (me.rendered) { me.el.addCls(args); } else { me.additionalCls = Ext.Array.unique(me.additionalCls.concat(args)); } return me; }, //{width:10, height:20}.
* @param {Mixed} width The new width to set. This may be one of:{width: widthValue, height: heightValue}.undefined to leave the width unchanged.undefined to leave the height unchanged.