source: branches/2.0/expressoMail1_2/js/search.js @ 2606

Revision 2606, 27.3 KB checked in by niltonneto, 14 years ago (diff)

Ticket #1040 - Corrige problemas ao redimensionar largura das divs principais.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1/**************************************************************************\
2 Início
3\**************************************************************************/
4        function searchE()
5        {
6                this.searchW   = new Array;
7                this.name_box_search = "";
8                this.all_boxes = new Array;
9                this.type = "";
10                this.fields = new Array("_ass","_de","_body","_para","_cc","_cco");
11        }
12       
13        //Monta os forms dentro da janela;
14        searchE.prototype.showForms = function(value){
15                // Principal
16                if(!Element("window_search")) {
17                        var form_search = document.createElement("DIV");
18                        form_search.style.visibility = 'hidden';
19                        form_search.style.top = '0px';
20                        form_search.style.left = '0px';
21                        form_search.id = "window_search";
22                        document.body.appendChild(form_search);                 
23                }
24               
25                // Pesquisa
26                if(!Element("div_form_search")){
27                        var div_form_search = document.createElement("DIV");
28                        div_form_search.id = "div_form_search";
29                        div_form_search.style.position = "absolute";
30                        div_form_search.style.left = "10px";
31                        div_form_search.style.top  = "10px";
32                        div_form_search.style.width = "770px";
33                        div_form_search.style.height = "300px";
34                        div_form_search.style.overflow = "hidden";
35                        div_form_search.innerHTML = "";
36                        var call_form_search = EsearchE.mount_form();
37                        div_form_search.appendChild(call_form_search);
38                        form_search.appendChild(div_form_search);
39
40                }       
41               
42                if(!Element("div_button_search")){
43                        var div_button_search    = document.createElement("DIV");
44                                div_button_search.id = "div_button_search";
45                                div_button_search.style.position = "absolute";
46                                div_button_search.style.left = "10px";
47                                div_button_search.style.top = "223px";
48                                div_button_search.style.width = "615px";
49                                div_button_search.style.height = "25px";
50                                div_button_search.innerHTML = "<table border='0' width='50%' cellpadding='0' cellspacing='0' align='right'>"+
51                                                                                          "<tr>"+
52                                                                                          "<td><input type='button' value=" + get_lang('Search') + " onclick='EsearchE.func_search()'></td>"+
53                                                                                          "<td><input type='button' value=" + get_lang('Clean') + " onclick='EsearchE.func_clean()'></td>"+
54                                                                                          "<td><input type='button' value=" + get_lang('Close') + " onclick='EsearchE.func_close(\"hidden\")'></td>"+
55                                                                                          "</tr>"+
56                                                                                          "</table>";
57                                form_search.appendChild(div_button_search);
58                }
59               
60                if(!Element("table_layer")){
61                        var table_layer    = "";
62                }
63               
64                if(value == "")
65                        EsearchE.showWindow(Element("window_search"));
66       
67                // Cria as caixas postais;
68                EsearchE.mount_folders();
69
70                if(value){
71                        Element("check_all_msg").checked = true;
72                        EsearchE.all_mailboxes();
73                        EsearchE.func_search(value);
74                }
75
76        }
77       
78        //Form
79        searchE.prototype.mount_form = function(value){
80                var form_sch = document.createElement("FORM");
81                form_sch.id  = "form_sch";
82
83                form_sch.innerHTML =  '<fieldset style="width:266px; text-align:right; padding: 5px; position:absolute;">'
84                                                        + '     <legend>'+get_lang('Inform your search in the text fields')+'</legend>'
85                                                        + '     <label>'+get_lang("From")+':</label>'
86                                                        + '     <input type="text" id="txt_de" size="19">'
87                                                        + '     <br style="margin-bottom:15px"/>'
88                                                        + '     <label>'+get_lang('To')+':</label>'
89                                                        + '     <input type="text" id="txt_para" size="19">'
90                                                        + '     <br style="margin-bottom:15px"/>'
91                                                        + '     <label>'+get_lang('Cc')+':</label>'
92                                                        + '     <input type="text" id="txt_cc" size="19">'
93                                                        + '     <br style="margin-bottom:15px"/>'
94                                                        + '     <label>'+get_lang('Subject')+':</label>'
95                                                        + '     <input type="text" id="txt_ass" size="19">'
96                                                        + '     <br style="margin-bottom:15px"/>'
97                                                        + '     <label>'+get_lang('Message body')+':</label>'
98                                                        + '     <input type="text" id="txt_body" size="19">'
99                                                        + '     <br style="margin-bottom:60px"/>'
100                                                        + '</fieldset>'
101                                                        + '<fieldset style="width:350px; padding: 5px; position:absolute; margin-left: 280px">'
102                                                        + '     <legend>'+get_lang('Search the messages in these folders')+'</legend>'
103                                                        + '     <div id="folders" style="width:160px; height:150px;float:left;margin-bottom:10px;"></div>'
104                                                        + '     <div style="float:left;height:100px;padding-top:50px;margin: 0 3px;">'
105                                                        + '             <input type="button" id="incluir" name="incluir" value=">>" onclick="EsearchE.add_mailboxes()">'
106                                                        + '             <br style="margin-bottom:15px">'
107                                                        + '             <input type="button" id="excluir" name="excluir" value="<<" onclick="EsearchE.del_mailboxes()">'
108                                                        + '     </div>'
109                                                        + ' <div style="float:left;">' 
110                                                        + '      <select multiple id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:140px;height:150px;"></select>'
111                                                        + ' </div>'
112                                                        + '     <br clear="both">'
113                                                        + '     <input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()">'
114                                                        + '     <b>'+get_lang('In all the folders')+'</b>'
115                                                        + '</fieldset>';
116               
117                return form_sch;
118        }
119
120        // Pastas;
121        searchE.prototype.mount_folders = function(){
122                connector.loadScript("TreeS");
123
124                if( Element("div_folders_search") == null){
125                        var div_folders = document.createElement("DIV");
126                                div_folders.id = "div_folders_search";
127                                div_folders.style.width = "155px";
128                                div_folders.style.height = "152px";
129                                div_folders.style.borderStyle = "outset";
130                                div_folders.style.borderColor = "black";
131                                div_folders.style.borderWidth = "1px";
132                                div_folders.style.background  = "#F7F7F7";
133                                div_folders.style.overflow = "auto";
134                                div_folders.innerHTML = "";
135                                var dest_div = Element("folders");
136                                dest_div.appendChild(div_folders);
137                }               
138                ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","","");
139        }
140       
141        //This func returns the most recent date
142        function date_comp(a,b)
143        {
144                var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
145                data1 = data1[0].substr(0, data1[0].indexOf('--'))
146                with ( data1 )
147                        data1 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
148                var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
149                data2 = data2[0].substr(0, data2[0].indexOf('--'))
150                with ( data2 )
151                        data2 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
152                return data2 - data1;
153        }
154        function date_comp_reverse(a,b)
155        {
156                return date_comp(b,a);
157        }
158       
159        function box_comp(a,b)
160        {
161        var compare = [];
162        compare[0] = a.substr(0, a.indexOf('--'));
163        compare[0] = compare[0].toLowerCase();
164        var temp=compare[0];
165        compare[1] = b.substr(0, b.indexOf('--'))
166        compare[1] = compare[1].toLowerCase();
167        compare.sort();
168        if (temp != compare[0])
169                return +1;
170        else
171                return -1;
172        }
173        function box_comp_reverse(a,b)
174        {
175                return box_comp(b,a);
176        }
177
178        function who_comp(a,b)
179        {
180        var compare = [];
181        compare[0] = a.substr(a.indexOf('--')+2);
182        compare[0] = compare[0].toLowerCase();
183        var temp=compare[0];
184        compare[1] = b.substr(b.indexOf('--')+2);
185        compare[1] = compare[1].toLowerCase();
186        compare.sort();
187        if (temp != compare[0])
188                return +1;
189        else
190                return -1;
191        }
192        function who_comp_reverse(a,b)
193        {
194                return who_comp(b,a);
195        }
196
197        function subject_comp(a,b)
198        {
199        var compare = [];
200        compare[0] = a.substr(a.indexOf('--')+2);
201        compare[0] = compare[0].substr(compare[0].indexOf('--')+2);
202        compare[0] = compare[0].toLowerCase();
203        var temp=compare[0];
204        compare[1] = b.substr(b.indexOf('--')+2);
205        compare[1] = compare[1].substr(compare[1].indexOf('--')+2);
206        compare[1] = compare[1].toLowerCase();
207        compare.sort();
208        if (temp != compare[0])
209                return +1;
210        else
211                return -1;
212        }
213        function subject_comp_reverse(a,b)
214        {
215                return subject_comp(b,a);
216        }
217
218        function size_comp(a,b)
219        {
220                var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
221                data1 = data1[0].substr(data1[0].indexOf('--')+2)
222                data1 = data1.substr(0,data1.indexOf('--'))
223                var size_a = parseInt(data1.substr(0,data1.indexOf(' ')));
224                if (data1.match("k"))
225                        size_a = size_a * 1024;
226                else
227                        if (data1.match("m"))
228                                size_a = size_a * 1048576;
229                var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
230                data2 = data2[0].substr(data2[0].indexOf('--')+2)
231                data2 = data2.substr(0,data2.indexOf('--'))
232                var size_b = parseInt(data2.substr(0,data2.indexOf(' ')));
233                if (data2.match("k"))
234                        size_b = size_b * 1024;
235                else
236                        if (data2.match("m"))
237                                size_b = size_b * 1048576;
238                return size_b - size_a;
239        }
240        function size_comp_reverse(a,b)
241        {
242                return size_comp(b,a);
243        }
244
245        // Form resultado
246        searchE.prototype.mount_result = function(data,sort_type){
247                var nw_array = new Array;
248                var var_tmp = data.substr(2, data.length - 4);
249                var_tmp  = var_tmp.split("####");
250                var cont = parseInt(0);
251                switch (sort_type)
252                {
253                        case 'SORTDATE':
254                                var_tmp.sort(date_comp);
255                                break;
256                        case 'SORTDATE_REVERSE':
257                                var_tmp.sort(date_comp_reverse);
258                                break;
259                        case 'SORTBOX':
260                                var_tmp.sort(box_comp);
261                                break;
262                        case 'SORTBOX_REVERSE':
263                                var_tmp.sort(box_comp_reverse);
264                                break;
265                        case 'SORTSUBJECT':
266                                var_tmp.sort(subject_comp);
267                                break;
268                        case 'SORTSUBJECT_REVERSE':
269                                var_tmp.sort(subject_comp_reverse);
270                                break;
271                        case 'SORTWHO':
272                                var_tmp.sort(who_comp);
273                                break;
274                        case 'SORTWHO_REVERSE':
275                                var_tmp.sort(who_comp_reverse);
276                                break;
277                        case 'SORTSIZE':
278                                var_tmp.sort(size_comp);
279                                break;
280                        case 'SORTSIZE_REVERSE':
281                                var_tmp.sort(size_comp_reverse);
282                                break;
283                        default:
284                                var showMsg = 1;
285                }
286
287                for(var i=0; i < var_tmp.length; i++){
288                        if(var_tmp[i] != "")
289                        {
290                                nw_array[cont] = var_tmp[i];
291                                cont++;
292                        }
293                }
294                if(nw_array.length > 0 && showMsg)
295                        write_msg(nw_array.length + " "+ get_lang('results found'));
296                numBox++;
297                var border_id = create_border(get_lang("Search Results"), "search_" + numBox);
298                if (!border_id)
299                {
300                    return;
301                }
302                currentTab = border_id;
303                openTab.type[currentTab] = 1;
304                var table = document.createElement("TABLE");
305                table.id    = "table_resultsearch_" + numBox;
306                table.frame = "void";
307                table.rules = "rows";
308                table.cellPadding = "0";
309                table.cellSpacing = "0";
310                table.className = "table_box";
311
312                var tbody = document.createElement("TBODY");
313                tbody.id    = "tbody_box_" + numBox;
314
315                for( var i=0; i < nw_array.length; i++){
316                        var tr = document.createElement("TR");
317                        tr.style.height = preferences.line_height;
318
319                        if (nw_array[i].match(/.*--.*--\w*--\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g) != null) //subject with "--"
320                        {
321                                var aux1 = nw_array[i].match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
322                                aux1 = aux1[0].split("--");
323                                nw_array[i] = nw_array[i].substr(0, nw_array[i].indexOf(aux1[0])-2);
324                                var aux = [];
325                                aux[0] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
326                                nw_array[i] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
327                                aux[1] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
328                                aux[2] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
329                                aux = aux.concat(aux1);
330                        }
331                        else
332                        {
333                                var aux = nw_array[i].split("--");
334                        }
335
336                        var mailbox = aux[0];
337                        var uid_msg = aux[6];
338                        var subject = aux[2];
339                        tr.id = uid_msg;
340
341                        // Keep the two lines together please
342                        tr.setAttribute('name',mailbox);
343                        tr.name = mailbox;
344
345                        if (aux[5].match("U"))
346                                add_className(tr,'tr_msg_unread');
347                        add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read');
348            var _onclick = function () { proxy_mensagens.get_msg(this.parentNode.id,url_encode(this.parentNode.getAttribute('name')),false,show_msg);};
349            for(var j=0 ; j < 10 ; j++)
350                        {
351                                var td = document.createElement("TD");
352                                if (j == 0)
353                                {
354                                        td.style.width = "1%";
355                                        var td1 = '<input type="checkbox" id="check_box_message_'+uid_msg+'"></input>';
356                                       
357                                }
358                                if (j == 1)
359                                {
360                                        td.style.width = "2%";
361                                        if (aux[5].match('T'))
362                                        {
363                                                attachNum = parseInt(aux[5].substr(aux[5].indexOf('T')+1));
364                                                td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>";
365                                        }
366                                        else
367                                                td1 = '';
368                                }
369                                if (j == 2)
370                                {
371                                        td.style.width = "1%";
372                                        td.id = "td_message_answered_"+uid_msg;
373                                        if (aux[5].match('X'))
374                                                td1 = '<img src=templates/'+template+'/images/forwarded.gif title=Forwarded>';
375                                        else
376                                                if (aux[5].match('A'))
377                                                        td1 = '<img src=templates/'+template+'/images/answered.gif>';
378                                                else
379                                                        td1 = '';
380                                }
381                                if (j == 3)
382                                {
383                                        td.style.width = "1%";
384                                        td.id = "td_message_important_"+uid_msg;
385                                        if (aux[5].match("F"))
386                                        {
387                                                add_className(tr, 'flagged_msg');
388                                                td.style.background = "url(templates/"+template+"/images/important.gif) no-repeat center";
389                                        }
390                                        else
391                                                td1 = '';
392                                }
393                                if (j == 4)
394                                {
395                                        td.style.width = "1%";
396                                        td.id = "td_message_sent_"+uid_msg;
397                                        td1 = '';
398                                }
399                                if (j == 5)
400                                {
401                                        td.style.width = "14%";
402                                        td.onclick = _onclick;
403                                        var nm_box = aux[0].split(cyrus_delimiter);
404                                        var td1 = nm_box.pop();
405                                        td.setAttribute("NoWrap","true");
406                                        td.style.overflow = "hidden";
407                                        td.style.color = "#42795b";
408                                        td.style.fontWeight = "bold";
409
410                                        if(td1 == "INBOX"){
411                                                var td1  = get_lang("Inbox");
412                                        }
413
414                                        if(proxy_mensagens.is_local_folder(td1)) {
415                                                var td1 = this.aux_local_folder_display(td1);
416                                        }
417                                }
418                                if( j == 6)
419                                {
420                                        if (aux[1].length > 29)
421                                                aux[1] = aux[1].substr(0,29) + "...";
422                                        td.style.width = "20%";
423                                        td.onclick = _onclick;
424                                        td.setAttribute("NoWrap","true");
425                                        td.style.overflow = "hidden";
426                                        var td1  =  '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>";
427                                }
428                                if( j == 7)
429                                {
430                                        var subject_encode = url_encode(subject);
431                                        if (! subject_encode)
432                                                aux[2] = get_lang("no subject") + "...";
433                                        if (aux[2].length > 70)
434                                                aux[2] = aux[2].substr(0,70) + "...";
435                                        td.style.width = "35%";
436                                        td.onclick = _onclick;
437                                        td.setAttribute("NoWrap","true");
438                                        td.style.overflow = "hidden";
439                                        var td1  = aux[2];
440
441                                }
442                                if( j == 8)
443                                {
444                                        td.style.width = "15%";
445                                        td.align = "center";
446                                        td.onclick = _onclick;
447                                        var td1  = aux[3];
448                                }
449                                if( j == 9)
450                                {
451                                        td.style.width = "10%";
452                                        td.align = "center";
453                                        td.onclick = _onclick;
454                                        var td1  = aux[4];
455                                }
456                                if (j == 10)
457                                {
458                                        if (aux[5].match("U"))
459                                                add_className(tr, 'tr_msg_unread');
460                                        if (aux[5].match("F"))
461                                                add_className(tr, 'flagged_msg');
462                                        var td1 = '';
463                                }
464                                td.innerHTML = td1;
465                                tr.appendChild(td);
466                        }
467                        aux.splice(0,(aux.length));
468
469                _dragArea.makeDragged(tr, uid_msg, subject, true, mailbox);
470                tbody.appendChild(tr);
471                }
472                table.appendChild(tbody);
473
474        var content_search =  Element('content_id_search_' + numBox);
475        var div_scroll_result = document.createElement("DIV");
476        div_scroll_result.id = "divScrollMain_"+numBox;
477        div_scroll_result.style.overflow = "auto";
478       
479                if(is_ie)
480                        Element("border_table").width = "99.5%";
481               
482                // Put header
483                var table_element = document.createElement("TABLE");
484                var tbody_element = document.createElement("TBODY");
485                table_element.setAttribute("id", "table_message_header_box");
486                table_element.className = "table_message_header_box";
487                tr_element = document.createElement("TR");
488                tr_element.className = "message_header";
489                td_element0 = document.createElement("TD");
490                td_element0.setAttribute("width", "1%");
491                chk_box_element = document.createElement("INPUT");
492                chk_box_element.id  = "chk_box_select_all_messages";
493                chk_box_element.setAttribute("type", "checkbox");
494                chk_box_element.className = "checkbox";
495                chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);};
496                chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')};
497                chk_box_element.onkeydown = function (e){
498                        if (is_ie)
499                        {
500                                if ((window.event.keyCode) == 46)
501                                        delete_msgs(current_folder,'selected','null');
502                        }
503                        else
504                        {
505                                if ((e.keyCode) == 46)
506                                        delete_msgs(current_folder,'selected','null');
507                        }
508                };
509               
510                td_element0.appendChild(chk_box_element);
511                td_element1 = document.createElement("TD");
512                td_element1.setAttribute("width", "20%");
513                td_element1.align = "left";
514                if (sort_type == 'SORTBOX')
515                {
516                        td_element1.onclick = function () { EsearchE.mount_result(data,'SORTBOX_REVERSE'); delete_border(border_id,false);};
517                        td_element1.innerHTML ="<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
518                }
519                else
520                {
521                        td_element1.onclick = function () { EsearchE.mount_result(data,'SORTBOX'); delete_border(border_id,false);};
522                        if  (sort_type == 'SORTBOX_REVERSE')
523                                td_element1.innerHTML ="<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
524                        else
525                                td_element1.innerHTML = get_lang("Folder");
526                }
527                td_element2 = document.createElement("TD");
528                td_element2.setAttribute("width", "20%");
529                td_element2.align = "left";
530                if (sort_type == 'SORTWHO')
531                {
532                        td_element2.onclick = function () { EsearchE.mount_result(data,'SORTWHO_REVERSE'); delete_border(border_id,false);};
533                        td_element2.innerHTML ="<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
534                }
535                else
536                {
537                        td_element2.onclick = function () { EsearchE.mount_result(data,'SORTWHO'); delete_border(border_id,false);};
538                        if  (sort_type == 'SORTWHO_REVERSE')
539                                td_element2.innerHTML ="<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
540                        else
541                                td_element2.innerHTML = get_lang("who");
542                }
543                td_element3 = document.createElement("TD");
544                td_element3.setAttribute("width", "35%");
545                td_element3.align = "left";
546                if (sort_type == 'SORTSUBJECT')
547                {
548                        td_element3.onclick = function () { EsearchE.mount_result(data,'SORTSUBJECT_REVERSE'); delete_border(border_id,false);};
549                        td_element3.innerHTML ="<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
550                }
551                else
552                {
553                        td_element3.onclick = function () { EsearchE.mount_result(data,'SORTSUBJECT'); delete_border(border_id,false);};
554                        if  (sort_type == 'SORTSUBJECT_REVERSE')
555                                td_element3.innerHTML ="<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
556                        else
557                                td_element3.innerHTML = get_lang("subject");
558                }
559                td_element4 = document.createElement("TD");
560                td_element4.setAttribute("width", "15%");
561                td_element4.align = "center";
562                if (sort_type == 'SORTDATE')
563                {
564                        td_element4.onclick = function () { EsearchE.mount_result(data,'SORTDATE_REVERSE'); delete_border(border_id,false);};
565                        td_element4.innerHTML ="<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
566                }
567                else
568                {
569                        td_element4.onclick = function () { EsearchE.mount_result(data,'SORTDATE'); delete_border(border_id,false);};
570                        if  (sort_type == 'SORTDATE_REVERSE')
571                                td_element4.innerHTML ="<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
572                        else
573                                td_element4.innerHTML = get_lang("Date");
574                }
575                td_element5 = document.createElement("TD");
576                td_element5.setAttribute("width", "10%");
577                td_element5.align = "center";
578                if (sort_type == 'SORTSIZE')
579                {
580                        td_element5.onclick = function () { EsearchE.mount_result(data,'SORTSIZE_REVERSE'); delete_border(border_id,false);};
581                        td_element5.innerHTML ="<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
582                }
583                else
584                {
585                        td_element5.onclick = function () { EsearchE.mount_result(data,'SORTSIZE'); delete_border(border_id,false);};
586                        if  (sort_type == 'SORTSIZE_REVERSE')
587                                td_element5.innerHTML ="<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
588                        else
589                                td_element5.innerHTML = get_lang("Size");
590                }
591                tr_element.appendChild(td_element0);
592                tr_element.appendChild(td_element1);
593                tr_element.appendChild(td_element2);
594                tr_element.appendChild(td_element3);
595                tr_element.appendChild(td_element4);
596                tr_element.appendChild(td_element5);
597                tbody_element.appendChild(tr_element);
598                table_element.appendChild(tbody_element);
599                content_search.appendChild(table_element);
600                /*end of "put header"*/
601               
602                if (!expresso_offline) {
603/*                      var span_options = document.createElement("SPAN");
604                        if (span_options)
605                                span_options.innerHTML = '<span title="' + get_lang("Delete") + '" style="margin-top:3px;margin-left:8px" class="message_options" onclick="javascript:move_search_msgs(\'' + content_search.id + '\');">' + get_lang("Delete") + '</span> | ' +
606                                '<span title="' +
607                                get_lang("Move") +
608                                '" class="message_options" onclick=wfolders.makeWindowNew(\"' +
609                                content_search.id +
610                                '\",\"move_to\",true)>' +
611                                get_lang("Move") +
612                                '</span>';*/
613                        div_scroll_result.appendChild(table);
614                        content_search.appendChild(div_scroll_result);
615                        /*if (span_options)
616                                content_search.appendChild(span_options);*/
617                }
618                else {
619                        div_scroll_result.appendChild(table);
620                        content_search.appendChild(div_scroll_result);
621                }
622                resizeWindow();
623        }
624
625        searchE.prototype.open_msg = function(mailbox, uid_msg, subject){
626                var handler_get_msg = function(data){
627                        if(Element("border_id_" + uid_msg + "_r")){alert(get_lang("This message is already opened!"));}
628                        else{draw_message(data,create_border(url_decode(subject), uid_msg + "_r"));}
629                        //set_msg_as_read(msgs_to_set[i], false);
630                }
631                proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg);
632                /*var args   = "$this.imap_functions.get_info_msg";
633                var params = "msg_number=" + uid_msg + "&msg_folder=" + mailbox;
634                cExecute(args,handler_get_msg,params);*/
635
636        }
637
638        // Adiciona caixas postais na busca;
639        searchE.prototype.add_mailboxes = function(){
640                var sel = Element("sel_search_nm_box1");
641                if (!proxy_mensagens.is_local_folder(this.name_box_search)) {
642                        var name_box     = this.name_box_search.split(cyrus_delimiter);
643                        if(this.name_box_search == "")
644                                return false;
645                        var name_box_def = "";
646                        if(name_box.length != 1){
647                                name_box_def = name_box[(name_box.length-1)];
648                        }else{
649                                name_box_def = get_lang("Inbox");               
650                        }
651                }
652                else {
653                        if(this.name_box_search=='local_root')
654                                return;
655                        if(this.name_box_search=='local_Inbox')
656                                name_box_def = get_lang("Inbox");
657                        else
658                                name_box_def = this.name_box_search.substr(6);//Retira o 'local_'
659                }
660                if( sel.length > 0){
661                        for(var i=0; i < sel.options.length; i++){
662                                if(sel.options[i].value == this.name_box_search){
663                                        alert(get_lang('This message is already selected!'));
664                                        return false;
665                                }
666                        }
667                }
668                var opt = new Option(lang_folder(name_box_def),this.name_box_search,false,true);
669                sel[sel.length] = opt;
670        }
671        // Remove as caixas postais na busca;
672        searchE.prototype.del_mailboxes = function(){
673                var sel = Element("sel_search_nm_box1");
674                if(sel.length > 0){
675                        for(var i=0; i < sel.options.length; i++){
676                                if(sel.options[i].selected == true){
677                                        sel.options[i] = null;
678                                        i--;
679                                }
680                        }
681                }
682       
683        }
684        // todas as caixas
685        searchE.prototype.all_mailboxes = function(){
686                var value = Element("check_all_msg").checked;
687                var cont = parseInt(0);
688                if(value){
689                        if(EsearchE.all_boxes.length > 0){
690                                EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length));                       
691                        }
692                        for(var i=0; i < folders.length; i++){
693                                EsearchE.all_boxes[cont] = folders[i].folder_id;
694                                cont++;
695                        }
696                }else{
697                        EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length));
698                }
699        }
700
701        // Search;
702        searchE.prototype.func_search = function(value){
703                var fields = "##";
704                        // Verifica se os campos estão preenchidos;
705                        if(trim(Element("txt_ass").value) != ""){
706                                fields += "SUBJECT " +  "<=>" +url_encode(Element("txt_ass").value) + "##";
707                        }
708                        if(trim(Element("txt_body").value) != ""){
709                                fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##";
710                        }
711                        if(trim(Element("txt_de").value) != ""){
712                                fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##";
713                        }
714                        if(trim(Element("txt_para").value) != ""){
715                                fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##";
716                        }
717                        if(trim(Element("txt_cc").value) != ""){
718                                fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##";
719                        }
720                        if(value) {
721                                fields = "##ALL " +  "<=>" +url_encode(value) + "##";
722                        }
723
724                if(fields == "##"){
725                        alert(get_lang("Define some search parameters!"));
726                        return false;
727                }
728                var local_folders = new Array();
729                var temp;
730               
731                if(Element("check_all_msg").checked){
732                        this.all_mailboxes();
733                        var nm_box = new Array;
734                        for(var i=0; i < EsearchE.all_boxes.length; i++){
735                                nm_box[i] = EsearchE.all_boxes[i] + fields;
736                        }
737                        if (preferences.use_local_messages == 1) {
738                                temp = expresso_local_messages.list_local_folders();
739                                for (var x in temp) {
740                                        local_folders.push(temp[x][0]);
741                                }
742                        }
743                }else{
744                        var nm_box = new Array;
745                        var sel_combo = Element("sel_search_nm_box1");
746                        if( sel_combo.options.length <= 0){
747                                alert(get_lang("Define the boxes to search!"));
748                                return false;
749                        }
750                       
751                        for(var i=0; i < sel_combo.options.length; i++){
752                                sel_combo.options[i].selected = true;
753                        }
754                        for(var i=0; i < sel_combo.options.length; i++){
755                                if(sel_combo.options[i].selected == true){
756                                        if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value))
757                                                nm_box[nm_box.length] = sel_combo.options[i].value + fields;
758                                        else
759                                                local_folders.push(sel_combo.options[i].value.substr(6));
760                                }
761                        }
762                }
763                var handler = function(data){
764                        var tmp;
765                        var countTmp= new Array();
766                        if (local_folders.length > 0) {
767                                tmp = expresso_local_messages.search(local_folders, fields);
768                                if (tmp!=false) {
769                                        var tmp2 = tmp.substr(2, data.length - 4);
770                                        countTmp = tmp.split('####');
771                                }
772                        }
773                        if((data == "none") && (countTmp.length==0)){alert(get_lang("None result was found."));}
774                        else if(countTmp.length > 50){alert(get_lang("More than %1 results. Please, try to refine your search.",50));}
775                        else if(data == "many results"){alert(get_lang("More than %1 results. Please, try to refine your search.",50));}
776                        else{EsearchE.mount_result((data=='none')?tmp:(countTmp.length==0)?data:data+tmp);}
777                }
778                var args   = "$this.imap_functions.search_msg";
779                var params = "condition=" + nm_box;
780                if(expresso_offline)
781                        handler('none');
782                else
783                        cExecute(args,handler,params);
784        }
785        // clean;
786        searchE.prototype.func_clean = function(){
787                // Limpa os campos;
788                for(var i=0; i < this.fields.length; i++){
789                        if(Element("txt" + this.fields[i]) != null){Element("txt" + this.fields[i]).value = "";}
790                }
791            if(Element("check_all_msg") != null){Element("check_all_msg").checked = false;}
792
793            EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length));
794                EsearchE.del_mailboxes();
795        }
796
797        // close
798        searchE.prototype.func_close = function(type){
799                var _this = this;
800                _this.name_box_search = "";
801                EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length));
802                _this.type = type;
803                _this.searchW['window_search'].close();
804        }
805        // Monta a janela em tela;
806        searchE.prototype.showWindow = function(div){
807                if(!this.searchW[div.id]) {
808                        div.style.width = "660px";
809                        div.style.height = "255px";
810                        div.style.visibility = "hidden";
811                        div.style.position = "absolute";
812                        div.style.zIndex = "10003";
813                        var title = ":: "+ get_lang("Search")+" ::";
814                        var wHeight = div.offsetHeight + "px";
815                        var wWidth =  div.offsetWidth   + "px";
816
817                        win = new dJSWin({
818                                id: 'ccList'+div.id,
819                                content_id: div.id,
820                                width: wWidth,
821                                height: wHeight,
822                                title_color: '#3978d6',
823                                bg_color: '#eee',
824                                title: title,
825                                title_text_color: 'white',
826                                button_y_img: '../phpgwapi/images/win_min.gif',
827                                button_x_img: '../phpgwapi/images/winclose.gif',
828                                border: true });
829                        this.searchW[div.id] = win;
830                        win.draw();
831                }else{
832                        var _this = this;
833                        win = this.searchW[div.id];
834                        if((_this.type == "close" && win.state == 0) || win.state == 2){EsearchE.func_clean();}
835                        win.draw();
836                }
837                win.open();     
838        }
839       
840        searchE.prototype.aux_local_folder_display = function(folder) {
841                if(!expresso_offline)
842                        return "(Local) " + lang_folder(folder.substr(6));
843                else
844                        return lang_folder(folder.substr(6));
845        }
846       
847// Cria o objeto
848        var EsearchE;
849        EsearchE = new searchE();
Note: See TracBrowser for help on using the repository browser.