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