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',
101 disabled : false, // or use a function..
105 register : function(obj) {
106 this.modules.push(obj);
114 * move modules into their correct place in the tree..
117 preBuild : function ()
119 var modules = this.modules;
120 this.modules = false;
122 function toObject(str)
124 if (typeof(str) == 'object') {
127 var ar = str.split('.');
131 eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
133 throw "Module not found : " + str;
135 Roo.each(ar, function(e) {
136 if (typeof(o[e]) == 'undefined') {
137 throw "Module not found : " + str;
145 Roo.each(modules , function (obj)
148 obj.parent = toObject(obj.parent);
150 if (!obj.parent.modules) {
151 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.order + '' });
154 obj.parent.modules.add(obj);
160 * Build the registered modules.
161 * @param {Object} parent element.
162 * @param {Function} optional method to call after module has been added.
166 build : function(parent, onComplete)
170 var cmp = function(a,b) {
171 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
174 if (!parent.modules) {
178 // make a flat list in order of modules to build.
182 // add modules to their parents..
183 var addMod = function(m) {
184 // console.log(m.modKey);
187 if (m.module.modules) {
188 m.module.modules.keySort('ASC', cmp );
189 m.module.modules.each(addMod);
192 m.finalize.name = m.name + " (clean up) ";
193 mods.push(m.finalize);
197 parent.modules.keySort('ASC', cmp );
198 parent.modules.each(addMod);
199 //this.allmods = mods;
204 onComplete.call(this);
208 // flash it up as modal - so we store the mask!?
209 Roo.MessageBox.show({ title: 'loading' });
210 Roo.MessageBox.show({
211 title: "Please wait...",
212 msg: "Building Interface...",
221 var progressRun = function() {
223 if (n >= mods.length) {
225 onComplete.call(this);
233 Roo.MessageBox.updateProgress(
234 (n+1)/mods.length, "Building Interface " + (n+1) +
235 " of " + mods.length +
236 (m.name ? (' - ' + m.name) : '')
239 if (typeof(m) == 'function') {
241 progressRun.defer(10, _this);
244 var disabled = (typeof(m.module.disabled) == 'function') ?
245 m.module.disabled.call(m.module.disabled) : m.module.disabled;
249 if (m.parent.layout && !disabled) {
250 m.module.add(m.parent.layout, m.region);
256 progressRun.defer(1, _this);