allow string based values for comboboxarray
[roojs1] / Roo / ComponentMgr.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12
13 /**
14  * @class Roo.ComponentMgr
15  * Provides a common registry of all components on a page so that they can be easily accessed by component id (see {@link Roo.getCmp}).
16  * @singleton
17  */
18 Roo.ComponentMgr = function(){
19     var all = new Roo.util.MixedCollection();
20
21     return {
22         /**
23          * Registers a component.
24          * @param {Roo.Component} c The component
25          */
26         register : function(c){
27             all.add(c);
28         },
29
30         /**
31          * Unregisters a component.
32          * @param {Roo.Component} c The component
33          */
34         unregister : function(c){
35             all.remove(c);
36         },
37
38         /**
39          * Returns a component by id
40          * @param {String} id The component id
41          */
42         get : function(id){
43             return all.get(id);
44         },
45
46         /**
47          * Registers a function that will be called when a specified component is added to ComponentMgr
48          * @param {String} id The component id
49          * @param {Funtction} fn The callback function
50          * @param {Object} scope The scope of the callback
51          */
52         onAvailable : function(id, fn, scope){
53             all.on("add", function(index, o){
54                 if(o.id == id){
55                     fn.call(scope || o, o);
56                     all.un("add", fn, scope);
57                 }
58             });
59         }
60     };
61 }();