2 * Original code for Roojs - LGPL
3 * <script type="text/javascript">
8 * This needs some more thought..
14 * @class Roo.XComponent
15 * @extends Roo.data.Observable
17 * A delayed Element creator...
19 * Mypart.xyx = new Roo.XComponent({
21 parent : 'Mypart.xyz', // empty == document.element.!!
25 disabled : function() {}
27 items : [ // technically only one component..
29 xtype : 'NestedLayoutPanel',
38 Roo.XComponent = function(cfg) {
40 Roo.XComponent.register(this);
43 Roo.extend(Roo.XComponent, Roo.util.Observable);
45 Roo.apply(Roo.XComponent,
47 * @property buildCompleted
48 * True when the builder has completed building the interface.
51 buildCompleted : false,
55 * array of modules to be created by registration system.
65 * Register components to be built later.
66 * @param {Object} details about module
68 * This solves the following issues
69 * - Building is not done on page load, but after an authentication process has occured.
70 * - Interface elements are registered on page load
71 * - Parent Interface elements may not be loaded before child, so this handles that..
78 module : 'Pman.Tab.projectMgr',
80 parent : 'Pman.layout',
81 disabled : false, // or use a function..
85 register : function(obj) {
86 this.modules.push(obj);
91 * convert a string to an object..
95 toObject : function(str)
97 if (typeof(str) == 'object') {
100 var ar = str.split('.');
104 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
106 throw "Module not found : " + str;
108 Roo.each(ar, function(e) {
109 if (typeof(o[e]) == 'undefined') {
110 throw "Module not found : " + str;
120 * move modules into their correct place in the tree..
123 preBuild : function ()
125 var modules = this.modules;
126 this.modules = false;
129 Roo.each(modules , function (obj)
132 obj.parent = toObject(obj.parent);
134 if (!obj.parent.modules) {
135 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.order + '' });
138 obj.parent.modules.add(obj);
144 * Build the registered modules.
145 * @param {Object} parent element.
146 * @param {Function} optional method to call after module has been added.
150 build : function(parent, onCompleteFn)
152 var onComplete = function () {
154 onCompleteFn.call(this);
156 Roo.MessageBox.hide();
162 var cmp = function(a,b) {
163 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
166 if (!parent.modules) {
170 // make a flat list in order of modules to build.
174 // add modules to their parents..
175 var addMod = function(m) {
176 // console.log(m.modKey);
179 if (m.module.modules) {
180 m.module.modules.keySort('ASC', cmp );
181 m.module.modules.each(addMod);
184 m.finalize.name = m.name + " (clean up) ";
185 mods.push(m.finalize);
189 parent.modules.keySort('ASC', cmp );
190 parent.modules.each(addMod);
191 //this.allmods = mods;
195 return onComplete.call(this);
197 // flash it up as modal - so we store the mask!?
198 Roo.MessageBox.show({ title: 'loading' });
199 Roo.MessageBox.show({
200 title: "Please wait...",
201 msg: "Building Interface...",
210 var progressRun = function() {
212 if (n >= mods.length) {
213 return onComplete.call(this);
219 Roo.MessageBox.updateProgress(
220 (n+1)/mods.length, "Building Interface " + (n+1) +
221 " of " + mods.length +
222 (m.name ? (' - ' + m.name) : '')
225 if (typeof(m) == 'function') {
227 progressRun.defer(10, _this);
230 var disabled = (typeof(m.module.disabled) == 'function') ?
231 m.module.disabled.call(m.module.disabled) : m.module.disabled;
235 if (m.parent.layout && !disabled) {
236 // modules have to support a 'add method'
237 // should we just move that code into here..
238 m.module.add(m.parent.layout, m.region);
244 progressRun.defer(1, _this);