2 * Original code for Roojs - LGPL
3 * <script type="text/javascript">
8 * This needs some more thought..
10 * compontent is taken..
18 * @class Roo.XComponent
19 * @extends Roo.data.Observable
21 * A delayed Element creator...
23 * Mypart.xyx = new Roo.XComponent({
25 parent : 'Mypart.xyz', // empty == document.element.!!
29 disabled : function() {}
31 items : [ // technically only one component..
33 xtype : 'NestedLayoutPanel',
42 Roo.XComponent = function(cfg) {
44 Roo.XComponent.register(this);
47 Roo.extend(Roo.XComponent, Roo.util.Observable);
49 Roo.apply(Roo.XComponent,
51 * @property buildCompleted
52 * True when the builder has completed building the interface.
55 buildCompleted : false,
59 * array of modules to be created by registration system.
69 * Register components to be built later.
70 * @param {Object} details about module
72 * This solves the following issues
73 * - Building is not done on page load, but after an authentication process has occured.
74 * - Interface elements are registered on page load
75 * - Parent Interface elements may not be loaded before child, so this handles that..
82 module : 'Pman.Tab.projectMgr',
84 parent : 'Pman.layout',
85 disabled : false, // or use a function..
89 register : function(obj) {
90 this.modules.push(obj);
95 * convert a string to an object..
99 toObject : function(str)
101 if (typeof(str) == 'object') {
104 var ar = str.split('.');
108 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
110 throw "Module not found : " + str;
112 Roo.each(ar, function(e) {
113 if (typeof(o[e]) == 'undefined') {
114 throw "Module not found : " + str;
124 * move modules into their correct place in the tree..
127 preBuild : function ()
129 var modules = this.modules;
130 this.modules = false;
133 Roo.each(modules , function (obj)
136 obj.parent = toObject(obj.parent);
138 if (!obj.parent.modules) {
139 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.order + '' });
142 obj.parent.modules.add(obj);
148 * Build the registered modules.
149 * @param {Object} parent element.
150 * @param {Function} optional method to call after module has been added.
154 build : function(parent, onCompleteFn)
156 var onComplete = function () {
158 onCompleteFn.call(this);
160 Roo.MessageBox.hide();
166 var cmp = function(a,b) {
167 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
170 if (!parent.modules) {
174 // make a flat list in order of modules to build.
178 // add modules to their parents..
179 var addMod = function(m) {
180 // console.log(m.modKey);
183 if (m.module.modules) {
184 m.module.modules.keySort('ASC', cmp );
185 m.module.modules.each(addMod);
188 m.finalize.name = m.name + " (clean up) ";
189 mods.push(m.finalize);
193 parent.modules.keySort('ASC', cmp );
194 parent.modules.each(addMod);
195 //this.allmods = mods;
199 return onComplete.call(this);
201 // flash it up as modal - so we store the mask!?
202 Roo.MessageBox.show({ title: 'loading' });
203 Roo.MessageBox.show({
204 title: "Please wait...",
205 msg: "Building Interface...",
214 var progressRun = function() {
216 if (n >= mods.length) {
217 return onComplete.call(this);
223 Roo.MessageBox.updateProgress(
224 (n+1)/mods.length, "Building Interface " + (n+1) +
225 " of " + mods.length +
226 (m.name ? (' - ' + m.name) : '')
229 if (typeof(m) == 'function') {
231 progressRun.defer(10, _this);
234 var disabled = (typeof(m.module.disabled) == 'function') ?
235 m.module.disabled.call(m.module.disabled) : m.module.disabled;
239 if (m.parent.layout && !disabled) {
240 // modules have to support a 'add method'
241 // should we just move that code into here..
242 m.module.add(m.parent.layout, m.region);
248 progressRun.defer(1, _this);