]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/ComponentManager.js
4 * Provides a registry of all Components (instances of {@link Ext.Component} or any subclass
5 * thereof) on a page so that they can be easily accessed by {@link Ext.Component component}
6 * {@link Ext.Component#getId id} (see {@link #get}, or the convenience method {@link Ext#getCmp Ext.getCmp}).
8 * This object also provides a registry of available Component _classes_
9 * indexed by a mnemonic code known as the Component's `xtype`.
10 * The `xtype` provides a way to avoid instantiating child Components
11 * when creating a full, nested config object for a complete Ext page.
13 * A child Component may be specified simply as a _config object_
14 * as long as the correct `xtype` is specified so that if and when the Component
15 * needs rendering, the correct type can be looked up for lazy instantiation.
17 * For a list of all available `xtype`, see {@link Ext.Component}.
19 Ext
. define ( 'Ext.ComponentManager' , {
20 alternateClassName
: 'Ext.ComponentMgr' ,
23 constructor : function () {
26 // The sole reason for this is just to support the old code of ComponentQuery
30 getArray : function () {
35 if ( map
. hasOwnProperty ( id
)) {
47 * Registers an item to be managed.
48 * @param {Object} component The item to register.
50 register : function ( component
) {
51 var id
= component
. getId ();
55 Ext
. Logger
. warn ( 'Registering a component with a id (`' + id
+ '`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`.' );
59 this . map
[ component
. getId ()] = component
;
63 * Unregisters an item by removing it from this manager.
64 * @param {Object} component The item to unregister.
66 unregister : function ( component
) {
67 delete this . map
[ component
. getId ()];
71 * Checks if an item type is registered.
72 * @param {String} component The mnemonic string by which the class may be looked up.
73 * @return {Boolean} Whether the type is registered.
75 isRegistered : function ( component
){
76 return this . map
[ component
] !== undefined ;
80 * Returns an item by id.
81 * For additional details see {@link Ext.util.HashMap#get}.
82 * @param {String} id The `id` of the item.
83 * @return {Object} The item, or `undefined` if not found.
90 * Creates a new Component from the specified config object using the
91 * config object's `xtype` to determine the class to instantiate.
92 * @param {Object} component A configuration object for the Component you wish to create.
93 * @param {Function} [defaultType] The constructor to provide the default Component type if
94 * the config object does not contain a `xtype`. (Optional if the config contains an `xtype`).
95 * @return {Ext.Component} The newly instantiated Component.
97 create : function ( component
, defaultType
) {
98 if ( component
. isComponent
) {
101 else if ( Ext
. isString ( component
)) {
102 return Ext
. createByAlias ( 'widget.' + component
);
105 var type
= component
. xtype
|| defaultType
;
107 return Ext
. createByAlias ( 'widget.' + type
, component
);
111 registerType
: Ext
. emptyFn