2 * Original code for Roojs - LGPL
3 * <script type="text/javascript">
8 * @extends Roo.data.Observable
10 * Document and interface builder class..
12 * MyApp = new Roo.Document({
13 * loadingIndicator : 'loading',
14 * listeners : Roo.Login.onLoad();
17 * MyApp.on('beforeload', function() {
24 Roo.Document = function(cfg) {
28 'beforeload' : true, // fired after page ready, before module building.
29 'load' : true, // fired after module building
30 'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
34 Roo.util.Observable.call(this,cfg);
36 Roo.onReady(function() {
37 _this.fireEvent('ready');
40 this.on('ready', onReady, this);
41 this.on('load', onLoad, this);
45 Roo.extend(Roo.Document, Roo.util.Observable, {
47 * @property buildCompleted
48 * True when the builder has completed building the interface.
51 buildCompleted : false,
53 * @property loadingIndicator
54 * ID of loading indictor element.
57 loadingIndicator : false,
60 * array of modules to be created by registration system.
66 // protected - on Ready handler.
69 // kludge to fix firebug debugger
70 if (typeof(console) == 'undefined') {
71 console = { log : function() { } };
75 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
85 * Register components to be built later.
86 * @param {Object} details about module
88 * This solves the following issues
89 * - Building is not done on page load, but after an authentication process has occured.
90 * - Interface elements are registered on page load
91 * - Parent Interface elements may not be loaded before child, so this handles that..
98 module : 'Pman.Tab.projectMgr',
100 parent : 'Pman.layout'
104 register : function(obj) {
105 this.modules.push(obj);
113 * move modules into their correct place in the tree..
116 preBuild : function ()
118 var modules = this.modules;
119 this.modules = false;
121 function toObject(str)
123 if (typeof(str) == 'object') {
126 var ar = str.split('.');
130 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
132 throw "Module not found : " + str;
134 Roo.each(ar, function(e) {
135 if (typeof(o[e]) == 'undefined') {
136 throw "Module not found : " + str;
144 Roo.each(modules , function (obj)
147 obj.parent = toObject(obj.parent);
149 if (!obj.parent.modules) {
150 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.order });
153 obj.parent.modules.add(obj);
159 * Build the registered modules.
160 * @param {Object} parent element.
161 * @param {Function} optional method to call after module has been added.
165 build : function(parent, onComplete)
169 var cmp = function(a,b) {
170 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
173 if (!parent.modules) {
176 parent.modules.keySort('ASC', cmp );
180 // add modules to their parents..
181 var addMod = function(m) {
182 // console.log(m.modKey);
185 if (m.module.modules) {
186 m.module.modules.keySort('ASC', cmp );
187 m.module.modules.each(addMod);
190 m.finalize.name = m.name + " (clean up) ";
191 mods.push(m.finalize);
196 parent.modules.each(addMod);
197 //this.allmods = mods;
201 if (onComplete) onComplete();
204 // flash it up as modal - so we store the mask!?
205 Ext.MessageBox.show({ title: 'loading' });
206 Ext.MessageBox.show({
207 title: "Please wait...",
208 msg: "Building Interface...",
216 var progressRun = function() {
221 Ext.MessageBox.updateProgress(
222 (n+1)/mods.length, "Building Interface " + (n+1) +
223 " of " + mods.length +
224 (m.name ? (' - ' + m.name) : '')
229 if (typeof(m) == 'function') {
233 if (m.parent.layout && !m.module.disabled) {
234 m.module.add(m.parent.layout, m.region);
241 if (n >= mods.length) {
247 progressRun.defer(10, Pman);
249 progressRun.defer(1, Pman);