Pman.js
[Pman.Core] / Pman.js
1 //<script type="text/javascript">
2
3 /**
4  * 
5  * >>> Pman.layout.getRegion('center').tabs.stripWrap
6  * ==> tab.???
7  * var tbh = Pman.layout.getRegion('center').tabs.stripWrap.child('div').createChild(
8  * 
9  * {tag: 'div', style: 'display:block;position:absolute;top:2;left:300;width:100%;height:25px'});
10  * 
11  * 
12  *  CHANGES
13  *  - gtranslate moved to Pman.GoogleTranslate
14  * 
15  * 
16  */
17  
18 if (typeof(_T) == 'undefined') { _T={};}
19  
20
21
22   
23
24 Pman = new Roo.Document(
25 {
26    /// appVersion: '1.7', // fixme = needs to be removed - use Global AppVersion
27     subMenuItems : [],
28     topMenuItems : [],
29     rightNames: { }, /// register right names here - so they can be translated and rendered.
30     /**
31      * @property {Roo.menu.Menu} pulldownMenu - the 'add menu pulldown, you can use it to add items..
32      *
33      */
34     pulldownMenu : false, 
35     
36     
37     buildCompleted : false, // flag to say if we are building interface..
38     events : {
39         'beforeload' : true, // fired after page ready, before module building.
40         'load' : true, // fired after module building
41         'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
42     },
43     
44     listeners : {
45         'ready' : function()
46         {
47             // kludge to fix firebug debugger
48             if (typeof(console) == 'undefined') {
49                 console = { log : function() {  } };
50             }
51             
52             // remove loader..
53             if (Roo.get('loading')) {
54                 Roo.get('loading').remove();
55             }
56             
57             Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
58             
59             // link errors...
60             
61             if (AppLinkError.length) {
62                 Roo.MessageBox.alert("Error", AppLinkError, function() {
63                     Pman.Login.onLoad();
64                 });
65                 return;
66             }
67             
68             
69             // reset password!!!!
70             if (showNewPass.length) {
71                 Pman.PasswordChange.show(  { passwordReset : showNewPass },
72                     function(data) {
73                         // fail and success we do  a load...
74                         Pman.Login.onLoad();
75                     }
76                 );
77                 return;
78             }
79              
80             Pman.Login.onLoad();
81             
82         },
83         'load' : function()
84         {
85             if (Roo.get('loading-logo-tile')) {
86                 Roo.get('loading-logo-tile').remove();
87             }
88             if (Roo.get('loading-logo-tile-top')) {
89                 Roo.get('loading-logo-tile-top').remove();
90             }
91             if (Roo.get('loading-logo-bottom')) {
92                 Roo.get('loading-logo-bottom').remove();
93             }
94             if (Roo.get('loading-logo-center')) {
95                 Roo.get('loading-logo-center').remove();
96             }
97         }   
98         
99     },
100    
101
102     
103     layout: false,
104     
105     onload: function() {
106         //this.fireEvent('beforeload',this);
107         
108         
109         
110         if (this.layout) {
111             return; // already loaded
112         } 
113         if (Roo.get('loading')) {
114             Roo.get('loading').remove();
115         }
116         if (Roo.get('loading-mask')) {
117             Roo.get('loading-mask').show();
118         }
119         
120         
121        
122         
123         /*
124         Roo.MessageBox.show({
125            title: "Please wait...",
126            msg: "Building Interface...",
127            width:340,
128            progress:true,
129            closable:false
130           
131         });
132         */
133         //Pman.onLoadBuild();
134         //Roo.get(document.body).mask("Building Interface");
135         //Pman.onLoadBuild.defer(100, Pman);
136        //Pman.onLoadBuild();
137                     
138    // },
139     //onLoadBuild : function() {
140         
141         var _this = this;
142         this.stime = new Date();
143         this.layout = new Roo.BorderLayout(document.body, {
144             north: {
145                 split:false,
146                 initialSize: 25,
147                 titlebar: false
148             },
149          
150              
151             center: {
152                 titlebar: false,
153                 autoScroll:false,
154                 closeOnTab: true,
155                 tabPosition: 'top',
156                 //resizeTabs: true,
157                 alwaysShowTabs: true,
158                 minTabWidth: 140
159             } ,
160             south: {
161                 collapsible : true,
162                 collapsed : true,
163                 split:false,
164                 height: 120,
165                 titlebar: false 
166             }
167             
168         });
169         
170         this.fireEvent('beforeload',this);
171         
172         
173         
174         this.layout.beginUpdate();
175         this.layout.add('north', new Roo.ContentPanel('title', 'North'));
176         var au = Pman.Login.authUser;
177         if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
178             Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
179             Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
180         }
181         if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
182             Roo.get('headerInformation-company-logo').dom.src =  baseURL + 
183                 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
184         } else {
185             Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
186         }
187         
188         Roo.get('headerInformation').dom.innerHTML = String.format(
189                 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
190                 au.name, au.email, au.company_id_name, 
191                 AppVersion , appNameShort
192         );
193         
194         
195         document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
196         Roo.QuickTips.init(); 
197         if (Roo.isGecko) {
198            Roo.useShims = true;
199         }
200        
201         //this.mainLayout.beginUpdate();
202         //var maskDom = Roo.get(document.body)._maskMsg.dom
203         this.layout.beginUpdate();
204         
205         Pman.building = true;
206         
207         this.buildModules(this, 
208             function() {
209                 
210                 _this.layout.getRegion('center').showPanel(0);
211                 _this.layout.endUpdate(); 
212                 _this.addTopToolbar();  
213                 _this.finalize();
214                 _this.fireEvent('load',this);
215                 
216                 if (!_this.layout.getRegion('south').panels.length) {
217                     _this.layout.getRegion('south').hide();
218                 }
219                 
220                 
221             }
222         );
223         
224         
225      
226     },
227     
228     addTopToolbar : function()
229     {
230           //console.log( "t6:" + ((new Date())-stime));
231         //this.mainLayout.endUpdate();
232         // make a new tab to hold administration stuff...
233         
234        
235         //console.log( "t7:" + ((new Date())-stime));
236         var se = Pman.layout.getRegion('center').tabs.stripEl;
237         var tbh = se.createChild( 
238                 { tag: 'td', style: 'width:100%;'  });
239         
240         var lotb = new Roo.Toolbar(tbh);
241         
242         if (Roo.isSafari) {
243             var tbl = se.child('table', true);
244             tbl.setAttribute('width', '100%');
245         }
246         lotb.add(
247             new Roo.Toolbar.Fill(), 
248      
249             {
250                 text: "Change Password",
251                 cls: 'x-btn-text-icon',
252                 icon: rootURL + '/Pman/templates/images/change-password.gif',
253                 handler : function(){
254                     Pman.PasswordChange.show({});
255                 }
256             }, '-'
257         );
258          
259         
260         if (this.topMenuItems.length) {
261             
262             Roo.each(this.topMenuItems, function (mi) {
263                 lotb.add(mi);
264             });
265             lotb.add('-');
266         }
267         
268         
269         
270         if (this.subMenuItems.length) {
271             
272             this.subMenuItems.sort(function (a,b) {
273                 return a.seqid > b.seqid ? 1 : -1;
274             });
275             // chop off last seperator.
276             // since we always add it.. just chop of last item
277             this.subMenuItems.pop(); 
278             
279             var btn = new Roo.Toolbar.Button( 
280                 {
281                     text: "Add New Item",
282                     cls: 'x-btn-text-icon',
283                     icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
284                     menu : {
285                         items : this.subMenuItems
286                     }     
287                 }
288             );
289             this.pulldownMenu = btn.menu;
290             lotb.add(btn, '-');
291             
292         }
293        
294         lotb.add(
295             {
296                 text: "Logout",
297                 cls: 'x-btn-text-icon',
298                 icon: rootURL + '/Pman/templates/images/logout.gif',
299                 handler: function() {
300                     Pman.Login.logout();
301                 }
302                  
303             }
304         );
305       
306        // this.layout.endUpdate();
307     },
308     
309     
310     finalize : function() {
311         
312       
313        
314         window.onbeforeunload = function(e) { 
315             e = e || window.event;
316             var r = "Closing this window will loose changes, are you sure you want to do that?";
317
318             // For IE and Firefox
319             if (e) {
320                 e.returnValue = r;
321             }
322
323             // For Safari
324             return r;
325             
326         };
327         
328         Roo.MessageBox.hide();
329         if (Roo.get('loading-mask')) {
330            Roo.get('loading-mask').remove();
331         }
332         
333         
334         this.buildCompleted = true; // now we can force refreshes on everything..
335         
336         
337         // does the URL indicate we want to see a system..
338         if (AppTrackOnLoad * 1 > 0) {
339             this.onLoadTrack(AppTrackOnLoad,false);
340         }
341         
342         // Open system..
343         
344         var forceAdmin = function(data)
345         {
346             if (!data || !data.id) {
347                 //Roo.log("Force Admin");
348                 Pman.Dialog.PersonStaff.show( 
349                     { 
350                         id : 0, 
351                         company_id : Pman.Login.authUser.company_id_id * 1, 
352                         company_id_name : Pman.Login.authUser.company_id_name
353                     }, function(data) {
354                         forceAdmin(data);
355                     }
356                 );
357                 return;
358             }
359             Roo.state.Manager.set('Pman.Login.username', data.email),
360             window.onbeforeunload = false;
361             document.location = baseURL + '?ts=' + Math.random();
362         }
363         
364         var forceCompany = function(data) {
365             if (Pman.Login.authUser.company_id * 1 > 0) {
366                 forceAdmin();
367                 return;
368             }
369             if (!data || !data.id) {
370                 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
371                     forceCompany(data);
372                 });
373                 return;
374             }
375             Pman.Login.authUser.company_id_id  = data.id;
376             Pman.Login.authUser.company_id  = data.id;
377             Pman.Login.authUser.company_id_name  = data.name;
378             forceAdmin();
379         }
380         
381         if (Pman.Login.authUser.id < 0) {
382             // admin company has been created - create the user..
383             if (Pman.Login.authUser.company_id_id* 1 > 0) {
384                 forceAdmin();
385                 return;
386             }
387             
388             forceCompany();
389             /// create account..
390             
391             
392         }
393         
394
395     },
396     
397     
398     // REMOVE THESE 
399     
400      
401     onLoadTrack : function(id,cb) {
402         this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
403     },
404     onLoadTrackEdit : function(id,cb) {
405         this.onLoadTrackCall(id, cb, 'Documents_');
406     },
407     
408     
409     /// ----------- FIXME -----
410     
411     
412     onLoadTrackCall : function(id,cb, cls) {
413         Roo.get(document.body).mask("Loading Document details");
414
415         Pman.request({
416             url: baseURL + '/Roo/Documents.html',  
417             params: {
418                 _id: id
419             },  
420             method: 'GET',  
421             success : function(data) {
422                 Roo.get(document.body).unmask();
423              
424                 
425                 switch(data.in_out) {
426                     case 'IN' : cls+='In';break;
427                     case 'OUT' : cls+='Out';break;
428                     case 'WIP' : cls+='Wip';break;
429                     default: 
430                         Roo.MessageBox.alert("Error", "invalid in_out");
431                         return;
432                 }
433                 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
434             }, 
435             
436             failure: function() {
437                 Roo.get(document.body).unmask();
438                 //if (cb) {
439                 //    cb.call(false);
440                 //}
441                  
442            }
443         });
444           
445     },
446     
447     refreshActivePanel : function() {
448         var actpan = this.layout.getRegion('center').getActivePanel();
449         if (actpan.controller && actpan.controller.paging) {
450             actpan.controller.paging.onClick('refresh');
451             return;
452         }
453         
454         var agid = Pman.layout.getRegion('center').getActivePanel().id;
455         if (!agid) {
456             return;
457         }
458         Pman.Tab[agid].paging.onClick('refresh');
459     },
460     toCidV : function(data) {
461         return 'C' + data.in_out.substring(0,1) + data.cid;
462     },
463     
464     
465     /**
466      * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
467      * @param {String} name the [Module].[permission] to check for
468      * @param {Char} lvl  - which type of permission to use (eg. S=show...)
469      * @returns {Boolean} tue indicates permission allowed
470      */
471     hasPerm: function(name, lvl) {
472         if (
473             (typeof(Pman.Login.authUser) != 'object')
474             ||
475             (typeof(Pman.Login.authUser.perms) != 'object')
476             ||
477             (typeof(Pman.Login.authUser.perms[name]) != 'string')
478             ) {
479                 return false;
480         }
481         
482         return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
483         
484     },
485     /**
486      * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
487      * @param {String} name the [Module].[permission] to check for
488      * @param {Char} lvl  - which type of permission to use (eg. S=show...)
489      * @returns {Boolean} tue indicates permission exists.
490      */
491     hasPermExists: function(name) {
492         if (
493             (typeof(Pman.Login.authUser) != 'object')
494             ||
495             (typeof(Pman.Login.authUser.perms) != 'object')
496             ||
497             (typeof(Pman.Login.authUser.perms[name]) != 'string')
498             ) {
499                 return false;
500         }
501         return true;
502     },
503     
504     
505     
506     
507     
508     
509     Readers : {},
510     ColModels : {},
511     Forms : {},
512     Tab : {},
513     Dialog : {},
514     
515     processResponse : function (response)
516     {
517         var res = '';
518         try {
519             res = Roo.decode(response.responseText);
520             // oops...
521             if (typeof(res) != 'object') {
522                 res = { success : false, errorMsg : res, errors : true };
523             }
524             if (typeof(res.success) == 'undefined') {
525                 res.success = false;
526             }
527             
528         } catch(e) {
529             res = { success : false,  errorMsg : response.responseText, errors : true };
530         }
531         return res;
532     },
533     genericDelete : function(tab,tbl) {
534         
535         var r = [];
536         
537             
538         var s = tab.grid.getSelectionModel().getSelections();
539         if (!s.length)  {
540             Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
541             return '';
542         }
543         
544         for(var i = 0; i < s.length; i++) {
545             r.push(s[i].data.id);
546         }
547     
548         Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
549             function(btn) {
550                 if (btn != 'yes') {
551                     return;
552                 }
553                 // what about the toolbar??
554                 tab.grid.getView().mainWrap.mask("Deleting");
555                 Pman.request({
556                     url: baseURL + '/Roo/'+tbl+'.php',
557                     method: 'GET',
558                     params: {
559                         _delete : r.join(',')
560                     },
561                     success: function(response) {
562                         tab.grid.getView().mainWrap.unmask();
563                         if ( tab.paging ) {
564                             tab.paging.onClick('refresh');   
565                         } else if (tab.refresh) {
566                             tab.refresh();
567                         } else if (tab.grid.footer && tab.grid.footer.onClick) {
568                             // new xtype built grids
569                             tab.grid.footer.onClick('refresh');   
570                         } else {
571                             tab.grid.getDataSource().load();
572                         }
573                         
574                         
575                         
576                     },
577                     failure: function(act) {
578                         tab.grid.getView().mainWrap.unmask();
579                         Roo.MessageBox.alert("Error", "Error Deleting");
580                     }
581                     
582                 });
583             }
584             
585         );
586         return '';
587     },
588     
589     
590     standardActionFailed :  function(f, act, cb) {
591     
592         if (act.failureType == 'client') {
593             Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
594             return;
595         }
596         if (act.failureType == 'connect') {
597             Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
598             return;
599         }
600         
601         if (act.type == 'submit') {
602             
603             Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
604                 String.format('{0}', act.result.errorMsg) : 
605                 "Saving failed = fix errors and try again", cb);
606             return;
607         }
608         
609         // what about load failing..
610         Roo.MessageBox.alert("Error", "Error loading details",cb); 
611     },
612     /**
613      * Depreciated - USE new Pman.Request
614     * 
615      * 
616      */
617     request : function(c) {
618         var r= new Roo.data.Connection({
619             timeout : typeof(c.timeout) == 'undefined' ?  30000 : c.timeout
620         });
621         r.request({
622             url: c.url,
623             method : c.method,
624             params: c.params,
625             xmlData : c.xmlData,
626             success:  function(response, opts)  {  // check successfull...
627                
628                 var res = Pman.processResponse(response);
629                 
630                 if (!res.success) { // error!
631                     if (c.failure) {
632                         if (true === c.failure.call(this,response, opts)) {
633                             return;
634                         }
635                     }
636                     Roo.MessageBox.hide();
637                     Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
638                     return;
639                 }
640                 
641                 c.success.call(this, res.data);
642                 
643                 return; 
644             },
645             failure :  function(response, opts)  {  // check successfull...
646                 
647                 if (c.failure) {
648                     if (true === c.failure.call(this,response, opts)) {
649                         return;
650                     }
651                 }
652                 Roo.MessageBox.hide();
653                 Roo.MessageBox.alert("Error", "Connection timed out sending");
654                 Roo.log(response);
655                 
656             },
657             scope: this
658             
659         });
660     },
661     
662     
663     // depreciated - use Pman.Download()
664     
665     download : function(c) {
666         
667         return new Pman.Download(c);
668     },
669     
670     // fixme - move to document manager...
671     downloadRevision : function(doc, rev)
672     {
673         this.download({
674             url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
675                 doc.project_id_code + '-' + doc.cidV + '-' + rev  + '-' +  doc.filename
676         }); 
677                     
678     },
679     
680     
681     exportCSV : function(c) {
682         
683         for(var i=0;i < c.csvFormat.length;i++) {
684             c.params['csvCols['+i+']'] = c.csvFormat[i][0];
685             c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
686         }
687         c.url +=  '?' + Roo.urlEncode(c.params);
688         this.download(c);
689
690     },
691     
692     
693     prettyDate : function (value) 
694     {
695         if (typeof(value) == 'string') {
696             var ds = Date.parseDate(value, 'Y-m-d H:i:s');
697             if (ds) {
698                 return this.prettyDate(ds);
699             }
700             ds = Date.parseDate(value, 'Y-m-d');
701             if (ds) {
702                 return this.prettyDate(ds);
703             }
704             return '';
705         }
706 // last 7 days...
707         if (!value) {
708             return '';
709         }
710         var td = new Date();
711         var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
712         if (daysSince < 7) {
713             return value.dateFormat('D H:i');
714         }
715         
716         // same month
717         if (td.dateFormat('m') == value.dateFormat('m')) {
718             return value.dateFormat('dS D');
719         }
720         // same year?
721         if (td.dateFormat('Y') == value.dateFormat('Y')) {
722             return value.dateFormat('dS M');
723         }
724         return value.dateFormat('d M Y');
725     },
726     loadException : function(a,b,c,d)
727     {
728         if (d && d.authFailure) {
729             Pman.Login.show();
730             return;
731         }
732         Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
733     },
734     
735     
736     /**
737      * 
738      * Routine to flash alerts in the title bar..
739      * 
740      * 
741      */
742     
743     notifyActive : false,
744     
745     notifyTitle: function(msg)
746     {
747         if (this.notifyActive ) {
748             return;
749         }
750         var stop = false;
751         
752         var stopper = function() {
753             stop = true;
754              document.title = oldtitle;
755         };
756         
757         Roo.get(document.body).on('mousemove', stopper, this);
758         var oldtitle = document.title;
759         var s = 1;
760         var _this = this;
761         var ivl = window.setInterval(function() {
762             
763             if (stop) {
764                 Roo.get(document.body).un('mousemove', stopper, this);
765                 _this.notifyActive = false;
766                 document.title = oldtitle;
767                 window.clearInterval(ivl);
768                 return true;
769             }
770             s = !s;
771             document.title = s ? msg : oldtitle;
772             return false;     
773         }, 1000); // every 120 secs = 2mins..
774          document.title =   msg;
775         
776         
777         
778     },
779     
780     modules : false,
781     /**
782      * example:
783      * 
784      * Pman.register({
785           modKey : '00-admin-xxxx',
786           module : Pman.Tab.projectMgr,
787           moduleName : 'Pman.Tab.projectMgr',
788           region : 'center',
789           parent : Pman.layout
790         })
791      * 
792      */
793     register : function(obj)
794     {
795         
796         // ignore registration of objects which are disabled.
797         appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
798         
799         if ((typeof(obj.moduleName) != 'undefined')
800                 && appDisabled.indexOf(obj.moduleName) > -1)
801         {
802             return;
803         }
804         
805         if (!obj.parent) {
806             if (obj.parent === false) {
807                 //console.log('skip module (no parent)' + obj.modkey);
808                 return;
809             }
810             // this is an error condition - the parent does not exist..
811             // technically it should not happen..
812             console.log("Parent is missing");
813             console.log(obj);
814             return;
815         }
816         if (!obj.parent.modules) {
817             obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.modKey });
818         }
819         
820         obj.parent.modules.add(obj);
821         
822     },
823     
824     buildModules : function(parent, onComplete) 
825     {
826         
827         var _this = this;
828         var cmp = function(a,b) {   
829             return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
830             
831         };
832         if (!parent.modules) {
833             return;
834         }
835         parent.modules.keySort('ASC',  cmp );
836         var mods = [];
837         
838         
839         // add modules to their parents..
840         var addMod = function(m) {
841            // console.log(m.modKey);
842             
843             mods.push(m);
844             if (m.module.modules) {
845                 m.module.modules.keySort('ASC',  cmp );
846                 m.module.modules.each(addMod);
847             }
848             if (m.finalize) {
849                 m.finalize.name = m.name + " (clean up) ";
850                 mods.push(m.finalize);
851             }
852             
853         }
854  
855         parent.modules.each(addMod);
856         //this.allmods = mods;
857         //console.log(mods);
858         //return;
859         if (!mods.length) {
860             if (onComplete) onComplete();
861             return;
862         }
863         // flash it up as modal - so we store the mask!?
864         Roo.MessageBox.show({ title: 'loading' });
865         Roo.MessageBox.show({
866            title: "Please wait...",
867            msg: "Building Interface...",
868            width:450,
869            progress:true,
870            closable:false,
871            modal: false
872           
873         });
874         var n = 0;
875         var progressRun = function() {
876             
877             var mod = mods[n];
878             
879             
880             Roo.MessageBox.updateProgress(
881                 (n+1)/mods.length,  "Building Interface " + (n+1) + 
882                     " of " + mods.length + 
883                     (mod.name ? (' - ' + mod.name) : '')
884                     );
885             
886             
887             
888             if (typeof(mod) == 'function') {
889                 mod();
890                 
891             } else  if (mod.parent.layout && !mod.module.disabled) {
892                 // honour permname setings..
893                 if (mod.permname && mod.permname.length) {
894                     if (Pman.hasPerm(mod.permname, 'S')) {
895                         mod.module.add(mod.parent.layout, mod.region);    
896                     }
897                 } else {
898                     mod.module.add(mod.parent.layout, mod.region);    
899                 }
900                     
901                  
902             }
903             
904             
905             n++;
906             if (n >= mods.length) {
907                 onComplete();  
908                 return;
909             }
910                 
911             
912             progressRun.defer(10, Pman);    
913         }
914         progressRun.defer(1, Pman);
915      
916         
917         
918     },
919     
920     invertColor : function(c)
921     {
922         // read..
923         var ca = [];
924         for(var i = 0; i < 3; i++){
925             ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
926         }
927             
928         // invert..
929         var col = '';
930         Roo.each(ca, function(hi) {
931             var h = parseInt(255-hi).toString(16);
932             if(h < 16){
933                 h = '0' + h;
934             }
935             col += h;
936         });
937         return '#' + col;
938         
939     }
940     
941     
942     
943     
944     
945     
946     
947 });
948