source: trunk/expressoMail1_2/js/InfoQuota.js @ 5426

Revision 5426, 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                var thead = document.createElement("THEAD");
100                var tbody = document.createElement("TBODY");
101                var tfoot = document.createElement("TFOOT");
102                table.appendChild(thead);
103                table.appendChild(tbody);
104                table.appendChild(tfoot);               
105                thead.style.background = "#FFF";
106                var tr_thead = document.createElement("TR");
107                tr_thead.style.fontSize = "10pt";
108                tr_thead.style.height = '10px';
109                tr_thead.style.background = "#3978d6";
110                tr_thead.style.color = "white";
111                tr_thead.style.fontWeight = "bold";
112                thead.appendChild(tr_thead);
113                var th_thead = document.createElement("TH");
114                th_thead.style.paddingRight = '5px';
115                th_thead.style.paddingLeft = '5px';             
116                th_thead.innerHTML = get_lang('Folder');
117                tr_thead.appendChild(th_thead);         
118                th_thead = document.createElement("TH");
119                th_thead.style.paddingRight = '5px';
120                th_thead.style.paddingLeft = '5px';
121                th_thead.style.align = "center";
122                th_thead.colSpan = "2";
123                th_thead.noWrap = "true";               
124                th_thead.innerHTML = get_lang('% used');
125                tr_thead.appendChild(th_thead);         
126                th_thead = document.createElement("TH");
127                th_thead.style.paddingRight = '5px';
128                th_thead.style.paddingLeft = '5px';
129                th_thead.noWrap = "true";
130                th_thead.innerHTML = get_lang("Size")+" (bytes)";
131                tr_thead.appendChild(th_thead);
132                tbody.style.overflowY = "auto";
133                tbody.style.overflowX = "hidden";
134                tbody.style.width = "50%";             
135                var last_folder = 'null';
136                for(var x in data) {
137                        if(x == 'quota_root') continue;                         
138                        q_used = borkb(data[x]['quota_used']);
139                        value = data[x]['quota_percent'];
140                        td01 = document.createElement("TD");
141                        td01.align="left";                     
142                        if(x.indexOf(last_folder+"/") == -1){
143                                last_folder = x;
144                                td01.innerHTML = "&nbsp;"+x;
145                                td01.setAttribute('title',x);
146                        }
147                        else {
148                                var a_folder = x.split('/');
149                                for (var i =0; i< a_folder.length;i++)
150                                        td01.innerHTML  += "&nbsp;&nbsp;";                             
151                                td01.innerHTML  += a_folder[a_folder.length-1];
152                                td01.setAttribute('title',a_folder[a_folder.length - 1]);
153                        }
154                       
155                        var user_max_width = ((parseInt(document.body.clientWidth,10)*0.7)^0);
156                        var max_len_permited = ((user_max_width*(1/6)*(0.5))^0);//tamanho maximo do nome de pasta
157                                               
158                        td01.width="40%";
159                        td01.style.maxWidth = max_len_permited + "px";
160                        td01.style.borderBottom = "1px dashed #DDD";           
161                        td01.setAttribute('class','td-info-quota');
162                       
163                        td02 = document.createElement("TD");
164                        td02.align="center";
165                        td02.width="5%";
166                        td02.setAttribute("noWrap","true");                     
167                        td02.innerHTML = value+"%";
168                        td11 = document.createElement("TD");
169                        td11.width="10%";
170                        td11.align="center";
171                        td11.setAttribute("noWrap","true");
172                        td11.style.borderBottom = "1px dashed #DDD";
173                        td11.innerHTML += '&nbsp;<span class="boxHeaderText">'+q_used+"</span>";
174                        tr2 = document.createElement("TR");
175                        td21 = document.createElement("TD");
176                        td21.setAttribute("noWrap","true");                     
177                        td21.height="15px";
178                        td22 = document.createElement("TD");   
179                        td21.setAttribute("background","../phpgwapi/templates/"+template+"/images/dsunused.gif");
180                        table221 = document.createElement("TABLE");
181                        tbody221 = document.createElement("TBODY");
182                        table221.appendChild(tbody221);
183                        table221.style.width=value+"%";
184                        td21.width="30%";
185                        table221.cellSpacing = 0;
186                        table221.cellPadding = 0;
187                        tr221 = document.createElement("TR");
188                        td221 = document.createElement("TD");
189                        td221.height="15px";
190                        td221.className = 'dsused';
191                        td221.style.width = '100%';                     
192                        tr221.appendChild(td221);
193                        tbody221.appendChild(tr221);
194                        td21.appendChild(table221);
195                        tr2.appendChild(td01);
196                        tr2.appendChild(td02);
197                        tr2.appendChild(td21);
198                        tr2.appendChild(td11); 
199                        tbody.appendChild(tr2);
200                }       
201                var tr_tfoot = document.createElement("TR");
202                tr_tfoot.style.fontSize = "10pt";               
203                tr_tfoot.style.color = "#bbb";
204                tr_tfoot.style.fontWeight = "bold";
205                tfoot.appendChild(tr_tfoot);           
206                var th_tfoot = document.createElement("TH");
207                th_tfoot.style.align = "center";
208                th_tfoot.colSpan = "4";
209                th_tfoot.style.paddingRight = '5px';
210                th_tfoot.style.paddingLeft = '5px';             
211                th_tfoot.innerHTML = get_lang("You are currently using %1 (%2%).",borkb(data.quota_root.quota_used*1024), data.quota_root.quota_percent);
212                tr_tfoot.appendChild(th_tfoot);         
213                return table;
214        }
215       
216/* Build the Object */ 
217        var InfoQuota;
218        InfoQuota = new emInfoQuota();
219       
220        /* Override function :: refresh and auto_refresh */     
221        var __build_quota = build_quota;
222        build_quota = function (data) {
223                __build_quota(data);
224                if(InfoQuota.win)
225                        InfoQuota.win.close();
226                InfoQuota.preLoad();
227        };
Note: See TracBrowser for help on using the repository browser.