1 | /**************************************************************************\ |
---|
2 | Início |
---|
3 | \**************************************************************************/ |
---|
4 | function searchE() |
---|
5 | { |
---|
6 | this.totalPages = 1; |
---|
7 | this.numPages = 5; |
---|
8 | this.lastPage = 0; |
---|
9 | this.searchW = []; |
---|
10 | this.condition = ""; |
---|
11 | this.sort_type = ""; |
---|
12 | //this.page = 0; |
---|
13 | this.name_box_search = ""; |
---|
14 | this.all_boxes = []; |
---|
15 | this.type = ""; |
---|
16 | this.txtfields = new Array("txt_ass","txt_de","txt_body","txt_para","txt_cc","txt_cco", "since_date", "before_date", "on_date"); |
---|
17 | this.selectFields = new Array("flagged", "seen", "answered", "recent"); |
---|
18 | } |
---|
19 | |
---|
20 | //Monta os forms dentro da janela; |
---|
21 | searchE.prototype.showForms = function(value) |
---|
22 | { |
---|
23 | // Principal |
---|
24 | if(!Element("window_search")) |
---|
25 | { |
---|
26 | var form_search = document.createElement("DIV"); |
---|
27 | form_search.style.visibility = 'hidden'; |
---|
28 | form_search.style.top = '0px'; |
---|
29 | form_search.style.left = '0px'; |
---|
30 | form_search.style.cursor = 'default'; |
---|
31 | form_search.id = "window_search"; |
---|
32 | document.body.appendChild(form_search); |
---|
33 | } |
---|
34 | $("#window_search").css("pointer", "default"); |
---|
35 | // Pesquisa |
---|
36 | if(!Element("div_form_search")) |
---|
37 | { |
---|
38 | var div_form_search = document.createElement("DIV"); |
---|
39 | div_form_search.id = "div_form_search"; |
---|
40 | div_form_search.style.position = "absolute"; |
---|
41 | div_form_search.style.left = "10px"; |
---|
42 | div_form_search.style.top = "10px"; |
---|
43 | div_form_search.style.borderStyle = "outset"; |
---|
44 | div_form_search.style.borderColor = "black"; |
---|
45 | div_form_search.style.borderWidth = "1px"; |
---|
46 | div_form_search.style.width = "784px"; |
---|
47 | div_form_search.style.height = "418px"; |
---|
48 | div_form_search.style.overflow = "hidden"; |
---|
49 | div_form_search.innerHTML = ""; |
---|
50 | var call_form_search = EsearchE.mount_form(); |
---|
51 | div_form_search.appendChild(call_form_search); |
---|
52 | form_search.appendChild(div_form_search); |
---|
53 | } |
---|
54 | |
---|
55 | if(!Element("div_button_search")){ |
---|
56 | var div_button_search = document.createElement("DIV"); |
---|
57 | div_button_search.id = "div_button_search"; |
---|
58 | div_button_search.style.position = "absolute"; |
---|
59 | div_button_search.style.marginLeft = "430px"; |
---|
60 | div_button_search.style.top = "223px"; |
---|
61 | div_button_search.style.width = "350px"; |
---|
62 | div_button_search.style.height = "25px"; |
---|
63 | div_button_search.innerHTML = "<table style='width: 100%;' border='0' cellpadding='0' cellspacing='0' align='center'>"+ |
---|
64 | "<tr>"+ |
---|
65 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Search') + " onclick='EsearchE.func_search()'></td>"+ |
---|
66 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Clean') + " onclick='EsearchE.func_clean()'></td>"+ |
---|
67 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Close') + " onclick='EsearchE.func_close(\"hidden\")'></td>"+ |
---|
68 | "</tr>"+ |
---|
69 | "</table>"; |
---|
70 | form_search.appendChild(div_button_search); |
---|
71 | } |
---|
72 | |
---|
73 | if(!Element("table_layer")){ |
---|
74 | var table_layer = ""; |
---|
75 | } |
---|
76 | |
---|
77 | if(value == "") |
---|
78 | EsearchE.showWindow(Element("window_search")); |
---|
79 | |
---|
80 | // Cria as caixas postais; |
---|
81 | EsearchE.mount_folders(); |
---|
82 | |
---|
83 | if(value) |
---|
84 | { |
---|
85 | Element("check_all_msg").checked = true; |
---|
86 | EsearchE.all_mailboxes(); |
---|
87 | EsearchE.func_search(value, null, 'SORTDATE_REVERSE'); |
---|
88 | } |
---|
89 | var dates = $("#since_date, #before_date").datepicker({ |
---|
90 | showOn: "button", |
---|
91 | buttonImage: "../phpgwapi/templates/default/images/datepopup.gif", |
---|
92 | buttonImageOnly: true, |
---|
93 | onSelect: function( selectedDate ) { |
---|
94 | var option = this.id == "since_date" ? "minDate" : "maxDate", |
---|
95 | instance = $( this ).data( "datepicker" ), |
---|
96 | date = $.datepicker.parseDate( |
---|
97 | instance.settings.dateFormat || |
---|
98 | $.datepicker._defaults.dateFormat, |
---|
99 | selectedDate, instance.settings ); |
---|
100 | dates.not( this ).datepicker( "option", option, date ); |
---|
101 | } |
---|
102 | }); |
---|
103 | $("#on_date").datepicker({ |
---|
104 | showOn: "button", |
---|
105 | buttonImage: "../phpgwapi/templates/default/images/datepopup.gif", |
---|
106 | buttonImageOnly: true |
---|
107 | }); |
---|
108 | } |
---|
109 | |
---|
110 | //Form |
---|
111 | searchE.prototype.mount_form = function(value) |
---|
112 | { |
---|
113 | var form_sch = document.createElement("FORM"); |
---|
114 | form_sch.id = "form_sch"; |
---|
115 | |
---|
116 | form_sch.innerHTML = '<fieldset style="width:400px; text-align:right; padding: 5px; position:absolute;">' |
---|
117 | + ' <legend>'+get_lang('Inform your search in the text fields')+'</legend>' |
---|
118 | + ' <label>'+get_lang("From")+':</label>' |
---|
119 | + ' <input style="margin-left: 6px;" type="text" id="txt_de" size="39">' |
---|
120 | + ' <br style="margin-bottom:15px"/>' |
---|
121 | + ' <label>'+get_lang('To')+':</label>' |
---|
122 | + ' <input style="margin-left: 6px;" type="text" id="txt_para" size="39">' |
---|
123 | + ' <br style="margin-bottom:15px"/>' |
---|
124 | + ' <label>'+get_lang('Cc')+':</label>' |
---|
125 | + ' <input style="margin-left: 6px;" type="text" id="txt_cc" size="39">' |
---|
126 | + ' <br style="margin-bottom:15px"/>' |
---|
127 | + ' <label>'+get_lang('Subject')+':</label>' |
---|
128 | + ' <input style="margin-left: 6px;" type="text" id="txt_ass" size="39">' |
---|
129 | + ' <br style="margin-bottom:15px"/>' |
---|
130 | + ' <label>'+get_lang('Message body')+':</label>' |
---|
131 | + ' <input style="margin-left: 6px;" type="text" id="txt_body" size="39">' |
---|
132 | |
---|
133 | + ' <br style="margin-bottom:30px"/>' |
---|
134 | + ' <label>'+get_lang("Since Date")+':</label>' |
---|
135 | + ' <input style="margin-left: 6px;" type="text" id="since_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
136 | //+ ' <img id="since_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
137 | + ' <label style="margin-left: 20px;">'+get_lang('Before Date')+':</label>' |
---|
138 | + ' <input style="margin-left: 6px;" type="text" id="before_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
139 | //+ ' <img id="before_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
140 | + ' <br style="margin-bottom:15px"/>' |
---|
141 | |
---|
142 | + ' <label>'+get_lang('On Date')+':</label>' |
---|
143 | + ' <input style="margin-left: 6px;" type="text" id="on_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
144 | //+ ' <img style="margin-right: -8px" id="on_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/><span> </span>' |
---|
145 | + ' <br style="margin-bottom:30px"/>' |
---|
146 | |
---|
147 | + ' <label>'+get_lang('Flags')+':</label>' |
---|
148 | + ' <select style="width:15em; margin-left: 6px" name="flagged" id="flagged">' |
---|
149 | + ' <option value=""/>' |
---|
150 | + ' <option value="FLAGGED">'+ get_lang("Flagged") +'</option>' |
---|
151 | + ' <option value="UNFLAGGED">'+ get_lang("Unflagged") +'</option>' |
---|
152 | + ' </select>' |
---|
153 | + ' <br style="margin-bottom:15px"/>' |
---|
154 | + ' <select style="width:15em;" name="seen" id="seen">' |
---|
155 | + ' <option value=""/>' |
---|
156 | + ' <option value="SEEN">'+ get_lang("Seen") +'</option>' |
---|
157 | + ' <option value="UNSEEN">'+ get_lang("Unseen") +'</option>' |
---|
158 | + ' </select>' |
---|
159 | + ' <br style="margin-bottom:15px"/>' |
---|
160 | + ' <select style="width:15em;" name="answered" id="answered">' |
---|
161 | + ' <option value=""/>' |
---|
162 | + ' <option value="ANSWERED">'+ get_lang('Answered/Forwarded') +'</option>' |
---|
163 | + ' <option value="UNANSWERED">'+ get_lang('Unanswered/Unforwarded') +'</option>' |
---|
164 | + ' </select>' |
---|
165 | + ' <br style="margin-bottom:15px"/>' |
---|
166 | + ' <select style="width:15em;visibility:hidden;" name="recent" id="recent">' |
---|
167 | + ' <option value=""/>' |
---|
168 | + ' <option value="RECENT">'+ get_lang('Recent') +'</option>' |
---|
169 | + ' <option value="OLD">'+ get_lang('Old') +'</option>' |
---|
170 | + ' </select>' |
---|
171 | |
---|
172 | + ' <br style="margin-bottom:60px"/>' |
---|
173 | + '</fieldset>' |
---|
174 | + '<fieldset style="width:350px; padding: 5px; position:absolute; margin-left: 414px">' |
---|
175 | + ' <legend>'+get_lang('Search the messages in these folders')+'</legend>' |
---|
176 | + ' <div id="folders" style="width:160px; height:150px;float:left;margin-bottom:10px;"></div>' |
---|
177 | + ' <div style="float:left;height:100px;padding-top:50px;margin: 0 3px;">' |
---|
178 | + ' <input type="button" id="incluir" name="incluir" value=">>" onclick="EsearchE.add_mailboxes()">' |
---|
179 | + ' <br style="margin-bottom:15px">' |
---|
180 | + ' <input type="button" id="excluir" name="excluir" value="<<" onclick="EsearchE.del_mailboxes()">' |
---|
181 | + ' </div>' |
---|
182 | + ' <div style="float:left;">' |
---|
183 | + ' <select multiple id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:140px;height:150px;"></select>' |
---|
184 | + ' </div>' |
---|
185 | + ' <br clear="both">' |
---|
186 | + ' <input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()">' |
---|
187 | + ' <b>'+get_lang('In all the folders')+'</b>' |
---|
188 | + '</fieldset>'; |
---|
189 | |
---|
190 | return form_sch; |
---|
191 | } |
---|
192 | |
---|
193 | // Pastas; |
---|
194 | searchE.prototype.mount_folders = function() |
---|
195 | { |
---|
196 | connector.loadScript("TreeS"); |
---|
197 | |
---|
198 | if( Element("div_folders_search") == null) |
---|
199 | { |
---|
200 | var div_folders = document.createElement("DIV"); |
---|
201 | div_folders.id = "div_folders_search"; |
---|
202 | div_folders.style.width = "155px"; |
---|
203 | div_folders.style.height = "152px"; |
---|
204 | div_folders.style.borderStyle = "outset"; |
---|
205 | div_folders.style.borderColor = "black"; |
---|
206 | div_folders.style.borderWidth = "1px"; |
---|
207 | div_folders.style.background = "#F7F7F7"; |
---|
208 | div_folders.style.overflow = "auto"; |
---|
209 | div_folders.innerHTML = ""; |
---|
210 | var dest_div = Element("folders"); |
---|
211 | dest_div.appendChild(div_folders); |
---|
212 | } |
---|
213 | ttree.make_tree($("#div_folders_search")[0],"_folders_tree_search","","","",""); |
---|
214 | } |
---|
215 | |
---|
216 | function openpage(data) |
---|
217 | { |
---|
218 | var _data = [3]; |
---|
219 | var _gears = []; |
---|
220 | var local_folders = []; |
---|
221 | |
---|
222 | // Gears - local |
---|
223 | if ( preferences.use_local_messages == 1 ) |
---|
224 | { |
---|
225 | temp = expresso_local_messages.list_local_folders(); |
---|
226 | for (var x in temp) |
---|
227 | { |
---|
228 | local_folders.push(temp[x][0]); |
---|
229 | } |
---|
230 | } |
---|
231 | |
---|
232 | if ( local_folders.length > 0 ) |
---|
233 | _gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() ); |
---|
234 | |
---|
235 | _data['data'] = data['data']; |
---|
236 | _data['num_msgs'] = data['num_msgs']; |
---|
237 | _data['gears_num_msgs'] = _gears.length; |
---|
238 | |
---|
239 | delete_border( data['currentTab'], false); |
---|
240 | |
---|
241 | EsearchE.mount_result(_data); |
---|
242 | } |
---|
243 | |
---|
244 | searchE.prototype.show_paging = function(size) |
---|
245 | { |
---|
246 | var span_pg = Element("span_paging"+currentTab); |
---|
247 | |
---|
248 | if( span_pg == null ) |
---|
249 | { |
---|
250 | span_pg = document.createElement('span'); |
---|
251 | span_pg.id = "span_paging"+currentTab; |
---|
252 | } |
---|
253 | else |
---|
254 | span_pg.innerHTML = ""; |
---|
255 | |
---|
256 | if(size > parseInt(preferences.max_email_per_page)) { |
---|
257 | this.totalPages = Math.ceil(size/preferences.max_email_per_page); |
---|
258 | if((size/preferences.max_email_per_page) > this.totalPages) |
---|
259 | this.totalPages++; |
---|
260 | } |
---|
261 | |
---|
262 | if(this.page != 0 && this.page != null) { |
---|
263 | _link = document.createElement("A"); |
---|
264 | if( this.value ) |
---|
265 | _link.href = 'javascript:EsearchE.quickSearchMail( false, '+0+', false, "'+currentTab+'" )'; |
---|
266 | else{ |
---|
267 | _link.href = 'javascript:EsearchE.page=0;'; |
---|
268 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page=0¤t_tab='+currentTab+'");'; |
---|
269 | } |
---|
270 | } |
---|
271 | else { |
---|
272 | _link = document.createElement("SPAN"); |
---|
273 | } |
---|
274 | span_pg.appendChild(_link); |
---|
275 | |
---|
276 | _link.innerHTML = "<<"; |
---|
277 | _link.title = get_lang("First"); |
---|
278 | span_pg.innerHTML += " "; |
---|
279 | |
---|
280 | if(this.page == this.lastPage + (this.numPages)) |
---|
281 | { |
---|
282 | this.lastPage = this.page - 1; |
---|
283 | } |
---|
284 | else if((this.lastPage != 0 && this.lastPage == this.page) || this.page == (this.totalPages-1)) |
---|
285 | { |
---|
286 | this.lastPage = this.page - (this.numPages - 1); |
---|
287 | } |
---|
288 | else if(this.page == 0) |
---|
289 | { |
---|
290 | this.lastPage = 0; |
---|
291 | } |
---|
292 | |
---|
293 | if(this.lastPage < 0) |
---|
294 | this.lastPage = 0; |
---|
295 | else if(this.lastPage > 0 && (this.lastPage > (this.totalPages -(this.numPages - 1)))) |
---|
296 | this.lastPage = this.totalPages -(this.numPages); |
---|
297 | |
---|
298 | var hasMarked = false; |
---|
299 | if(this.page == null){ |
---|
300 | this.page = 0; |
---|
301 | } |
---|
302 | for(i = this.lastPage; i <= this.totalPages; i++) |
---|
303 | { |
---|
304 | if( ( i * preferences.max_email_per_page ) > size) |
---|
305 | { |
---|
306 | break; |
---|
307 | } |
---|
308 | |
---|
309 | if( this.page == i || (i == this.totalPages && !hasMarked) ) |
---|
310 | { |
---|
311 | var _link = document.createElement('span'); |
---|
312 | _link.setAttribute("style", "font-weight:bold; color:red") |
---|
313 | _link.innerHTML = ( this.page + 1 ) + " "; |
---|
314 | } |
---|
315 | else |
---|
316 | { |
---|
317 | var _page = i; |
---|
318 | var _link = document.createElement('A'); |
---|
319 | _link.innerHTML = ( _page + 1 ) + " "; |
---|
320 | if( this.value ) |
---|
321 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+i+', false, "'+currentTab+'" )'; |
---|
322 | else{ |
---|
323 | _link.href = 'javascript:EsearchE.page='+i+';'; |
---|
324 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+_page+'¤t_tab='+currentTab+'");'; |
---|
325 | } |
---|
326 | } |
---|
327 | _link.innerHTML = " ... "; |
---|
328 | if(i == (this.lastPage + this.numPages)) |
---|
329 | { |
---|
330 | span_pg.appendChild( _link ); |
---|
331 | break; |
---|
332 | } |
---|
333 | else if(this.lastPage == 0 || i != this.lastPage) |
---|
334 | { |
---|
335 | _link.innerHTML = " "+( i + 1 )+" "; |
---|
336 | } |
---|
337 | //span_pg.innerHTML += " "; |
---|
338 | |
---|
339 | span_pg.appendChild( _link ); |
---|
340 | } |
---|
341 | |
---|
342 | if(this.page != (this.totalPages - 1)) { |
---|
343 | _link = document.createElement("A"); |
---|
344 | if( this.value ) |
---|
345 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+(this.totalPages-1)+', false, "'+currentTab+'" )'; |
---|
346 | else{ |
---|
347 | _link.href = 'javascript:EsearchE.page='+(this.totalPages-1)+';'; |
---|
348 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+(this.totalPages-1)+'¤t_tab='+currentTab+'");'; |
---|
349 | } |
---|
350 | } |
---|
351 | else { |
---|
352 | _link = document.createElement("SPAN"); |
---|
353 | } |
---|
354 | |
---|
355 | span_pg.innerHTML += " "; |
---|
356 | span_pg.appendChild(_link); |
---|
357 | |
---|
358 | _link.title = get_lang("Last"); |
---|
359 | _link.innerHTML += ">>"; |
---|
360 | |
---|
361 | Element("div_menu_c3").appendChild(span_pg); |
---|
362 | } |
---|
363 | |
---|
364 | searchE.prototype.searchFor = function( borderID, sortType ) |
---|
365 | { |
---|
366 | var border_id = borderID; |
---|
367 | var sort_type = sortType; |
---|
368 | var is_local = border_id.match('.*_local_.*'); |
---|
369 | if(!is_local) |
---|
370 | if( this.value ) |
---|
371 | return this.quickSearchMail( document.getElementsByName(currentTab)[0].value, false, sortType, border_id ); |
---|
372 | |
---|
373 | var args = "$this.imap_functions.search_msg"; |
---|
374 | var params = "condition="+EsearchE.condition+"&page="+EsearchE.page+"&sort_type="+sort_type; |
---|
375 | |
---|
376 | var handler = function( data ) |
---|
377 | { |
---|
378 | var allMsg = [3]; |
---|
379 | var gears = []; |
---|
380 | var local_folders = []; |
---|
381 | |
---|
382 | if ( preferences.use_local_messages == 1 && is_local) |
---|
383 | { |
---|
384 | temp = expresso_local_messages.list_local_folders(); |
---|
385 | |
---|
386 | for (var x in temp) |
---|
387 | { |
---|
388 | local_folders.push( temp[x][0] ); |
---|
389 | } |
---|
390 | |
---|
391 | |
---|
392 | if ( local_folders.length > 0 ){ |
---|
393 | var currentSearch = document.getElementsByName(currentTab); |
---|
394 | expresso_local_messages.setSortType(sortType); |
---|
395 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##" ); |
---|
396 | } |
---|
397 | } |
---|
398 | if (!is_local) |
---|
399 | { |
---|
400 | if( data['num_msgs']) |
---|
401 | { |
---|
402 | allMsg['data'] = data['data']; |
---|
403 | allMsg['num_msgs'] = data['num_msgs']; |
---|
404 | |
---|
405 | } |
---|
406 | } |
---|
407 | |
---|
408 | if (gears.length > 0) |
---|
409 | { |
---|
410 | allMsg['data_gears'] = gears; |
---|
411 | } |
---|
412 | |
---|
413 | var currentSearch = document.getElementsByName(currentTab)[0].value; |
---|
414 | |
---|
415 | delete_border( border_id, false ); |
---|
416 | |
---|
417 | EsearchE.mount_result( allMsg , sort_type, null, null, null, currentSearch ); |
---|
418 | }; |
---|
419 | |
---|
420 | if (is_local) |
---|
421 | { |
---|
422 | eval("handler('none')"); |
---|
423 | } |
---|
424 | else |
---|
425 | { |
---|
426 | cExecute(args,handler,params); |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | searchE.prototype.viewLocalMessage = function() |
---|
431 | { |
---|
432 | var data = [2]; |
---|
433 | var gears = []; |
---|
434 | var local_folders = []; |
---|
435 | |
---|
436 | // Gears - local |
---|
437 | if ( preferences.use_local_messages == 1 ) |
---|
438 | { |
---|
439 | temp = expresso_local_messages.list_local_folders(); |
---|
440 | |
---|
441 | for (var x in temp) |
---|
442 | { |
---|
443 | local_folders.push( temp[x][0] ); |
---|
444 | } |
---|
445 | |
---|
446 | if ( local_folders.length > 0 ){ |
---|
447 | var currentSearch = document.getElementsByName(currentTab); |
---|
448 | if(currentSearch[0].value != ''){ |
---|
449 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##"); |
---|
450 | }else{ |
---|
451 | if(openTab.condition[currentTab]){ |
---|
452 | var condit = openTab.condition[currentTab][0].split(','); |
---|
453 | var filter = condit[0].split('##'); |
---|
454 | gears = expresso_local_messages.search( local_folders, '##'+filter[1]+'##'); |
---|
455 | |
---|
456 | } |
---|
457 | |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | data['data_gears'] = gears; |
---|
462 | data['num_msgs'] = gears.length; |
---|
463 | |
---|
464 | if(data['num_msgs'] != undefined) |
---|
465 | write_msg( data['num_msgs'] + " " + get_lang("results found") ); |
---|
466 | |
---|
467 | EsearchE.mount_result( data, 'SORTDATE' ); |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | searchE.prototype.make_tr_message = function(aux,border_id,i) { |
---|
472 | var tr = document.createElement("TR"); |
---|
473 | if(typeof(preferences.line_height) != 'undefined') |
---|
474 | tr.style.height = preferences.line_height; |
---|
475 | |
---|
476 | var mailbox = aux.boxname; |
---|
477 | var uid_msg = aux.uid; |
---|
478 | var subject = aux.subject; |
---|
479 | |
---|
480 | tr.id = uid_msg+"_s"+numBox; |
---|
481 | |
---|
482 | // Keep the two lines together please |
---|
483 | tr.setAttribute('name',mailbox); |
---|
484 | tr.name = mailbox; |
---|
485 | |
---|
486 | if ( aux.flag.match("U") ) |
---|
487 | add_className(tr,'tr_msg_unread'); |
---|
488 | |
---|
489 | add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read'); |
---|
490 | |
---|
491 | var _onclick = function() |
---|
492 | { |
---|
493 | proxy_mensagens.get_msg(this.parentNode.id,url_encode(this.parentNode.getAttribute('name')),false,show_msg); |
---|
494 | }; |
---|
495 | |
---|
496 | for(var j=0 ; j <= 10 ; j++) |
---|
497 | { |
---|
498 | var td = document.createElement("TD"); |
---|
499 | add_className(td, 'td_msg'); |
---|
500 | if (j == 0) |
---|
501 | { |
---|
502 | td.setAttribute("width", colSizes[1][0]); |
---|
503 | var chk_onclick; |
---|
504 | if (is_ie) |
---|
505 | chk_onclick = "changeBgColor(window.event,"+uid_msg+");"; |
---|
506 | else |
---|
507 | chk_onclick = "changeBgColor(event,"+uid_msg+");"; //'search_' + numBox |
---|
508 | var td1 = '<input type="checkbox" onclick="' + chk_onclick + '" id="' + border_id + '_check_box_message_'+uid_msg+'"></input>'; |
---|
509 | |
---|
510 | } |
---|
511 | if (j == 1) |
---|
512 | { |
---|
513 | td.setAttribute("width", colSizes[1][1]); |
---|
514 | if (aux.flag.match('T')) |
---|
515 | { |
---|
516 | attachNum = parseInt(aux.flag.substr(aux.flag.indexOf('T')+1)); |
---|
517 | td1 = "<img src='templates/"+template+"/images/clip.gif'>"; |
---|
518 | } |
---|
519 | else |
---|
520 | td1 = ''; |
---|
521 | } |
---|
522 | if (j == 2) |
---|
523 | { |
---|
524 | td.setAttribute("width", colSizes[1][2]); |
---|
525 | td.id = "td_message_answered_"+uid_msg; |
---|
526 | if (aux.flag.match('X')) |
---|
527 | td1 = '<img src=templates/'+template+'/images/forwarded.gif title="'+get_lang('Forwarded')+'">'; |
---|
528 | else |
---|
529 | if (aux.flag.match('A')) |
---|
530 | td1 = '<img src=templates/'+template+'/images/answered.gif title="'+get_lang('Answered')+'">'; |
---|
531 | else |
---|
532 | td1 = ''; |
---|
533 | } |
---|
534 | if (j == 3) |
---|
535 | { |
---|
536 | td.setAttribute("width", colSizes[1][3]); |
---|
537 | td.id = "td_message_important_"+uid_msg; |
---|
538 | if (aux.flag.match("F")) |
---|
539 | { |
---|
540 | add_className(tr, 'flagged_msg'); |
---|
541 | td1 = "<img src='templates/"+template+"/images/important.gif' title='"+get_lang('Flagged')+"'>"; |
---|
542 | } |
---|
543 | else |
---|
544 | td1 = ''; |
---|
545 | } |
---|
546 | if (j == 4) |
---|
547 | { |
---|
548 | td.setAttribute("width", colSizes[1][4]); |
---|
549 | td.id = "td_message_sent_"+uid_msg; |
---|
550 | td1 = ''; |
---|
551 | } |
---|
552 | |
---|
553 | if ( j == 5 ) |
---|
554 | { |
---|
555 | td.setAttribute("width", colSizes[1][5]); |
---|
556 | td.className = "td_resizable"; |
---|
557 | td.onclick = _onclick; |
---|
558 | var nm_box = aux.boxname.split(cyrus_delimiter); |
---|
559 | var td1 = nm_box.pop(); |
---|
560 | td.setAttribute("NoWrap","true"); |
---|
561 | td.style.overflow = "hidden"; |
---|
562 | td.style.color = "#42795b"; |
---|
563 | td.style.fontWeight = "bold"; |
---|
564 | |
---|
565 | var td1 = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1); |
---|
566 | |
---|
567 | td1 = translateFolder(td1); |
---|
568 | |
---|
569 | |
---|
570 | if( proxy_mensagens.is_local_folder(td1)) |
---|
571 | { |
---|
572 | var td1 = this.aux_local_folder_display(td1); |
---|
573 | } |
---|
574 | } |
---|
575 | |
---|
576 | if( j == 6 ) |
---|
577 | { |
---|
578 | if ( aux.from.name !== null && aux.from.name.length > 29) |
---|
579 | aux.from.name = aux.from.name.substr(0,29) + "..."; |
---|
580 | |
---|
581 | td.setAttribute("width", colSizes[1][6]); |
---|
582 | td.className = "td_resizable"; |
---|
583 | td.onclick = _onclick; |
---|
584 | td.setAttribute("NoWrap","true"); |
---|
585 | td.style.overflow = "hidden"; |
---|
586 | |
---|
587 | var td1 = '<div style="width:100%;overflow:hidden">'+aux.from.name+"</div>"; |
---|
588 | } |
---|
589 | |
---|
590 | if( j == 7 ) |
---|
591 | { |
---|
592 | var subject_encode = url_encode(subject); |
---|
593 | |
---|
594 | if (! subject_encode) |
---|
595 | aux.subject = get_lang("no subject") + "..."; |
---|
596 | if (aux.subject.length > 70) |
---|
597 | aux.subject = aux.subject.substr(0,70) + "..."; |
---|
598 | |
---|
599 | td.setAttribute("width", colSizes[1][7]); |
---|
600 | td.className = "td_resizable"; |
---|
601 | td.onclick = _onclick; |
---|
602 | td.setAttribute("NoWrap","true"); |
---|
603 | td.style.overflow = "hidden"; |
---|
604 | |
---|
605 | var td1 = aux.subject; |
---|
606 | } |
---|
607 | |
---|
608 | if( j == 8 ) |
---|
609 | { |
---|
610 | td.setAttribute("width", colSizes[1][8]); |
---|
611 | td.className = "td_resizable"; |
---|
612 | td.align = "center"; |
---|
613 | td.onclick = _onclick; |
---|
614 | |
---|
615 | if( validate_date( aux.udate ) ) |
---|
616 | { |
---|
617 | var td1 = aux.udate; |
---|
618 | } |
---|
619 | else |
---|
620 | { |
---|
621 | var dt = new Date( aux.udate * 1000 ); |
---|
622 | var td1 = dt.getDate() + "/"; |
---|
623 | |
---|
624 | if( !( dt.getMonth() + 1 ).toString().match(/\d{2}/) ) |
---|
625 | td1 += "0"+( dt.getMonth() + 1 ) + "/"; |
---|
626 | else |
---|
627 | td1 += ( dt.getMonth() + 1 ) + "/"; |
---|
628 | |
---|
629 | td1 += dt.getFullYear(); |
---|
630 | } |
---|
631 | } |
---|
632 | |
---|
633 | if( j == 9 ) |
---|
634 | { |
---|
635 | td.setAttribute("width", "9.4%");//alinhamento dos campos data e tamanho |
---|
636 | td.className = "td_resizable"; |
---|
637 | td.align = "center"; |
---|
638 | td.onclick = _onclick; |
---|
639 | var td1 = borkb(aux.size); |
---|
640 | } |
---|
641 | |
---|
642 | if( j == 10 ) |
---|
643 | { |
---|
644 | if (aux.flag.match("U")) |
---|
645 | add_className(tr, 'tr_msg_unread'); |
---|
646 | if (aux.flag.match("F")) |
---|
647 | add_className(tr, 'flagged_msg'); |
---|
648 | var td1 = ''; |
---|
649 | } |
---|
650 | if (j<10) { |
---|
651 | td.innerHTML = td1; |
---|
652 | tr.appendChild(td); |
---|
653 | } |
---|
654 | } |
---|
655 | |
---|
656 | _dragArea.makeDragged(tr, uid_msg, subject, true, mailbox); |
---|
657 | |
---|
658 | return tr; |
---|
659 | } |
---|
660 | |
---|
661 | // Form resultado |
---|
662 | searchE.prototype.mount_result = function( Data, sort_type, keep_border, keep_filled, division, actualSearch ) |
---|
663 | { |
---|
664 | var data = ( Data['data'] ) ? Data['data'] : Data['data_gears']; |
---|
665 | |
---|
666 | if ( data == undefined ) |
---|
667 | return; |
---|
668 | |
---|
669 | var cont = parseInt(0); |
---|
670 | |
---|
671 | if ( typeof(sort_type) != 'undefined') |
---|
672 | this.sort_type = sort_type; |
---|
673 | else |
---|
674 | sort_type = this.sort_type; |
---|
675 | |
---|
676 | if ( keep_border ) { |
---|
677 | var border_id = currentTab; |
---|
678 | } |
---|
679 | else { |
---|
680 | if(isNaN(numBox)){ |
---|
681 | var aux = numBox.split("_"); |
---|
682 | numBox = parseInt(aux[0]) + 1; |
---|
683 | }else{ |
---|
684 | inc_abas_search++; |
---|
685 | numBox = inc_abas_search; |
---|
686 | } |
---|
687 | if( Data['data'] ) |
---|
688 | if(!actualSearch) |
---|
689 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox); |
---|
690 | else |
---|
691 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox, actualSearch); |
---|
692 | if( Data['data_gears']) |
---|
693 | if(!actualSearch) |
---|
694 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox); |
---|
695 | else |
---|
696 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox, actualSearch); |
---|
697 | } |
---|
698 | |
---|
699 | if (!border_id) |
---|
700 | return; |
---|
701 | |
---|
702 | currentTab = border_id; |
---|
703 | openTab.content_id[currentTab] = Element('content_id_search_' + numBox); |
---|
704 | openTab.type[currentTab] = 1; |
---|
705 | openTab.condition[currentTab] = this.condition; |
---|
706 | |
---|
707 | if ( keep_border ) { |
---|
708 | var content_search = Element('content_id_' + border_id); |
---|
709 | var div_scroll_result = Element("divScrollMain_"+numBox); |
---|
710 | |
---|
711 | content_search.removeChild(div_scroll_result); |
---|
712 | |
---|
713 | if( !keep_filled ) |
---|
714 | div_scroll_result = false; |
---|
715 | } |
---|
716 | |
---|
717 | var table = document.createElement("TABLE"); |
---|
718 | table.id = "table_resultsearch_" + numBox; |
---|
719 | table.frame = "void"; |
---|
720 | table.rules = "rows"; |
---|
721 | table.cellPadding = "0"; |
---|
722 | table.cellSpacing = "0"; |
---|
723 | table.className = "table_box"; |
---|
724 | |
---|
725 | var tbody = document.createElement("TBODY"); |
---|
726 | tbody.id = "tbody_box_" + numBox; |
---|
727 | |
---|
728 | for( var i=0; i < data.length; i++) |
---|
729 | { |
---|
730 | if(data[i] !== null){ |
---|
731 | var tr = EsearchE.make_tr_message(data[i],border_id,i); |
---|
732 | tbody.appendChild(tr); |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | //global_search++; //Tabs from search must not have the same id on its tr's // use numBox instead of this! |
---|
737 | |
---|
738 | table.appendChild(tbody); |
---|
739 | |
---|
740 | var colgr_element = buildColGroup(1); |
---|
741 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
742 | table.appendChild(colgr_element); |
---|
743 | |
---|
744 | var content_search = Element('content_id_' + border_id); |
---|
745 | |
---|
746 | if( !div_scroll_result ) |
---|
747 | { |
---|
748 | var div_scroll_result = document.createElement("DIV"); |
---|
749 | div_scroll_result.id = "divScrollMain_"+numBox; |
---|
750 | div_scroll_result.style.overflowY = "scroll"; |
---|
751 | div_scroll_result.style.overflowX = "hidden"; |
---|
752 | div_scroll_result.style.width ="100%"; |
---|
753 | |
---|
754 | if (is_mozilla){ |
---|
755 | div_scroll_result.style.overflow = "-moz-scrollbars-vertical"; |
---|
756 | div_scroll_result.style.width ="100%"; |
---|
757 | } |
---|
758 | } |
---|
759 | if( division ) |
---|
760 | { |
---|
761 | var _div = document.createElement("div"); |
---|
762 | _div.className = 'local-messages-search-warning'; |
---|
763 | _div.innerHTML = division; |
---|
764 | div_scroll_result.appendChild(_div); |
---|
765 | } |
---|
766 | |
---|
767 | if(is_ie) |
---|
768 | Element("border_table").width = "99.5%"; |
---|
769 | |
---|
770 | // Put header |
---|
771 | var table_element = document.createElement("TABLE"); |
---|
772 | var tbody_element = document.createElement("TBODY"); |
---|
773 | if (is_ie) |
---|
774 | { |
---|
775 | table_element.attachEvent("onmousemove",changeCursorState); |
---|
776 | table_element.attachEvent("onmousedown",startColResize); |
---|
777 | } |
---|
778 | else { |
---|
779 | table_element.addEventListener("mousemove",changeCursorState,false); |
---|
780 | table_element.addEventListener("mousedown",startColResize,false); |
---|
781 | } |
---|
782 | table_element.setAttribute("id", "table_message_header_box_"+numBox); |
---|
783 | table_element.className = "table_message_header_box"; |
---|
784 | if (!is_ie) |
---|
785 | table_element.style.width = "98.8%"; |
---|
786 | table_element.emptyBody = false; |
---|
787 | |
---|
788 | tr_element = document.createElement("TR"); |
---|
789 | tr_element.className = "message_header"; |
---|
790 | td_element0 = createTDElement(1,0); |
---|
791 | chk_box_element = document.createElement("INPUT"); |
---|
792 | if(border_id.indexOf('local') > 0) |
---|
793 | chk_box_element.id = "chk_box_select_all_messages_search_local"; |
---|
794 | else |
---|
795 | chk_box_element.id = "chk_box_select_all_messages_search"; |
---|
796 | chk_box_element.setAttribute("type", "checkbox"); |
---|
797 | chk_box_element.className = "checkbox"; |
---|
798 | chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);}; |
---|
799 | chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')}; |
---|
800 | chk_box_element.onkeydown = function (e) |
---|
801 | { |
---|
802 | if (is_ie) |
---|
803 | { |
---|
804 | if ((window.event.keyCode) == 46) |
---|
805 | delete_msgs(current_folder,'selected','null'); |
---|
806 | } |
---|
807 | else |
---|
808 | { |
---|
809 | if ((e.keyCode) == 46) |
---|
810 | delete_msgs(current_folder,'selected','null'); |
---|
811 | } |
---|
812 | }; |
---|
813 | |
---|
814 | td_element0.appendChild(chk_box_element); |
---|
815 | td_element01 = createTDElement(1,1); |
---|
816 | td_element02 = createTDElement(1,2); |
---|
817 | td_element03 = createTDElement(1,3); |
---|
818 | td_element04 = createTDElement(1,4); |
---|
819 | td_element1 = createTDElement(1,5,"th_resizable","left"); |
---|
820 | |
---|
821 | var arrow_ascendant = function(Text) |
---|
822 | { |
---|
823 | return "<b>" + Text + "</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
824 | } |
---|
825 | |
---|
826 | // Ordernar Pasta |
---|
827 | if ( sort_type == 'SORTBOX' /*|| sort_type == 'SORTBOX_REVERSE'*/ ) |
---|
828 | { |
---|
829 | if( Data['data'] ) |
---|
830 | { |
---|
831 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
832 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
833 | } |
---|
834 | else |
---|
835 | { |
---|
836 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
837 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
838 | } |
---|
839 | } |
---|
840 | else |
---|
841 | { |
---|
842 | if( Data['data'] ) |
---|
843 | { |
---|
844 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
845 | } |
---|
846 | else |
---|
847 | { |
---|
848 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
849 | } |
---|
850 | td_element1.innerHTML = ( sort_type == 'SORTBOX_REVERSE' ) ? arrow_ascendant(get_lang("Folder")) : get_lang("Folder"); |
---|
851 | } |
---|
852 | |
---|
853 | // Ordernar Quem |
---|
854 | td_element2 = createTDElement(1,6,"th_resizable","left"); |
---|
855 | |
---|
856 | if (sort_type == 'SORTFROM' || sort_type == 'SORTWHO' /*|| sort_type == 'SORTWHO_REVERSE' || sort_type == 'SORTFROM_REVERSE'*/ ) |
---|
857 | { |
---|
858 | if(Data['data']) |
---|
859 | { |
---|
860 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTFROM_REVERSE'); }; |
---|
861 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
862 | } |
---|
863 | else |
---|
864 | { |
---|
865 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO_REVERSE'); }; |
---|
866 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
867 | } |
---|
868 | } |
---|
869 | else |
---|
870 | { |
---|
871 | if( Data['data'] ) |
---|
872 | { |
---|
873 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
874 | } |
---|
875 | else |
---|
876 | { |
---|
877 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
878 | } |
---|
879 | td_element2.innerHTML = ( sort_type == 'SORTWHO_REVERSE' ) ? arrow_ascendant(get_lang("From")) : get_lang("From"); |
---|
880 | } |
---|
881 | |
---|
882 | // Ordernar Subject |
---|
883 | td_element3 = createTDElement(1,7,"th_resizable","left"); |
---|
884 | |
---|
885 | if (sort_type == 'SORTSUBJECT' /*|| sort_type == 'SORTSUBJECT_REVERSE'*/) |
---|
886 | { |
---|
887 | if( Data['data']) |
---|
888 | { |
---|
889 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
890 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
891 | } |
---|
892 | else |
---|
893 | { |
---|
894 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
895 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
896 | } |
---|
897 | } |
---|
898 | else |
---|
899 | { |
---|
900 | if( Data['data'] ) |
---|
901 | { |
---|
902 | td_element3.onclick = function(){ EsearchE.searchFor( border_id, 'SORTSUBJECT'); }; |
---|
903 | } |
---|
904 | else |
---|
905 | { |
---|
906 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT'); }; |
---|
907 | } |
---|
908 | td_element3.innerHTML = ( sort_type == 'SORTSUBJECT_REVERSE' ) ? arrow_ascendant(get_lang("subject")) : get_lang("subject"); |
---|
909 | } |
---|
910 | |
---|
911 | // Ordernar Data |
---|
912 | td_element4 = createTDElement(1,8,"th_resizable","center"); |
---|
913 | |
---|
914 | if ( sort_type == 'SORTDATE' /*|| sort_type == 'SORTDATE_REVERSE'*/ ) |
---|
915 | { |
---|
916 | if( Data['data'] ) |
---|
917 | { |
---|
918 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
919 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
920 | } |
---|
921 | else |
---|
922 | { |
---|
923 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
924 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
925 | } |
---|
926 | } |
---|
927 | else |
---|
928 | { |
---|
929 | if( Data['data'] ) |
---|
930 | { |
---|
931 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
932 | } |
---|
933 | else |
---|
934 | { |
---|
935 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
936 | } |
---|
937 | td_element4.innerHTML = ( sort_type == 'SORTDATE_REVERSE' ) ? arrow_ascendant(get_lang("Date")) : get_lang("Date"); |
---|
938 | } |
---|
939 | |
---|
940 | // Ordernar Tamanho |
---|
941 | td_element5 = createTDElement(1,9,"th_resizable","center"); |
---|
942 | |
---|
943 | if ( sort_type == 'SORTSIZE' /*|| sort_type == 'SORTSIZE_REVERSE'*/ ) |
---|
944 | { |
---|
945 | if( Data['data'] ) |
---|
946 | { |
---|
947 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
948 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
949 | } |
---|
950 | else |
---|
951 | { |
---|
952 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
953 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
954 | } |
---|
955 | } |
---|
956 | else |
---|
957 | { |
---|
958 | if( Data['data'] ) |
---|
959 | { |
---|
960 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
961 | } |
---|
962 | else |
---|
963 | { |
---|
964 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
965 | } |
---|
966 | td_element5.innerHTML = ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size"); |
---|
967 | } |
---|
968 | |
---|
969 | tr_element.appendChild(td_element0); |
---|
970 | tr_element.appendChild(td_element01); |
---|
971 | tr_element.appendChild(td_element02); |
---|
972 | tr_element.appendChild(td_element03); |
---|
973 | tr_element.appendChild(td_element04); |
---|
974 | tr_element.appendChild(td_element1); |
---|
975 | tr_element.appendChild(td_element2); |
---|
976 | tr_element.appendChild(td_element3); |
---|
977 | tr_element.appendChild(td_element4); |
---|
978 | tr_element.appendChild(td_element5); |
---|
979 | tbody_element.appendChild(tr_element); |
---|
980 | table_element.appendChild(tbody_element); |
---|
981 | |
---|
982 | var colgr_element = buildColGroup(1); |
---|
983 | colgr_element.setAttribute("id","colgroup_head_"+numBox); |
---|
984 | table_element.appendChild(colgr_element); |
---|
985 | |
---|
986 | if( parseInt( Data['gears_num_msgs'] ) > 0 && !keep_filled) |
---|
987 | { |
---|
988 | var messagesWarning = document.getElementById("local-messages-search-warning_"+border_id); |
---|
989 | if(!messagesWarning){ |
---|
990 | var _div_gears = document.createElement("div"); |
---|
991 | _div_gears.id = "local-messages-search-warning_"+border_id; |
---|
992 | _div_gears.onclick = function(){ EsearchE.viewLocalMessage(); }; |
---|
993 | _div_gears.className = 'local-messages-search-warning'; |
---|
994 | _div_gears.innerHTML = get_lang("The search has% 1 messages stored locally. Want to see them ? Click here.", Data['gears_num_msgs']); |
---|
995 | content_search.appendChild(_div_gears); |
---|
996 | } |
---|
997 | } |
---|
998 | |
---|
999 | var _divScroll = document.getElementById("divScrollHead_"+numBox); |
---|
1000 | |
---|
1001 | if( _divScroll ){ |
---|
1002 | content_search.removeChild(_divScroll); |
---|
1003 | _divScroll = false; |
---|
1004 | } |
---|
1005 | |
---|
1006 | _divScroll = document.createElement("DIV"); |
---|
1007 | _divScroll.id = "divScrollHead_"+numBox; |
---|
1008 | _divScroll.style.overflowY = "hidden"; |
---|
1009 | _divScroll.style.overflowX = "hidden"; |
---|
1010 | _divScroll.style.width ="100%"; |
---|
1011 | |
---|
1012 | if (is_mozilla){ |
---|
1013 | _divScroll.style.width ="99.3%"; |
---|
1014 | } |
---|
1015 | _divScroll.appendChild(table_element); |
---|
1016 | content_search.appendChild(_divScroll); |
---|
1017 | |
---|
1018 | /*end of "put header"*/ |
---|
1019 | if ( !expresso_offline ) |
---|
1020 | { |
---|
1021 | div_scroll_result.appendChild(table); |
---|
1022 | content_search.appendChild(div_scroll_result); |
---|
1023 | } |
---|
1024 | else |
---|
1025 | { |
---|
1026 | div_scroll_result.appendChild(table); |
---|
1027 | content_search.appendChild(div_scroll_result); |
---|
1028 | } |
---|
1029 | |
---|
1030 | resizeWindow(); |
---|
1031 | if(typeof(Data.data_gears)=="undefined") |
---|
1032 | EsearchE.show_paging( Data['num_msgs'] ); |
---|
1033 | } |
---|
1034 | |
---|
1035 | searchE.prototype.open_msg = function(mailbox, uid_msg, subject) |
---|
1036 | { |
---|
1037 | var handler_get_msg = function(data) |
---|
1038 | { |
---|
1039 | if( Element("border_id_" + uid_msg + "_r") ) |
---|
1040 | alert(get_lang("This message is already opened!")); |
---|
1041 | else |
---|
1042 | draw_message( data, create_border(url_decode(subject), uid_msg + "_r") ); |
---|
1043 | } |
---|
1044 | |
---|
1045 | proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg); |
---|
1046 | } |
---|
1047 | |
---|
1048 | // Adiciona caixas postais na busca; |
---|
1049 | searchE.prototype.add_mailboxes = function() |
---|
1050 | { |
---|
1051 | var sel = Element("sel_search_nm_box1"); |
---|
1052 | if (!proxy_mensagens.is_local_folder(this.name_box_search)) { |
---|
1053 | var name_box = this.name_box_search.split(cyrus_delimiter); |
---|
1054 | if(this.name_box_search == "") |
---|
1055 | return false; |
---|
1056 | var name_box_def = ""; |
---|
1057 | if(name_box.length != 1){ |
---|
1058 | name_box_def = name_box[(name_box.length-1)]; |
---|
1059 | }else{ |
---|
1060 | name_box_def = get_lang("Inbox"); |
---|
1061 | } |
---|
1062 | } |
---|
1063 | else { |
---|
1064 | if(this.name_box_search=='local_root') |
---|
1065 | return; |
---|
1066 | if(this.name_box_search=='local_Inbox') |
---|
1067 | name_box_def = get_lang("Inbox"); |
---|
1068 | else if(this.name_box_search.indexOf("/")!="-1") { |
---|
1069 | final_pos = this.name_box_search.lastIndexOf("/"); |
---|
1070 | name_box_def = this.name_box_search.substr(final_pos+1); |
---|
1071 | } |
---|
1072 | else |
---|
1073 | name_box_def = this.name_box_search.substr(6);//Retira o 'local_' |
---|
1074 | } |
---|
1075 | if( sel.length > 0){ |
---|
1076 | for(var i=0; i < sel.options.length; i++){ |
---|
1077 | if(sel.options[i].value == this.name_box_search){ |
---|
1078 | alert(get_lang('This message is already selected!')); |
---|
1079 | return false; |
---|
1080 | } |
---|
1081 | } |
---|
1082 | } |
---|
1083 | name_box_def = translateFolder(name_box_def); |
---|
1084 | var opt = new Option(lang_folder(name_box_def),this.name_box_search,false,true); |
---|
1085 | sel[sel.length] = opt; |
---|
1086 | } |
---|
1087 | |
---|
1088 | // Remove as caixas postais na busca; |
---|
1089 | searchE.prototype.del_mailboxes = function() |
---|
1090 | { |
---|
1091 | var sel = Element("sel_search_nm_box1"); |
---|
1092 | if(sel.length > 0) |
---|
1093 | { |
---|
1094 | for(var i=0; i < sel.options.length; i++) |
---|
1095 | { |
---|
1096 | if(sel.options[i].selected == true) |
---|
1097 | { |
---|
1098 | sel.options[i] = null; |
---|
1099 | i--; |
---|
1100 | } |
---|
1101 | } |
---|
1102 | } |
---|
1103 | |
---|
1104 | } |
---|
1105 | |
---|
1106 | // todas as caixas |
---|
1107 | searchE.prototype.all_mailboxes = function() |
---|
1108 | { |
---|
1109 | var value = Element("check_all_msg").checked; |
---|
1110 | var cont = parseInt(0); |
---|
1111 | if(value) |
---|
1112 | { |
---|
1113 | if(EsearchE.all_boxes.length > 0) |
---|
1114 | { |
---|
1115 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1116 | } |
---|
1117 | for(var i=0; i < folders.length; i++) |
---|
1118 | { |
---|
1119 | EsearchE.all_boxes[cont++] = folders[i].folder_id; |
---|
1120 | } |
---|
1121 | } |
---|
1122 | else |
---|
1123 | { |
---|
1124 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1125 | } |
---|
1126 | } |
---|
1127 | |
---|
1128 | // Search; |
---|
1129 | searchE.prototype.func_search_complex = function() |
---|
1130 | { |
---|
1131 | var fields = "##"; |
---|
1132 | // Verifica se os campos estão preenchidos; |
---|
1133 | if(trim(Element("txt_ass").value) != ""){ |
---|
1134 | fields += "SUBJECT " + "<=>" +url_encode(Element("txt_ass").value) + "##"; |
---|
1135 | } |
---|
1136 | if(trim(Element("txt_body").value) != ""){ |
---|
1137 | fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##"; |
---|
1138 | } |
---|
1139 | if(trim(Element("txt_de").value) != ""){ |
---|
1140 | fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##"; |
---|
1141 | } |
---|
1142 | if(trim(Element("txt_para").value) != ""){ |
---|
1143 | fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##"; |
---|
1144 | } |
---|
1145 | if(trim(Element("txt_cc").value) != ""){ |
---|
1146 | fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##"; |
---|
1147 | } |
---|
1148 | if (trim(Element("since_date").value) != "") |
---|
1149 | { |
---|
1150 | if (validate_date(Element("since_date").value)) |
---|
1151 | { |
---|
1152 | fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##"; |
---|
1153 | } |
---|
1154 | else |
---|
1155 | { |
---|
1156 | alert(get_lang('Invalid date on field %1', get_lang('Since Date'))); |
---|
1157 | return false; |
---|
1158 | } |
---|
1159 | } |
---|
1160 | |
---|
1161 | if (trim(Element("before_date").value) != "") |
---|
1162 | { |
---|
1163 | if (validate_date(Element("before_date").value)) |
---|
1164 | { |
---|
1165 | fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##"; |
---|
1166 | } |
---|
1167 | else |
---|
1168 | { |
---|
1169 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
1170 | return false; |
---|
1171 | } |
---|
1172 | } |
---|
1173 | if ((trim(Element("since_date").value) != "") && (trim(Element("before_date").value) != "")){ |
---|
1174 | if(!(validate_date_order(trim(Element("since_date").value), trim(Element("before_date").value)))){ |
---|
1175 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
1176 | return false; |
---|
1177 | } |
---|
1178 | } |
---|
1179 | if(trim(Element("on_date").value) != "") |
---|
1180 | { |
---|
1181 | if (validate_date(Element("on_date").value)) |
---|
1182 | { |
---|
1183 | fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##"; |
---|
1184 | } |
---|
1185 | else |
---|
1186 | { |
---|
1187 | alert(get_lang('Invalid date on field %1', get_lang('On Date'))); |
---|
1188 | return false; |
---|
1189 | } |
---|
1190 | |
---|
1191 | } |
---|
1192 | |
---|
1193 | if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != "") |
---|
1194 | { |
---|
1195 | if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED") |
---|
1196 | { |
---|
1197 | fields += "FLAGGED##"; |
---|
1198 | } |
---|
1199 | else |
---|
1200 | { |
---|
1201 | fields += "UNFLAGGED##"; |
---|
1202 | } |
---|
1203 | } |
---|
1204 | |
---|
1205 | if(trim(Element("seen").options[Element("seen").selectedIndex].value) != "") |
---|
1206 | { |
---|
1207 | if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN") |
---|
1208 | { |
---|
1209 | fields += "SEEN##"; |
---|
1210 | } |
---|
1211 | else |
---|
1212 | { |
---|
1213 | fields += "UNSEEN##"; |
---|
1214 | } |
---|
1215 | } |
---|
1216 | |
---|
1217 | if(trim(Element("answered").options[Element("answered").selectedIndex].value) != "") |
---|
1218 | { |
---|
1219 | if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){ |
---|
1220 | fields += "ANSWERED##"; |
---|
1221 | } |
---|
1222 | else { |
---|
1223 | fields += "UNANSWERED##"; |
---|
1224 | } |
---|
1225 | } |
---|
1226 | |
---|
1227 | if(trim(Element("recent").options[Element("recent").selectedIndex].value) != "") |
---|
1228 | { |
---|
1229 | if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT") |
---|
1230 | { |
---|
1231 | fields += "RECENT##"; |
---|
1232 | } |
---|
1233 | else |
---|
1234 | { |
---|
1235 | fields += "OLD##"; |
---|
1236 | } |
---|
1237 | } |
---|
1238 | |
---|
1239 | if(fields == "##") |
---|
1240 | { |
---|
1241 | alert(get_lang("Define some search parameters!")); |
---|
1242 | return false; |
---|
1243 | } |
---|
1244 | |
---|
1245 | var local_folders = new Array(); |
---|
1246 | var temp; |
---|
1247 | |
---|
1248 | if( Element("check_all_msg").checked ) |
---|
1249 | { |
---|
1250 | this.all_mailboxes(); |
---|
1251 | var nm_box = new Array; |
---|
1252 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
1253 | { |
---|
1254 | nm_box[i] = EsearchE.all_boxes[i] + fields; |
---|
1255 | } |
---|
1256 | if (preferences.use_local_messages == 1) |
---|
1257 | { |
---|
1258 | temp = expresso_local_messages.list_local_folders(); |
---|
1259 | for (var x in temp) |
---|
1260 | { |
---|
1261 | local_folders.push(temp[x][0]); |
---|
1262 | } |
---|
1263 | } |
---|
1264 | } |
---|
1265 | else |
---|
1266 | { |
---|
1267 | var nm_box = new Array; |
---|
1268 | var sel_combo = Element("sel_search_nm_box1"); |
---|
1269 | |
---|
1270 | if( sel_combo.options.length <= 0) |
---|
1271 | { |
---|
1272 | alert(get_lang("Define the boxes to search!")); |
---|
1273 | return false; |
---|
1274 | } |
---|
1275 | |
---|
1276 | for(var i=0; i < sel_combo.options.length; i++) |
---|
1277 | { |
---|
1278 | sel_combo.options[i].selected = true; |
---|
1279 | } |
---|
1280 | |
---|
1281 | for(var i=0; i < sel_combo.options.length; i++) |
---|
1282 | { |
---|
1283 | if( sel_combo.options[i].selected == true ) |
---|
1284 | { |
---|
1285 | if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)) |
---|
1286 | nm_box[nm_box.length] = sel_combo.options[i].value + fields; |
---|
1287 | else |
---|
1288 | local_folders.push(sel_combo.options[i].value.substr(6)); |
---|
1289 | } |
---|
1290 | } |
---|
1291 | } |
---|
1292 | |
---|
1293 | var handler = function( data ) |
---|
1294 | { |
---|
1295 | var allMsg = [3]; |
---|
1296 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
1297 | var tmp = []; |
---|
1298 | |
---|
1299 | // Gears - local |
---|
1300 | if ( local_folders.length > 0 ){ |
---|
1301 | expresso_local_messages.setSortType('SORTDATE'); |
---|
1302 | tmp = expresso_local_messages.search( local_folders, fields ); |
---|
1303 | } |
---|
1304 | |
---|
1305 | if( data['num_msgs'] ) |
---|
1306 | { |
---|
1307 | allMsg['data'] = data['data']; |
---|
1308 | allMsg['num_msgs'] = data['num_msgs']; |
---|
1309 | } |
---|
1310 | |
---|
1311 | if( tmp.length > 0 ) |
---|
1312 | { |
---|
1313 | allMsg['gears_num_msgs'] = tmp.length ; |
---|
1314 | } |
---|
1315 | |
---|
1316 | if( ( data['num_msgs'] ) == 0 ) |
---|
1317 | { |
---|
1318 | alert( get_lang("None result was found.") ); |
---|
1319 | } |
---|
1320 | else |
---|
1321 | { |
---|
1322 | if( (tmp.length > 0) && (!data['num_msgs']) ) |
---|
1323 | { |
---|
1324 | EsearchE.viewLocalMessage(); |
---|
1325 | } |
---|
1326 | else |
---|
1327 | { |
---|
1328 | if(count > 0) |
---|
1329 | EsearchE.func_clean(); |
---|
1330 | write_msg( count + " " + get_lang("results found") ); |
---|
1331 | EsearchE.mount_result( allMsg, 'SORTDATE' ); |
---|
1332 | } |
---|
1333 | } |
---|
1334 | } |
---|
1335 | |
---|
1336 | this.condition = nm_box; |
---|
1337 | this.page = 0; |
---|
1338 | var args = "$this.imap_functions.search_msg"; |
---|
1339 | var params = "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE"; |
---|
1340 | |
---|
1341 | if( expresso_offline ) |
---|
1342 | handler('none'); |
---|
1343 | else |
---|
1344 | cExecute( args, handler, params); |
---|
1345 | } |
---|
1346 | |
---|
1347 | searchE.prototype.func_search = function(value, page, sort, border_id) |
---|
1348 | { |
---|
1349 | if( !value ) |
---|
1350 | this.func_search_complex(); |
---|
1351 | else |
---|
1352 | this.quickSearchMail( value, page, sort, border_id ); |
---|
1353 | } |
---|
1354 | |
---|
1355 | searchE.prototype.quickSearchMail = function(value, page, sort, border_id) |
---|
1356 | { |
---|
1357 | var local_folders = new Array(); |
---|
1358 | var temp; |
---|
1359 | var not_found_corrent_folder = true; |
---|
1360 | |
---|
1361 | // if( Element("check_all_msg").checked ) |
---|
1362 | // { |
---|
1363 | this.all_mailboxes(); |
---|
1364 | var nm_box = new Array; |
---|
1365 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
1366 | { |
---|
1367 | nm_box[i] = EsearchE.all_boxes[i]/* + fields*/; |
---|
1368 | } |
---|
1369 | if (preferences.use_local_messages == 1) |
---|
1370 | { |
---|
1371 | temp = expresso_local_messages.list_local_folders(); |
---|
1372 | for (var x in temp) |
---|
1373 | { |
---|
1374 | local_folders.push(temp[x][0]); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | this.sort = sort || this.sort || "SORTDATE"; |
---|
1378 | this.page = isNaN(page) ? ( value ? 0 : this.page ) : page; |
---|
1379 | this.value = value || this.value || false; |
---|
1380 | |
---|
1381 | if( !this.value ) |
---|
1382 | return alert( "Busca sem caracteres." ); |
---|
1383 | |
---|
1384 | var args = "$this.imap_functions.quickSearchMail"; |
---|
1385 | var params = { page: this.page, sort: this.sort, search: this.value }; |
---|
1386 | |
---|
1387 | var selection1 = [], selection2 = []; |
---|
1388 | |
---|
1389 | for( var i = 0; i < nm_box.length; i++ ) |
---|
1390 | if( nm_box[i] === current_folder ) |
---|
1391 | continue; |
---|
1392 | else if( /^user/.test(nm_box[i]) ) |
---|
1393 | selection2[selection2.length] = nm_box[i]; |
---|
1394 | else |
---|
1395 | selection1[selection1.length] = nm_box[i]; |
---|
1396 | |
---|
1397 | if( expresso_offline ) |
---|
1398 | handler('none'); |
---|
1399 | else |
---|
1400 | { |
---|
1401 | var url = [], labels = []; |
---|
1402 | |
---|
1403 | params['folder'] = current_folder; |
---|
1404 | url[0] = args + "&" + $.param( params ); |
---|
1405 | labels[0] = "mensagem na sua pasta atual"; |
---|
1406 | |
---|
1407 | if(selection1.length) |
---|
1408 | { |
---|
1409 | params['folder'] = selection1; |
---|
1410 | url[1] = args + "&" + $.param( params ); |
---|
1411 | labels[1] = "mensagens nas suas outras pastas"; |
---|
1412 | } |
---|
1413 | if(selection2.length) |
---|
1414 | { |
---|
1415 | params['folder'] = selection2; |
---|
1416 | url[2] = args + "&" + $.param( params ); |
---|
1417 | labels[2] = "mensagens nas suas pastas compartilhadas"; |
---|
1418 | } |
---|
1419 | var link = ' <a href="#" onclick="connector.cancelRequest(); clean_msg(); return false;">cancelar<a/>'; |
---|
1420 | |
---|
1421 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
1422 | |
---|
1423 | var keepFilled = false; |
---|
1424 | |
---|
1425 | var handler = function( data ) |
---|
1426 | { |
---|
1427 | data = $.parseJSON( Base64.decode(data) ); |
---|
1428 | |
---|
1429 | var allMsg = { |
---|
1430 | num_msgs: ( data['num_msgs'] || 0 ), |
---|
1431 | data: ( data['data'] || data['msgs'] || data ) |
---|
1432 | }; |
---|
1433 | |
---|
1434 | // Gears - local |
---|
1435 | if ( local_folders.length > 0 ){ |
---|
1436 | expresso_local_messages.setSortType('SORTDATE'); |
---|
1437 | var tmp = expresso_local_messages.search( local_folders, "##ALL <=>" + url_encode(value) + "##" ); |
---|
1438 | |
---|
1439 | if( tmp.length > 0 ) |
---|
1440 | if( !allMsg['num_msgs'] ){ |
---|
1441 | clean_msg(); |
---|
1442 | not_found_corrent_folder = false; |
---|
1443 | if(tmp.length) |
---|
1444 | allMsg['gears_num_msgs'] = tmp.length; |
---|
1445 | }else |
---|
1446 | allMsg['gears_num_msgs'] = tmp.length; |
---|
1447 | } |
---|
1448 | |
---|
1449 | if( !allMsg['num_msgs'] && !url.length && not_found_corrent_folder){ |
---|
1450 | clean_msg(); |
---|
1451 | //alert( get_lang("None result was found.") ); |
---|
1452 | return EsearchE.viewLocalMessage(); |
---|
1453 | } |
---|
1454 | |
---|
1455 | if( allMsg['num_msgs'] ) |
---|
1456 | EsearchE.total = allMsg['num_msgs'] = Math.max( (EsearchE.total || 0), allMsg['num_msgs'] ); |
---|
1457 | |
---|
1458 | EsearchE.mount_result( allMsg, EsearchE.sort, ( keepFilled || border_id === currentTab ), keepFilled, "Foram encontradas " + data['msgs'].length + " "+labels.shift()+"." ); |
---|
1459 | |
---|
1460 | keepFilled = true; |
---|
1461 | |
---|
1462 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
1463 | |
---|
1464 | if( url.length ) |
---|
1465 | cExecute( url.shift(), handler ); |
---|
1466 | else |
---|
1467 | clean_msg(); |
---|
1468 | } |
---|
1469 | |
---|
1470 | cExecute( url.shift(), handler ); |
---|
1471 | } |
---|
1472 | } |
---|
1473 | |
---|
1474 | // clean; |
---|
1475 | searchE.prototype.func_clean = function() |
---|
1476 | { |
---|
1477 | // Limpa os campos; |
---|
1478 | for( var i=0; i < this.txtfields.length; i++ ) |
---|
1479 | { |
---|
1480 | if( Element(this.txtfields[i]) != null ) |
---|
1481 | Element(this.txtfields[i]).value = ""; |
---|
1482 | } |
---|
1483 | |
---|
1484 | for(i = 0; i < this.selectFields.length; i++) |
---|
1485 | { |
---|
1486 | if (Element(this.selectFields[i])) |
---|
1487 | Element(this.selectFields[i]).selectedIndex = 0; |
---|
1488 | } |
---|
1489 | |
---|
1490 | if( Element("check_all_msg") != null ) |
---|
1491 | Element("check_all_msg").checked = false; |
---|
1492 | |
---|
1493 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1494 | EsearchE.del_mailboxes(); |
---|
1495 | $("#since_date, #before_date").datepicker("option", "minDate", ""); |
---|
1496 | $("#since_date, #before_date").datepicker("option", "maxDate", ""); |
---|
1497 | } |
---|
1498 | |
---|
1499 | // close |
---|
1500 | searchE.prototype.func_close = function(type) |
---|
1501 | { |
---|
1502 | var _this = this; |
---|
1503 | _this.name_box_search = ""; |
---|
1504 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1505 | _this.type = type; |
---|
1506 | _this.searchW['window_search'].close(); |
---|
1507 | $("#since_date, #before_date, #on_date").datepicker( "destroy" ); |
---|
1508 | } |
---|
1509 | // Monta a janela em tela; |
---|
1510 | searchE.prototype.showWindow = function(div) |
---|
1511 | { |
---|
1512 | if(!this.searchW[div.id]) |
---|
1513 | { |
---|
1514 | div.style.width = "804px"; |
---|
1515 | div.style.height = "440px"; |
---|
1516 | div.style.visibility = "hidden"; |
---|
1517 | div.style.position = "absolute"; |
---|
1518 | div.style.zIndex = "10"; |
---|
1519 | var title = ":: "+ get_lang("Search")+" ::"; |
---|
1520 | var wHeight = div.offsetHeight + "px"; |
---|
1521 | var wWidth = div.offsetWidth + "px"; |
---|
1522 | |
---|
1523 | win = new dJSWin({ |
---|
1524 | id: 'ccList'+div.id, |
---|
1525 | content_id: div.id, |
---|
1526 | width: wWidth, |
---|
1527 | height: wHeight, |
---|
1528 | title_color: '#3978d6', |
---|
1529 | bg_color: '#eee', |
---|
1530 | title: title, |
---|
1531 | title_text_color: 'white', |
---|
1532 | button_y_img: '../phpgwapi/images/win_min.gif', |
---|
1533 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
1534 | border: true}); |
---|
1535 | this.searchW[div.id] = win; |
---|
1536 | win.draw(); |
---|
1537 | } |
---|
1538 | else |
---|
1539 | { |
---|
1540 | var _this = this; |
---|
1541 | win = this.searchW[div.id]; |
---|
1542 | if((_this.type == "close" && win.state == 0) || win.state == 2){EsearchE.func_clean();} |
---|
1543 | win.draw(); |
---|
1544 | } |
---|
1545 | win.open(); |
---|
1546 | } |
---|
1547 | |
---|
1548 | searchE.prototype.aux_local_folder_display = function(folder) |
---|
1549 | { |
---|
1550 | if(!expresso_offline) |
---|
1551 | return "(Local) " + lang_folder(folder.substr(6)); |
---|
1552 | else |
---|
1553 | return lang_folder(folder.substr(6)); |
---|
1554 | } |
---|
1555 | |
---|
1556 | searchE.prototype.refresh = function(alert_new_msg){ |
---|
1557 | var handler_refresh = function(data){ |
---|
1558 | var allMsg = [3]; |
---|
1559 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
1560 | |
---|
1561 | if( data['num_msgs'] ) |
---|
1562 | { |
---|
1563 | allMsg['data'] = data['data']; |
---|
1564 | allMsg['num_msgs'] = data['num_msgs']; |
---|
1565 | } |
---|
1566 | |
---|
1567 | if( ( data['num_msgs'] ) == 0 ) |
---|
1568 | { |
---|
1569 | alert( get_lang("None result was found.") ); |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | if( data['num_msgs'] ) |
---|
1574 | { |
---|
1575 | write_msg( count + " " + get_lang("results found") ); |
---|
1576 | EsearchE.mount_result( allMsg, 'SORTDATE', true ); |
---|
1577 | } |
---|
1578 | } |
---|
1579 | } |
---|
1580 | |
---|
1581 | this.condition = openTab.condition[currentTab]; |
---|
1582 | |
---|
1583 | var sort_type = (this.sort_type ? this.sort_type : 'SORTDATE'); |
---|
1584 | |
---|
1585 | if( expresso_offline ) |
---|
1586 | handler('none'); |
---|
1587 | else |
---|
1588 | cExecute( "$this.imap_functions.search_msg", handler_refresh, "condition="+openTab.condition[currentTab]+"&page="+EsearchE.page+"&sort_type="+sort_type); |
---|
1589 | } |
---|
1590 | |
---|
1591 | |
---|
1592 | // Cria o objeto |
---|
1593 | var EsearchE; |
---|
1594 | EsearchE = new searchE(); |
---|