4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-Component-method-constructor'><span id='Ext-Component'>/**
19 </span></span> * @class Ext.Component
20 * @extends Ext.AbstractComponent
21 * <p>Base class for all Ext components. All subclasses of Component may participate in the automated
22 * Ext component lifecycle of creation, rendering and destruction which is provided by the {@link Ext.container.Container Container} class.
23 * Components may be added to a Container through the {@link Ext.container.Container#items items} config option at the time the Container is created,
24 * or they may be added dynamically via the {@link Ext.container.Container#add add} method.</p>
25 * <p>The Component base class has built-in support for basic hide/show and enable/disable and size control behavior.</p>
26 * <p>All Components are registered with the {@link Ext.ComponentManager} on construction so that they can be referenced at any time via
27 * {@link Ext#getCmp Ext.getCmp}, passing the {@link #id}.</p>
28 * <p>All user-developed visual widgets that are required to participate in automated lifecycle and size management should subclass Component.</p>
29 * <p>See the <a href="http://sencha.com/learn/Tutorial:Creating_new_UI_controls">Creating new UI controls</a> tutorial for details on how
30 * and to either extend or augment ExtJs base classes to create custom Components.</p>
31 * <p>Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the
32 * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:</p>
35 ------------- ------------------
36 button {@link Ext.button.Button}
37 buttongroup {@link Ext.container.ButtonGroup}
38 colorpalette {@link Ext.picker.Color}
39 component {@link Ext.Component}
40 container {@link Ext.container.Container}
41 cycle {@link Ext.button.Cycle}
42 dataview {@link Ext.view.View}
43 datepicker {@link Ext.picker.Date}
44 editor {@link Ext.Editor}
45 editorgrid {@link Ext.grid.plugin.Editing}
46 grid {@link Ext.grid.Panel}
47 multislider {@link Ext.slider.Multi}
48 panel {@link Ext.panel.Panel}
49 progress {@link Ext.ProgressBar}
50 slider {@link Ext.slider.Single}
51 spacer {@link Ext.toolbar.Spacer}
52 splitbutton {@link Ext.button.Split}
53 tabpanel {@link Ext.tab.Panel}
54 treepanel {@link Ext.tree.Panel}
55 viewport {@link Ext.container.Viewport}
56 window {@link Ext.window.Window}
59 ---------------------------------------
60 paging {@link Ext.toolbar.Paging}
61 toolbar {@link Ext.toolbar.Toolbar}
62 tbfill {@link Ext.toolbar.Fill}
63 tbitem {@link Ext.toolbar.Item}
64 tbseparator {@link Ext.toolbar.Separator}
65 tbspacer {@link Ext.toolbar.Spacer}
66 tbtext {@link Ext.toolbar.TextItem}
69 ---------------------------------------
70 menu {@link Ext.menu.Menu}
71 menucheckitem {@link Ext.menu.CheckItem}
72 menuitem {@link Ext.menu.Item}
73 menuseparator {@link Ext.menu.Separator}
74 menutextitem {@link Ext.menu.Item}
77 ---------------------------------------
78 form {@link Ext.form.Panel}
79 checkbox {@link Ext.form.field.Checkbox}
80 combo {@link Ext.form.field.ComboBox}
81 datefield {@link Ext.form.field.Date}
82 displayfield {@link Ext.form.field.Display}
83 field {@link Ext.form.field.Base}
84 fieldset {@link Ext.form.FieldSet}
85 hidden {@link Ext.form.field.Hidden}
86 htmleditor {@link Ext.form.field.HtmlEditor}
87 label {@link Ext.form.Label}
88 numberfield {@link Ext.form.field.Number}
89 radio {@link Ext.form.field.Radio}
90 radiogroup {@link Ext.form.RadioGroup}
91 textarea {@link Ext.form.field.TextArea}
92 textfield {@link Ext.form.field.Text}
93 timefield {@link Ext.form.field.Time}
94 trigger {@link Ext.form.field.Trigger}
97 ---------------------------------------
98 chart {@link Ext.chart.Chart}
99 barchart {@link Ext.chart.series.Bar}
100 columnchart {@link Ext.chart.series.Column}
101 linechart {@link Ext.chart.series.Line}
102 piechart {@link Ext.chart.series.Pie}
104 </pre><p>
105 * It should not usually be necessary to instantiate a Component because there are provided subclasses which implement specialized Component
106 * use cases which over most application needs. However it is possible to instantiate a base Component, and it will be renderable,
107 * or will particpate in layouts as the child item of a Container:
108 {@img Ext.Component/Ext.Component.png Ext.Component component}
109 <pre><code>
110 Ext.create('Ext.Component', {
111 html: 'Hello world!',
117 backgroundColor:'#000000'
119 renderTo: Ext.getBody()
121 </code></pre>
123 *<p>The Component above creates its encapsulating <code>div</code> upon render, and use the configured HTML as content. More complex
124 * internal structure may be created using the {@link #renderTpl} configuration, although to display database-derived mass
125 * data, it is recommended that an ExtJS data-backed Component such as a {@link Ext.view.View View}, or
126 * {@link Ext.grid.Panel GridPanel}, or {@link Ext.tree.Panel TreePanel} be used.</p>
128 * Creates new Component.
129 * @param {Ext.core.Element/String/Object} config The configuration options may be specified as either:
130 * <div class="mdetail-params"><ul>
131 * <li><b>an element</b> :
132 * <p class="sub-desc">it is set as the internal element and its id used as the component id</p></li>
133 * <li><b>a string</b> :
134 * <p class="sub-desc">it is assumed to be the id of an existing element and is used as the component id</p></li>
135 * <li><b>anything else</b> :
136 * <p class="sub-desc">it is assumed to be a standard config object and is applied to the component</p></li>
137 * </ul></div>
140 Ext.define('Ext.Component', {
142 /* Begin Definitions */
144 alias: ['widget.component', 'widget.box'],
146 extend: 'Ext.AbstractComponent',
149 'Ext.util.DelayedTask'
154 'Ext.resizer.Resizer',
155 'Ext.util.ComponentDragger'
159 floating: 'Ext.util.Floating'
163 // Collapse/expand directions
164 DIRECTION_TOP: 'top',
165 DIRECTION_RIGHT: 'right',
166 DIRECTION_BOTTOM: 'bottom',
167 DIRECTION_LEFT: 'left',
169 VERTICAL_DIRECTION: /^(?:top|bottom)$/
172 /* End Definitions */
174 <span id='Ext-Component-cfg-resizable'> /**
175 </span> * @cfg {Mixed} resizable
176 * <p>Specify as <code>true</code> to apply a {@link Ext.resizer.Resizer Resizer} to this Component
177 * after rendering.</p>
178 * <p>May also be specified as a config object to be passed to the constructor of {@link Ext.resizer.Resizer Resizer}
179 * to override any defaults. By default the Component passes its minimum and maximum size, and uses
180 * <code>{@link Ext.resizer.Resizer#dynamic}: false</code></p>
183 <span id='Ext-Component-cfg-resizeHandles'> /**
184 </span> * @cfg {String} resizeHandles
185 * A valid {@link Ext.resizer.Resizer} handles config string (defaults to 'all'). Only applies when resizable = true.
187 resizeHandles: 'all',
189 <span id='Ext-Component-cfg-autoScroll'> /**
190 </span> * @cfg {Boolean} autoScroll
191 * <code>true</code> to use overflow:'auto' on the components layout element and show scroll bars automatically when
192 * necessary, <code>false</code> to clip any overflowing content (defaults to <code>false</code>).
195 <span id='Ext-Component-cfg-floating'> /**
196 </span> * @cfg {Boolean} floating
197 * <p>Specify as true to float the Component outside of the document flow using CSS absolute positioning.</p>
198 * <p>Components such as {@link Ext.window.Window Window}s and {@link Ext.menu.Menu Menu}s are floating
199 * by default.</p>
200 * <p>Floating Components that are programatically {@link Ext.Component#render rendered} will register themselves with the global
201 * {@link Ext.WindowManager ZIndexManager}</p>
202 * <h3 class="pa">Floating Components as child items of a Container</h3>
203 * <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
204 * examining the ownerCt chain.</p>
205 * <p>When configured as floating, Components acquire, at render time, a {@link Ext.ZIndexManager ZIndexManager} which manages a stack
206 * of related floating Components. The ZIndexManager brings a single floating Component to the top of its stack when
207 * the Component's {@link #toFront} method is called.</p>
208 * <p>The ZIndexManager is found by traversing up the {@link #ownerCt} chain to find an ancestor which itself is floating. This is so that
209 * descendant floating Components of floating <i>Containers</i> (Such as a ComboBox dropdown within a Window) can have its zIndex managed relative
210 * to any siblings, but always <b>above</b> that floating ancestor Container.</p>
211 * <p>If no floating ancestor is found, a floating Component registers itself with the default {@link Ext.WindowManager ZIndexManager}.</p>
212 * <p>Floating components <i>do not participate in the Container's layout</i>. Because of this, they are not rendered until you explicitly
213 * {@link #show} them.</p>
214 * <p>After rendering, the ownerCt reference is deleted, and the {@link #floatParent} property is set to the found floating ancestor Container.
215 * If no floating ancestor Container was found the {@link #floatParent} property will not be set.</p>
219 <span id='Ext-Component-cfg-toFrontOnShow'> /**
220 </span> * @cfg {Boolean} toFrontOnShow
221 * <p>True to automatically call {@link #toFront} when the {@link #show} method is called
222 * on an already visible, floating component (default is <code>true</code>).</p>
226 <span id='Ext-Component-property-zIndexManager'> /**
227 </span> * <p>Optional. Only present for {@link #floating} Components after they have been rendered.</p>
228 * <p>A reference to the ZIndexManager which is managing this Component's z-index.</p>
229 * <p>The {@link Ext.ZIndexManager ZIndexManager} maintains a stack of floating Component z-indices, and also provides a single modal
230 * mask which is insert just beneath the topmost visible modal floating Component.</p>
231 * <p>Floating Components may be {@link #toFront brought to the front} or {@link #toBack sent to the back} of the z-index stack.</p>
232 * <p>This defaults to the global {@link Ext.WindowManager ZIndexManager} for floating Components that are programatically
233 * {@link Ext.Component#render rendered}.</p>
234 * <p>For {@link #floating} Components which are added to a Container, the ZIndexManager is acquired from the first ancestor Container found
235 * which is floating, or if not found the global {@link Ext.WindowManager ZIndexManager} is used.</p>
236 * <p>See {@link #floating} and {@link #floatParent}</p>
237 * @property zIndexManager
238 * @type Ext.ZIndexManager
241 <span id='Ext-Component-property-floatParent'> /**
242 </span> * <p>Optional. Only present for {@link #floating} Components which were inserted as descendant items of floating Containers.</p>
243 * <p>Floating Components that are programatically {@link Ext.Component#render rendered} will not have a <code>floatParent</code> property.</p>
244 * <p>For {@link #floating} Components which are child items of a Container, the floatParent will be the floating ancestor Container which is
245 * responsible for the base z-index value of all its floating descendants. It provides a {@link Ext.ZIndexManager ZIndexManager} which provides
246 * z-indexing services for all its descendant floating Components.</p>
247 * <p>For example, the dropdown {@link Ext.view.BoundList BoundList} of a ComboBox which is in a Window will have the Window as its
248 * <code>floatParent</code></p>
249 * <p>See {@link #floating} and {@link #zIndexManager}</p>
250 * @property floatParent
251 * @type Ext.Container
254 <span id='Ext-Component-cfg-draggable'> /**
255 </span> * @cfg {Mixed} draggable
256 * <p>Specify as true to make a {@link #floating} Component draggable using the Component's encapsulating element as the drag handle.</p>
257 * <p>This may also be specified as a config object for the {@link Ext.util.ComponentDragger ComponentDragger} which is instantiated to perform dragging.</p>
258 * <p>For example to create a Component which may only be dragged around using a certain internal element as the drag handle,
259 * use the delegate option:</p>
260 * <code><pre>
265 backgroundColor: '#fff',
266 border: '1px solid black'
268 html: '&lt;h1 style="cursor:move"&gt;The title&lt;/h1&gt;&lt;p&gt;The content&lt;/p&gt;',
273 </pre></code>
276 <span id='Ext-Component-cfg-maintainFlex'> /**
277 </span> * @cfg {Boolean} maintainFlex
278 * <p><b>Only valid when a sibling element of a {@link Ext.resizer.Splitter Splitter} within a {@link Ext.layout.container.VBox VBox} or
279 * {@link Ext.layout.container.HBox HBox} layout.</b></p>
280 * <p>Specifies that if an immediate sibling Splitter is moved, the Component on the <i>other</i> side is resized, and this
281 * Component maintains its configured {@link Ext.layout.container.Box#flex flex} value.</p>
288 ariaRole: 'presentation',
293 monPropRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
295 //renderTpl: new Ext.XTemplate(
296 // '<div id="{id}" class="{baseCls} {cls} {cmpCls}<tpl if="typeof ui !== \'undefined\'"> {uiBase}-{ui}</tpl>"<tpl if="typeof style !== \'undefined\'"> style="{style}"</tpl>></div>', {
298 // disableFormats: true
301 constructor: function(config) {
302 config = config || {};
303 if (config.initialConfig) {
305 // Being initialized from an Ext.Action instance...
306 if (config.isAction) {
307 this.baseAction = config;
309 config = config.initialConfig;
310 // component cloning / action set up
312 else if (config.tagName || config.dom || Ext.isString(config)) {
316 id: config.id || config
320 this.callParent([config]);
322 // If we were configured from an instance of Ext.Action, (or configured with a baseAction option),
323 // register this Component as one of its items
324 if (this.baseAction){
325 this.baseAction.addComponent(this);
329 initComponent: function() {
336 me.enableBubble(me.bubbleEvents);
341 afterRender: function() {
343 resizable = me.resizable;
346 me.makeFloating(me.floating);
348 me.el.setVisibilityMode(Ext.core.Element[me.hideMode.toUpperCase()]);
351 if (Ext.isDefined(me.autoScroll)) {
352 me.setAutoScroll(me.autoScroll);
356 if (!(me.x && me.y) && (me.pageX || me.pageY)) {
357 me.setPagePosition(me.pageX, me.pageY);
361 me.initResizable(resizable);
371 initAria: function() {
372 var actionEl = this.getActionEl(),
373 role = this.ariaRole;
375 actionEl.dom.setAttribute('role', role);
379 <span id='Ext-Component-method-setAutoScroll'> /**
380 </span> * Sets the overflow on the content element of the component.
381 * @param {Boolean} scroll True to allow the Component to auto scroll.
382 * @return {Ext.Component} this
384 setAutoScroll : function(scroll){
389 targetEl = me.getTargetEl();
390 targetEl.setStyle('overflow', scroll ? 'auto' : '');
391 if (scroll && (Ext.isIE6 || Ext.isIE7)) {
392 // The scrollable container element must be non-statically positioned or IE6/7 will make
393 // positioned children stay in place rather than scrolling with the rest of the content
397 me.autoScroll = scroll;
402 makeFloating : function(cfg){
403 this.mixins.floating.constructor.call(this, cfg);
406 initResizable: function(resizable) {
407 resizable = Ext.apply({
410 constrainTo: this.constrainTo,
411 handles: this.resizeHandles
413 resizable.target = this;
414 this.resizer = Ext.create('Ext.resizer.Resizer', resizable);
417 getDragEl: function() {
421 initDraggable: function() {
423 ddConfig = Ext.applyIf({
424 el: this.getDragEl(),
425 constrainTo: me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : me.el.dom.parentNode)
428 // Add extra configs if Component is specified to be constrained
429 if (me.constrain || me.constrainDelegate) {
430 ddConfig.constrain = me.constrain;
431 ddConfig.constrainDelegate = me.constrainDelegate;
434 this.dd = Ext.create('Ext.util.ComponentDragger', this, ddConfig);
437 <span id='Ext-Component-method-setPosition'> /**
438 </span> * Sets the left and top of the component. To set the page XY position instead, use {@link #setPagePosition}.
439 * This method fires the {@link #move} event.
440 * @param {Number} left The new left
441 * @param {Number} top The new top
442 * @param {Mixed} animate If true, the Component is <i>animated</i> into its new position. You may also pass an animation configuration.
443 * @return {Ext.Component} this
445 setPosition: function(x, y, animate) {
449 adj, adjX, adjY, xIsNumber, yIsNumber;
451 if (Ext.isArray(x)) {
463 adj = me.adjustPosition(x, y);
466 xIsNumber = Ext.isNumber(adjX);
467 yIsNumber = Ext.isNumber(adjY);
469 if (xIsNumber || yIsNumber) {
479 me.animate(Ext.apply({
482 afteranimate: Ext.Function.bind(me.afterSetPosition, me, [adjX, adjY])
491 else if (!yIsNumber) {
495 el.setLeftTop(adjX, adjY);
497 me.afterSetPosition(adjX, adjY);
503 <span id='Ext-Component-method-afterSetPosition'> /**
504 </span> * @private Template method called after a Component has been positioned.
506 afterSetPosition: function(ax, ay) {
507 this.onPosition(ax, ay);
508 this.fireEvent('move', this, ax, ay);
511 showAt: function(x, y, animate) {
512 // A floating Component is positioned relative to its ownerCt if any.
514 this.setPosition(x, y, animate);
516 this.setPagePosition(x, y, animate);
521 <span id='Ext-Component-method-setPagePosition'> /**
522 </span> * Sets the page XY position of the component. To set the left and top instead, use {@link #setPosition}.
523 * This method fires the {@link #move} event.
524 * @param {Number} x The new x position
525 * @param {Number} y The new y position
526 * @param {Mixed} animate If passed, the Component is <i>animated</i> into its new position. If this parameter
527 * is a number, it is used as the animation duration in milliseconds.
528 * @return {Ext.Component} this
530 setPagePosition: function(x, y, animate) {
534 if (Ext.isArray(x)) {
540 if (me.floating && me.floatParent) {
541 // Floating Components being positioned in their ownerCt have to be made absolute
542 p = me.floatParent.getTargetEl().getViewRegion();
543 if (Ext.isNumber(x) && Ext.isNumber(p.left)) {
546 if (Ext.isNumber(y) && Ext.isNumber(p.top)) {
549 me.setPosition(x, y, animate);
552 p = me.el.translatePoints(x, y);
553 me.setPosition(p.left, p.top, animate);
558 <span id='Ext-Component-method-getBox'> /**
559 </span> * Gets the current box measurements of the component's underlying element.
560 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
561 * @return {Object} box An object in the format {x, y, width, height}
563 getBox : function(local){
564 var pos = this.getPosition(local);
565 var s = this.getSize();
571 <span id='Ext-Component-method-updateBox'> /**
572 </span> * Sets the current box measurements of the component's underlying element.
573 * @param {Object} box An object in the format {x, y, width, height}
574 * @return {Ext.Component} this
576 updateBox : function(box){
577 this.setSize(box.width, box.height);
578 this.setPagePosition(box.x, box.y);
583 getOuterSize: function() {
586 width: el.getWidth() + el.getMargin('lr'),
587 height: el.getHeight() + el.getMargin('tb')
592 adjustSize: function(w, h) {
593 if (this.autoWidth) {
597 if (this.autoHeight) {
608 adjustPosition: function(x, y) {
610 // Floating Components being positioned in their ownerCt have to be made absolute
611 if (this.floating && this.floatParent) {
612 var o = this.floatParent.getTargetEl().getViewRegion();
623 <span id='Ext-Component-method-getPosition'> /**
624 </span> * Gets the current XY position of the component's underlying element.
625 * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
626 * @return {Array} The XY position of the element (e.g., [100, 200])
628 getPosition: function(local) {
632 if (local === true) {
633 return [el.getLeft(true), el.getTop(true)];
635 xy = this.xy || el.getXY();
637 // Floating Components in an ownerCt have to have their positions made relative
638 if (this.floating && this.floatParent) {
639 var o = this.floatParent.getTargetEl().getViewRegion();
646 // Todo: add in xtype prefix support
648 return this.id || (this.id = (this.getXType() || 'ext-comp') + '-' + this.getAutoId());
651 onEnable: function() {
652 var actionEl = this.getActionEl();
653 actionEl.dom.removeAttribute('aria-disabled');
654 actionEl.dom.disabled = false;
658 onDisable: function() {
659 var actionEl = this.getActionEl();
660 actionEl.dom.setAttribute('aria-disabled', true);
661 actionEl.dom.disabled = true;
665 <span id='Ext-Component-method-show'> /**
666 </span> * <p>Shows this Component, rendering it first if {@link #autoRender} or {@link #floating} are <code>true</code>.</p>
667 * <p>After being shown, a {@link #floating} Component (such as a {@link Ext.window.Window}), is activated it and brought to the front of
668 * its {@link #zIndexManager z-index stack}.</p>
669 * @param {String/Element} animateTarget Optional, and <b>only valid for {@link #floating} Components such as
670 * {@link Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have been configured
671 * with <code>floating: true</code>.</b> The target from which the Component should
672 * animate from while opening (defaults to null with no animation)
673 * @param {Function} callback (optional) A callback function to call after the Component is displayed. Only necessary if animation was specified.
674 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Component.
675 * @return {Component} this
677 show: function(animateTarget, cb, scope) {
678 if (this.rendered && this.isVisible()) {
679 if (this.toFrontOnShow && this.floating) {
682 } else if (this.fireEvent('beforeshow', this) !== false) {
685 // Render on first show if there is an autoRender config, or if this is a floater (Window, Menu, BoundList etc).
686 if (!this.rendered && (this.autoRender || this.floating)) {
691 this.onShow.apply(this, arguments);
693 // Notify any owning Container unless it's suspended.
694 // Floating Components do not participate in layouts.
695 if (this.ownerCt && !this.floating && !(this.ownerCt.suspendLayout || this.ownerCt.layout.layoutBusy)) {
696 this.ownerCt.doLayout();
698 this.afterShow.apply(this, arguments);
704 beforeShow: Ext.emptyFn,
706 // Private. Override in subclasses where more complex behaviour is needed.
711 if (this.floating && this.constrain) {
714 me.callParent(arguments);
717 afterShow: function(animateTarget, cb, scope) {
723 // Default to configured animate target if none passed
724 animateTarget = animateTarget || me.animateTarget;
726 // Need to be able to ghost the Component
728 animateTarget = null;
730 // If we're animating, kick of an animation of the ghost from the target to the *Element* current box
732 animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
733 toBox = me.el.getBox();
734 fromBox = animateTarget.getBox();
735 fromBox.width += 'px';
736 fromBox.height += 'px';
738 toBox.height += 'px';
739 me.el.addCls(Ext.baseCSSPrefix + 'hide-offsets');
740 ghostPanel = me.ghost();
741 ghostPanel.el.stopAnimation();
743 ghostPanel.el.animate({
747 afteranimate: function() {
748 delete ghostPanel.componentLayout.lastComponentSize;
750 me.el.removeCls(Ext.baseCSSPrefix + 'hide-offsets');
754 Ext.callback(cb, scope || me);
763 Ext.callback(cb, scope || me);
765 me.fireEvent('show', me);
768 <span id='Ext-Component-method-hide'> /**
769 </span> * Hides this Component, setting it to invisible using the configured {@link #hideMode}.
770 * @param {String/Element/Component} animateTarget Optional, and <b>only valid for {@link #floating} Components such as
771 * {@link Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have been configured
772 * with <code>floating: true</code>.</b>.
773 * The target to which the Component should animate while hiding (defaults to null with no animation)
774 * @param {Function} callback (optional) A callback function to call after the Component is hidden.
775 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Component.
776 * @return {Ext.Component} this
780 // Clear the flag which is set if a floatParent was hidden while this is visible.
781 // If a hide operation was subsequently called, that pending show must be hidden.
782 this.showOnParentShow = false;
784 if (!(this.rendered && !this.isVisible()) && this.fireEvent('beforehide', this) !== false) {
787 this.onHide.apply(this, arguments);
789 // Notify any owning Container unless it's suspended.
790 // Floating Components do not participate in layouts.
791 if (this.ownerCt && !this.floating && !(this.ownerCt.suspendLayout || this.ownerCt.layout.layoutBusy)) {
792 this.ownerCt.doLayout();
799 // Possibly animate down to a target element.
800 onHide: function(animateTarget, cb, scope) {
805 // Default to configured animate target if none passed
806 animateTarget = animateTarget || me.animateTarget;
808 // Need to be able to ghost the Component
810 animateTarget = null;
812 // If we're animating, kick off an animation of the ghost down to the target
814 animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
815 ghostPanel = me.ghost();
816 ghostPanel.el.stopAnimation();
817 toBox = animateTarget.getBox();
819 toBox.height += 'px';
820 ghostPanel.el.animate({
823 afteranimate: function() {
824 delete ghostPanel.componentLayout.lastComponentSize;
825 ghostPanel.el.hide();
826 me.afterHide(cb, scope);
832 if (!animateTarget) {
833 me.afterHide(cb, scope);
837 afterHide: function(cb, scope) {
838 Ext.callback(cb, scope || this);
839 this.fireEvent('hide', this);
842 <span id='Ext-Component-method-onDestroy'> /**
844 * Template method to contribute functionality at destroy time.
846 onDestroy: function() {
849 // Ensure that any ancillary components are destroyed.
855 // Different from AbstractComponent
856 if (me.actionMode == 'container' || me.removeMode == 'container') {
857 me.container.remove();
864 deleteMembers: function() {
865 var args = arguments,
868 for (; i < len; ++i) {
869 delete this[args[i]];
873 <span id='Ext-Component-method-focus'> /**
874 </span> * Try to focus this component.
875 * @param {Boolean} selectText (optional) If applicable, true to also select the text in this component
876 * @param {Boolean/Number} delay (optional) Delay the focus this number of milliseconds (true for 10 milliseconds).
877 * @return {Ext.Component} this
879 focus: function(selectText, delay) {
885 me.focusTask = Ext.create('Ext.util.DelayedTask', me.focus);
887 me.focusTask.delay(Ext.isNumber(delay) ? delay : 10, null, me, [selectText, false]);
891 if (me.rendered && !me.isDestroyed) {
892 // getFocusEl could return a Component.
893 focusEl = me.getFocusEl();
895 if (focusEl.dom && selectText === true) {
896 focusEl.dom.select();
899 // Focusing a floating Component brings it to the front of its stack.
900 // this is performed by its zIndexManager. Pass preventFocus true to avoid recursion.
908 <span id='Ext-Component-method-getFocusEl'> /**
910 * Returns the focus holder element associated with this Component. By default, this is the Component's encapsulating
911 * element. Subclasses which use embedded focusable elements (such as Window and Button) should override this for use
912 * by the {@link #focus} method.
913 * @returns {Ext.core.Element} the focus holing element.
915 getFocusEl: function() {
922 this.getFocusEl().blur();
932 getResizeEl: function() {
937 getPositionEl: function() {
942 getActionEl: function() {
947 getVisibilityEl: function() {
952 onResize: Ext.emptyFn,
955 getBubbleTarget: function() {
960 getContentTarget: function() {
964 <span id='Ext-Component-method-cloneConfig'> /**
965 </span> * Clone the current component using the original config values passed into this instance by default.
966 * @param {Object} overrides A new config containing any properties to override in the cloned version.
967 * An id property can be passed on this object, otherwise one will be generated to avoid duplicates.
968 * @return {Ext.Component} clone The cloned copy of this component
970 cloneConfig: function(overrides) {
971 overrides = overrides || {};
972 var id = overrides.id || Ext.id();
973 var cfg = Ext.applyIf(overrides, this.initialConfig);
976 var self = Ext.getClass(this);
979 return new self(cfg);
982 <span id='Ext-Component-method-getXType'> /**
983 </span> * Gets the xtype for this component as registered with {@link Ext.ComponentManager}. For a list of all
984 * available xtypes, see the {@link Ext.Component} header. Example usage:
985 * <pre><code>
986 var t = new Ext.form.field.Text();
987 alert(t.getXType()); // alerts 'textfield'
988 </code></pre>
989 * @return {String} The xtype
991 getXType: function() {
992 return this.self.xtype;
995 <span id='Ext-Component-method-findParentBy'> /**
996 </span> * Find a container above this component at any level by a custom function. If the passed function returns
997 * true, the container will be returned.
998 * @param {Function} fn The custom function to call with the arguments (container, this component).
999 * @return {Ext.container.Container} The first Container for which the custom function returns true
1001 findParentBy: function(fn) {
1004 // Iterate up the ownerCt chain until there's no ownerCt, or we find an ancestor which matches using the selector function.
1005 for (p = this.ownerCt; p && !fn(p, this); p = p.ownerCt);
1009 <span id='Ext-Component-method-findParentByType'> /**
1010 </span> * <p>Find a container above this component at any level by xtype or class</p>
1011 * <p>See also the {@link Ext.Component#up up} method.</p>
1012 * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
1013 * @return {Ext.container.Container} The first Container which matches the given xtype or class
1015 findParentByType: function(xtype) {
1016 return Ext.isFunction(xtype) ?
1017 this.findParentBy(function(p) {
1018 return p.constructor === xtype;
1024 <span id='Ext-Component-method-bubble'> /**
1025 </span> * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope (<i>this</i>) of
1026 * function call will be the scope provided or the current component. The arguments to the function
1027 * will be the args provided or the current component. If the function returns false at any point,
1028 * the bubble is stopped.
1029 * @param {Function} fn The function to call
1030 * @param {Object} scope (optional) The scope of the function (defaults to current node)
1031 * @param {Array} args (optional) The args to call the function with (default to passing the current component)
1032 * @return {Ext.Component} this
1034 bubble: function(fn, scope, args) {
1037 if (fn.apply(scope || p, args || [p]) === false) {
1045 getProxy: function() {
1047 this.proxy = this.el.createProxy(Ext.baseCSSPrefix + 'proxy-el', Ext.getBody(), true);