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