2 * Original code for Roojs - LGPL
3 * <script type="text/javascript">
8 * This needs some more thought..
10 * compontent is taken..
12 * Mypart.xyx = new Roo.XComponent({
14 parent : 'Mypart.xyz',
18 disabled : function() {}
20 items : [ // technically only one component..
22 xtype : 'NestedLayoutPanel',
32 * @class Roo.Documents
33 * @extends Roo.data.Observable
35 * Document and interface builder class..
37 * MyApp = new Roo.Document({
38 * loadingIndicator : 'loading',
39 * listeners : Roo.Login.onLoad();
42 * MyApp.on('beforeload', function() {
49 Roo.Document = function(cfg) {
53 'beforeload' : true, // fired after page ready, before module building.
54 'load' : true, // fired after module building
55 'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
59 Roo.util.Observable.call(this,cfg);
61 Roo.onReady(function() {
62 _this.fireEvent('ready');
65 this.on('ready', onReady, this);
66 this.on('load', onLoad, this);
70 Roo.extend(Roo.Document, Roo.util.Observable, {
72 * @property buildCompleted
73 * True when the builder has completed building the interface.
76 buildCompleted : false,
78 * @property loadingIndicator
79 * ID of loading indictor element.
82 loadingIndicator : false,
85 * array of modules to be created by registration system.
91 // protected - on Ready handler.
94 // kludge to fix firebug debugger
95 if (typeof(console) == 'undefined') {
96 console = { log : function() { } };
100 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
110 * Register components to be built later.
111 * @param {Object} details about module
113 * This solves the following issues
114 * - Building is not done on page load, but after an authentication process has occured.
115 * - Interface elements are registered on page load
116 * - Parent Interface elements may not be loaded before child, so this handles that..
123 module : 'Pman.Tab.projectMgr',
125 parent : 'Pman.layout',
126 disabled : false, // or use a function..
130 register : function(obj) {
131 this.modules.push(obj);
139 * move modules into their correct place in the tree..
142 preBuild : function ()
144 var modules = this.modules;
145 this.modules = false;
147 function toObject(str)
149 if (typeof(str) == 'object') {
152 var ar = str.split('.');
156 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
158 throw "Module not found : " + str;
160 Roo.each(ar, function(e) {
161 if (typeof(o[e]) == 'undefined') {
162 throw "Module not found : " + str;
170 Roo.each(modules , function (obj)
173 obj.parent = toObject(obj.parent);
175 if (!obj.parent.modules) {
176 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.order + '' });
179 obj.parent.modules.add(obj);
185 * Build the registered modules.
186 * @param {Object} parent element.
187 * @param {Function} optional method to call after module has been added.
191 build : function(parent, onCompleteFn)
193 var onComplete = function () {
195 onCompleteFn.call(this);
197 Roo.MessageBox.hide();
203 var cmp = function(a,b) {
204 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
207 if (!parent.modules) {
211 // make a flat list in order of modules to build.
215 // add modules to their parents..
216 var addMod = function(m) {
217 // console.log(m.modKey);
220 if (m.module.modules) {
221 m.module.modules.keySort('ASC', cmp );
222 m.module.modules.each(addMod);
225 m.finalize.name = m.name + " (clean up) ";
226 mods.push(m.finalize);
230 parent.modules.keySort('ASC', cmp );
231 parent.modules.each(addMod);
232 //this.allmods = mods;
236 return onComplete.call(this);
238 // flash it up as modal - so we store the mask!?
239 Roo.MessageBox.show({ title: 'loading' });
240 Roo.MessageBox.show({
241 title: "Please wait...",
242 msg: "Building Interface...",
251 var progressRun = function() {
253 if (n >= mods.length) {
254 return onComplete.call(this);
260 Roo.MessageBox.updateProgress(
261 (n+1)/mods.length, "Building Interface " + (n+1) +
262 " of " + mods.length +
263 (m.name ? (' - ' + m.name) : '')
266 if (typeof(m) == 'function') {
268 progressRun.defer(10, _this);
271 var disabled = (typeof(m.module.disabled) == 'function') ?
272 m.module.disabled.call(m.module.disabled) : m.module.disabled;
276 if (m.parent.layout && !disabled) {
277 // modules have to support a 'add method'
278 // should we just move that code into here..
279 m.module.add(m.parent.layout, m.region);
285 progressRun.defer(1, _this);