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