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