3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.Component"></div>/**
10 * @class Ext.Component
11 * @extends Ext.util.Observable
12 * <p>Base class for all Ext components. All subclasses of Component may participate in the automated
13 * Ext component lifecycle of creation, rendering and destruction which is provided by the {@link Ext.Container Container} class.
14 * Components may be added to a Container through the {@link Ext.Container#items items} config option at the time the Container is created,
15 * or they may be added dynamically via the {@link Ext.Container#add add} method.</p>
16 * <p>The Component base class has built-in support for basic hide/show and enable/disable behavior.</p>
17 * <p>All Components are registered with the {@link Ext.ComponentMgr} on construction so that they can be referenced at any time via
18 * {@link Ext#getCmp}, passing the {@link #id}.</p>
19 * <p>All user-developed visual widgets that are required to participate in automated lifecycle and size management should subclass Component (or
20 * {@link Ext.BoxComponent} if managed box model handling is required, ie height and width management).</p>
21 * <p>See the <a href="http://extjs.com/learn/Tutorial:Creating_new_UI_controls">Creating new UI controls</a> tutorial for details on how
22 * and to either extend or augment ExtJs base classes to create custom Components.</p>
23 * <p>Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the
24 * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:</p>
27 ------------- ------------------
28 box {@link Ext.BoxComponent}
29 button {@link Ext.Button}
30 buttongroup {@link Ext.ButtonGroup}
31 colorpalette {@link Ext.ColorPalette}
32 component {@link Ext.Component}
33 container {@link Ext.Container}
34 cycle {@link Ext.CycleButton}
35 dataview {@link Ext.DataView}
36 datepicker {@link Ext.DatePicker}
37 editor {@link Ext.Editor}
38 editorgrid {@link Ext.grid.EditorGridPanel}
39 flash {@link Ext.FlashComponent}
40 grid {@link Ext.grid.GridPanel}
41 listview {@link Ext.ListView}
42 panel {@link Ext.Panel}
43 progress {@link Ext.ProgressBar}
44 propertygrid {@link Ext.grid.PropertyGrid}
45 slider {@link Ext.Slider}
46 spacer {@link Ext.Spacer}
47 splitbutton {@link Ext.SplitButton}
48 tabpanel {@link Ext.TabPanel}
49 treepanel {@link Ext.tree.TreePanel}
50 viewport {@link Ext.ViewPort}
51 window {@link Ext.Window}
54 ---------------------------------------
55 paging {@link Ext.PagingToolbar}
56 toolbar {@link Ext.Toolbar}
57 tbbutton {@link Ext.Toolbar.Button} (deprecated; use button)
58 tbfill {@link Ext.Toolbar.Fill}
59 tbitem {@link Ext.Toolbar.Item}
60 tbseparator {@link Ext.Toolbar.Separator}
61 tbspacer {@link Ext.Toolbar.Spacer}
62 tbsplit {@link Ext.Toolbar.SplitButton} (deprecated; use splitbutton)
63 tbtext {@link Ext.Toolbar.TextItem}
66 ---------------------------------------
67 menu {@link Ext.menu.Menu}
68 colormenu {@link Ext.menu.ColorMenu}
69 datemenu {@link Ext.menu.DateMenu}
70 menubaseitem {@link Ext.menu.BaseItem}
71 menucheckitem {@link Ext.menu.CheckItem}
72 menuitem {@link Ext.menu.Item}
73 menuseparator {@link Ext.menu.Separator}
74 menutextitem {@link Ext.menu.TextItem}
77 ---------------------------------------
78 form {@link Ext.form.FormPanel}
79 checkbox {@link Ext.form.Checkbox}
80 checkboxgroup {@link Ext.form.CheckboxGroup}
81 combo {@link Ext.form.ComboBox}
82 datefield {@link Ext.form.DateField}
83 displayfield {@link Ext.form.DisplayField}
84 field {@link Ext.form.Field}
85 fieldset {@link Ext.form.FieldSet}
86 hidden {@link Ext.form.Hidden}
87 htmleditor {@link Ext.form.HtmlEditor}
88 label {@link Ext.form.Label}
89 numberfield {@link Ext.form.NumberField}
90 radio {@link Ext.form.Radio}
91 radiogroup {@link Ext.form.RadioGroup}
92 textarea {@link Ext.form.TextArea}
93 textfield {@link Ext.form.TextField}
94 timefield {@link Ext.form.TimeField}
95 trigger {@link Ext.form.TriggerField}
98 ---------------------------------------
99 chart {@link Ext.chart.Chart}
100 barchart {@link Ext.chart.BarChart}
101 cartesianchart {@link Ext.chart.CartesianChart}
102 columnchart {@link Ext.chart.ColumnChart}
103 linechart {@link Ext.chart.LineChart}
104 piechart {@link Ext.chart.PieChart}
107 ---------------------------------------
108 arraystore {@link Ext.data.ArrayStore}
109 directstore {@link Ext.data.DirectStore}
110 groupingstore {@link Ext.data.GroupingStore}
111 jsonstore {@link Ext.data.JsonStore}
112 simplestore {@link Ext.data.SimpleStore} (deprecated; use arraystore)
113 store {@link Ext.data.Store}
114 xmlstore {@link Ext.data.XmlStore}
117 * @param {Ext.Element/String/Object} config The configuration options may be specified as either:
118 * <div class="mdetail-params"><ul>
119 * <li><b>an element</b> :
120 * <p class="sub-desc">it is set as the internal element and its id used as the component id</p></li>
121 * <li><b>a string</b> :
122 * <p class="sub-desc">it is assumed to be the id of an existing element and is used as the component id</p></li>
123 * <li><b>anything else</b> :
124 * <p class="sub-desc">it is assumed to be a standard config object and is applied to the component</p></li>
127 Ext.Component = function(config){
128 config = config || {};
129 if(config.initialConfig){
130 if(config.isAction){ // actions
131 this.baseAction = config;
133 config = config.initialConfig; // component cloning / action set up
134 }else if(config.tagName || config.dom || Ext.isString(config)){ // element object
135 config = {applyTo: config, id: config.id || config};
138 <div id="prop-Ext.Component-initialConfig"></div>/**
139 * This Component's initial configuration specification. Read-only.
141 * @property initialConfig
143 this.initialConfig = config;
145 Ext.apply(this, config);
147 <div id="event-Ext.Component-added"></div>/**
149 * Fires when a component is added to an Ext.Container
150 * @param {Ext.Component} this
151 * @param {Ext.Container} ownerCt Container which holds the component
152 * @param {number} index Position at which the component was added
155 <div id="event-Ext.Component-disable"></div>/**
157 * Fires after the component is disabled.
158 * @param {Ext.Component} this
161 <div id="event-Ext.Component-enable"></div>/**
163 * Fires after the component is enabled.
164 * @param {Ext.Component} this
167 <div id="event-Ext.Component-beforeshow"></div>/**
169 * Fires before the component is shown by calling the {@link #show} method.
170 * Return false from an event handler to stop the show.
171 * @param {Ext.Component} this
174 <div id="event-Ext.Component-show"></div>/**
176 * Fires after the component is shown when calling the {@link #show} method.
177 * @param {Ext.Component} this
180 <div id="event-Ext.Component-beforehide"></div>/**
182 * Fires before the component is hidden by calling the {@link #hide} method.
183 * Return false from an event handler to stop the hide.
184 * @param {Ext.Component} this
187 <div id="event-Ext.Component-hide"></div>/**
189 * Fires after the component is hidden.
190 * Fires after the component is hidden when calling the {@link #hide} method.
191 * @param {Ext.Component} this
194 <div id="event-Ext.Component-removed"></div>/**
196 * Fires when a component is removed from an Ext.Container
197 * @param {Ext.Component} this
198 * @param {Ext.Container} ownerCt Container which holds the component
201 <div id="event-Ext.Component-beforerender"></div>/**
202 * @event beforerender
203 * Fires before the component is {@link #rendered}. Return false from an
204 * event handler to stop the {@link #render}.
205 * @param {Ext.Component} this
208 <div id="event-Ext.Component-render"></div>/**
210 * Fires after the component markup is {@link #rendered}.
211 * @param {Ext.Component} this
214 <div id="event-Ext.Component-afterrender"></div>/**
216 * <p>Fires after the component rendering is finished.</p>
217 * <p>The afterrender event is fired after this Component has been {@link #rendered}, been postprocesed
218 * by any afterRender method defined for the Component, and, if {@link #stateful}, after state
219 * has been restored.</p>
220 * @param {Ext.Component} this
223 <div id="event-Ext.Component-beforedestroy"></div>/**
224 * @event beforedestroy
225 * Fires before the component is {@link #destroy}ed. Return false from an event handler to stop the {@link #destroy}.
226 * @param {Ext.Component} this
229 <div id="event-Ext.Component-destroy"></div>/**
231 * Fires after the component is {@link #destroy}ed.
232 * @param {Ext.Component} this
235 <div id="event-Ext.Component-beforestaterestore"></div>/**
236 * @event beforestaterestore
237 * Fires before the state of the component is restored. Return false from an event handler to stop the restore.
238 * @param {Ext.Component} this
239 * @param {Object} state The hash of state values returned from the StateProvider. If this
240 * event is not vetoed, then the state object is passed to <b><tt>applyState</tt></b>. By default,
241 * that simply copies property values into this Component. The method maybe overriden to
242 * provide custom state restoration.
244 'beforestaterestore',
245 <div id="event-Ext.Component-staterestore"></div>/**
246 * @event staterestore
247 * Fires after the state of the component is restored.
248 * @param {Ext.Component} this
249 * @param {Object} state The hash of state values returned from the StateProvider. This is passed
250 * to <b><tt>applyState</tt></b>. By default, that simply copies property values into this
251 * Component. The method maybe overriden to provide custom state restoration.
254 <div id="event-Ext.Component-beforestatesave"></div>/**
255 * @event beforestatesave
256 * Fires before the state of the component is saved to the configured state provider. Return false to stop the save.
257 * @param {Ext.Component} this
258 * @param {Object} state The hash of state values. This is determined by calling
259 * <b><tt>getState()</tt></b> on the Component. This method must be provided by the
260 * developer to return whetever representation of state is required, by default, Ext.Component
261 * has a null implementation.
264 <div id="event-Ext.Component-statesave"></div>/**
266 * Fires after the state of the component is saved to the configured state provider.
267 * @param {Ext.Component} this
268 * @param {Object} state The hash of state values. This is determined by calling
269 * <b><tt>getState()</tt></b> on the Component. This method must be provided by the
270 * developer to return whetever representation of state is required, by default, Ext.Component
271 * has a null implementation.
276 Ext.ComponentMgr.register(this);
277 Ext.Component.superclass.constructor.call(this);
280 this.baseAction.addComponent(this);
283 this.initComponent();
286 if(Ext.isArray(this.plugins)){
287 for(var i = 0, len = this.plugins.length; i < len; i++){
288 this.plugins[i] = this.initPlugin(this.plugins[i]);
291 this.plugins = this.initPlugin(this.plugins);
295 if(this.stateful !== false){
300 this.applyToMarkup(this.applyTo);
302 }else if(this.renderTo){
303 this.render(this.renderTo);
304 delete this.renderTo;
309 Ext.Component.AUTO_ID = 1000;
311 Ext.extend(Ext.Component, Ext.util.Observable, {
312 // Configs below are used for all Components when rendered by FormLayout.
313 <div id="cfg-Ext.Component-fieldLabel"></div>/**
314 * @cfg {String} fieldLabel <p>The label text to display next to this Component (defaults to '').</p>
315 * <br><p><b>Note</b>: this config is only used when this Component is rendered by a Container which
316 * has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout manager (e.g.
317 * {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>).</p><br>
318 * <p>Also see <tt>{@link #hideLabel}</tt> and
319 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</p>
320 * Example use:<pre><code>
323 renderTo: Ext.getBody(),
331 <div id="cfg-Ext.Component-labelStyle"></div>/**
332 * @cfg {String} labelStyle <p>A CSS style specification string to apply directly to this field's
333 * label. Defaults to the container's labelStyle value if set (e.g.,
334 * <tt>{@link Ext.layout.FormLayout#labelStyle}</tt> , or '').</p>
335 * <br><p><b>Note</b>: see the note for <code>{@link #clearCls}</code>.</p><br>
336 * <p>Also see <code>{@link #hideLabel}</code> and
337 * <code>{@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</code></p>
338 * Example use:<pre><code>
341 renderTo: Ext.getBody(),
345 labelStyle: 'font-weight:bold;'
350 <div id="cfg-Ext.Component-labelSeparator"></div>/**
351 * @cfg {String} labelSeparator <p>The separator to display after the text of each
352 * <tt>{@link #fieldLabel}</tt>. This property may be configured at various levels.
353 * The order of precedence is:
354 * <div class="mdetail-params"><ul>
355 * <li>field / component level</li>
356 * <li>container level</li>
357 * <li>{@link Ext.layout.FormLayout#labelSeparator layout level} (defaults to colon <tt>':'</tt>)</li>
359 * To display no separator for this field's label specify empty string ''.</p>
360 * <br><p><b>Note</b>: see the note for <tt>{@link #clearCls}</tt>.</p><br>
361 * <p>Also see <tt>{@link #hideLabel}</tt> and
362 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</p>
363 * Example use:<pre><code>
366 renderTo: Ext.getBody(),
368 labelSeparator: '~' // layout config has lowest priority (defaults to ':')
370 {@link Ext.layout.FormLayout#labelSeparator labelSeparator}: '>>', // config at container level
373 fieldLabel: 'Field 1',
374 labelSeparator: '...' // field/component level config supersedes others
377 fieldLabel: 'Field 2' // labelSeparator will be '='
382 <div id="cfg-Ext.Component-hideLabel"></div>/**
383 * @cfg {Boolean} hideLabel <p><tt>true</tt> to completely hide the label element
384 * ({@link #fieldLabel label} and {@link #labelSeparator separator}). Defaults to <tt>false</tt>.
385 * By default, even if you do not specify a <tt>{@link #fieldLabel}</tt> the space will still be
386 * reserved so that the field will line up with other fields that do have labels.
387 * Setting this to <tt>true</tt> will cause the field to not reserve that space.</p>
388 * <br><p><b>Note</b>: see the note for <tt>{@link #clearCls}</tt>.</p><br>
389 * Example use:<pre><code>
392 renderTo: Ext.getBody(),
400 <div id="cfg-Ext.Component-clearCls"></div>/**
401 * @cfg {String} clearCls <p>The CSS class used to to apply to the special clearing div rendered
402 * directly after each form field wrapper to provide field clearing (defaults to
403 * <tt>'x-form-clear-left'</tt>).</p>
404 * <br><p><b>Note</b>: this config is only used when this Component is rendered by a Container
405 * which has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout
406 * manager (e.g. {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>) and either a
407 * <tt>{@link #fieldLabel}</tt> is specified or <tt>isFormField=true</tt> is specified.</p><br>
408 * <p>See {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} also.</p>
410 <div id="cfg-Ext.Component-itemCls"></div>/**
411 * @cfg {String} itemCls
412 * <p><b>Note</b>: this config is only used when this Component is rendered by a Container which
413 * has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout manager (e.g.
414 * {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>).</p><br>
415 * <p>An additional CSS class to apply to the div wrapping the form item
416 * element of this field. If supplied, <tt>itemCls</tt> at the <b>field</b> level will override
417 * the default <tt>itemCls</tt> supplied at the <b>container</b> level. The value specified for
418 * <tt>itemCls</tt> will be added to the default class (<tt>'x-form-item'</tt>).</p>
419 * <p>Since it is applied to the item wrapper (see
420 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}), it allows
421 * you to write standard CSS rules that can apply to the field, the label (if specified), or
422 * any other element within the markup for the field.</p>
423 * <br><p><b>Note</b>: see the note for <tt>{@link #fieldLabel}</tt>.</p><br>
424 * Example use:<pre><code>
425 // Apply a style to the field's label:
427 .required .x-form-item-label {font-weight:bold;color:red;}
432 renderTo: Ext.getBody(),
436 itemCls: 'required' //this label will be styled
439 fieldLabel: 'Favorite Color'
445 // Configs below are used for all Components when rendered by AnchorLayout.
446 <div id="cfg-Ext.Component-anchor"></div>/**
447 * @cfg {String} anchor <p><b>Note</b>: this config is only used when this Component is rendered
448 * by a Container which has been configured to use an <b>{@link Ext.layout.AnchorLayout AnchorLayout}</b>
449 * based layout manager, for example:<div class="mdetail-params"><ul>
450 * <li>{@link Ext.form.FormPanel}</li>
451 * <li>specifying <code>layout: 'anchor' // or 'form', or 'absolute'</code></li>
453 * <p>See {@link Ext.layout.AnchorLayout}.{@link Ext.layout.AnchorLayout#anchor anchor} also.</p>
456 <div id="cfg-Ext.Component-id"></div>/**
458 * <p>The <b>unique</b> id of this component (defaults to an {@link #getId auto-assigned id}).
459 * You should assign an id if you need to be able to access the component later and you do
460 * not have an object reference available (e.g., using {@link Ext}.{@link Ext#getCmp getCmp}).</p>
461 * <p>Note that this id will also be used as the element id for the containing HTML element
462 * that is rendered to the page for this component. This allows you to write id-based CSS
463 * rules to style the specific instance of this component uniquely, and also to select
464 * sub-elements using this component's id as the parent.</p>
465 * <p><b>Note</b>: to avoid complications imposed by a unique <tt>id</tt> also see
466 * <code>{@link #itemId}</code> and <code>{@link #ref}</code>.</p>
467 * <p><b>Note</b>: to access the container of an item see <code>{@link #ownerCt}</code>.</p>
469 <div id="cfg-Ext.Component-itemId"></div>/**
470 * @cfg {String} itemId
471 * <p>An <tt>itemId</tt> can be used as an alternative way to get a reference to a component
472 * when no object reference is available. Instead of using an <code>{@link #id}</code> with
473 * {@link Ext}.{@link Ext#getCmp getCmp}, use <code>itemId</code> with
474 * {@link Ext.Container}.{@link Ext.Container#getComponent getComponent} which will retrieve
475 * <code>itemId</code>'s or <tt>{@link #id}</tt>'s. Since <code>itemId</code>'s are an index to the
476 * container's internal MixedCollection, the <code>itemId</code> is scoped locally to the container --
477 * avoiding potential conflicts with {@link Ext.ComponentMgr} which requires a <b>unique</b>
478 * <code>{@link #id}</code>.</p>
480 var c = new Ext.Panel({ //
481 {@link Ext.BoxComponent#height height}: 300,
482 {@link #renderTo}: document.body,
483 {@link Ext.Container#layout layout}: 'auto',
484 {@link Ext.Container#items items}: [
487 {@link Ext.Panel#title title}: 'Panel 1',
488 {@link Ext.BoxComponent#height height}: 150
492 {@link Ext.Panel#title title}: 'Panel 2',
493 {@link Ext.BoxComponent#height height}: 150
497 p1 = c.{@link Ext.Container#getComponent getComponent}('p1'); // not the same as {@link Ext#getCmp Ext.getCmp()}
498 p2 = p1.{@link #ownerCt}.{@link Ext.Container#getComponent getComponent}('p2'); // reference via a sibling
500 * <p>Also see <tt>{@link #id}</tt> and <code>{@link #ref}</code>.</p>
501 * <p><b>Note</b>: to access the container of an item see <tt>{@link #ownerCt}</tt>.</p>
503 <div id="cfg-Ext.Component-xtype"></div>/**
504 * @cfg {String} xtype
505 * The registered <tt>xtype</tt> to create. This config option is not used when passing
506 * a config object into a constructor. This config option is used only when
507 * lazy instantiation is being used, and a child item of a Container is being
508 * specified not as a fully instantiated Component, but as a <i>Component config
509 * object</i>. The <tt>xtype</tt> will be looked up at render time up to determine what
510 * type of child Component to create.<br><br>
511 * The predefined xtypes are listed {@link Ext.Component here}.
513 * If you subclass Components to create your own Components, you may register
514 * them using {@link Ext.ComponentMgr#registerType} in order to be able to
515 * take advantage of lazy instantiation and rendering.
517 <div id="cfg-Ext.Component-ptype"></div>/**
518 * @cfg {String} ptype
519 * The registered <tt>ptype</tt> to create. This config option is not used when passing
520 * a config object into a constructor. This config option is used only when
521 * lazy instantiation is being used, and a Plugin is being
522 * specified not as a fully instantiated Component, but as a <i>Component config
523 * object</i>. The <tt>ptype</tt> will be looked up at render time up to determine what
524 * type of Plugin to create.<br><br>
525 * If you create your own Plugins, you may register them using
526 * {@link Ext.ComponentMgr#registerPlugin} in order to be able to
527 * take advantage of lazy instantiation and rendering.
529 <div id="cfg-Ext.Component-cls"></div>/**
531 * An optional extra CSS class that will be added to this component's Element (defaults to ''). This can be
532 * useful for adding customized styles to the component or any of its children using standard CSS rules.
534 <div id="cfg-Ext.Component-overCls"></div>/**
535 * @cfg {String} overCls
536 * An optional extra CSS class that will be added to this component's Element when the mouse moves
537 * over the Element, and removed when the mouse moves out. (defaults to ''). This can be
538 * useful for adding customized 'active' or 'hover' styles to the component or any of its children using standard CSS rules.
540 <div id="cfg-Ext.Component-style"></div>/**
541 * @cfg {String} style
542 * A custom style specification to be applied to this component's Element. Should be a valid argument to
543 * {@link Ext.Element#applyStyles}.
547 renderTo: Ext.getBody(),
548 width: 400, height: 300,
568 <div id="cfg-Ext.Component-ctCls"></div>/**
569 * @cfg {String} ctCls
570 * <p>An optional extra CSS class that will be added to this component's container. This can be useful for
571 * adding customized styles to the container or any of its children using standard CSS rules. See
572 * {@link Ext.layout.ContainerLayout}.{@link Ext.layout.ContainerLayout#extraCls extraCls} also.</p>
573 * <p><b>Note</b>: <tt>ctCls</tt> defaults to <tt>''</tt> except for the following class
574 * which assigns a value by default:
575 * <div class="mdetail-params"><ul>
576 * <li>{@link Ext.layout.Box Box Layout} : <tt>'x-box-layout-ct'</tt></li>
578 * To configure the above Class with an extra CSS class append to the default. For example,
579 * for BoxLayout (Hbox and Vbox):<pre><code>
580 * ctCls: 'x-box-layout-ct custom-class'
584 <div id="cfg-Ext.Component-disabled"></div>/**
585 * @cfg {Boolean} disabled
586 * Render this component disabled (default is false).
589 <div id="cfg-Ext.Component-hidden"></div>/**
590 * @cfg {Boolean} hidden
591 * Render this component hidden (default is false). If <tt>true</tt>, the
592 * {@link #hide} method will be called internally.
595 <div id="cfg-Ext.Component-plugins"></div>/**
596 * @cfg {Object/Array} plugins
597 * An object or array of objects that will provide custom functionality for this component. The only
598 * requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component.
599 * When a component is created, if any plugins are available, the component will call the init method on each
600 * plugin, passing a reference to itself. Each plugin can then call methods or respond to events on the
601 * component as needed to provide its functionality.
603 <div id="cfg-Ext.Component-applyTo"></div>/**
604 * @cfg {Mixed} applyTo
605 * <p>Specify the id of the element, a DOM element or an existing Element corresponding to a DIV
606 * that is already present in the document that specifies some structural markup for this
607 * component.</p><div><ul>
608 * <li><b>Description</b> : <ul>
609 * <div class="sub-desc">When <tt>applyTo</tt> is used, constituent parts of the component can also be specified
610 * by id or CSS class name within the main element, and the component being created may attempt
611 * to create its subcomponents from that markup if applicable.</div>
613 * <li><b>Notes</b> : <ul>
614 * <div class="sub-desc">When using this config, a call to render() is not required.</div>
615 * <div class="sub-desc">If applyTo is specified, any value passed for {@link #renderTo} will be ignored and the target
616 * element's parent node will automatically be used as the component's container.</div>
620 <div id="cfg-Ext.Component-renderTo"></div>/**
621 * @cfg {Mixed} renderTo
622 * <p>Specify the id of the element, a DOM element or an existing Element that this component
623 * will be rendered into.</p><div><ul>
624 * <li><b>Notes</b> : <ul>
625 * <div class="sub-desc">Do <u>not</u> use this option if the Component is to be a child item of
626 * a {@link Ext.Container Container}. It is the responsibility of the
627 * {@link Ext.Container Container}'s {@link Ext.Container#layout layout manager}
628 * to render and manage its child items.</div>
629 * <div class="sub-desc">When using this config, a call to render() is not required.</div>
632 * <p>See <tt>{@link #render}</tt> also.</p>
634 <div id="cfg-Ext.Component-stateful"></div>/**
635 * @cfg {Boolean} stateful
636 * <p>A flag which causes the Component to attempt to restore the state of
637 * internal properties from a saved state on startup. The component must have
638 * either a <code>{@link #stateId}</code> or <code>{@link #id}</code> assigned
639 * for state to be managed. Auto-generated ids are not guaranteed to be stable
640 * across page loads and cannot be relied upon to save and restore the same
641 * state for a component.<p>
642 * <p>For state saving to work, the state manager's provider must have been
643 * set to an implementation of {@link Ext.state.Provider} which overrides the
644 * {@link Ext.state.Provider#set set} and {@link Ext.state.Provider#get get}
645 * methods to save and recall name/value pairs. A built-in implementation,
646 * {@link Ext.state.CookieProvider} is available.</p>
647 * <p>To set the state provider for the current page:</p>
649 Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
650 expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now
653 * <p>A stateful Component attempts to save state when one of the events
654 * listed in the <code>{@link #stateEvents}</code> configuration fires.</p>
655 * <p>To save state, a stateful Component first serializes its state by
656 * calling <b><code>getState</code></b>. By default, this function does
657 * nothing. The developer must provide an implementation which returns an
658 * object hash which represents the Component's restorable state.</p>
659 * <p>The value yielded by getState is passed to {@link Ext.state.Manager#set}
660 * which uses the configured {@link Ext.state.Provider} to save the object
661 * keyed by the Component's <code>{@link stateId}</code>, or, if that is not
662 * specified, its <code>{@link #id}</code>.</p>
663 * <p>During construction, a stateful Component attempts to <i>restore</i>
664 * its state by calling {@link Ext.state.Manager#get} passing the
665 * <code>{@link #stateId}</code>, or, if that is not specified, the
666 * <code>{@link #id}</code>.</p>
667 * <p>The resulting object is passed to <b><code>applyState</code></b>.
668 * The default implementation of <code>applyState</code> simply copies
669 * properties into the object, but a developer may override this to support
670 * more behaviour.</p>
671 * <p>You can perform extra processing on state save and restore by attaching
672 * handlers to the {@link #beforestaterestore}, {@link #staterestore},
673 * {@link #beforestatesave} and {@link #statesave} events.</p>
675 <div id="cfg-Ext.Component-stateId"></div>/**
676 * @cfg {String} stateId
677 * The unique id for this component to use for state management purposes
678 * (defaults to the component id if one was set, otherwise null if the
679 * component is using a generated id).
680 * <p>See <code>{@link #stateful}</code> for an explanation of saving and
681 * restoring Component state.</p>
683 <div id="cfg-Ext.Component-stateEvents"></div>/**
684 * @cfg {Array} stateEvents
685 * <p>An array of events that, when fired, should trigger this component to
686 * save its state (defaults to none). <code>stateEvents</code> may be any type
687 * of event supported by this component, including browser or custom events
688 * (e.g., <tt>['click', 'customerchange']</tt>).</p>
689 * <p>See <code>{@link #stateful}</code> for an explanation of saving and
690 * restoring Component state.</p>
692 <div id="cfg-Ext.Component-autoEl"></div>/**
693 * @cfg {Mixed} autoEl
694 * <p>A tag name or {@link Ext.DomHelper DomHelper} spec used to create the {@link #getEl Element} which will
695 * encapsulate this Component.</p>
696 * <p>You do not normally need to specify this. For the base classes {@link Ext.Component}, {@link Ext.BoxComponent},
697 * and {@link Ext.Container}, this defaults to <b><tt>'div'</tt></b>. The more complex Ext classes use a more complex
698 * DOM structure created by their own onRender methods.</p>
699 * <p>This is intended to allow the developer to create application-specific utility Components encapsulated by
700 * different DOM elements. Example usage:</p><pre><code>
705 src: 'http://www.example.com/example.jpg'
711 html: 'autoEl is cool!'
716 cls: 'ux-unordered-list',
720 html: 'First list item'
727 <div id="cfg-Ext.Component-disabledClass"></div>/**
728 * @cfg {String} disabledClass
729 * CSS class added to the component when it is disabled (defaults to 'x-item-disabled').
731 disabledClass : 'x-item-disabled',
732 <div id="cfg-Ext.Component-allowDomMove"></div>/**
733 * @cfg {Boolean} allowDomMove
734 * Whether the component can move the Dom node when rendering (defaults to true).
737 <div id="cfg-Ext.Component-autoShow"></div>/**
738 * @cfg {Boolean} autoShow
739 * True if the component should check for hidden classes (e.g. 'x-hidden' or 'x-hide-display') and remove
740 * them on render (defaults to false).
743 <div id="cfg-Ext.Component-hideMode"></div>/**
744 * @cfg {String} hideMode
745 * <p>How this component should be hidden. Supported values are <tt>'visibility'</tt>
746 * (css visibility), <tt>'offsets'</tt> (negative offset position) and <tt>'display'</tt>
748 * <br><p><b>Note</b>: the default of <tt>'display'</tt> is generally preferred
749 * since items are automatically laid out when they are first shown (no sizing
750 * is done while hidden).</p>
752 hideMode : 'display',
753 <div id="cfg-Ext.Component-hideParent"></div>/**
754 * @cfg {Boolean} hideParent
755 * True to hide and show the component's container when hide/show is called on the component, false to hide
756 * and show the component itself (defaults to false). For example, this can be used as a shortcut for a hide
757 * button on a window by setting hide:true on the button when adding it to its parent container.
760 <div id="prop-Ext.Component-el"></div>/**
761 * <p>The {@link Ext.Element} which encapsulates this Component. Read-only.</p>
762 * <p>This will <i>usually</i> be a <DIV> element created by the class's onRender method, but
763 * that may be overridden using the <code>{@link #autoEl}</code> config.</p>
764 * <br><p><b>Note</b>: this element will not be available until this Component has been rendered.</p><br>
765 * <p>To add listeners for <b>DOM events</b> to this Component (as opposed to listeners
766 * for this Component's own Observable events), see the {@link Ext.util.Observable#listeners listeners}
767 * config for a suggestion, or use a render listener directly:</p><pre><code>
769 title: 'The Clickable Panel',
771 render: function(p) {
772 // Append the Panel to the click handler's argument list.
773 p.getEl().on('click', handlePanelClick.createDelegate(null, [p], true));
775 single: true // Remove the listener after first invocation
779 * <p>See also <tt>{@link #getEl getEl}</p>
783 <div id="prop-Ext.Component-ownerCt"></div>/**
784 * This Component's owner {@link Ext.Container Container} (defaults to undefined, and is set automatically when
785 * this Component is added to a Container). Read-only.
786 * <p><b>Note</b>: to access items within the Container see <tt>{@link #itemId}</tt>.</p>
787 * @type Ext.Container
790 <div id="prop-Ext.Component-hidden"></div>/**
791 * True if this component is hidden. Read-only.
795 <div id="prop-Ext.Component-disabled"></div>/**
796 * True if this component is disabled. Read-only.
800 <div id="prop-Ext.Component-rendered"></div>/**
801 * True if this component has been rendered. Read-only.
807 <div id="cfg-Ext.Component-contentEl"></div>/**
808 * @cfg {String} contentEl
809 * <p>Optional. Specify an existing HTML element, or the <code>id</code> of an existing HTML element to use as the content
810 * for this component.</p>
812 * <li><b>Description</b> :
813 * <div class="sub-desc">This config option is used to take an existing HTML element and place it in the layout element
814 * of a new component (it simply moves the specified DOM element <i>after the Component is rendered</i> to use as the content.</div></li>
816 * <div class="sub-desc">The specified HTML element is appended to the layout element of the component <i>after any configured
817 * {@link #html HTML} has been inserted</i>, and so the document will not contain this element at the time the {@link #render} event is fired.</div>
818 * <div class="sub-desc">The specified HTML element used will not participate in any <code><b>{@link Ext.Container#layout layout}</b></code>
819 * scheme that the Component may use. It is just HTML. Layouts operate on child <code><b>{@link Ext.Container#items items}</b></code>.</div>
820 * <div class="sub-desc">Add either the <code>x-hidden</code> or the <code>x-hide-display</code> CSS class to
821 * prevent a brief flicker of the content before it is rendered to the panel.</div></li>
824 <div id="cfg-Ext.Component-html"></div>/**
825 * @cfg {String/Object} html
826 * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the layout element
827 * content (defaults to ''). The HTML content is added after the component is rendered,
828 * so the document will not contain this HTML at the time the {@link #render} event is fired.
829 * This content is inserted into the body <i>before</i> any configured {@link #contentEl} is appended.
832 <div id="cfg-Ext.Component-tpl"></div>/**
834 * An <bold>{@link Ext.Template}</bold>, <bold>{@link Ext.XTemplate}</bold>
835 * or an array of strings to form an Ext.XTemplate.
836 * Used in conjunction with the <code>{@link #data}</code> and
837 * <code>{@link #tplWriteMode}</code> configurations.
840 <div id="cfg-Ext.Component-tplWriteMode"></div>/**
841 * @cfg {String} tplWriteMode The Ext.(X)Template method to use when
842 * updating the content area of the Component. Defaults to <tt>'overwrite'</tt>
843 * (see <code>{@link Ext.XTemplate#overwrite}</code>).
845 tplWriteMode : 'overwrite',
847 <div id="cfg-Ext.Component-data"></div>/**
849 * The initial set of data to apply to the <code>{@link #tpl}</code> to
850 * update the content area of the Component.
855 ctype : 'Ext.Component',
861 getActionEl : function(){
862 return this[this.actionMode];
865 initPlugin : function(p){
866 if(p.ptype && !Ext.isFunction(p.init)){
867 p = Ext.ComponentMgr.createPlugin(p);
868 }else if(Ext.isString(p)){
869 p = Ext.ComponentMgr.createPlugin({
878 * Function to be implemented by Component subclasses to be part of standard component initialization flow (it is empty by default).
880 // Traditional constructor:
881 Ext.Foo = function(config){
882 // call superclass constructor:
883 Ext.Foo.superclass.constructor.call(this, config);
889 Ext.extend(Ext.Foo, Ext.Bar, {
893 // initComponent replaces the constructor:
894 Ext.Foo = Ext.extend(Ext.Bar, {
895 initComponent : function(){
896 // call superclass initComponent
897 Ext.Container.superclass.initComponent.call(this);
906 initComponent : Ext.emptyFn,
908 <div id="method-Ext.Component-render"></div>/**
909 * <p>Render this Component into the passed HTML element.</p>
910 * <p><b>If you are using a {@link Ext.Container Container} object to house this Component, then
911 * do not use the render method.</b></p>
912 * <p>A Container's child Components are rendered by that Container's
913 * {@link Ext.Container#layout layout} manager when the Container is first rendered.</p>
914 * <p>Certain layout managers allow dynamic addition of child components. Those that do
915 * include {@link Ext.layout.CardLayout}, {@link Ext.layout.AnchorLayout},
916 * {@link Ext.layout.FormLayout}, {@link Ext.layout.TableLayout}.</p>
917 * <p>If the Container is already rendered when a new child Component is added, you may need to call
918 * the Container's {@link Ext.Container#doLayout doLayout} to refresh the view which causes any
919 * unrendered child Components to be rendered. This is required so that you can add multiple
920 * child components if needed while only refreshing the layout once.</p>
921 * <p>When creating complex UIs, it is important to remember that sizing and positioning
922 * of child items is the responsibility of the Container's {@link Ext.Container#layout layout} manager.
923 * If you expect child items to be sized in response to user interactions, you must
924 * configure the Container with a layout manager which creates and manages the type of layout you
926 * <p><b>Omitting the Container's {@link Ext.Container#layout layout} config means that a basic
927 * layout manager is used which does nothing but render child components sequentially into the
928 * Container. No sizing or positioning will be performed in this situation.</b></p>
929 * @param {Element/HTMLElement/String} container (optional) The element this Component should be
930 * rendered into. If it is being created from existing markup, this should be omitted.
931 * @param {String/Number} position (optional) The element ID or DOM node index within the container <b>before</b>
932 * which this component will be inserted (defaults to appending to the end of the container)
934 render : function(container, position){
935 if(!this.rendered && this.fireEvent('beforerender', this) !== false){
936 if(!container && this.el){
937 this.el = Ext.get(this.el);
938 container = this.el.dom.parentNode;
939 this.allowDomMove = false;
941 this.container = Ext.get(container);
943 this.container.addClass(this.ctCls);
945 this.rendered = true;
946 if(position !== undefined){
947 if(Ext.isNumber(position)){
948 position = this.container.dom.childNodes[position];
950 position = Ext.getDom(position);
953 this.onRender(this.container, position || null);
955 this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
958 this.el.addClass(this.cls);
962 this.el.applyStyles(this.style);
966 this.el.addClassOnOver(this.overCls);
968 this.fireEvent('render', this);
971 // Populate content of the component with html, contentEl or
973 var contentTarget = this.getContentTarget();
975 contentTarget.update(Ext.DomHelper.markup(this.html));
979 var ce = Ext.getDom(this.contentEl);
980 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
981 contentTarget.appendChild(ce);
984 if (!this.tpl.compile) {
985 this.tpl = new Ext.XTemplate(this.tpl);
988 this.tpl[this.tplWriteMode](contentTarget, this.data);
992 this.afterRender(this.container);
996 // call this so we don't fire initial hide events.
1000 // pass silent so the event doesn't fire the first time.
1004 if(this.stateful !== false){
1005 this.initStateEvents();
1007 this.fireEvent('afterrender', this);
1013 <div id="method-Ext.Component-update"></div>/**
1014 * Update the content area of a component.
1015 * @param {Mixed} htmlOrData
1016 * If this component has been configured with a template via the tpl config
1017 * then it will use this argument as data to populate the template.
1018 * If this component was not configured with a template, the components
1019 * content area will be updated via Ext.Element update
1020 * @param {Boolean} loadScripts
1021 * (optional) Only legitimate when using the html configuration. Defaults to false
1022 * @param {Function} callback
1023 * (optional) Only legitimate when using the html configuration. Callback to execute when scripts have finished loading
1025 update: function(htmlOrData, loadScripts, cb) {
1026 var contentTarget = this.getContentTarget();
1027 if (this.tpl && typeof htmlOrData !== "string") {
1028 this.tpl[this.tplWriteMode](contentTarget, htmlOrData || {});
1030 var html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
1031 contentTarget.update(html, loadScripts, cb);
1038 * Method to manage awareness of when components are added to their
1039 * respective Container, firing an added event.
1040 * References are established at add time rather than at render time.
1041 * @param {Ext.Container} container Container which holds the component
1042 * @param {number} pos Position at which the component was added
1044 onAdded : function(container, pos) {
1045 this.ownerCt = container;
1047 this.fireEvent('added', this, container, pos);
1052 * Method to manage awareness of when components are removed from their
1053 * respective Container, firing an removed event. References are properly
1054 * cleaned up after removing a component from its owning container.
1056 onRemoved : function() {
1058 this.fireEvent('removed', this, this.ownerCt);
1059 delete this.ownerCt;
1064 * Method to establish a reference to a component.
1066 initRef : function() {
1067 <div id="cfg-Ext.Component-ref"></div>/**
1069 * <p>A path specification, relative to the Component's <code>{@link #ownerCt}</code>
1070 * specifying into which ancestor Container to place a named reference to this Component.</p>
1071 * <p>The ancestor axis can be traversed by using '/' characters in the path.
1072 * For example, to put a reference to a Toolbar Button into <i>the Panel which owns the Toolbar</i>:</p><pre><code>
1073 var myGrid = new Ext.grid.EditorGridPanel({
1074 title: 'My EditorGridPanel',
1076 colModel: myColModel,
1079 handler: saveChanges,
1081 ref: '../saveButton'
1084 afteredit: function() {
1085 // The button reference is in the GridPanel
1086 myGrid.saveButton.enable();
1091 * <p>In the code above, if the <code>ref</code> had been <code>'saveButton'</code>
1092 * the reference would have been placed into the Toolbar. Each '/' in the <code>ref</code>
1093 * moves up one level from the Component's <code>{@link #ownerCt}</code>.</p>
1094 * <p>Also see the <code>{@link #added}</code> and <code>{@link #removed}</code> events.</p>
1096 if(this.ref && !this.refOwner){
1097 var levels = this.ref.split('/'),
1098 last = levels.length,
1102 while(t && i < last){
1107 t[this.refName = levels[--i]] = this;
1108 <div id="prop-Ext.Component-refOwner"></div>/**
1109 * @type Ext.Container
1110 * @property refOwner
1111 * The ancestor Container into which the {@link #ref} reference was inserted if this Component
1112 * is a child of a Container, and has been configured with a <code>ref</code>.
1119 removeRef : function() {
1120 if (this.refOwner && this.refName) {
1121 delete this.refOwner[this.refName];
1122 delete this.refOwner;
1127 initState : function(){
1128 if(Ext.state.Manager){
1129 var id = this.getStateId();
1131 var state = Ext.state.Manager.get(id);
1133 if(this.fireEvent('beforestaterestore', this, state) !== false){
1134 this.applyState(Ext.apply({}, state));
1135 this.fireEvent('staterestore', this, state);
1143 getStateId : function(){
1144 return this.stateId || ((this.id.indexOf('ext-comp-') == 0 || this.id.indexOf('ext-gen') == 0) ? null : this.id);
1148 initStateEvents : function(){
1149 if(this.stateEvents){
1150 for(var i = 0, e; e = this.stateEvents[i]; i++){
1151 this.on(e, this.saveState, this, {delay:100});
1157 applyState : function(state){
1159 Ext.apply(this, state);
1164 getState : function(){
1169 saveState : function(){
1170 if(Ext.state.Manager && this.stateful !== false){
1171 var id = this.getStateId();
1173 var state = this.getState();
1174 if(this.fireEvent('beforestatesave', this, state) !== false){
1175 Ext.state.Manager.set(id, state);
1176 this.fireEvent('statesave', this, state);
1182 <div id="method-Ext.Component-applyToMarkup"></div>/**
1183 * Apply this component to existing markup that is valid. With this function, no call to render() is required.
1184 * @param {String/HTMLElement} el
1186 applyToMarkup : function(el){
1187 this.allowDomMove = false;
1188 this.el = Ext.get(el);
1189 this.render(this.el.dom.parentNode);
1192 <div id="method-Ext.Component-addClass"></div>/**
1193 * Adds a CSS class to the component's underlying element.
1194 * @param {string} cls The CSS class name to add
1195 * @return {Ext.Component} this
1197 addClass : function(cls){
1199 this.el.addClass(cls);
1201 this.cls = this.cls ? this.cls + ' ' + cls : cls;
1206 <div id="method-Ext.Component-removeClass"></div>/**
1207 * Removes a CSS class from the component's underlying element.
1208 * @param {string} cls The CSS class name to remove
1209 * @return {Ext.Component} this
1211 removeClass : function(cls){
1213 this.el.removeClass(cls);
1215 this.cls = this.cls.split(' ').remove(cls).join(' ');
1221 // default function is not really useful
1222 onRender : function(ct, position){
1223 if(!this.el && this.autoEl){
1224 if(Ext.isString(this.autoEl)){
1225 this.el = document.createElement(this.autoEl);
1227 var div = document.createElement('div');
1228 Ext.DomHelper.overwrite(div, this.autoEl);
1229 this.el = div.firstChild;
1232 this.el.id = this.getId();
1236 this.el = Ext.get(this.el);
1237 if(this.allowDomMove !== false){
1238 ct.dom.insertBefore(this.el.dom, position);
1240 Ext.removeNode(div);
1248 getAutoCreate : function(){
1249 var cfg = Ext.isObject(this.autoCreate) ?
1250 this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
1251 if(this.id && !cfg.id){
1258 afterRender : Ext.emptyFn,
1260 <div id="method-Ext.Component-destroy"></div>/**
1261 * Destroys this component by purging any event listeners, removing the component's element from the DOM,
1262 * removing the component from its {@link Ext.Container} (if applicable) and unregistering it from
1263 * {@link Ext.ComponentMgr}. Destruction is generally handled automatically by the framework and this method
1264 * should usually not need to be called directly.
1267 destroy : function(){
1268 if(!this.isDestroyed){
1269 if(this.fireEvent('beforedestroy', this) !== false){
1270 this.destroying = true;
1271 this.beforeDestroy();
1272 if(this.ownerCt && this.ownerCt.remove){
1273 this.ownerCt.remove(this, false);
1277 if(this.actionMode == 'container' || this.removeMode == 'container'){
1278 this.container.remove();
1282 Ext.ComponentMgr.unregister(this);
1283 this.fireEvent('destroy', this);
1284 this.purgeListeners();
1285 this.destroying = false;
1286 this.isDestroyed = true;
1291 deleteMembers : function(){
1292 var args = arguments;
1293 for(var i = 0, len = args.length; i < len; ++i){
1294 delete this[args[i]];
1299 beforeDestroy : Ext.emptyFn,
1302 onDestroy : Ext.emptyFn,
1304 <div id="method-Ext.Component-getEl"></div>/**
1305 * <p>Returns the {@link Ext.Element} which encapsulates this Component.</p>
1306 * <p>This will <i>usually</i> be a <DIV> element created by the class's onRender method, but
1307 * that may be overridden using the {@link #autoEl} config.</p>
1308 * <br><p><b>Note</b>: this element will not be available until this Component has been rendered.</p><br>
1309 * <p>To add listeners for <b>DOM events</b> to this Component (as opposed to listeners
1310 * for this Component's own Observable events), see the {@link #listeners} config for a suggestion,
1311 * or use a render listener directly:</p><pre><code>
1313 title: 'The Clickable Panel',
1315 render: function(p) {
1316 // Append the Panel to the click handler's argument list.
1317 p.getEl().on('click', handlePanelClick.createDelegate(null, [p], true));
1319 single: true // Remove the listener after first invocation
1323 * @return {Ext.Element} The Element which encapsulates this Component.
1330 getContentTarget : function(){
1334 <div id="method-Ext.Component-getId"></div>/**
1335 * Returns the <code>id</code> of this component or automatically generates and
1336 * returns an <code>id</code> if an <code>id</code> is not defined yet:<pre><code>
1337 * 'ext-comp-' + (++Ext.Component.AUTO_ID)
1339 * @return {String} id
1342 return this.id || (this.id = 'ext-comp-' + (++Ext.Component.AUTO_ID));
1345 <div id="method-Ext.Component-getItemId"></div>/**
1346 * Returns the <code>{@link #itemId}</code> of this component. If an
1347 * <code>{@link #itemId}</code> was not assigned through configuration the
1348 * <code>id</code> is returned using <code>{@link #getId}</code>.
1351 getItemId : function(){
1352 return this.itemId || this.getId();
1355 <div id="method-Ext.Component-focus"></div>/**
1356 * Try to focus this component.
1357 * @param {Boolean} selectText (optional) If applicable, true to also select the text in this component
1358 * @param {Boolean/Number} delay (optional) Delay the focus this number of milliseconds (true for 10 milliseconds)
1359 * @return {Ext.Component} this
1361 focus : function(selectText, delay){
1363 this.focus.defer(Ext.isNumber(delay) ? delay : 10, this, [selectText, false]);
1368 if(selectText === true){
1369 this.el.dom.select();
1383 <div id="method-Ext.Component-disable"></div>/**
1384 * Disable this component and fire the 'disable' event.
1385 * @return {Ext.Component} this
1387 disable : function(/* private */ silent){
1391 this.disabled = true;
1392 if(silent !== true){
1393 this.fireEvent('disable', this);
1399 onDisable : function(){
1400 this.getActionEl().addClass(this.disabledClass);
1401 this.el.dom.disabled = true;
1404 <div id="method-Ext.Component-enable"></div>/**
1405 * Enable this component and fire the 'enable' event.
1406 * @return {Ext.Component} this
1408 enable : function(){
1412 this.disabled = false;
1413 this.fireEvent('enable', this);
1418 onEnable : function(){
1419 this.getActionEl().removeClass(this.disabledClass);
1420 this.el.dom.disabled = false;
1423 <div id="method-Ext.Component-setDisabled"></div>/**
1424 * Convenience function for setting disabled/enabled by boolean.
1425 * @param {Boolean} disabled
1426 * @return {Ext.Component} this
1428 setDisabled : function(disabled){
1429 return this[disabled ? 'disable' : 'enable']();
1432 <div id="method-Ext.Component-show"></div>/**
1433 * Show this component. Listen to the '{@link #beforeshow}' event and return
1434 * <tt>false</tt> to cancel showing the component. Fires the '{@link #show}'
1435 * event after showing the component.
1436 * @return {Ext.Component} this
1439 if(this.fireEvent('beforeshow', this) !== false){
1440 this.hidden = false;
1441 if(this.autoRender){
1442 this.render(Ext.isBoolean(this.autoRender) ? Ext.getBody() : this.autoRender);
1447 this.fireEvent('show', this);
1453 onShow : function(){
1454 this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
1457 <div id="method-Ext.Component-hide"></div>/**
1458 * Hide this component. Listen to the '{@link #beforehide}' event and return
1459 * <tt>false</tt> to cancel hiding the component. Fires the '{@link #hide}'
1460 * event after hiding the component. Note this method is called internally if
1461 * the component is configured to be <code>{@link #hidden}</code>.
1462 * @return {Ext.Component} this
1465 if(this.fireEvent('beforehide', this) !== false){
1467 this.fireEvent('hide', this);
1481 onHide : function(){
1482 this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
1486 getVisibilityEl : function(){
1487 return this.hideParent ? this.container : this.getActionEl();
1490 <div id="method-Ext.Component-setVisible"></div>/**
1491 * Convenience function to hide or show this component by boolean.
1492 * @param {Boolean} visible True to show, false to hide
1493 * @return {Ext.Component} this
1495 setVisible : function(visible){
1496 return this[visible ? 'show' : 'hide']();
1499 <div id="method-Ext.Component-isVisible"></div>/**
1500 * Returns true if this component is visible.
1501 * @return {Boolean} True if this component is visible, false otherwise.
1503 isVisible : function(){
1504 return this.rendered && this.getVisibilityEl().isVisible();
1507 <div id="method-Ext.Component-cloneConfig"></div>/**
1508 * Clone the current component using the original config values passed into this instance by default.
1509 * @param {Object} overrides A new config containing any properties to override in the cloned version.
1510 * An id property can be passed on this object, otherwise one will be generated to avoid duplicates.
1511 * @return {Ext.Component} clone The cloned copy of this component
1513 cloneConfig : function(overrides){
1514 overrides = overrides || {};
1515 var id = overrides.id || Ext.id();
1516 var cfg = Ext.applyIf(overrides, this.initialConfig);
1517 cfg.id = id; // prevent dup id
1518 return new this.constructor(cfg);
1521 <div id="method-Ext.Component-getXType"></div>/**
1522 * Gets the xtype for this component as registered with {@link Ext.ComponentMgr}. For a list of all
1523 * available xtypes, see the {@link Ext.Component} header. Example usage:
1525 var t = new Ext.form.TextField();
1526 alert(t.getXType()); // alerts 'textfield'
1528 * @return {String} The xtype
1530 getXType : function(){
1531 return this.constructor.xtype;
1534 <div id="method-Ext.Component-isXType"></div>/**
1535 * <p>Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended
1536 * from the xtype (default) or whether it is directly of the xtype specified (shallow = true).</p>
1537 * <p><b>If using your own subclasses, be aware that a Component must register its own xtype
1538 * to participate in determination of inherited xtypes.</b></p>
1539 * <p>For a list of all available xtypes, see the {@link Ext.Component} header.</p>
1540 * <p>Example usage:</p>
1542 var t = new Ext.form.TextField();
1543 var isText = t.isXType('textfield'); // true
1544 var isBoxSubclass = t.isXType('box'); // true, descended from BoxComponent
1545 var isBoxInstance = t.isXType('box', true); // false, not a direct BoxComponent instance
1547 * @param {String} xtype The xtype to check for this Component
1548 * @param {Boolean} shallow (optional) False to check whether this Component is descended from the xtype (this is
1549 * the default), or true to check whether this Component is directly of the specified xtype.
1550 * @return {Boolean} True if this component descends from the specified xtype, false otherwise.
1552 isXType : function(xtype, shallow){
1553 //assume a string by default
1554 if (Ext.isFunction(xtype)){
1555 xtype = xtype.xtype; //handle being passed the class, e.g. Ext.Component
1556 }else if (Ext.isObject(xtype)){
1557 xtype = xtype.constructor.xtype; //handle being passed an instance
1560 return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 : this.constructor.xtype == xtype;
1563 <div id="method-Ext.Component-getXTypes"></div>/**
1564 * <p>Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all
1565 * available xtypes, see the {@link Ext.Component} header.</p>
1566 * <p><b>If using your own subclasses, be aware that a Component must register its own xtype
1567 * to participate in determination of inherited xtypes.</b></p>
1568 * <p>Example usage:</p>
1570 var t = new Ext.form.TextField();
1571 alert(t.getXTypes()); // alerts 'component/box/field/textfield'
1573 * @return {String} The xtype hierarchy string
1575 getXTypes : function(){
1576 var tc = this.constructor;
1578 var c = [], sc = this;
1579 while(sc && sc.constructor.xtype){
1580 c.unshift(sc.constructor.xtype);
1581 sc = sc.constructor.superclass;
1584 tc.xtypes = c.join('/');
1589 <div id="method-Ext.Component-findParentBy"></div>/**
1590 * Find a container above this component at any level by a custom function. If the passed function returns
1591 * true, the container will be returned.
1592 * @param {Function} fn The custom function to call with the arguments (container, this component).
1593 * @return {Ext.Container} The first Container for which the custom function returns true
1595 findParentBy : function(fn) {
1596 for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
1600 <div id="method-Ext.Component-findParentByType"></div>/**
1601 * Find a container above this component at any level by xtype or class
1602 * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
1603 * @return {Ext.Container} The first Container which matches the given xtype or class
1605 findParentByType : function(xtype) {
1606 return Ext.isFunction(xtype) ?
1607 this.findParentBy(function(p){
1608 return p.constructor === xtype;
1610 this.findParentBy(function(p){
1611 return p.constructor.xtype === xtype;
1616 getPositionEl : function(){
1617 return this.positionEl || this.el;
1621 purgeListeners : function(){
1622 Ext.Component.superclass.purgeListeners.call(this);
1624 this.on('beforedestroy', this.clearMons, this, {single: true});
1629 clearMons : function(){
1630 Ext.each(this.mons, function(m){
1631 m.item.un(m.ename, m.fn, m.scope);
1637 createMons: function(){
1640 this.on('beforedestroy', this.clearMons, this, {single: true});
1644 <div id="method-Ext.Component-mon"></div>/**
1645 * <p>Adds listeners to any Observable object (or Elements) which are automatically removed when this Component
1646 * is destroyed. Usage:</p><code><pre>
1647 myGridPanel.mon(myGridPanel.getSelectionModel(), 'selectionchange', handleSelectionChange, null, {buffer: 50});
1649 * <p>or:</p><code><pre>
1650 myGridPanel.mon(myGridPanel.getSelectionModel(), {
1651 selectionchange: handleSelectionChange,
1655 * @param {Observable|Element} item The item to which to add a listener/listeners.
1656 * @param {Object|String} ename The event name, or an object containing event name properties.
1657 * @param {Function} fn Optional. If the <code>ename</code> parameter was an event name, this
1658 * is the handler function.
1659 * @param {Object} scope Optional. If the <code>ename</code> parameter was an event name, this
1660 * is the scope (<code>this</code> reference) in which the handler function is executed.
1661 * @param {Object} opt Optional. If the <code>ename</code> parameter was an event name, this
1662 * is the {@link Ext.util.Observable#addListener addListener} options.
1664 mon : function(item, ename, fn, scope, opt){
1666 if(Ext.isObject(ename)){
1667 var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
1674 if(Ext.isFunction(o[e])){
1677 item: item, ename: e, fn: o[e], scope: o.scope
1679 item.on(e, o[e], o.scope, o);
1681 // individual options
1683 item: item, ename: e, fn: o[e], scope: o.scope
1692 item: item, ename: ename, fn: fn, scope: scope
1694 item.on(ename, fn, scope, opt);
1697 <div id="method-Ext.Component-mun"></div>/**
1698 * Removes listeners that were added by the {@link #mon} method.
1699 * @param {Observable|Element} item The item from which to remove a listener/listeners.
1700 * @param {Object|String} ename The event name, or an object containing event name properties.
1701 * @param {Function} fn Optional. If the <code>ename</code> parameter was an event name, this
1702 * is the handler function.
1703 * @param {Object} scope Optional. If the <code>ename</code> parameter was an event name, this
1704 * is the scope (<code>this</code> reference) in which the handler function is executed.
1706 mun : function(item, ename, fn, scope){
1709 for(var i = 0, len = this.mons.length; i < len; ++i){
1711 if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
1712 this.mons.splice(i, 1);
1713 item.un(ename, fn, scope);
1721 <div id="method-Ext.Component-nextSibling"></div>/**
1722 * Returns the next component in the owning container
1723 * @return Ext.Component
1725 nextSibling : function(){
1727 var index = this.ownerCt.items.indexOf(this);
1728 if(index != -1 && index+1 < this.ownerCt.items.getCount()){
1729 return this.ownerCt.items.itemAt(index+1);
1735 <div id="method-Ext.Component-previousSibling"></div>/**
1736 * Returns the previous component in the owning container
1737 * @return Ext.Component
1739 previousSibling : function(){
1741 var index = this.ownerCt.items.indexOf(this);
1743 return this.ownerCt.items.itemAt(index-1);
1749 <div id="method-Ext.Component-getBubbleTarget"></div>/**
1750 * Provides the link for Observable's fireEvent method to bubble up the ownership hierarchy.
1751 * @return {Ext.Container} the Container which owns this Component.
1753 getBubbleTarget : function(){
1754 return this.ownerCt;
1758 Ext.reg('component', Ext.Component);</pre>
\r