Roo/Document.js
[roojs1] / Roo / Document.js
1 /*
2  * Original code for Roojs - LGPL
3  * <script type="text/javascript">
4  */
5  
6 /**
7  * @class Roo.Documents
8  * @extends Roo.data.Observable
9  * 
10  * Document and interface builder class..
11  * 
12  * MyApp = new Roo.Document({
13  *     loadingIndicator : 'loading' 
14  * });
15  * 
16  * MyApp.on('beforeload', function() {
17  *      MyApp.register()
18  
19  * 
20  * 
21  * 
22  */
23 Roo.Document = function(cfg) {
24      
25     this.addEvents({ 
26         'ready' : true,
27         'beforeload' : true, // fired after page ready, before module building.
28         'load' : true, // fired after module building
29         'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
30         
31     });
32     Roo.util.Observable.call(this,cfg);
33     var _this = this;
34     Roo.onReady(function() {
35         _this.fireEvent('ready');
36     },null,false);
37     
38     this.on('ready', onReady, this);
39     this.on('load', onLoad, this);  
40     
41 }
42 Roo.extend(Roo.Document, Roo.util.Observable, {
43     /**
44      * @property  buildCompleted
45      * True when the builder has completed building the interface.
46      * @type Boolean
47      */
48     buildCompleted : false,
49      /**
50      * @property  loadingIndicator
51      * ID of loading indictor element.
52      * @type String
53      */
54     loadingIndicator : false,
55     
56     
57     
58     onReady : 
59     listeners : {
60         'ready' : function()
61         {
62             // kludge to fix firebug debugger
63             if (typeof(console) == 'undefined') {
64                 console = { log : function() {  } };
65             }
66             
67             // remove loader..
68             if (Roo.get('loading')) {
69                 Roo.get('loading').remove();
70             }
71             
72             Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
73             
74             // link errors...
75             
76             if (AppLinkError.length) {
77                 Ext.MessageBox.alert("Error", AppLinkError, function() {
78                     Pman.Login.onLoad();
79                 });
80                 return;
81             }
82             
83             
84             // reset password!!!!
85             if (showNewPass.length) {
86                 Pman.PasswordChange.show(  { passwordReset : showNewPass },
87                     function(data) {
88                         // fail and success we do  a load...
89                         Pman.Login.onLoad();
90                     }
91                 );
92                 return;
93             }
94              
95             Pman.Login.onLoad();
96             
97         },
98         'load' : function()
99         {
100             if (Roo.get('loading-logo-tile')) {
101                 Roo.get('loading-logo-tile').remove();
102             }
103             if (Roo.get('loading-logo-tile-top')) {
104                 Roo.get('loading-logo-tile-top').remove();
105             }
106             if (Roo.get('loading-logo-bottom')) {
107                 Roo.get('loading-logo-bottom').remove();
108             }
109             if (Roo.get('loading-logo-center')) {
110                 Roo.get('loading-logo-center').remove();
111             }
112         }   
113         
114     },
115    
116     
117     
118 });
119