3 * @extends Ext.AbstractComponent
4 * <p>Base class for all Ext components. All subclasses of Component may participate in the automated
5 * Ext component lifecycle of creation, rendering and destruction which is provided by the {@link Ext.container.Container Container} class.
6 * Components may be added to a Container through the {@link Ext.container.Container#items items} config option at the time the Container is created,
7 * or they may be added dynamically via the {@link Ext.container.Container#add add} method.</p>
8 * <p>The Component base class has built-in support for basic hide/show and enable/disable and size control behavior.</p>
9 * <p>All Components are registered with the {@link Ext.ComponentManager} on construction so that they can be referenced at any time via
10 * {@link Ext#getCmp Ext.getCmp}, passing the {@link #id}.</p>
11 * <p>All user-developed visual widgets that are required to participate in automated lifecycle and size management should subclass Component.</p>
12 * <p>See the <a href="http://sencha.com/learn/Tutorial:Creating_new_UI_controls">Creating new UI controls</a> tutorial for details on how
13 * and to either extend or augment ExtJs base classes to create custom Components.</p>
14 * <p>Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the
15 * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:</p>
18 ------------- ------------------
19 button {@link Ext.button.Button}
20 buttongroup {@link Ext.container.ButtonGroup}
21 colorpalette {@link Ext.picker.Color}
22 component {@link Ext.Component}
23 container {@link Ext.container.Container}
24 cycle {@link Ext.button.Cycle}
25 dataview {@link Ext.view.View}
26 datepicker {@link Ext.picker.Date}
27 editor {@link Ext.Editor}
28 editorgrid {@link Ext.grid.plugin.Editing}
29 grid {@link Ext.grid.Panel}
30 multislider {@link Ext.slider.Multi}
31 panel {@link Ext.panel.Panel}
32 progress {@link Ext.ProgressBar}
33 slider {@link Ext.slider.Single}
34 spacer {@link Ext.toolbar.Spacer}
35 splitbutton {@link Ext.button.Split}
36 tabpanel {@link Ext.tab.Panel}
37 treepanel {@link Ext.tree.Panel}
38 viewport {@link Ext.container.Viewport}
39 window {@link Ext.window.Window}
42 ---------------------------------------
43 paging {@link Ext.toolbar.Paging}
44 toolbar {@link Ext.toolbar.Toolbar}
45 tbfill {@link Ext.toolbar.Fill}
46 tbitem {@link Ext.toolbar.Item}
47 tbseparator {@link Ext.toolbar.Separator}
48 tbspacer {@link Ext.toolbar.Spacer}
49 tbtext {@link Ext.toolbar.TextItem}
52 ---------------------------------------
53 menu {@link Ext.menu.Menu}
54 menucheckitem {@link Ext.menu.CheckItem}
55 menuitem {@link Ext.menu.Item}
56 menuseparator {@link Ext.menu.Separator}
57 menutextitem {@link Ext.menu.Item}
60 ---------------------------------------
61 form {@link Ext.form.Panel}
62 checkbox {@link Ext.form.field.Checkbox}
63 combo {@link Ext.form.field.ComboBox}
64 datefield {@link Ext.form.field.Date}
65 displayfield {@link Ext.form.field.Display}
66 field {@link Ext.form.field.Base}
67 fieldset {@link Ext.form.FieldSet}
68 hidden {@link Ext.form.field.Hidden}
69 htmleditor {@link Ext.form.field.HtmlEditor}
70 label {@link Ext.form.Label}
71 numberfield {@link Ext.form.field.Number}
72 radio {@link Ext.form.field.Radio}
73 radiogroup {@link Ext.form.RadioGroup}
74 textarea {@link Ext.form.field.TextArea}
75 textfield {@link Ext.form.field.Text}
76 timefield {@link Ext.form.field.Time}
77 trigger {@link Ext.form.field.Trigger}
80 ---------------------------------------
81 chart {@link Ext.chart.Chart}
82 barchart {@link Ext.chart.series.Bar}
83 columnchart {@link Ext.chart.series.Column}
84 linechart {@link Ext.chart.series.Line}
85 piechart {@link Ext.chart.series.Pie}
88 * It should not usually be necessary to instantiate a Component because there are provided subclasses which implement specialized Component
89 * use cases which over most application needs. However it is possible to instantiate a base Component, and it will be renderable,
90 * or will particpate in layouts as the child item of a Container:
91 {@img Ext.Component/Ext.Component.png Ext.Component component}
93 Ext.create('Ext.Component', {
100 backgroundColor:'#000000'
102 renderTo: Ext.getBody()
106 *<p>The Component above creates its encapsulating <code>div</code> upon render, and use the configured HTML as content. More complex
107 * internal structure may be created using the {@link #renderTpl} configuration, although to display database-derived mass
108 * data, it is recommended that an ExtJS data-backed Component such as a {Ext.view.DataView DataView}, or {Ext.grid.Panel GridPanel},
109 * or {@link Ext.tree.Panel TreePanel} be used.</p>
111 * @param {Ext.core.Element/String/Object} config The configuration options may be specified as either:
112 * <div class="mdetail-params"><ul>
113 * <li><b>an element</b> :
114 * <p class="sub-desc">it is set as the internal element and its id used as the component id</p></li>
115 * <li><b>a string</b> :
116 * <p class="sub-desc">it is assumed to be the id of an existing element and is used as the component id</p></li>
117 * <li><b>anything else</b> :
118 * <p class="sub-desc">it is assumed to be a standard config object and is applied to the component</p></li>
122 Ext.define('Ext.Component', {
124 /* Begin Definitions */
126 alias: ['widget.component', 'widget.box'],
128 extend: 'Ext.AbstractComponent',
131 'Ext.util.DelayedTask'
136 'Ext.resizer.Resizer',
137 'Ext.util.ComponentDragger'
141 floating: 'Ext.util.Floating'
145 // Collapse/expand directions
146 DIRECTION_TOP: 'top',
147 DIRECTION_RIGHT: 'right',
148 DIRECTION_BOTTOM: 'bottom',
149 DIRECTION_LEFT: 'left'
152 /* End Definitions */
155 * @cfg {Mixed} resizable
156 * <p>Specify as <code>true</code> to apply a {@link Ext.resizer.Resizer Resizer} to this Component
157 * after rendering.</p>
158 * <p>May also be specified as a config object to be passed to the constructor of {@link Ext.resizer.Resizer Resizer}
159 * to override any defaults. By default the Component passes its minimum and maximum size, and uses
160 * <code>{@link Ext.resizer.Resizer#dynamic}: false</code></p>
164 * @cfg {String} resizeHandles
165 * A valid {@link Ext.resizer.Resizer} handles config string (defaults to 'all'). Only applies when resizable = true.
167 resizeHandles: 'all',
170 * @cfg {Boolean} autoScroll
171 * <code>true</code> to use overflow:'auto' on the components layout element and show scroll bars automatically when
172 * necessary, <code>false</code> to clip any overflowing content (defaults to <code>false</code>).
176 * @cfg {Boolean} floating
177 * <p>Specify as true to float the Component outside of the document flow using CSS absolute positioning.</p>
178 * <p>Components such as {@link Ext.window.Window Window}s and {@link Ext.menu.Menu Menu}s are floating
180 * <p>Floating Components that are programatically {@link Ext.Component#render rendered} will register themselves with the global
181 * {@link Ext.WindowManager ZIndexManager}</p>
182 * <h3 class="pa">Floating Components as child items of a Container</h3>
183 * <p>A floating Component may be used as a child item of a Container. This just allows the floating Component to seek a ZIndexManager by
184 * examining the ownerCt chain.</p>
185 * <p>When configured as floating, Components acquire, at render time, a {@link Ext.ZIndexManager ZIndexManager} which manages a stack
186 * of related floating Components. The ZIndexManager brings a single floating Component to the top of its stack when
187 * the Component's {@link #toFront} method is called.</p>
188 * <p>The ZIndexManager is found by traversing up the {@link #ownerCt} chain to find an ancestor which itself is floating. This is so that
189 * descendant floating Components of floating <i>Containers</i> (Such as a ComboBox dropdown within a Window) can have its zIndex managed relative
190 * to any siblings, but always <b>above</b> that floating ancestor Container.</p>
191 * <p>If no floating ancestor is found, a floating Component registers itself with the default {@link Ext.WindowManager ZIndexManager}.</p>
192 * <p>Floating components <i>do not participate in the Container's layout</i>. Because of this, they are not rendered until you explicitly
193 * {@link #show} them.</p>
194 * <p>After rendering, the ownerCt reference is deleted, and the {@link #floatParent} property is set to the found floating ancestor Container.
195 * If no floating ancestor Container was found the {@link #floatParent} property will not be set.</p>
200 * @cfg {Boolean} toFrontOnShow
201 * <p>True to automatically call {@link #toFront} when the {@link #show} method is called
202 * on an already visible, floating component (default is <code>true</code>).</p>
207 * <p>Optional. Only present for {@link #floating} Components after they have been rendered.</p>
208 * <p>A reference to the ZIndexManager which is managing this Component's z-index.</p>
209 * <p>The {@link Ext.ZIndexManager ZIndexManager} maintains a stack of floating Component z-indices, and also provides a single modal
210 * mask which is insert just beneath the topmost visible modal floating Component.</p>
211 * <p>Floating Components may be {@link #toFront brought to the front} or {@link #toBack sent to the back} of the z-index stack.</p>
212 * <p>This defaults to the global {@link Ext.WindowManager ZIndexManager} for floating Components that are programatically
213 * {@link Ext.Component#render rendered}.</p>
214 * <p>For {@link #floating} Components which are added to a Container, the ZIndexManager is acquired from the first ancestor Container found
215 * which is floating, or if not found the global {@link Ext.WindowManager ZIndexManager} is used.</p>
216 * <p>See {@link #floating} and {@link #floatParent}</p>
217 * @property zIndexManager
218 * @type Ext.ZIndexManager
222 * <p>Optional. Only present for {@link #floating} Components which were inserted as descendant items of floating Containers.</p>
223 * <p>Floating Components that are programatically {@link Ext.Component#render rendered} will not have a <code>floatParent</code> property.</p>
224 * <p>For {@link #floating} Components which are child items of a Container, the floatParent will be the floating ancestor Container which is
225 * responsible for the base z-index value of all its floating descendants. It provides a {@link Ext.ZIndexManager ZIndexManager} which provides
226 * z-indexing services for all its descendant floating Components.</p>
227 * <p>For example, the dropdown {@link Ext.view.BoundList BoundList} of a ComboBox which is in a Window will have the Window as its
228 * <code>floatParent</code></p>
229 * <p>See {@link #floating} and {@link #zIndexManager}</p>
230 * @property floatParent
231 * @type Ext.Container
235 * @cfg {Mixed} draggable
236 * <p>Specify as true to make a {@link #floating} Component draggable using the Component's encapsulating element as the drag handle.</p>
237 * <p>This may also be specified as a config object for the {@link Ext.util.ComponentDragger ComponentDragger} which is instantiated to perform dragging.</p>
238 * <p>For example to create a Component which may only be dragged around using a certain internal element as the drag handle,
239 * use the delegate option:</p>
245 backgroundColor: '#fff',
246 border: '1px solid black'
248 html: '<h1 style="cursor:move">The title</h1><p>The content</p>',
257 * @cfg {Boolean} maintainFlex
258 * <p><b>Only valid when a sibling element of a {@link Ext.resizer.Splitter Splitter} within a {@link Ext.layout.container.VBox VBox} or
259 * {@link Ext.layout.container.HBox HBox} layout.</b></p>
260 * <p>Specifies that if an immediate sibling Splitter is moved, the Component on the <i>other</i> side is resized, and this
261 * Component maintains its configured {@link Ext.layout.container.Box#flex flex} value.</p>
268 ariaRole: 'presentation',
273 monPropRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
275 //renderTpl: new Ext.XTemplate(
276 // '<div id="{id}" class="{baseCls} {cls} {cmpCls}<tpl if="typeof ui !== \'undefined\'"> {uiBase}-{ui}</tpl>"<tpl if="typeof style !== \'undefined\'"> style="{style}"</tpl>></div>', {
278 // disableFormats: true
281 constructor: function(config) {
282 config = config || {};
283 if (config.initialConfig) {
285 // Being initialized from an Ext.Action instance...
286 if (config.isAction) {
287 this.baseAction = config;
289 config = config.initialConfig;
290 // component cloning / action set up
292 else if (config.tagName || config.dom || Ext.isString(config)) {
296 id: config.id || config
300 this.callParent([config]);
302 // If we were configured from an instance of Ext.Action, (or configured with a baseAction option),
303 // register this Component as one of its items
304 if (this.baseAction){
305 this.baseAction.addComponent(this);
309 initComponent: function() {
316 me.enableBubble(me.bubbleEvents);
321 afterRender: function() {
323 resizable = me.resizable;
326 me.makeFloating(me.floating);
328 me.el.setVisibilityMode(Ext.core.Element[me.hideMode.toUpperCase()]);
331 me.setAutoScroll(me.autoScroll);
334 if (!(me.x && me.y) && (me.pageX || me.pageY)) {
335 me.setPagePosition(me.pageX, me.pageY);
339 me.initResizable(resizable);
349 initAria: function() {
350 var actionEl = this.getActionEl(),
351 role = this.ariaRole;
353 actionEl.dom.setAttribute('role', role);
358 * Sets the overflow on the content element of the component.
359 * @param {Boolean} scroll True to allow the Component to auto scroll.
360 * @return {Ext.Component} this
362 setAutoScroll : function(scroll){
367 targetEl = me.getTargetEl();
368 targetEl.setStyle('overflow', scroll ? 'auto' : '');
369 if (scroll && (Ext.isIE6 || Ext.isIE7)) {
370 // The scrollable container element must be non-statically positioned or IE6/7 will make
371 // positioned children stay in place rather than scrolling with the rest of the content
375 me.autoScroll = scroll;
380 makeFloating : function(cfg){
381 this.mixins.floating.constructor.call(this, cfg);
384 initResizable: function(resizable) {
385 resizable = Ext.apply({
388 constrainTo: this.constrainTo,
389 handles: this.resizeHandles
391 resizable.target = this;
392 this.resizer = Ext.create('Ext.resizer.Resizer', resizable);
395 getDragEl: function() {
399 initDraggable: function() {
401 ddConfig = Ext.applyIf({
402 el: this.getDragEl(),
403 constrainTo: me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : me.el.dom.parentNode)
406 // Add extra configs if Component is specified to be constrained
407 if (me.constrain || me.constrainDelegate) {
408 ddConfig.constrain = me.constrain;
409 ddConfig.constrainDelegate = me.constrainDelegate;
412 this.dd = Ext.create('Ext.util.ComponentDragger', this, ddConfig);
416 * Sets the left and top of the component. To set the page XY position instead, use {@link #setPagePosition}.
417 * This method fires the {@link #move} event.
418 * @param {Number} left The new left
419 * @param {Number} top The new top
420 * @param {Mixed} animate If true, the Component is <i>animated</i> into its new position. You may also pass an animation configuration.
421 * @return {Ext.Component} this
423 setPosition: function(x, y, animate) {
427 adj, adjX, adjY, xIsNumber, yIsNumber;
429 if (Ext.isArray(x)) {
441 adj = me.adjustPosition(x, y);
444 xIsNumber = Ext.isNumber(adjX);
445 yIsNumber = Ext.isNumber(adjY);
447 if (xIsNumber || yIsNumber) {
457 me.animate(Ext.apply({
460 afteranimate: Ext.Function.bind(me.afterSetPosition, me, [adjX, adjY])
469 else if (!yIsNumber) {
473 el.setLeftTop(adjX, adjY);
475 me.afterSetPosition(adjX, adjY);
482 * @private Template method called after a Component has been positioned.
484 afterSetPosition: function(ax, ay) {
485 this.onPosition(ax, ay);
486 this.fireEvent('move', this, ax, ay);
489 showAt: function(x, y, animate) {
490 // A floating Component is positioned relative to its ownerCt if any.
492 this.setPosition(x, y, animate);
494 this.setPagePosition(x, y, animate);
500 * Sets the page XY position of the component. To set the left and top instead, use {@link #setPosition}.
501 * This method fires the {@link #move} event.
502 * @param {Number} x The new x position
503 * @param {Number} y The new y position
504 * @param {Mixed} animate If passed, the Component is <i>animated</i> into its new position. If this parameter
505 * is a number, it is used as the animation duration in milliseconds.
506 * @return {Ext.Component} this
508 setPagePosition: function(x, y, animate) {
512 if (Ext.isArray(x)) {
518 if (me.floating && me.floatParent) {
519 // Floating Components being positioned in their ownerCt have to be made absolute
520 p = me.floatParent.getTargetEl().getViewRegion();
521 if (Ext.isNumber(x) && Ext.isNumber(p.left)) {
524 if (Ext.isNumber(y) && Ext.isNumber(p.top)) {
527 me.setPosition(x, y, animate);
530 p = me.el.translatePoints(x, y);
531 me.setPosition(p.left, p.top, animate);
537 * Gets the current box measurements of the component's underlying element.
538 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
539 * @return {Object} box An object in the format {x, y, width, height}
541 getBox : function(local){
542 var pos = this.getPosition(local);
543 var s = this.getSize();
550 * Sets the current box measurements of the component's underlying element.
551 * @param {Object} box An object in the format {x, y, width, height}
552 * @return {Ext.Component} this
554 updateBox : function(box){
555 this.setSize(box.width, box.height);
556 this.setPagePosition(box.x, box.y);
561 getOuterSize: function() {
564 width: el.getWidth() + el.getMargin('lr'),
565 height: el.getHeight() + el.getMargin('tb')
570 adjustSize: function(w, h) {
571 if (this.autoWidth) {
575 if (this.autoHeight) {
586 adjustPosition: function(x, y) {
588 // Floating Components being positioned in their ownerCt have to be made absolute
589 if (this.floating && this.floatParent) {
590 var o = this.floatParent.getTargetEl().getViewRegion();
602 * Gets the current XY position of the component's underlying element.
603 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
604 * @return {Array} The XY position of the element (e.g., [100, 200])
606 getPosition: function(local) {
610 if (local === true) {
611 return [el.getLeft(true), el.getTop(true)];
613 xy = this.xy || el.getXY();
615 // Floating Components in an ownerCt have to have their positions made relative
616 if (this.floating && this.floatParent) {
617 var o = this.floatParent.getTargetEl().getViewRegion();
624 // Todo: add in xtype prefix support
626 return this.id || (this.id = (this.getXType() || 'ext-comp') + '-' + this.getAutoId());
629 onEnable: function() {
630 var actionEl = this.getActionEl();
631 actionEl.dom.removeAttribute('aria-disabled');
632 actionEl.dom.disabled = false;
636 onDisable: function() {
637 var actionEl = this.getActionEl();
638 actionEl.dom.setAttribute('aria-disabled', true);
639 actionEl.dom.disabled = true;
644 * <p>Shows this Component, rendering it first if {@link #autoRender} or {{@link "floating} are <code>true</code>.</p>
645 * <p>After being shown, a {@link #floating} Component (such as a {@link Ext.window.Window}), is activated it and brought to the front of
646 * its {@link #ZIndexManager z-index stack}.</p>
647 * @param {String/Element} animateTarget Optional, and <b>only valid for {@link #floating} Components such as
648 * {@link Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have been configured
649 * with <code>floating: true</code>.</b> The target from which the Component should
650 * animate from while opening (defaults to null with no animation)
651 * @param {Function} callback (optional) A callback function to call after the Component is displayed. Only necessary if animation was specified.
652 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Component.
653 * @return {Component} this
655 show: function(animateTarget, cb, scope) {
656 if (this.rendered && this.isVisible()) {
657 if (this.toFrontOnShow && this.floating) {
660 } else if (this.fireEvent('beforeshow', this) !== false) {
663 // Render on first show if there is an autoRender config, or if this is a floater (Window, Menu, BoundList etc).
664 if (!this.rendered && (this.autoRender || this.floating)) {
669 this.onShow.apply(this, arguments);
671 // Notify any owning Container unless it's suspended.
672 // Floating Components do not participate in layouts.
673 if (this.ownerCt && !this.floating && !(this.ownerCt.suspendLayout || this.ownerCt.layout.layoutBusy)) {
674 this.ownerCt.doLayout();
676 this.afterShow.apply(this, arguments);
682 beforeShow: Ext.emptyFn,
684 // Private. Override in subclasses where more complex behaviour is needed.
689 if (this.floating && this.constrain) {
692 me.callParent(arguments);
695 afterShow: function(animateTarget, cb, scope) {
701 // Default to configured animate target if none passed
702 animateTarget = animateTarget || me.animateTarget;
704 // Need to be able to ghost the Component
706 animateTarget = null;
708 // If we're animating, kick of an animation of the ghost from the target to the *Element* current box
710 animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
711 toBox = me.el.getBox();
712 fromBox = animateTarget.getBox();
713 fromBox.width += 'px';
714 fromBox.height += 'px';
716 toBox.height += 'px';
717 me.el.addCls(Ext.baseCSSPrefix + 'hide-offsets');
718 ghostPanel = me.ghost();
719 ghostPanel.el.stopAnimation();
721 ghostPanel.el.animate({
725 afteranimate: function() {
726 delete ghostPanel.componentLayout.lastComponentSize;
728 me.el.removeCls(Ext.baseCSSPrefix + 'hide-offsets');
732 Ext.callback(cb, scope || me);
741 Ext.callback(cb, scope || me);
743 me.fireEvent('show', me);
747 * Hides this Component, setting it to invisible using the configured {@link #hideMode}.
748 * @param {String/Element/Component} animateTarget Optional, and <b>only valid for {@link #floating} Components such as
749 * {@link Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have been configured
750 * with <code>floating: true</code>.</b>.
751 * The target to which the Component should animate while hiding (defaults to null with no animation)
752 * @param {Function} callback (optional) A callback function to call after the Component is hidden.
753 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Component.
754 * @return {Ext.Component} this
758 // Clear the flag which is set if a floatParent was hidden while this is visible.
759 // If a hide operation was subsequently called, that pending show must be hidden.
760 this.showOnParentShow = false;
762 if (!(this.rendered && !this.isVisible()) && this.fireEvent('beforehide', this) !== false) {
765 this.onHide.apply(this, arguments);
767 // Notify any owning Container unless it's suspended.
768 // Floating Components do not participate in layouts.
769 if (this.ownerCt && !this.floating && !(this.ownerCt.suspendLayout || this.ownerCt.layout.layoutBusy)) {
770 this.ownerCt.doLayout();
777 // Possibly animate down to a target element.
778 onHide: function(animateTarget, cb, scope) {
783 // Default to configured animate target if none passed
784 animateTarget = animateTarget || me.animateTarget;
786 // Need to be able to ghost the Component
788 animateTarget = null;
790 // If we're animating, kick off an animation of the ghost down to the target
792 animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
793 ghostPanel = me.ghost();
794 ghostPanel.el.stopAnimation();
795 toBox = animateTarget.getBox();
797 toBox.height += 'px';
798 ghostPanel.el.animate({
801 afteranimate: function() {
802 delete ghostPanel.componentLayout.lastComponentSize;
803 ghostPanel.el.hide();
804 me.afterHide(cb, scope);
810 if (!animateTarget) {
811 me.afterHide(cb, scope);
815 afterHide: function(cb, scope) {
816 Ext.callback(cb, scope || this);
817 this.fireEvent('hide', this);
822 * Template method to contribute functionality at destroy time.
824 onDestroy: function() {
827 // Ensure that any ancillary components are destroyed.
833 // Different from AbstractComponent
834 if (me.actionMode == 'container' || me.removeMode == 'container') {
835 me.container.remove();
841 deleteMembers: function() {
842 var args = arguments,
845 for (; i < len; ++i) {
846 delete this[args[i]];
851 * Try to focus this component.
852 * @param {Boolean} selectText (optional) If applicable, true to also select the text in this component
853 * @param {Boolean/Number} delay (optional) Delay the focus this number of milliseconds (true for 10 milliseconds).
854 * @return {Ext.Component} this
856 focus: function(selectText, delay) {
861 me.focusTask.delay(Ext.isNumber(delay) ? delay: 10, null, me, [selectText, false]);
865 if (me.rendered && !me.isDestroyed) {
866 // getFocusEl could return a Component.
867 focusEl = me.getFocusEl();
869 if (focusEl.dom && selectText === true) {
870 focusEl.dom.select();
873 // Focusing a floating Component brings it to the front of its stack.
874 // this is performed by its zIndexManager. Pass preventFocus true to avoid recursion.
884 * Returns the focus holder element associated with this Component. By default, this is the Component's encapsulating
885 * element. Subclasses which use embedded focusable elements (such as Window and Button) should override this for use
886 * by the {@link #focus} method.
887 * @returns {Ext.core.Element} the focus holing element.
889 getFocusEl: function() {
896 this.getFocusEl().blur();
906 getResizeEl: function() {
911 getPositionEl: function() {
916 getActionEl: function() {
921 getVisibilityEl: function() {
926 onResize: Ext.emptyFn,
929 getBubbleTarget: function() {
934 getContentTarget: function() {
939 * Clone the current component using the original config values passed into this instance by default.
940 * @param {Object} overrides A new config containing any properties to override in the cloned version.
941 * An id property can be passed on this object, otherwise one will be generated to avoid duplicates.
942 * @return {Ext.Component} clone The cloned copy of this component
944 cloneConfig: function(overrides) {
945 overrides = overrides || {};
946 var id = overrides.id || Ext.id();
947 var cfg = Ext.applyIf(overrides, this.initialConfig);
950 var self = Ext.getClass(this);
953 return new self(cfg);
957 * Gets the xtype for this component as registered with {@link Ext.ComponentManager}. For a list of all
958 * available xtypes, see the {@link Ext.Component} header. Example usage:
960 var t = new Ext.form.field.Text();
961 alert(t.getXType()); // alerts 'textfield'
963 * @return {String} The xtype
965 getXType: function() {
966 return this.self.xtype;
970 * Find a container above this component at any level by a custom function. If the passed function returns
971 * true, the container will be returned.
972 * @param {Function} fn The custom function to call with the arguments (container, this component).
973 * @return {Ext.container.Container} The first Container for which the custom function returns true
975 findParentBy: function(fn) {
978 // Iterate up the ownerCt chain until there's no ownerCt, or we find an ancestor which matches using the selector function.
979 for (p = this.ownerCt; p && !fn(p, this); p = p.ownerCt);
984 * <p>Find a container above this component at any level by xtype or class</p>
985 * <p>See also the {@link Ext.Component#up up} method.</p>
986 * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
987 * @return {Ext.container.Container} The first Container which matches the given xtype or class
989 findParentByType: function(xtype) {
990 return Ext.isFunction(xtype) ?
991 this.findParentBy(function(p) {
992 return p.constructor === xtype;
999 * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope (<i>this</i>) of
1000 * function call will be the scope provided or the current component. The arguments to the function
1001 * will be the args provided or the current component. If the function returns false at any point,
1002 * the bubble is stopped.
1003 * @param {Function} fn The function to call
1004 * @param {Object} scope (optional) The scope of the function (defaults to current node)
1005 * @param {Array} args (optional) The args to call the function with (default to passing the current component)
1006 * @return {Ext.Component} this
1008 bubble: function(fn, scope, args) {
1011 if (fn.apply(scope || p, args || [p]) === false) {
1019 getProxy: function() {
1021 this.proxy = this.el.createProxy(Ext.baseCSSPrefix + 'proxy-el', Ext.getBody(), true);
1028 // A single focus delayer for all Components.
1029 this.prototype.focusTask = Ext.create('Ext.util.DelayedTask', this.prototype.focus);