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.ComponentMgr"></div>/**
10 * @class Ext.ComponentMgr
11 * <p>Provides a registry of all Components (instances of {@link Ext.Component} or any subclass
12 * thereof) on a page so that they can be easily accessed by {@link Ext.Component component}
13 * {@link Ext.Component#id id} (see {@link #get}, or the convenience method {@link Ext#getCmp Ext.getCmp}).</p>
14 * <p>This object also provides a registry of available Component <i>classes</i>
15 * indexed by a mnemonic code known as the Component's {@link Ext.Component#xtype xtype}.
16 * The <code>{@link Ext.Component#xtype xtype}</code> provides a way to avoid instantiating child Components
17 * when creating a full, nested config object for a complete Ext page.</p>
18 * <p>A child Component may be specified simply as a <i>config object</i>
19 * as long as the correct <code>{@link Ext.Component#xtype xtype}</code> is specified so that if and when the Component
20 * needs rendering, the correct type can be looked up for lazy instantiation.</p>
21 * <p>For a list of all available <code>{@link Ext.Component#xtype xtypes}</code>, see {@link Ext.Component}.</p>
24 Ext.ComponentMgr = function(){
25 var all = new Ext.util.MixedCollection();
30 <div id="method-Ext.ComponentMgr-register"></div>/**
31 * Registers a component.
32 * @param {Ext.Component} c The component
34 register : function(c){
38 <div id="method-Ext.ComponentMgr-unregister"></div>/**
39 * Unregisters a component.
40 * @param {Ext.Component} c The component
42 unregister : function(c){
46 <div id="method-Ext.ComponentMgr-get"></div>/**
47 * Returns a component by {@link Ext.Component#id id}.
48 * For additional details see {@link Ext.util.MixedCollection#get}.
49 * @param {String} id The component {@link Ext.Component#id id}
50 * @return Ext.Component The Component, <code>undefined</code> if not found, or <code>null</code> if a
57 <div id="method-Ext.ComponentMgr-onAvailable"></div>/**
58 * Registers a function that will be called when a Component with the specified id is added to ComponentMgr. This will happen on instantiation.
59 * @param {String} id The component {@link Ext.Component#id id}
60 * @param {Function} fn The callback function
61 * @param {Object} scope The scope (<code>this</code> reference) in which the callback is executed. Defaults to the Component.
63 onAvailable : function(id, fn, scope){
64 all.on("add", function(index, o){
66 fn.call(scope || o, o);
67 all.un("add", fn, scope);
72 <div id="prop-Ext.ComponentMgr-all"></div>/**
73 * The MixedCollection used internally for the component cache. An example usage may be subscribing to
74 * events on the MixedCollection to monitor addition or removal. Read-only.
75 * @type {MixedCollection}
79 <div id="method-Ext.ComponentMgr-isRegistered"></div>/**
80 * Checks if a Component type is registered.
81 * @param {Ext.Component} xtype The mnemonic string by which the Component class may be looked up
82 * @return {Boolean} Whether the type is registered.
84 isRegistered : function(xtype){
85 return types[xtype] !== undefined;
88 <div id="method-Ext.ComponentMgr-registerType"></div>/**
89 * <p>Registers a new Component constructor, keyed by a new
90 * {@link Ext.Component#xtype}.</p>
91 * <p>Use this method (or its alias {@link Ext#reg Ext.reg}) to register new
92 * subclasses of {@link Ext.Component} so that lazy instantiation may be used when specifying
94 * see {@link Ext.Container#items}</p>
95 * @param {String} xtype The mnemonic string by which the Component class may be looked up.
96 * @param {Constructor} cls The new Component class.
98 registerType : function(xtype, cls){
103 <div id="method-Ext.ComponentMgr-create"></div>/**
104 * Creates a new Component from the specified config object using the
105 * config object's {@link Ext.component#xtype xtype} to determine the class to instantiate.
106 * @param {Object} config A configuration object for the Component you wish to create.
107 * @param {Constructor} defaultType The constructor to provide the default Component type if
108 * the config object does not contain a <code>xtype</code>. (Optional if the config contains a <code>xtype</code>).
109 * @return {Ext.Component} The newly instantiated Component.
111 create : function(config, defaultType){
112 return config.render ? config : new types[config.xtype || defaultType](config);
115 <div id="method-Ext.ComponentMgr-registerPlugin"></div>/**
116 * <p>Registers a new Plugin constructor, keyed by a new
117 * {@link Ext.Component#ptype}.</p>
118 * <p>Use this method (or its alias {@link Ext#preg Ext.preg}) to register new
119 * plugins for {@link Ext.Component}s so that lazy instantiation may be used when specifying
121 * @param {String} ptype The mnemonic string by which the Plugin class may be looked up.
122 * @param {Constructor} cls The new Plugin class.
124 registerPlugin : function(ptype, cls){
129 <div id="method-Ext.ComponentMgr-createPlugin"></div>/**
130 * Creates a new Plugin from the specified config object using the
131 * config object's {@link Ext.component#ptype ptype} to determine the class to instantiate.
132 * @param {Object} config A configuration object for the Plugin you wish to create.
133 * @param {Constructor} defaultType The constructor to provide the default Plugin type if
134 * the config object does not contain a <code>ptype</code>. (Optional if the config contains a <code>ptype</code>).
135 * @return {Ext.Component} The newly instantiated Plugin.
137 createPlugin : function(config, defaultType){
138 var PluginCls = ptypes[config.ptype || defaultType];
139 if (PluginCls.init) {
142 return new PluginCls(config);
148 <div id="method-Ext-reg"></div>/**
149 * Shorthand for {@link Ext.ComponentMgr#registerType}
150 * @param {String} xtype The {@link Ext.component#xtype mnemonic string} by which the Component class
152 * @param {Constructor} cls The new Component class.
156 Ext.reg = Ext.ComponentMgr.registerType; // this will be called a lot internally, shorthand to keep the bytes down
157 <div id="method-Ext-preg"></div>/**
158 * Shorthand for {@link Ext.ComponentMgr#registerPlugin}
159 * @param {String} ptype The {@link Ext.component#ptype mnemonic string} by which the Plugin class
161 * @param {Constructor} cls The new Plugin class.
165 Ext.preg = Ext.ComponentMgr.registerPlugin;
166 <div id="method-Ext-create"></div>/**
167 * Shorthand for {@link Ext.ComponentMgr#create}
168 * Creates a new Component from the specified config object using the
169 * config object's {@link Ext.component#xtype xtype} to determine the class to instantiate.
170 * @param {Object} config A configuration object for the Component you wish to create.
171 * @param {Constructor} defaultType The constructor to provide the default Component type if
172 * the config object does not contain a <code>xtype</code>. (Optional if the config contains a <code>xtype</code>).
173 * @return {Ext.Component} The newly instantiated Component.
177 Ext.create = Ext.ComponentMgr.create;</pre>
\r