source: sandbox/2.2.0.2/expressoMail1_2/js/InfoQuota.js @ 4561

Revision 4561, 6.7 KB checked in by airton, 13 years ago (diff)

Ticket #1820 - Ajuste para exibir os detalhes da quota no chrome - r4536

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