source: branches/2.2/expressoMail1_2/js/InfoQuota.js @ 5098

Revision 5098, 6.7 KB checked in by niltonneto, 13 years ago (diff)

Ticket #2280 - Corrigido problema de carregamento do arquivo InfoQuota?.js

Line 
1function emInfoQuota ()
2        {
3                this.win;
4                this.el;       
5        }
6       
7        emInfoQuota.prototype.preLoad = function(){
8                if(Element("table_quota")) {
9                        Element("table_quota").style.cursor = "pointer";
10                        Element("table_quota").title = get_lang("View Quota Usage in Folders");                 
11                        Element("table_quota").onclick = function (){
12                                InfoQuota.showList();
13                        }               
14                }
15        }
16
17        emInfoQuota.prototype.showList = function()
18        {
19                var _this = this;               
20                var el = Element("window_InfoQuota");
21                if(!el) {
22                        el = document.createElement("DIV");
23                        el.style.visibility = "hidden";
24                        el.style.position = "absolute";
25                        el.style.left = "0px";
26                        el.style.top = "0px";
27                        el.style.overflowY = "auto";
28                        el.align = "center";                   
29                        div.style.height = "400px";                     
30                        el.id = 'window_InfoQuota';
31                        document.body.appendChild(el);
32                }               
33               
34                var handler_buildQuota = function(data){                       
35                        el.appendChild(InfoQuota.buildQuota(data));                     
36                        el.innerHTML += '<br><input style="margin-bottom:10px" type="button" value=' + get_lang("Close")+
37                        ' id="InfoQuota_button_close" onClick="InfoQuota.close_window();">';                   
38                        _this.showWindow(el);
39                }
40               
41                cExecute ("expressoMail1_2.imap_functions.get_quota_folders", handler_buildQuota);             
42        }
43
44        emInfoQuota.prototype.showWindow = function (div)
45        {                                                       
46                if(! this.win) {
47                        div.style.height = "350px";
48                        div.style.width = "450px";
49                        var title = get_lang("View Quota Usage in Folders");                   
50                        var wHeight = div.offsetHeight + "px";
51                        var wWidth =  div.offsetWidth   + "px";                 
52
53                        this.win = new dJSWin({                 
54                                id: 'win_'+div.id,
55                                content_id: div.id,
56                                width: wWidth,
57                                height: wHeight,
58                                title_color: '#3978d6',
59                                title_align: 'center',
60                                bg_color: '#eee',
61                                title: title,                                           
62                                title_text_color: 'white',
63                                button_x_img: '../phpgwapi/images/winclose.gif',
64                                border: true });
65                                               
66                        this.win.draw();
67                        this.win.title.align = "center";
68                }
69               
70                this.win.open();
71        }
72
73        emInfoQuota.prototype.close_window = function() {               
74                this.win.close();
75        }
76       
77        emInfoQuota.prototype.buildQuota = function (data){
78                if(Element("window_InfoQuota")){
79                        Element("window_InfoQuota").innerHTML = '';
80                }
81                var content = '';
82                var q_limit = borkb(data.quota_root.quota_limit*1024);         
83               
84                var value = '';
85                var q_used = '';
86                var table = document.createElement("TABLE");
87                table.id = "table_quota";
88                table.style.border="1px solid #CCC";
89                table.style.marginTop = "10px";
90                table.style.width="100%";
91                if (navigator.userAgent.toLowerCase().indexOf('chrome') == -1)// chrome == > -1
92                        table.style.height="80%";
93                table.style.background = "#FFF";
94                table.cellSpacing = 5;
95                table.cellPadding = 0;                         
96                var thead = document.createElement("THEAD");
97                var tbody = document.createElement("TBODY");
98                var tfoot = document.createElement("TFOOT");
99                table.appendChild(thead);
100                table.appendChild(tbody);
101                table.appendChild(tfoot);               
102                thead.style.background = "#FFF";
103                var tr_thead = document.createElement("TR");
104                tr_thead.style.fontSize = "10pt";
105                tr_thead.style.height = '10px';
106                tr_thead.style.background = "#3978d6";
107                tr_thead.style.color = "white";
108                tr_thead.style.fontWeight = "bold";
109                thead.appendChild(tr_thead);
110                var th_thead = document.createElement("TH");
111                th_thead.style.paddingRight = '5px';
112                th_thead.style.paddingLeft = '5px';             
113                th_thead.innerHTML = get_lang('Folder');
114                tr_thead.appendChild(th_thead);         
115                th_thead = document.createElement("TH");
116                th_thead.style.paddingRight = '5px';
117                th_thead.style.paddingLeft = '5px';
118                th_thead.style.align = "center";
119                th_thead.colSpan = "2";
120                th_thead.noWrap = "true";               
121                th_thead.innerHTML = get_lang('% used');
122                tr_thead.appendChild(th_thead);         
123                th_thead = document.createElement("TH");
124                th_thead.style.paddingRight = '5px';
125                th_thead.style.paddingLeft = '5px';
126                th_thead.noWrap = "true";
127                th_thead.innerHTML = get_lang("Size")+" (bytes)";
128                tr_thead.appendChild(th_thead);
129                tbody.style.overflowY = "auto";
130                tbody.style.overflowX = "hidden";
131                tbody.style.width = "50%";             
132                var last_folder = 'null';
133                for(var x in data) {
134                        if(x == 'quota_root') continue;                         
135                        q_used = borkb(data[x]['quota_used']);
136                        value = data[x]['quota_percent'];
137                        td01 = document.createElement("TD");
138                        td01.align="left";                     
139                        if(x.indexOf(last_folder+"/") == -1){
140                                last_folder = x;
141                                td01.innerHTML = "&nbsp;"+x;
142                        }
143                        else {
144                                var a_folder = x.split('/');
145                                for (var i =0; i< a_folder.length;i++)
146                                        td01.innerHTML  += "&nbsp;&nbsp;";                             
147                                td01.innerHTML  += a_folder[a_folder.length-1];
148                        }
149                       
150                        td01.style.borderBottom = "1px dashed #DDD";
151                        td01.width="40%";
152                        td01.setAttribute("noWrap","true");                     
153                        td02 = document.createElement("TD");
154                        td02.align="center";
155                        td02.width="5%";
156                        td02.setAttribute("noWrap","true");                     
157                        td02.innerHTML = value+"%";
158                        td11 = document.createElement("TD");
159                        td11.width="10%";
160                        td11.align="center";
161                        td11.setAttribute("noWrap","true");
162                        td11.style.borderBottom = "1px dashed #DDD";
163                        td11.innerHTML += '&nbsp;<span class="boxHeaderText">'+q_used+"</span>";
164                        tr2 = document.createElement("TR");
165                        td21 = document.createElement("TD");
166                        td21.setAttribute("noWrap","true");                     
167                        td21.height="15px";
168                        td22 = document.createElement("TD");   
169                        td21.setAttribute("background","../phpgwapi/templates/"+template+"/images/dsunused.gif");
170                        table221 = document.createElement("TABLE");
171                        tbody221 = document.createElement("TBODY");
172                        table221.appendChild(tbody221);
173                        table221.style.width=value+"%";
174                        td21.width="30%";
175                        table221.cellSpacing = 0;
176                        table221.cellPadding = 0;
177                        tr221 = document.createElement("TR");
178                        td221 = document.createElement("TD");
179                        td221.height="15px";
180                        td221.className = 'dsused';                     
181                        td221.style.width = '100%';
182                        tr221.appendChild(td221);
183                        tbody221.appendChild(tr221);
184                        td21.appendChild(table221);
185                        tr2.appendChild(td01);
186                        tr2.appendChild(td02);
187                        tr2.appendChild(td21);
188                        tr2.appendChild(td11); 
189                        tbody.appendChild(tr2);
190                }       
191                var tr_tfoot = document.createElement("TR");
192                tr_tfoot.style.fontSize = "10pt";               
193                tr_tfoot.style.color = "#bbb";
194                tr_tfoot.style.fontWeight = "bold";
195                tfoot.appendChild(tr_tfoot);           
196                var th_tfoot = document.createElement("TH");
197                th_tfoot.style.align = "center";
198                th_tfoot.colSpan = "4";
199                th_tfoot.style.paddingRight = '5px';
200                th_tfoot.style.paddingLeft = '5px';             
201                th_tfoot.innerHTML = get_lang("You are currently using %1 (%2%).",borkb(data.quota_root.quota_used*1024), data.quota_root.quota_percent);
202                tr_tfoot.appendChild(th_tfoot);         
203                return table;
204        }
205       
206/* Build the Object */ 
207        var InfoQuota;
208        InfoQuota = new emInfoQuota();
209        InfoQuota.preLoad();
210        /* Override function :: refresh and auto_refresh */     
211        var __build_quota = build_quota;
212        build_quota = function (data) {
213                __build_quota(data);
214                if(InfoQuota.win)
215                        InfoQuota.win.close();
216                InfoQuota.preLoad();
217        };
Note: See TracBrowser for help on using the repository browser.