source: sandbox/2.5.1-evolucao/expressoMail1_2/js/InfoQuota.js @ 5430

Revision 5430, 7.1 KB checked in by angelo, 12 years ago (diff)

Ticket #2456 - Ajustar tamanho da tela de visualizacao de pastas

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               
48                var newWidth = ((parseInt(document.body.clientWidth,10)*0.7)^0);
49                if(! this.win) {
50                        div.style.height = "350px";
51                        div.style.width = newWidth + "px";
52                        var title = get_lang("View Quota Usage in Folders");                   
53                        var wHeight = div.offsetHeight + "px";
54                        var wWidth =  div.offsetWidth   + "px";                 
55
56                        this.win = new dJSWin({                 
57                                id: 'win_'+div.id,
58                                content_id: div.id,
59                                width: wWidth,
60                                height: wHeight,
61                                title_color: '#3978d6',
62                                title_align: 'center',
63                                bg_color: '#eee',
64                                title: title,                                           
65                                title_text_color: 'white',
66                                button_x_img: '../phpgwapi/images/winclose.gif',
67                                border: true });
68                                               
69                        this.win.draw();
70                        this.win.title.align = "center";
71                }
72               
73                this.win.open();
74        }
75
76        emInfoQuota.prototype.close_window = function() {               
77                this.win.close();
78        }
79       
80        emInfoQuota.prototype.buildQuota = function (data){
81                if(Element("window_InfoQuota")){
82                        Element("window_InfoQuota").innerHTML = '';
83                }
84                var content = '';
85                var q_limit = borkb(data.quota_root.quota_limit*1024);         
86               
87                var value = '';
88                var q_used = '';
89                var table = document.createElement("TABLE");
90                table.id = "table_quota";
91                table.style.border="1px solid #CCC";
92                table.style.marginTop = "10px";
93                table.style.width="100%";
94                if (navigator.userAgent.toLowerCase().indexOf('chrome') == -1)// chrome == > -1
95                table.style.height="80%";
96                table.style.background = "#FFF";
97                table.cellSpacing = 5;
98                table.cellPadding = 0;
99                if (is_ie)
100                        table.setAttribute('class','table-info-quota');
101                                               
102                var thead = document.createElement("THEAD");
103                var tbody = document.createElement("TBODY");
104                var tfoot = document.createElement("TFOOT");
105                table.appendChild(thead);
106                table.appendChild(tbody);
107                table.appendChild(tfoot);               
108                thead.style.background = "#FFF";
109                var tr_thead = document.createElement("TR");
110                tr_thead.style.fontSize = "10pt";
111                tr_thead.style.height = '15px';
112                tr_thead.style.background = "#3978d6";
113                tr_thead.style.color = "white";
114                tr_thead.style.fontWeight = "bold";
115                thead.appendChild(tr_thead);
116                var th_thead = document.createElement("TH");
117                th_thead.style.paddingRight = '5px';
118                th_thead.style.paddingLeft = '5px';             
119                th_thead.innerHTML = get_lang('Folder');
120                tr_thead.appendChild(th_thead);         
121                th_thead = document.createElement("TH");
122                th_thead.style.paddingRight = '5px';
123                th_thead.style.paddingLeft = '5px';
124                th_thead.style.align = "center";
125                th_thead.colSpan = "2";
126                th_thead.noWrap = "true";               
127                th_thead.innerHTML = get_lang('% used');
128                tr_thead.appendChild(th_thead);         
129                th_thead = document.createElement("TH");
130                th_thead.style.paddingRight = '5px';
131                th_thead.style.paddingLeft = '5px';
132                th_thead.noWrap = "true";
133                th_thead.innerHTML = get_lang("Size")+" (bytes)";
134                tr_thead.appendChild(th_thead);
135                tbody.style.overflowY = "auto";
136                tbody.style.overflowX = "hidden";
137                tbody.style.width = "50%";             
138                var last_folder = 'null';
139                for(var x in data) {
140                        if(x == 'quota_root') continue;                         
141                        q_used = borkb(data[x]['quota_used']);
142                        value = data[x]['quota_percent'];
143                        td01 = document.createElement("TD");
144                        td01.align="left";                     
145                        if(x.indexOf(last_folder+"/") == -1){
146                                last_folder = x;
147                                td01.innerHTML = "&nbsp;"+x;
148                                td01.setAttribute('title',x);
149                        }
150                        else {
151                                var a_folder = x.split('/');
152                                for (var i =0; i< a_folder.length;i++)
153                                        td01.innerHTML  += "&nbsp;&nbsp;";                             
154                                td01.innerHTML  += a_folder[a_folder.length-1];
155                                td01.setAttribute('title',a_folder[a_folder.length - 1]);
156                        }
157                       
158                        var user_max_width = ((parseInt(document.body.clientWidth,10)*0.7)^0);
159                        var max_len_permited = ((user_max_width*(1/6)*(0.5))^0);//tamanho maximo do nome de pasta
160                                               
161                        td01.width="40%";
162                        td01.style.maxWidth = max_len_permited + "px";
163                        td01.style.borderBottom = "1px dashed #DDD";
164                        td01.setAttribute('class','td-info-quota');                                             
165                        td02 = document.createElement("TD");
166                        td02.align="center";
167                        td02.width="5%";
168                        td02.setAttribute("noWrap","true");                     
169                        td02.innerHTML = value+"%";
170                        td11 = document.createElement("TD");
171                        td11.width="10%";
172                        td11.align="center";
173                        td11.setAttribute("noWrap","true");
174                        td11.style.borderBottom = "1px dashed #DDD";
175                        td11.innerHTML += '&nbsp;<span class="boxHeaderText">'+q_used+"</span>";
176                        tr2 = document.createElement("TR");
177                        td21 = document.createElement("TD");
178                        td21.setAttribute("noWrap","true");                     
179                        td21.height="15px";
180                        td22 = document.createElement("TD");   
181                        td21.setAttribute("background","../phpgwapi/templates/"+template+"/images/dsunused.gif");
182                        table221 = document.createElement("TABLE");
183                        tbody221 = document.createElement("TBODY");
184                        table221.appendChild(tbody221);
185                        table221.style.width=value+"%";
186                        td21.width="30%";
187                        table221.cellSpacing = 0;
188                        table221.cellPadding = 0;
189                        tr221 = document.createElement("TR");
190                        td221 = document.createElement("TD");
191                        td221.height="15px";
192                        td221.className = 'dsused';
193                        td221.style.width = '100%';                     
194                        tr221.appendChild(td221);
195                        tbody221.appendChild(tr221);
196                        td21.appendChild(table221);
197                        tr2.appendChild(td01);
198                        tr2.appendChild(td02);
199                        tr2.appendChild(td21);
200                        tr2.appendChild(td11); 
201                        tbody.appendChild(tr2);
202                }       
203                var tr_tfoot = document.createElement("TR");
204                tr_tfoot.style.fontSize = "10pt";               
205                tr_tfoot.style.color = "#bbb";
206                tr_tfoot.style.fontWeight = "bold";
207                tfoot.appendChild(tr_tfoot);           
208                var th_tfoot = document.createElement("TH");
209                th_tfoot.style.align = "center";
210                th_tfoot.colSpan = "4";
211                th_tfoot.style.paddingRight = '5px';
212                th_tfoot.style.paddingLeft = '5px';             
213                th_tfoot.innerHTML = get_lang("You are currently using %1 (%2%).",borkb(data.quota_root.quota_used*1024), data.quota_root.quota_percent);
214                tr_tfoot.appendChild(th_tfoot);         
215               
216                return table;
217        }
218       
219/* Build the Object */ 
220        var InfoQuota;
221        InfoQuota = new emInfoQuota();
222       
223        /* Override function :: refresh and auto_refresh */     
224        var __build_quota = build_quota;
225        build_quota = function (data) {
226                __build_quota(data);
227                if(InfoQuota.win)
228                        InfoQuota.win.close();
229                InfoQuota.preLoad();
230        };
Note: See TracBrowser for help on using the repository browser.