3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.AbstractManager"></div>/**
16 * @class Ext.AbstractManager
18 * Base Manager class - extended by ComponentMgr and PluginMgr
20 Ext.AbstractManager = Ext.extend(Object, {
23 constructor: function(config) {
24 Ext.apply(this, config || {});
26 <div id="prop-Ext.AbstractManager-all"></div>/**
27 * Contains all of the items currently managed
29 * @type Ext.util.MixedCollection
31 this.all = new Ext.util.MixedCollection();
36 <div id="method-Ext.AbstractManager-get"></div>/**
37 * Returns a component by {@link Ext.Component#id id}.
38 * For additional details see {@link Ext.util.MixedCollection#get}.
39 * @param {String} id The component {@link Ext.Component#id id}
40 * @return Ext.Component The Component, <code>undefined</code> if not found, or <code>null</code> if a
44 return this.all.get(id);
47 <div id="method-Ext.AbstractManager-register"></div>/**
48 * Registers an item to be managed
49 * @param {Mixed} item The item to register
51 register: function(item) {
55 <div id="method-Ext.AbstractManager-unregister"></div>/**
56 * Unregisters a component by removing it from this manager
57 * @param {Mixed} item The item to unregister
59 unregister: function(item) {
60 this.all.remove(item);
63 <div id="method-Ext.AbstractManager-registerType"></div>/**
64 * <p>Registers a new Component constructor, keyed by a new
65 * {@link Ext.Component#xtype}.</p>
66 * <p>Use this method (or its alias {@link Ext#reg Ext.reg}) to register new
67 * subclasses of {@link Ext.Component} so that lazy instantiation may be used when specifying
69 * see {@link Ext.Container#items}</p>
70 * @param {String} xtype The mnemonic string by which the Component class may be looked up.
71 * @param {Constructor} cls The new Component class.
73 registerType : function(type, cls){
74 this.types[type] = cls;
75 cls[this.typeName] = type;
78 <div id="method-Ext.AbstractManager-isRegistered"></div>/**
79 * Checks if a Component type is registered.
80 * @param {Ext.Component} xtype The mnemonic string by which the Component class may be looked up
81 * @return {Boolean} Whether the type is registered.
83 isRegistered : function(type){
84 return this.types[type] !== undefined;
87 <div id="method-Ext.AbstractManager-create"></div>/**
88 * Creates and returns an instance of whatever this manager manages, based on the supplied type and config object
89 * @param {Object} config The config object
90 * @param {String} defaultType If no type is discovered in the config object, we fall back to this type
91 * @return {Mixed} The instance of whatever this manager is managing
93 create: function(config, defaultType) {
94 var type = config[this.typeName] || config.type || defaultType,
95 Constructor = this.types[type];
97 if (Constructor == undefined) {
98 throw new Error(String.format("The '{0}' type has not been registered with this manager", type));
101 return new Constructor(config);
104 <div id="method-Ext.AbstractManager-onAvailable"></div>/**
105 * Registers a function that will be called when a Component with the specified id is added to the manager. This will happen on instantiation.
106 * @param {String} id The component {@link Ext.Component#id id}
107 * @param {Function} fn The callback function
108 * @param {Object} scope The scope (<code>this</code> reference) in which the callback is executed. Defaults to the Component.
110 onAvailable : function(id, fn, scope){
113 all.on("add", function(index, o){
115 fn.call(scope || o, o);
116 all.un("add", fn, scope);