[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)); |
---|
[7561] | 530 | td1 = ''; |
---|
| 531 | $(td).addClass("expressomail-sprites-clip"); |
---|
[4821] | 532 | } |
---|
| 533 | else |
---|
| 534 | td1 = ''; |
---|
| 535 | } |
---|
| 536 | if (j == 2) |
---|
| 537 | { |
---|
| 538 | td.setAttribute("width", colSizes[1][2]); |
---|
| 539 | td.id = "td_message_answered_"+uid_msg; |
---|
| 540 | if (aux.flag.match('X')) |
---|
[6528] | 541 | td1 = '<img src=templates/'+template+'/images/forwarded.png title="'+get_lang('Forwarded')+'">'; |
---|
[4821] | 542 | else |
---|
| 543 | if (aux.flag.match('A')) |
---|
[6528] | 544 | td1 = '<img src=templates/'+template+'/images/answered.png title="'+get_lang('Answered')+'">'; |
---|
[4821] | 545 | else |
---|
| 546 | td1 = ''; |
---|
| 547 | } |
---|
| 548 | if (j == 3) |
---|
| 549 | { |
---|
| 550 | td.setAttribute("width", colSizes[1][3]); |
---|
[5134] | 551 | td.id = "td_message_important_"+uid_msg; |
---|
[4821] | 552 | if (aux.flag.match("F")) |
---|
| 553 | { |
---|
| 554 | add_className(tr, 'flagged_msg'); |
---|
[5578] | 555 | td1 = "<img src='templates/"+template+"/images/important.png' title='"+get_lang('Flagged')+"'>"; |
---|
[4821] | 556 | } |
---|
| 557 | else |
---|
| 558 | td1 = ''; |
---|
| 559 | } |
---|
| 560 | if (j == 4) |
---|
| 561 | { |
---|
[8242] | 562 | if (preferences['use_followupflags_and_labels'] == '1'){ |
---|
| 563 | if(border_id.split("local").length == 1){ |
---|
| 564 | td.setAttribute("width", colSizes[1][4]); |
---|
| 565 | td.id = "td_message_followup_search_"+uid_msg; |
---|
| 566 | td.setAttribute("class","search-result-item"); |
---|
| 567 | td1 = '<div class="flag-edited" style="width:8px;height:6px;"><img src="../prototype/modules/mail/img/flagEditor.png"></div>'; |
---|
| 568 | |
---|
| 569 | $(td).click(function(event, ui){ |
---|
| 570 | var messageClickedId = $(this).attr('id').match(/td_message_followup_search_([\d]+)/)[1]; |
---|
[8153] | 571 | |
---|
[8242] | 572 | var loading = $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 573 | .find('img[alt=Carregando]'); |
---|
[8153] | 574 | |
---|
[8242] | 575 | //Verificar se está carregando a bandeira. |
---|
| 576 | //Caso esteja ele sai da função até que seja carregado. |
---|
| 577 | if( loading.length ) { |
---|
| 578 | return false; |
---|
| 579 | } |
---|
[8153] | 580 | |
---|
[8242] | 581 | var followupColor = $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css('backgroundColor'); |
---|
[8153] | 582 | |
---|
[8242] | 583 | |
---|
| 584 | var followupColor = $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css('backgroundColor'); |
---|
| 585 | |
---|
| 586 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 587 | .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" />'); |
---|
| 588 | |
---|
| 589 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", "transparent"); |
---|
| 590 | |
---|
| 591 | /**TODO Alterar após melhorias no filtro da camada javascript*/ |
---|
| 592 | DataLayer.remove('followupflagged', false); |
---|
| 593 | var flagged = DataLayer.get('followupflagged', {filter: [ |
---|
| 594 | 'AND', |
---|
| 595 | ['=', 'messageNumber', messageClickedId], |
---|
| 596 | ['=', 'folderName', mailbox] |
---|
| 597 | ]}); |
---|
| 598 | if(flagged == '' || flagged == [] || flagged == 'undefined'){ |
---|
| 599 | /** |
---|
| 600 | * Aplica followupflag de Acompanhamento |
---|
| 601 | */ |
---|
| 602 | aux.followupflagged = { |
---|
| 603 | uid : User.me.id, |
---|
| 604 | folderName : mailbox, |
---|
| 605 | messageNumber : messageClickedId, |
---|
| 606 | alarmTime : false, |
---|
| 607 | backgroundColor : '#FF2016', |
---|
| 608 | followupflagId: '1' |
---|
| 609 | }; |
---|
[5533] | 610 | |
---|
[8242] | 611 | aux.followupflagged.id = DataLayer.put('followupflagged', aux.followupflagged); |
---|
| 612 | DataLayer.commit(false, false, function(data){ |
---|
| 613 | var fail = false; |
---|
| 614 | $.each(data, function(index, value) { |
---|
| 615 | fail = false; |
---|
| 616 | if(typeof value === 'string'){ |
---|
| 617 | fail = value; |
---|
| 618 | } |
---|
| 619 | }); |
---|
| 620 | |
---|
| 621 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 622 | .css({"background-image":"url(../prototype/modules/mail/img/flagEditor.png)"}) |
---|
| 623 | .find('img').remove();; |
---|
| 624 | |
---|
| 625 | if (fail) { |
---|
| 626 | |
---|
| 627 | var isCurrentFolder = current_folder == mailbox ? '#td_message_followup_' + messageClickedId + ', ' : ''; |
---|
| 628 | $(isCurrentFolder + 'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", "#CCCCCC"); |
---|
| 629 | |
---|
| 630 | $('#td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 631 | .append("<img src='../prototype/modules/mail/img/flagEditor.png'/>"); |
---|
| 632 | |
---|
| 633 | MsgsCallbackFollowupflag[fail](); |
---|
| 634 | return false; |
---|
[7414] | 635 | } |
---|
[8242] | 636 | |
---|
| 637 | if(current_folder == mailbox){ |
---|
| 638 | $('#td_message_followup_' + messageClickedId + ', ' + |
---|
| 639 | 'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).attr('title', get_lang('Follow up')).find(".flag-edited").css("background", aux.followupflagged.backgroundColor); |
---|
| 640 | |
---|
| 641 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).attr('title', get_lang('Follow up')).find(".flag-edited").css("background", aux.followupflagged.backgroundColor) |
---|
| 642 | .append("<img src='../prototype/modules/mail/img/flagEditor.png'/>"); |
---|
| 643 | }else{ |
---|
| 644 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).attr('title', get_lang('Follow up')).find(".flag-edited").css("background", aux.followupflagged.backgroundColor) |
---|
| 645 | .append("<img src='../prototype/modules/mail/img/flagEditor.png'/>"); |
---|
| 646 | } |
---|
| 647 | updateCacheFollowupflag(messageClickedId, mailbox, true); |
---|
[7414] | 648 | }); |
---|
[8242] | 649 | |
---|
[7414] | 650 | |
---|
[8242] | 651 | }else if(onceOpenedHeadersMessages[mailbox][messageClickedId]['followupflagged'].followupflag.name == 'Follow up'){ |
---|
| 652 | /** |
---|
| 653 | * Remover followupflag de Acompanhamento (DFD0078:RI25) |
---|
| 654 | */ |
---|
| 655 | $(this).find(".flag-edited").css("background", "#cccccc"); |
---|
| 656 | DataLayer.remove('followupflagged', flagged[0].id ); |
---|
| 657 | DataLayer.commit(false, false, function(){ |
---|
| 658 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").html('<img src="../prototype/modules/mail/img/flagEditor.png">') |
---|
| 659 | .css({"width":"8px","height":"6px"/*,"background-image":"url(../prototype/modules/mail/img/flagEditor.png)"*/}); |
---|
| 660 | if(current_folder == mailbox){ |
---|
| 661 | updateCacheFollowupflag(messageClickedId, mailbox, false); |
---|
| 662 | |
---|
| 663 | $('#td_message_followup_' + messageClickedId + ', ' + |
---|
| 664 | 'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).attr('title', '').find(".flag-edited").css("background", '#CCC'); |
---|
| 665 | |
---|
| 666 | $('#td_message_followup_' + messageClickedId + ', ' + |
---|
| 667 | 'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 668 | .css({"background-image":"url(../prototype/modules/mail/img/flagEditor.png)"}); |
---|
| 669 | }else{ |
---|
| 670 | updateCacheFollowupflag(messageClickedId, mailbox, false); |
---|
| 671 | |
---|
| 672 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).attr('title', '').find(".flag-edited").css("background", '#CCC'); |
---|
| 673 | |
---|
| 674 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
| 675 | .css({"background-image":"url(../prototype/modules/mail/img/flagEditor.png)"}) |
---|
| 676 | .append("<img src='../prototype/modules/mail/img/flagEditor.png'/>"); |
---|
| 677 | } |
---|
| 678 | }); |
---|
| 679 | |
---|
| 680 | } else { |
---|
[7414] | 681 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited") |
---|
[8242] | 682 | .css({"background-image":"url(../prototype/modules/mail/img/flagEditor.png)"}).find('img').remove(); |
---|
[7414] | 683 | |
---|
[8242] | 684 | $('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", followupColor) |
---|
| 685 | .append("<img src='../prototype/modules/mail/img/flagEditor.png'/>"); |
---|
[8153] | 686 | |
---|
[8242] | 687 | //Pega id do checkbox |
---|
| 688 | var id = $(this).parents('[role="'+messageClickedId+'_'+mailbox+'"]').attr('class', 'selected_msg').find(':checkbox').attr('id'); |
---|
[7414] | 689 | |
---|
[8242] | 690 | //verifica se o checkbox já está selecionada |
---|
| 691 | if($('#' + id).attr('checked') != 'checked') |
---|
| 692 | $(this).parents('[role="'+messageClickedId+'_'+mailbox+'"]').attr('class', 'selected_msg').find(':checkbox').trigger('click'); |
---|
[7414] | 693 | |
---|
[8242] | 694 | updateSelectedMsgs(true,messageClickedId); |
---|
| 695 | configureFollowupflag(); |
---|
| 696 | } |
---|
| 697 | //if(!){} |
---|
[5649] | 698 | |
---|
[8242] | 699 | }); |
---|
| 700 | } |
---|
| 701 | }else{ |
---|
| 702 | td.setAttribute("width", colSizes[1][4]); |
---|
| 703 | td.innerHTML = '<div></div>'; |
---|
| 704 | } |
---|
[5533] | 705 | } |
---|
| 706 | if (j == 5) |
---|
| 707 | { |
---|
[7414] | 708 | if(border_id.split("local").length == 1){ |
---|
| 709 | td.setAttribute("width", colSizes[1][5]); |
---|
| 710 | td.id = "td_message_labels_search_"+uid_msg; |
---|
| 711 | td.setAttribute("class","td-label-search"); |
---|
| 712 | |
---|
| 713 | if (aux.labels) { |
---|
[7544] | 714 | //td1 = '<img src="../prototype/modules/mail/img/tag.png">'; |
---|
[8153] | 715 | $(td).css({'background-image':'url(../prototype/modules/mail/img/mail-sprites.png)','margin-left': '0px', 'margin-top':'3px', 'background-position': '0px -1706px', 'background-repeat':'no-repeat no-repeat'}); |
---|
[7414] | 716 | updateLabelsColumn(aux) |
---|
| 717 | } else { |
---|
| 718 | td1 = ''; |
---|
| 719 | } |
---|
[5533] | 720 | } |
---|
| 721 | } |
---|
| 722 | if (j == 6) |
---|
| 723 | { |
---|
| 724 | td.setAttribute("width", colSizes[1][6]); |
---|
[4821] | 725 | td.id = "td_message_sent_"+uid_msg; |
---|
| 726 | td1 = ''; |
---|
| 727 | } |
---|
| 728 | |
---|
[5533] | 729 | if ( j == 7 ) |
---|
[4821] | 730 | { |
---|
[5533] | 731 | td.setAttribute("width", colSizes[1][7]); |
---|
[4821] | 732 | td.className = "td_resizable"; |
---|
| 733 | td.onclick = _onclick; |
---|
| 734 | var nm_box = aux.boxname.split(cyrus_delimiter); |
---|
| 735 | var td1 = nm_box.pop(); |
---|
| 736 | td.setAttribute("NoWrap","true"); |
---|
| 737 | td.style.overflow = "hidden"; |
---|
| 738 | td.style.color = "#42795b"; |
---|
| 739 | td.style.fontWeight = "bold"; |
---|
| 740 | |
---|
| 741 | var td1 = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1); |
---|
[5533] | 742 | td1 = translateFolder(td1); |
---|
[4821] | 743 | |
---|
[5533] | 744 | if (proxy_mensagens.is_local_folder(td1)) { |
---|
[4821] | 745 | var td1 = this.aux_local_folder_display(td1); |
---|
| 746 | } |
---|
| 747 | } |
---|
| 748 | |
---|
[5533] | 749 | if( j == 8 ) |
---|
[4821] | 750 | { |
---|
[5451] | 751 | var name; |
---|
| 752 | if( aux.from.name != undefined){ |
---|
| 753 | name = aux.from.name; |
---|
| 754 | }else{ |
---|
| 755 | name = aux.from; |
---|
| 756 | } |
---|
| 757 | if ( name !== null && name.length > 29) |
---|
| 758 | name = name.substr(0,29) + "..."; |
---|
[4821] | 759 | |
---|
[5533] | 760 | td.setAttribute("width", colSizes[1][8]); |
---|
[4821] | 761 | td.className = "td_resizable"; |
---|
| 762 | td.onclick = _onclick; |
---|
| 763 | td.setAttribute("NoWrap","true"); |
---|
| 764 | td.style.overflow = "hidden"; |
---|
[5444] | 765 | |
---|
[5451] | 766 | var td1 = '<div style="width:100%;overflow:hidden">'+name+"</div>"; |
---|
[4821] | 767 | } |
---|
| 768 | |
---|
[5533] | 769 | if( j == 9 ) |
---|
[4821] | 770 | { |
---|
[6365] | 771 | //var subject_encode = url_encode(subject); |
---|
| 772 | aux.subject = html_entities(aux.subject); |
---|
| 773 | if (aux.subject.length <= 1) |
---|
| 774 | aux.subject = "(" + get_lang("no subject") + ")"; |
---|
[4821] | 775 | if (aux.subject.length > 70) |
---|
| 776 | aux.subject = aux.subject.substr(0,70) + "..."; |
---|
| 777 | |
---|
[5533] | 778 | td.setAttribute("width", colSizes[1][9]); |
---|
[5486] | 779 | td.className = "td_resizable td_msg_search_subject"; |
---|
[4821] | 780 | td.onclick = _onclick; |
---|
| 781 | td.setAttribute("NoWrap","true"); |
---|
| 782 | td.style.overflow = "hidden"; |
---|
| 783 | |
---|
| 784 | var td1 = aux.subject; |
---|
| 785 | } |
---|
| 786 | |
---|
[5533] | 787 | if( j == 10 ) |
---|
[4821] | 788 | { |
---|
[5533] | 789 | td.setAttribute("width", colSizes[1][10]); |
---|
[4821] | 790 | td.className = "td_resizable"; |
---|
| 791 | td.align = "center"; |
---|
| 792 | td.onclick = _onclick; |
---|
| 793 | |
---|
[7414] | 794 | if(validate_date(new String(aux.udate))){ |
---|
[4821] | 795 | var td1 = aux.udate; |
---|
| 796 | } |
---|
| 797 | else |
---|
| 798 | { |
---|
| 799 | var dt = new Date( aux.udate * 1000 ); |
---|
| 800 | var td1 = dt.getDate() + "/"; |
---|
| 801 | |
---|
| 802 | if( !( dt.getMonth() + 1 ).toString().match(/\d{2}/) ) |
---|
| 803 | td1 += "0"+( dt.getMonth() + 1 ) + "/"; |
---|
| 804 | else |
---|
| 805 | td1 += ( dt.getMonth() + 1 ) + "/"; |
---|
| 806 | |
---|
| 807 | td1 += dt.getFullYear(); |
---|
| 808 | } |
---|
| 809 | } |
---|
| 810 | |
---|
[5533] | 811 | if( j == 11 ) |
---|
[4821] | 812 | { |
---|
[5549] | 813 | td.setAttribute("width", colSizes[1][11]); |
---|
[4821] | 814 | td.className = "td_resizable"; |
---|
| 815 | td.align = "center"; |
---|
| 816 | td.onclick = _onclick; |
---|
[5452] | 817 | if(aux.Size != undefined){ |
---|
| 818 | var td1 = borkb(aux.Size); |
---|
| 819 | } |
---|
| 820 | else{ |
---|
| 821 | var td1 = borkb(aux.size); |
---|
| 822 | } |
---|
[4821] | 823 | } |
---|
| 824 | |
---|
[5533] | 825 | if( j == 12 ) |
---|
[4821] | 826 | { |
---|
| 827 | if (aux.flag.match("U")) |
---|
| 828 | add_className(tr, 'tr_msg_unread'); |
---|
| 829 | if (aux.flag.match("F")) |
---|
| 830 | add_className(tr, 'flagged_msg'); |
---|
| 831 | var td1 = ''; |
---|
| 832 | } |
---|
[5533] | 833 | if (j<12) { |
---|
[4821] | 834 | td.innerHTML = td1; |
---|
[7715] | 835 | td1 = ''; |
---|
[5533] | 836 | //Carregar os followupflag nos resultados. |
---|
| 837 | if (aux.followupflagged) { |
---|
[5738] | 838 | if(aux.followupflagged.followupflag.id < 7){ |
---|
| 839 | var nameFollowupflag = get_lang(aux.followupflagged.followupflag.name); |
---|
| 840 | }else{ |
---|
| 841 | var nameFollowupflag = aux.followupflagged.followupflag.name; |
---|
| 842 | } |
---|
| 843 | $(td).attr('title', nameFollowupflag) |
---|
[5533] | 844 | .find(".flag-edited").css("background",aux.followupflagged.backgroundColor); |
---|
| 845 | if(aux.followupflagged.isDone == "1"){ |
---|
| 846 | $(td).find(".flag-edited").find("img") |
---|
| 847 | .attr("src", "../prototype/modules/mail/img/flagChecked.png") |
---|
| 848 | .css("margin-left","-3px"); |
---|
| 849 | } |
---|
| 850 | } else { |
---|
| 851 | $(td).find(".flag-edited").css("background","#cccccc"); |
---|
| 852 | } |
---|
| 853 | |
---|
[5548] | 854 | |
---|
[4821] | 855 | tr.appendChild(td); |
---|
| 856 | } |
---|
| 857 | } |
---|
| 858 | |
---|
[5486] | 859 | //_dragArea.makeDragged(tr, uid_msg, subject, true, mailbox); |
---|
| 860 | $(tr).draggable({ |
---|
[5499] | 861 | start : function(){ |
---|
[7751] | 862 | $('.upper, .lower').show(); |
---|
| 863 | $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); |
---|
[5499] | 864 | if($(".shared-folders").length){ |
---|
| 865 | $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ |
---|
| 866 | over : function(a, b){ |
---|
| 867 | //SETA BORDA EM VOLTA DA PASTA |
---|
[7786] | 868 | $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); |
---|
[7751] | 869 | over = $(this); |
---|
| 870 | $(this).addClass("folder-over"); |
---|
| 871 | if(($(this)[0] != $(this).parent().find(".head_folder")[0])) |
---|
| 872 | if($(this).prev()[0]) |
---|
| 873 | if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ |
---|
| 874 | setTimeout(function(){ |
---|
| 875 | if(over.hasClass("folder-over")) |
---|
| 876 | over.prev().trigger("click"); |
---|
| 877 | }, 500); |
---|
| 878 | |
---|
| 879 | } |
---|
[5499] | 880 | }, |
---|
[7786] | 881 | out : function(a,b){ |
---|
[5499] | 882 | //RETIRA BORDA EM VOLTA DA PASTA |
---|
[7786] | 883 | $(b.helper).find(".draggin-folder,.draggin-mail").css("color", ""); |
---|
[7751] | 884 | $(this).removeClass("folder-over"); |
---|
[5499] | 885 | }, |
---|
| 886 | //accept: ".draggin_mail", |
---|
| 887 | drop : function(event, ui){ |
---|
| 888 | $(this).css("border", ""); |
---|
| 889 | if($(this).parent().attr('id') == undefined){ |
---|
| 890 | var folder_to = 'INBOX'; |
---|
| 891 | var to_folder_title = get_lang("Inbox"); |
---|
| 892 | }else{ |
---|
| 893 | var folder_to = $(this).parent().attr('id'); |
---|
| 894 | var to_folder_title = $(this).attr('title'); |
---|
| 895 | } |
---|
| 896 | var folder_to_move = ui.draggable.parent().attr('id'); |
---|
| 897 | var border_id = ui.draggable.find("input[type=hidden]").attr("name"); |
---|
| 898 | // Mensagens : SE O DROP VIER DA LISTA DE MENSAGENS : |
---|
| 899 | if(ui.draggable.parents('[id^="content_id_"]')[0]){ |
---|
| 900 | move_search_msgs("content_id_"+border_id, folder_to, to_folder_title); |
---|
| 901 | return refresh(); |
---|
| 902 | } |
---|
| 903 | } |
---|
| 904 | }); |
---|
| 905 | } |
---|
| 906 | }, |
---|
| 907 | stop :function(){ |
---|
[7751] | 908 | $('.upper, .lower').hide(); |
---|
[5499] | 909 | $(".shared-folders").parent().find(".folder").droppable("destroy"); |
---|
| 910 | }, |
---|
[5486] | 911 | helper: function(event){ |
---|
[5499] | 912 | if($(this).find("input:checkbox").attr("checked") != "checked"){ |
---|
| 913 | $(this).find("input:checkbox").trigger('click'); |
---|
| 914 | $(this).addClass("selected_msg"); |
---|
| 915 | } |
---|
[5486] | 916 | if($("#content_id_"+border_id).find("tr input:checked").length > 1) |
---|
| 917 | return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : (($("#content_id_"+border_id).find("tr input:checked")).length+" mensagens selecionadas"), type: "messages"})); |
---|
| 918 | if( $(this).find(".td_msg_search_subject").text().length > 18 ) |
---|
| 919 | return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_search_subject").text().substring(0,18) + "...", type: "messages"})); |
---|
| 920 | else |
---|
| 921 | return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_search_subject").text(), type: "messages"})); |
---|
| 922 | }, |
---|
[7786] | 923 | cursorAt: {top: 5, left: 56}, |
---|
[5486] | 924 | refreshPositions: true , |
---|
| 925 | scroll: true, |
---|
| 926 | scrollSensitivity: 100, |
---|
| 927 | scrollSpeed: 100, |
---|
| 928 | containment: "#divAppbox" |
---|
[6456] | 929 | }).bind("contextmenu", function(event){ |
---|
[5533] | 930 | if(event.button == 2) |
---|
| 931 | if($(this).find("input:checkbox").attr("checked") != "checked"){ |
---|
| 932 | $(this).find("input:checkbox").trigger('click'); |
---|
| 933 | $(this).addClass("selected_msg"); |
---|
[5506] | 934 | } |
---|
[5486] | 935 | }); |
---|
[4821] | 936 | return tr; |
---|
| 937 | } |
---|
| 938 | |
---|
[3802] | 939 | // Form resultado |
---|
[5219] | 940 | searchE.prototype.mount_result = function( Data, sort_type, keep_border, keep_filled, division, actualSearch ) |
---|
[3842] | 941 | { |
---|
| 942 | var data = ( Data['data'] ) ? Data['data'] : Data['data_gears']; |
---|
| 943 | if ( data == undefined ) |
---|
[3802] | 944 | return; |
---|
[5548] | 945 | |
---|
| 946 | var msg_folder = get_current_folder(); |
---|
| 947 | var messageNumbers = new Array(); |
---|
| 948 | var messageFolders = new Array(); |
---|
| 949 | for (var i=0; i<data.length; i++) { |
---|
| 950 | messageNumbers.push(data[i].uid); |
---|
| 951 | messageFolders.push(data[i].boxname); |
---|
| 952 | } |
---|
| 953 | |
---|
[5575] | 954 | |
---|
| 955 | |
---|
[5533] | 956 | |
---|
[3802] | 957 | var cont = parseInt(0); |
---|
[3018] | 958 | |
---|
[3842] | 959 | if ( typeof(sort_type) != 'undefined') |
---|
[3802] | 960 | this.sort_type = sort_type; |
---|
| 961 | else |
---|
| 962 | sort_type = this.sort_type; |
---|
| 963 | |
---|
[4821] | 964 | if ( keep_border ) { |
---|
[7727] | 965 | /*Recupera o id da ultima aba de pesquisa rápida aberta que não seja de pesquisa local |
---|
| 966 | para que continue o processamento na mesma aba caso a aba seja alternada durante o processamento da pesquisa.*/ |
---|
| 967 | var border_id = $('#border_tr > [id*="_search"]:not([id*="_search_local"]):last').attr("id"); |
---|
| 968 | border_id = border_id.split("border_id_").reverse()[0]; |
---|
[4821] | 969 | } |
---|
| 970 | else { |
---|
[5172] | 971 | if(isNaN(numBox)){ |
---|
| 972 | var aux = numBox.split("_"); |
---|
| 973 | numBox = parseInt(aux[0]) + 1; |
---|
[5215] | 974 | }else{ |
---|
| 975 | inc_abas_search++; |
---|
| 976 | numBox = inc_abas_search; |
---|
| 977 | } |
---|
[4821] | 978 | if( Data['data'] ) |
---|
[5219] | 979 | if(!actualSearch) |
---|
| 980 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox); |
---|
| 981 | else |
---|
| 982 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox, actualSearch); |
---|
[4821] | 983 | if( Data['data_gears']) |
---|
[5219] | 984 | if(!actualSearch) |
---|
| 985 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox); |
---|
| 986 | else |
---|
| 987 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox, actualSearch); |
---|
[4821] | 988 | } |
---|
| 989 | |
---|
[3682] | 990 | if (!border_id) |
---|
| 991 | return; |
---|
| 992 | |
---|
| 993 | currentTab = border_id; |
---|
[5134] | 994 | openTab.content_id[currentTab] = Element('content_id_search_' + numBox); |
---|
[3682] | 995 | openTab.type[currentTab] = 1; |
---|
[4821] | 996 | openTab.condition[currentTab] = this.condition; |
---|
| 997 | |
---|
| 998 | if ( keep_border ) { |
---|
| 999 | var content_search = Element('content_id_' + border_id); |
---|
[7727] | 1000 | numBox = border_id.split("_")[1]; |
---|
[5134] | 1001 | var div_scroll_result = Element("divScrollMain_"+numBox); |
---|
| 1002 | |
---|
[4821] | 1003 | content_search.removeChild(div_scroll_result); |
---|
[5134] | 1004 | |
---|
| 1005 | if( !keep_filled ) |
---|
| 1006 | div_scroll_result = false; |
---|
[4821] | 1007 | } |
---|
| 1008 | |
---|
[2] | 1009 | var table = document.createElement("TABLE"); |
---|
[5134] | 1010 | table.id = "table_resultsearch_" + numBox; |
---|
[3842] | 1011 | table.frame = "void"; |
---|
| 1012 | table.rules = "rows"; |
---|
| 1013 | table.cellPadding = "0"; |
---|
| 1014 | table.cellSpacing = "0"; |
---|
| 1015 | table.className = "table_box"; |
---|
[72] | 1016 | |
---|
[3682] | 1017 | var tbody = document.createElement("TBODY"); |
---|
[5134] | 1018 | tbody.id = "tbody_box_" + numBox; |
---|
[3380] | 1019 | |
---|
[3842] | 1020 | for( var i=0; i < data.length; i++) |
---|
| 1021 | { |
---|
[5134] | 1022 | if(data[i] !== null){ |
---|
[4821] | 1023 | var tr = EsearchE.make_tr_message(data[i],border_id,i); |
---|
[3842] | 1024 | tbody.appendChild(tr); |
---|
[2] | 1025 | } |
---|
[5134] | 1026 | } |
---|
[3842] | 1027 | |
---|
[4802] | 1028 | //global_search++; //Tabs from search must not have the same id on its tr's // use numBox instead of this! |
---|
[3802] | 1029 | |
---|
[2] | 1030 | table.appendChild(tbody); |
---|
[832] | 1031 | |
---|
[4062] | 1032 | var colgr_element = buildColGroup(1); |
---|
[5134] | 1033 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
[4062] | 1034 | table.appendChild(colgr_element); |
---|
| 1035 | |
---|
[4807] | 1036 | var content_search = Element('content_id_' + border_id); |
---|
[5134] | 1037 | |
---|
| 1038 | if( !div_scroll_result ) |
---|
| 1039 | { |
---|
[3842] | 1040 | var div_scroll_result = document.createElement("DIV"); |
---|
[5134] | 1041 | div_scroll_result.id = "divScrollMain_"+numBox; |
---|
[4062] | 1042 | div_scroll_result.style.overflowY = "scroll"; |
---|
| 1043 | div_scroll_result.style.overflowX = "hidden"; |
---|
| 1044 | div_scroll_result.style.width ="100%"; |
---|
[3842] | 1045 | |
---|
[4062] | 1046 | if (is_mozilla){ |
---|
| 1047 | div_scroll_result.style.overflow = "-moz-scrollbars-vertical"; |
---|
| 1048 | div_scroll_result.style.width ="100%"; |
---|
| 1049 | } |
---|
[5134] | 1050 | } |
---|
| 1051 | if( division ) |
---|
| 1052 | { |
---|
| 1053 | var _div = document.createElement("div"); |
---|
| 1054 | _div.className = 'local-messages-search-warning'; |
---|
| 1055 | _div.innerHTML = division; |
---|
| 1056 | div_scroll_result.appendChild(_div); |
---|
| 1057 | } |
---|
[4062] | 1058 | |
---|
[67] | 1059 | if(is_ie) |
---|
[72] | 1060 | Element("border_table").width = "99.5%"; |
---|
[3380] | 1061 | |
---|
[832] | 1062 | // Put header |
---|
[67] | 1063 | var table_element = document.createElement("TABLE"); |
---|
| 1064 | var tbody_element = document.createElement("TBODY"); |
---|
[4062] | 1065 | if (is_ie) |
---|
| 1066 | { |
---|
| 1067 | table_element.attachEvent("onmousemove",changeCursorState); |
---|
| 1068 | table_element.attachEvent("onmousedown",startColResize); |
---|
| 1069 | } |
---|
| 1070 | else { |
---|
| 1071 | table_element.addEventListener("mousemove",changeCursorState,false); |
---|
| 1072 | table_element.addEventListener("mousedown",startColResize,false); |
---|
| 1073 | } |
---|
[5134] | 1074 | table_element.setAttribute("id", "table_message_header_box_"+numBox); |
---|
[67] | 1075 | table_element.className = "table_message_header_box"; |
---|
[4062] | 1076 | if (!is_ie) |
---|
| 1077 | table_element.style.width = "98.8%"; |
---|
| 1078 | table_element.emptyBody = false; |
---|
| 1079 | |
---|
[67] | 1080 | tr_element = document.createElement("TR"); |
---|
| 1081 | tr_element.className = "message_header"; |
---|
[4062] | 1082 | td_element0 = createTDElement(1,0); |
---|
[156] | 1083 | chk_box_element = document.createElement("INPUT"); |
---|
[5264] | 1084 | if(border_id.indexOf('local') > 0) |
---|
| 1085 | chk_box_element.id = "chk_box_select_all_messages_search_local"; |
---|
| 1086 | else |
---|
| 1087 | chk_box_element.id = "chk_box_select_all_messages_search"; |
---|
[156] | 1088 | chk_box_element.setAttribute("type", "checkbox"); |
---|
| 1089 | chk_box_element.className = "checkbox"; |
---|
[163] | 1090 | chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);}; |
---|
[5587] | 1091 | chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages from this page.')}; |
---|
[3842] | 1092 | chk_box_element.onkeydown = function (e) |
---|
| 1093 | { |
---|
[156] | 1094 | if (is_ie) |
---|
| 1095 | { |
---|
| 1096 | if ((window.event.keyCode) == 46) |
---|
[832] | 1097 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 1098 | } |
---|
| 1099 | else |
---|
| 1100 | { |
---|
| 1101 | if ((e.keyCode) == 46) |
---|
[832] | 1102 | delete_msgs(current_folder,'selected','null'); |
---|
[156] | 1103 | } |
---|
| 1104 | }; |
---|
[3380] | 1105 | |
---|
[156] | 1106 | td_element0.appendChild(chk_box_element); |
---|
[4062] | 1107 | td_element01 = createTDElement(1,1); |
---|
| 1108 | td_element02 = createTDElement(1,2); |
---|
| 1109 | td_element03 = createTDElement(1,3); |
---|
| 1110 | td_element04 = createTDElement(1,4); |
---|
[5533] | 1111 | td_element05 = createTDElement(1,5); |
---|
| 1112 | td_element06 = createTDElement(1,6); |
---|
| 1113 | td_element1 = createTDElement(1,7,"th_resizable","left"); |
---|
[3842] | 1114 | |
---|
| 1115 | var arrow_ascendant = function(Text) |
---|
[832] | 1116 | { |
---|
[3842] | 1117 | return "<b>" + Text + "</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
[832] | 1118 | } |
---|
[5533] | 1119 | |
---|
[3842] | 1120 | // Ordernar Pasta |
---|
[5134] | 1121 | if ( sort_type == 'SORTBOX' /*|| sort_type == 'SORTBOX_REVERSE'*/ ) |
---|
[3842] | 1122 | { |
---|
| 1123 | if( Data['data'] ) |
---|
| 1124 | { |
---|
[6232] | 1125 | td_element1.onclick = function(){EsearchE.searchFor(border_id, 'SORTBOX_REVERSE');}; |
---|
[3846] | 1126 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1127 | } |
---|
| 1128 | else |
---|
| 1129 | { |
---|
[6232] | 1130 | td_element1.onclick = function(){EsearchE.searchFor(border_id, 'SORTBOX_REVERSE');}; |
---|
[4796] | 1131 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1132 | } |
---|
| 1133 | } |
---|
[832] | 1134 | else |
---|
| 1135 | { |
---|
[3842] | 1136 | if( Data['data'] ) |
---|
| 1137 | { |
---|
[6232] | 1138 | td_element1.onclick = function(){EsearchE.searchFor(border_id, 'SORTBOX');}; |
---|
[3842] | 1139 | } |
---|
[832] | 1140 | else |
---|
[3842] | 1141 | { |
---|
[6232] | 1142 | td_element1.onclick = function(){EsearchE.searchFor(border_id, 'SORTBOX');}; |
---|
[3842] | 1143 | } |
---|
| 1144 | td_element1.innerHTML = ( sort_type == 'SORTBOX_REVERSE' ) ? arrow_ascendant(get_lang("Folder")) : get_lang("Folder"); |
---|
[832] | 1145 | } |
---|
[3842] | 1146 | |
---|
| 1147 | // Ordernar Quem |
---|
[5533] | 1148 | td_element2 = createTDElement(1,8,"th_resizable","left"); |
---|
[3842] | 1149 | |
---|
[5134] | 1150 | if (sort_type == 'SORTFROM' || sort_type == 'SORTWHO' /*|| sort_type == 'SORTWHO_REVERSE' || sort_type == 'SORTFROM_REVERSE'*/ ) |
---|
[832] | 1151 | { |
---|
[3842] | 1152 | if(Data['data']) |
---|
| 1153 | { |
---|
[6232] | 1154 | td_element2.onclick = function(){EsearchE.searchFor(border_id, 'SORTFROM_REVERSE');}; |
---|
[4771] | 1155 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1156 | } |
---|
| 1157 | else |
---|
| 1158 | { |
---|
[6232] | 1159 | td_element2.onclick = function(){EsearchE.searchFor(border_id, 'SORTWHO_REVERSE');}; |
---|
[5197] | 1160 | td_element2.innerHTML = "<b>"+get_lang("From")+"</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_element2.onclick = function(){EsearchE.searchFor(border_id, 'SORTWHO');}; |
---|
[3842] | 1168 | } |
---|
[832] | 1169 | else |
---|
[3842] | 1170 | { |
---|
[6232] | 1171 | td_element2.onclick = function(){EsearchE.searchFor(border_id, 'SORTWHO');}; |
---|
[3842] | 1172 | } |
---|
[5197] | 1173 | td_element2.innerHTML = ( sort_type == 'SORTWHO_REVERSE' ) ? arrow_ascendant(get_lang("From")) : get_lang("From"); |
---|
[832] | 1174 | } |
---|
[3842] | 1175 | |
---|
| 1176 | // Ordernar Subject |
---|
[5533] | 1177 | td_element3 = createTDElement(1,9,"th_resizable","left"); |
---|
[3842] | 1178 | |
---|
[5134] | 1179 | if (sort_type == 'SORTSUBJECT' /*|| sort_type == 'SORTSUBJECT_REVERSE'*/) |
---|
[832] | 1180 | { |
---|
[3842] | 1181 | if( Data['data']) |
---|
| 1182 | { |
---|
[6232] | 1183 | td_element3.onclick = function(){EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE');}; |
---|
[3846] | 1184 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1185 | } |
---|
| 1186 | else |
---|
| 1187 | { |
---|
[6232] | 1188 | td_element3.onclick = function(){EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE');}; |
---|
[4796] | 1189 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</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_element3.onclick = function(){EsearchE.searchFor( border_id, 'SORTSUBJECT');}; |
---|
[3842] | 1197 | } |
---|
[832] | 1198 | else |
---|
[3842] | 1199 | { |
---|
[6232] | 1200 | td_element3.onclick = function(){EsearchE.searchFor(border_id, 'SORTSUBJECT');}; |
---|
[3842] | 1201 | } |
---|
| 1202 | td_element3.innerHTML = ( sort_type == 'SORTSUBJECT_REVERSE' ) ? arrow_ascendant(get_lang("subject")) : get_lang("subject"); |
---|
[832] | 1203 | } |
---|
[3842] | 1204 | |
---|
| 1205 | // Ordernar Data |
---|
[5533] | 1206 | td_element4 = createTDElement(1,10,"th_resizable","center"); |
---|
[3842] | 1207 | |
---|
[5134] | 1208 | if ( sort_type == 'SORTDATE' /*|| sort_type == 'SORTDATE_REVERSE'*/ ) |
---|
[832] | 1209 | { |
---|
[3842] | 1210 | if( Data['data'] ) |
---|
| 1211 | { |
---|
[6232] | 1212 | td_element4.onclick = function(){EsearchE.searchFor(border_id, 'SORTDATE_REVERSE');}; |
---|
[3846] | 1213 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1214 | } |
---|
| 1215 | else |
---|
| 1216 | { |
---|
[6232] | 1217 | td_element4.onclick = function(){EsearchE.searchFor(border_id, 'SORTDATE_REVERSE');}; |
---|
[4796] | 1218 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1219 | } |
---|
[832] | 1220 | } |
---|
| 1221 | else |
---|
| 1222 | { |
---|
[3842] | 1223 | if( Data['data'] ) |
---|
| 1224 | { |
---|
[6232] | 1225 | td_element4.onclick = function(){EsearchE.searchFor(border_id, 'SORTDATE');}; |
---|
[3842] | 1226 | } |
---|
[832] | 1227 | else |
---|
[3842] | 1228 | { |
---|
[6232] | 1229 | td_element4.onclick = function(){EsearchE.searchFor(border_id, 'SORTDATE');}; |
---|
[3842] | 1230 | } |
---|
| 1231 | td_element4.innerHTML = ( sort_type == 'SORTDATE_REVERSE' ) ? arrow_ascendant(get_lang("Date")) : get_lang("Date"); |
---|
| 1232 | } |
---|
| 1233 | |
---|
| 1234 | // Ordernar Tamanho |
---|
[5533] | 1235 | td_element5 = createTDElement(1,11,"th_resizable","center"); |
---|
[3842] | 1236 | |
---|
[5134] | 1237 | if ( sort_type == 'SORTSIZE' /*|| sort_type == 'SORTSIZE_REVERSE'*/ ) |
---|
[832] | 1238 | { |
---|
[3842] | 1239 | if( Data['data'] ) |
---|
| 1240 | { |
---|
[6232] | 1241 | td_element5.onclick = function(){EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE');}; |
---|
[3846] | 1242 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1243 | } |
---|
| 1244 | else |
---|
| 1245 | { |
---|
[6232] | 1246 | td_element5.onclick = function(){EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE');}; |
---|
[4796] | 1247 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
[3842] | 1248 | } |
---|
[832] | 1249 | } |
---|
| 1250 | else |
---|
| 1251 | { |
---|
[3842] | 1252 | if( Data['data'] ) |
---|
| 1253 | { |
---|
[6232] | 1254 | td_element5.onclick = function(){EsearchE.searchFor(border_id, 'SORTSIZE');}; |
---|
[3842] | 1255 | } |
---|
[832] | 1256 | else |
---|
[3842] | 1257 | { |
---|
[6232] | 1258 | td_element5.onclick = function(){EsearchE.searchFor(border_id, 'SORTSIZE');}; |
---|
[3842] | 1259 | } |
---|
| 1260 | td_element5.innerHTML = ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size"); |
---|
[832] | 1261 | } |
---|
[3842] | 1262 | |
---|
[5533] | 1263 | //Abrir a Tela de de Configuracao de Acompanhamento |
---|
| 1264 | |
---|
| 1265 | |
---|
[156] | 1266 | tr_element.appendChild(td_element0); |
---|
[4062] | 1267 | tr_element.appendChild(td_element01); |
---|
| 1268 | tr_element.appendChild(td_element02); |
---|
| 1269 | tr_element.appendChild(td_element03); |
---|
| 1270 | tr_element.appendChild(td_element04); |
---|
[5533] | 1271 | tr_element.appendChild(td_element05); |
---|
| 1272 | tr_element.appendChild(td_element06); |
---|
[67] | 1273 | tr_element.appendChild(td_element1); |
---|
| 1274 | tr_element.appendChild(td_element2); |
---|
| 1275 | tr_element.appendChild(td_element3); |
---|
| 1276 | tr_element.appendChild(td_element4); |
---|
| 1277 | tr_element.appendChild(td_element5); |
---|
| 1278 | tbody_element.appendChild(tr_element); |
---|
| 1279 | table_element.appendChild(tbody_element); |
---|
[3842] | 1280 | |
---|
[5533] | 1281 | |
---|
[4062] | 1282 | var colgr_element = buildColGroup(1); |
---|
[5134] | 1283 | colgr_element.setAttribute("id","colgroup_head_"+numBox); |
---|
[4062] | 1284 | table_element.appendChild(colgr_element); |
---|
| 1285 | |
---|
[5134] | 1286 | if( parseInt( Data['gears_num_msgs'] ) > 0 && !keep_filled) |
---|
[3842] | 1287 | { |
---|
[5219] | 1288 | var messagesWarning = document.getElementById("local-messages-search-warning_"+border_id); |
---|
| 1289 | if(!messagesWarning){ |
---|
| 1290 | var _div_gears = document.createElement("div"); |
---|
| 1291 | _div_gears.id = "local-messages-search-warning_"+border_id; |
---|
[6232] | 1292 | _div_gears.onclick = function(){EsearchE.viewLocalMessage();}; |
---|
[5219] | 1293 | _div_gears.className = 'local-messages-search-warning'; |
---|
| 1294 | _div_gears.innerHTML = get_lang("The search has% 1 messages stored locally. Want to see them ? Click here.", Data['gears_num_msgs']); |
---|
| 1295 | content_search.appendChild(_div_gears); |
---|
| 1296 | } |
---|
[3842] | 1297 | } |
---|
| 1298 | |
---|
[5134] | 1299 | var _divScroll = document.getElementById("divScrollHead_"+numBox); |
---|
| 1300 | |
---|
| 1301 | if( _divScroll ){ |
---|
| 1302 | content_search.removeChild(_divScroll); |
---|
| 1303 | _divScroll = false; |
---|
| 1304 | } |
---|
[3842] | 1305 | |
---|
[4062] | 1306 | _divScroll = document.createElement("DIV"); |
---|
[5471] | 1307 | _divScroll.id = "divScrollHead_"+numBox; |
---|
[4062] | 1308 | _divScroll.style.overflowY = "hidden"; |
---|
| 1309 | _divScroll.style.overflowX = "hidden"; |
---|
| 1310 | _divScroll.style.width ="100%"; |
---|
| 1311 | |
---|
| 1312 | if (is_mozilla){ |
---|
| 1313 | _divScroll.style.width ="99.3%"; |
---|
| 1314 | } |
---|
| 1315 | _divScroll.appendChild(table_element); |
---|
| 1316 | content_search.appendChild(_divScroll); |
---|
[5134] | 1317 | |
---|
[1121] | 1318 | /*end of "put header"*/ |
---|
[3842] | 1319 | if ( !expresso_offline ) |
---|
| 1320 | { |
---|
[1121] | 1321 | div_scroll_result.appendChild(table); |
---|
| 1322 | content_search.appendChild(div_scroll_result); |
---|
| 1323 | } |
---|
[3842] | 1324 | else |
---|
| 1325 | { |
---|
[1121] | 1326 | div_scroll_result.appendChild(table); |
---|
| 1327 | content_search.appendChild(div_scroll_result); |
---|
| 1328 | } |
---|
[3842] | 1329 | |
---|
[3223] | 1330 | resizeWindow(); |
---|
[5471] | 1331 | if(typeof(Data.data_gears)=="undefined") |
---|
| 1332 | EsearchE.show_paging( Data['num_msgs'] ); |
---|
[7414] | 1333 | |
---|
| 1334 | Data = null; |
---|
| 1335 | data = null; |
---|
[2] | 1336 | } |
---|
| 1337 | |
---|
[3842] | 1338 | searchE.prototype.open_msg = function(mailbox, uid_msg, subject) |
---|
| 1339 | { |
---|
| 1340 | var handler_get_msg = function(data) |
---|
| 1341 | { |
---|
| 1342 | if( Element("border_id_" + uid_msg + "_r") ) |
---|
| 1343 | alert(get_lang("This message is already opened!")); |
---|
| 1344 | else |
---|
| 1345 | draw_message( data, create_border(url_decode(subject), uid_msg + "_r") ); |
---|
[2] | 1346 | } |
---|
[3842] | 1347 | |
---|
[3802] | 1348 | proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg); |
---|
[2] | 1349 | } |
---|
| 1350 | |
---|
| 1351 | // Adiciona caixas postais na busca; |
---|
[3842] | 1352 | searchE.prototype.add_mailboxes = function() |
---|
| 1353 | { |
---|
[69] | 1354 | var sel = Element("sel_search_nm_box1"); |
---|
[7414] | 1355 | this.name_box_search = folder.id; |
---|
[5471] | 1356 | |
---|
| 1357 | if (!proxy_mensagens.is_local_folder(this.name_box_search)) |
---|
| 1358 | { |
---|
[689] | 1359 | var name_box = this.name_box_search.split(cyrus_delimiter); |
---|
| 1360 | if(this.name_box_search == "") |
---|
| 1361 | return false; |
---|
| 1362 | var name_box_def = ""; |
---|
| 1363 | if(name_box.length != 1){ |
---|
| 1364 | name_box_def = name_box[(name_box.length-1)]; |
---|
| 1365 | }else{ |
---|
[3380] | 1366 | name_box_def = get_lang("Inbox"); |
---|
[689] | 1367 | } |
---|
[2] | 1368 | } |
---|
[5471] | 1369 | else |
---|
| 1370 | { |
---|
[689] | 1371 | if(this.name_box_search=='local_root') |
---|
| 1372 | return; |
---|
| 1373 | if(this.name_box_search=='local_Inbox') |
---|
| 1374 | name_box_def = get_lang("Inbox"); |
---|
[3802] | 1375 | else if(this.name_box_search.indexOf("/")!="-1") { |
---|
| 1376 | final_pos = this.name_box_search.lastIndexOf("/"); |
---|
| 1377 | name_box_def = this.name_box_search.substr(final_pos+1); |
---|
| 1378 | } |
---|
[7414] | 1379 | else { |
---|
| 1380 | name_box_def = folder.caption + " (local)"; //this.name_box_search.substr(6);//Retira o 'local_' |
---|
| 1381 | } |
---|
[689] | 1382 | } |
---|
[5471] | 1383 | |
---|
| 1384 | if( sel.length > 0) |
---|
| 1385 | { |
---|
| 1386 | for(var i=0; i < sel.options.length; i++) |
---|
| 1387 | { |
---|
| 1388 | if(sel.options[i].value == this.name_box_search) |
---|
| 1389 | { |
---|
[2] | 1390 | alert(get_lang('This message is already selected!')); |
---|
| 1391 | return false; |
---|
| 1392 | } |
---|
| 1393 | } |
---|
| 1394 | } |
---|
[5471] | 1395 | |
---|
| 1396 | name_box_def = translateFolder(name_box_def); |
---|
| 1397 | sel[sel.length] = new Option(lang_folder(name_box_def),this.name_box_search,false,true); |
---|
[2] | 1398 | } |
---|
[3842] | 1399 | |
---|
| 1400 | // Remove as caixas postais na busca; |
---|
| 1401 | searchE.prototype.del_mailboxes = function() |
---|
| 1402 | { |
---|
[69] | 1403 | var sel = Element("sel_search_nm_box1"); |
---|
[5480] | 1404 | |
---|
| 1405 | if( sel && ( sel.length > 0 ) ) |
---|
[3842] | 1406 | { |
---|
| 1407 | for(var i=0; i < sel.options.length; i++) |
---|
| 1408 | { |
---|
| 1409 | if(sel.options[i].selected == true) |
---|
| 1410 | { |
---|
[2] | 1411 | sel.options[i] = null; |
---|
| 1412 | i--; |
---|
| 1413 | } |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | } |
---|
[3842] | 1417 | |
---|
[2] | 1418 | // todas as caixas |
---|
[3842] | 1419 | searchE.prototype.all_mailboxes = function() |
---|
| 1420 | { |
---|
[5484] | 1421 | var value = Element("check_all_msg") ? Element("check_all_msg").checked : this.elementChecked ; |
---|
[2] | 1422 | var cont = parseInt(0); |
---|
[3842] | 1423 | if(value) |
---|
| 1424 | { |
---|
| 1425 | if(EsearchE.all_boxes.length > 0) |
---|
| 1426 | { |
---|
[3380] | 1427 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
[2] | 1428 | } |
---|
[3842] | 1429 | for(var i=0; i < folders.length; i++) |
---|
| 1430 | { |
---|
| 1431 | EsearchE.all_boxes[cont++] = folders[i].folder_id; |
---|
[2] | 1432 | } |
---|
[3842] | 1433 | } |
---|
| 1434 | else |
---|
| 1435 | { |
---|
[2] | 1436 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 1437 | } |
---|
| 1438 | } |
---|
| 1439 | |
---|
| 1440 | // Search; |
---|
[5134] | 1441 | searchE.prototype.func_search_complex = function() |
---|
[3842] | 1442 | { |
---|
[2] | 1443 | var fields = "##"; |
---|
[5471] | 1444 | // Verifica se os campos estão preenchidos; |
---|
| 1445 | if(trim(Element("txt_ass").value) != ""){ |
---|
| 1446 | fields += "SUBJECT " + "<=>" +url_encode(Element("txt_ass").value) + "##"; |
---|
| 1447 | } |
---|
| 1448 | if(trim(Element("txt_body").value) != ""){ |
---|
| 1449 | fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##"; |
---|
| 1450 | } |
---|
| 1451 | if(trim(Element("txt_de").value) != ""){ |
---|
| 1452 | fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##"; |
---|
| 1453 | } |
---|
| 1454 | if(trim(Element("txt_para").value) != ""){ |
---|
| 1455 | fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##"; |
---|
| 1456 | } |
---|
| 1457 | if(trim(Element("txt_cc").value) != ""){ |
---|
| 1458 | fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##"; |
---|
| 1459 | } |
---|
| 1460 | if (trim(Element("since_date").value) != "") |
---|
| 1461 | { |
---|
| 1462 | if (validate_date(Element("since_date").value)) |
---|
[3842] | 1463 | { |
---|
[5471] | 1464 | fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##"; |
---|
[3842] | 1465 | } |
---|
[5471] | 1466 | else |
---|
[3842] | 1467 | { |
---|
[5471] | 1468 | alert(get_lang('Invalid date on field %1', get_lang('Since Date'))); |
---|
| 1469 | return false; |
---|
[3842] | 1470 | } |
---|
[5471] | 1471 | } |
---|
| 1472 | |
---|
| 1473 | if (trim(Element("before_date").value) != "") |
---|
| 1474 | { |
---|
| 1475 | if (validate_date(Element("before_date").value)) |
---|
[3842] | 1476 | { |
---|
[5471] | 1477 | fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##"; |
---|
| 1478 | } |
---|
| 1479 | else |
---|
[3842] | 1480 | { |
---|
[5471] | 1481 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
[3842] | 1482 | return false; |
---|
| 1483 | } |
---|
[5471] | 1484 | } |
---|
| 1485 | |
---|
| 1486 | if ((trim(Element("since_date").value) != "") && (trim(Element("before_date").value) != "")){ |
---|
| 1487 | if(!(validate_date_order(trim(Element("since_date").value), trim(Element("before_date").value)))){ |
---|
| 1488 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
| 1489 | return false; |
---|
| 1490 | } |
---|
| 1491 | } |
---|
| 1492 | |
---|
| 1493 | if(trim(Element("on_date").value) != "") |
---|
| 1494 | { |
---|
| 1495 | if (validate_date(Element("on_date").value)) |
---|
| 1496 | { |
---|
| 1497 | fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##"; |
---|
[3842] | 1498 | } |
---|
[5471] | 1499 | else |
---|
| 1500 | { |
---|
| 1501 | alert(get_lang('Invalid date on field %1', get_lang('On Date'))); |
---|
| 1502 | return false; |
---|
| 1503 | } |
---|
[3842] | 1504 | |
---|
[5471] | 1505 | } |
---|
| 1506 | |
---|
| 1507 | if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != "") |
---|
| 1508 | { |
---|
| 1509 | if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED") |
---|
[3842] | 1510 | { |
---|
[5471] | 1511 | fields += "FLAGGED##"; |
---|
[3842] | 1512 | } |
---|
[5471] | 1513 | else |
---|
| 1514 | { |
---|
| 1515 | fields += "UNFLAGGED##"; |
---|
| 1516 | } |
---|
| 1517 | } |
---|
[3842] | 1518 | |
---|
[5471] | 1519 | if(trim(Element("seen").options[Element("seen").selectedIndex].value) != "") |
---|
| 1520 | { |
---|
| 1521 | if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN") |
---|
[3842] | 1522 | { |
---|
[5471] | 1523 | fields += "SEEN##"; |
---|
[3842] | 1524 | } |
---|
[5471] | 1525 | else |
---|
[3842] | 1526 | { |
---|
[5471] | 1527 | fields += "UNSEEN##"; |
---|
[3842] | 1528 | } |
---|
[5471] | 1529 | } |
---|
[3842] | 1530 | |
---|
[5471] | 1531 | if(trim(Element("answered").options[Element("answered").selectedIndex].value) != "") |
---|
| 1532 | { |
---|
| 1533 | if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){ |
---|
| 1534 | fields += "ANSWERED##"; |
---|
| 1535 | } |
---|
| 1536 | else { |
---|
| 1537 | fields += "UNANSWERED##"; |
---|
| 1538 | } |
---|
| 1539 | } |
---|
| 1540 | |
---|
| 1541 | if(trim(Element("recent").options[Element("recent").selectedIndex].value) != "") |
---|
| 1542 | { |
---|
| 1543 | if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT") |
---|
[3842] | 1544 | { |
---|
[5471] | 1545 | fields += "RECENT##"; |
---|
[3842] | 1546 | } |
---|
[5471] | 1547 | else |
---|
| 1548 | { |
---|
| 1549 | fields += "OLD##"; |
---|
| 1550 | } |
---|
| 1551 | } |
---|
[3842] | 1552 | |
---|
| 1553 | if(fields == "##") |
---|
| 1554 | { |
---|
[3711] | 1555 | alert(get_lang("Define some search parameters!")); |
---|
| 1556 | return false; |
---|
| 1557 | } |
---|
[3842] | 1558 | |
---|
[3711] | 1559 | var local_folders = new Array(); |
---|
| 1560 | var temp; |
---|
| 1561 | |
---|
[5484] | 1562 | if( Element("check_all_msg") ? Element("check_all_msg").checked : this.elementChecked ) |
---|
[3842] | 1563 | { |
---|
[3711] | 1564 | this.all_mailboxes(); |
---|
| 1565 | var nm_box = new Array; |
---|
[3842] | 1566 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
| 1567 | { |
---|
[3711] | 1568 | nm_box[i] = EsearchE.all_boxes[i] + fields; |
---|
| 1569 | } |
---|
[3842] | 1570 | if (preferences.use_local_messages == 1) |
---|
| 1571 | { |
---|
[7414] | 1572 | local_folders[0] = ""; //se local_folders[0] estiver vazio, busca em todas as pastas |
---|
[3711] | 1573 | } |
---|
[3842] | 1574 | } |
---|
| 1575 | else |
---|
| 1576 | { |
---|
[3711] | 1577 | var nm_box = new Array; |
---|
| 1578 | var sel_combo = Element("sel_search_nm_box1"); |
---|
[3842] | 1579 | |
---|
| 1580 | if( sel_combo.options.length <= 0) |
---|
| 1581 | { |
---|
[3711] | 1582 | alert(get_lang("Define the boxes to search!")); |
---|
[2] | 1583 | return false; |
---|
| 1584 | } |
---|
[3380] | 1585 | |
---|
[3842] | 1586 | for(var i=0; i < sel_combo.options.length; i++) |
---|
| 1587 | { |
---|
[3711] | 1588 | sel_combo.options[i].selected = true; |
---|
[2] | 1589 | } |
---|
[3842] | 1590 | |
---|
[5813] | 1591 | var get_children = function(folder, arr_folder){ |
---|
| 1592 | for(var y = 0; y < folder.children.length; y++){ |
---|
| 1593 | if(folder.children[y]){ |
---|
| 1594 | arr_folder[arr_folder.length] = folder.children[y].id; |
---|
| 1595 | if (folder.children[y].children.length > 0) |
---|
| 1596 | arr_folder = get_children(folder.children[y], arr_folder); |
---|
| 1597 | |
---|
| 1598 | } |
---|
| 1599 | } |
---|
| 1600 | return arr_folder; |
---|
| 1601 | } |
---|
| 1602 | |
---|
[5480] | 1603 | for( var i=0; i < sel_combo.options.length; i++ ) |
---|
[3842] | 1604 | { |
---|
| 1605 | if( sel_combo.options[i].selected == true ) |
---|
| 1606 | { |
---|
[5813] | 1607 | var arr_folders = new Array(); |
---|
| 1608 | if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)){ |
---|
[3711] | 1609 | nm_box[nm_box.length] = sel_combo.options[i].value + fields; |
---|
[5813] | 1610 | |
---|
| 1611 | for (x in cp_tree1){ |
---|
| 1612 | if(cp_tree1[x].id == sel_combo.options[i].value){ |
---|
| 1613 | arr_folders = get_children(cp_tree1[x], arr_folders); |
---|
| 1614 | for (index in arr_folders){ |
---|
| 1615 | nm_box[nm_box.length] = arr_folders[index] + fields; |
---|
| 1616 | } |
---|
| 1617 | } |
---|
| 1618 | } |
---|
| 1619 | for (x in cp_tree2){ |
---|
| 1620 | if(cp_tree2[x].id == sel_combo.options[i].value){ |
---|
| 1621 | arr_folders = get_children(cp_tree2[x], arr_folders); |
---|
| 1622 | for (index in arr_folders){ |
---|
| 1623 | nm_box[nm_box.length] = arr_folders[index] + fields; |
---|
| 1624 | } |
---|
| 1625 | } |
---|
| 1626 | } |
---|
| 1627 | |
---|
| 1628 | }else |
---|
[3711] | 1629 | local_folders.push(sel_combo.options[i].value.substr(6)); |
---|
[2] | 1630 | } |
---|
| 1631 | } |
---|
[3711] | 1632 | } |
---|
[3842] | 1633 | |
---|
[5471] | 1634 | var handler = function( data ) |
---|
| 1635 | { |
---|
[5480] | 1636 | var allMsg = [3]; |
---|
[5471] | 1637 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
| 1638 | var tmp = []; |
---|
[3711] | 1639 | |
---|
[5471] | 1640 | // Gears - local |
---|
[5480] | 1641 | if ( local_folders.length > 0 ) |
---|
| 1642 | { |
---|
[5471] | 1643 | expresso_local_messages.setSortType('SORTDATE'); |
---|
[7414] | 1644 | //tmp = expresso_local_messages.search( local_folders, fields ); |
---|
| 1645 | expresso_mail_archive.search(local_folders, fields); |
---|
| 1646 | tmp = expresso_mail_archive.search_queryresult; |
---|
[5471] | 1647 | } |
---|
[5134] | 1648 | |
---|
[5480] | 1649 | if ( data['num_msgs'] ) |
---|
[5471] | 1650 | { |
---|
| 1651 | allMsg['data'] = data['data']; |
---|
| 1652 | allMsg['num_msgs'] = data['num_msgs']; |
---|
| 1653 | } |
---|
[3842] | 1654 | |
---|
[7414] | 1655 | if (tmp) { |
---|
| 1656 | if ( tmp.length > 0 ) |
---|
| 1657 | { |
---|
| 1658 | allMsg['gears_num_msgs'] = tmp.length ; |
---|
| 1659 | } |
---|
| 1660 | } else { |
---|
| 1661 | allMsg['gears_num_msgs'] = 0; |
---|
[5471] | 1662 | } |
---|
[4853] | 1663 | |
---|
[5480] | 1664 | if ( ( data['num_msgs'] ) == 0 ) |
---|
[5471] | 1665 | { |
---|
| 1666 | alert( get_lang("None result was found.") ); |
---|
| 1667 | } |
---|
| 1668 | else |
---|
| 1669 | { |
---|
[7414] | 1670 | if( ( tmp && tmp.length > 0) && ( !data['num_msgs'] ) ) |
---|
[5444] | 1671 | { |
---|
[5471] | 1672 | EsearchE.viewLocalMessage(); |
---|
[5444] | 1673 | } |
---|
| 1674 | else |
---|
| 1675 | { |
---|
[5480] | 1676 | if( count > 0 ) |
---|
| 1677 | { |
---|
[5471] | 1678 | EsearchE.func_clean(); |
---|
[5480] | 1679 | } |
---|
[5471] | 1680 | write_msg( count + " " + get_lang("results found") ); |
---|
[5480] | 1681 | |
---|
[5471] | 1682 | EsearchE.mount_result( allMsg, 'SORTDATE' ); |
---|
[5444] | 1683 | } |
---|
[5471] | 1684 | } |
---|
[5480] | 1685 | }; |
---|
[3842] | 1686 | |
---|
[5480] | 1687 | // Close Dialog |
---|
| 1688 | if( this.divElement != null ) |
---|
| 1689 | { |
---|
[6910] | 1690 | $(this.divElement.parentNode).dialog("close").dialog("destroy"); |
---|
[5847] | 1691 | this.modal.dialog("close"); |
---|
[5480] | 1692 | this.divElement.parentNode.removeChild(this.divElement); |
---|
| 1693 | this.divElement = null; |
---|
| 1694 | } |
---|
| 1695 | |
---|
[5471] | 1696 | this.condition = nm_box; |
---|
| 1697 | this.page = 0; |
---|
| 1698 | var args = "$this.imap_functions.search_msg"; |
---|
| 1699 | var params = "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE"; |
---|
[4853] | 1700 | |
---|
[5471] | 1701 | if( expresso_offline ) |
---|
| 1702 | handler('none'); |
---|
| 1703 | else |
---|
| 1704 | cExecute( args, handler, params); |
---|
[5134] | 1705 | } |
---|
| 1706 | |
---|
| 1707 | searchE.prototype.func_search = function(value, page, sort, border_id) |
---|
| 1708 | { |
---|
| 1709 | if( !value ) |
---|
[5480] | 1710 | { |
---|
| 1711 | this.func_search_complex(); |
---|
| 1712 | } |
---|
[5134] | 1713 | else |
---|
[5480] | 1714 | { |
---|
| 1715 | this.quickSearchMail( value, page, sort, border_id ); |
---|
| 1716 | } |
---|
[5134] | 1717 | } |
---|
| 1718 | |
---|
[6232] | 1719 | searchE.prototype.quickSearchAbort = function(){ |
---|
| 1720 | xhr.abort(); |
---|
| 1721 | } |
---|
| 1722 | |
---|
| 1723 | /* |
---|
| 1724 | * Removido o cExecute e trocado pelo $.ajax do jquery que melhor implementa os controles ajax de requisições |
---|
| 1725 | * possibilitando o cancelamento real da requisição e liberando usabilidade das demais funcionalidades do módulo |
---|
| 1726 | **/ |
---|
[5134] | 1727 | searchE.prototype.quickSearchMail = function(value, page, sort, border_id) |
---|
| 1728 | { |
---|
[7414] | 1729 | var local_folders = new Array; |
---|
[5134] | 1730 | var temp; |
---|
| 1731 | var not_found_corrent_folder = true; |
---|
[5471] | 1732 | this.all_mailboxes(); |
---|
| 1733 | var nm_box = new Array; |
---|
| 1734 | |
---|
| 1735 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
| 1736 | { |
---|
| 1737 | nm_box[i] = EsearchE.all_boxes[i]; |
---|
| 1738 | } |
---|
| 1739 | |
---|
[7414] | 1740 | //Inserido valor vazio no array para representar todas as pastas locais |
---|
[5471] | 1741 | if (preferences.use_local_messages == 1) |
---|
[7414] | 1742 | local_folders.push(""); |
---|
[5471] | 1743 | |
---|
[5134] | 1744 | this.sort = sort || this.sort || "SORTDATE"; |
---|
| 1745 | this.page = isNaN(page) ? ( value ? 0 : this.page ) : page; |
---|
| 1746 | this.value = value || this.value || false; |
---|
[5219] | 1747 | |
---|
[5134] | 1748 | if( !this.value ) |
---|
| 1749 | return alert( "Busca sem caracteres." ); |
---|
| 1750 | |
---|
| 1751 | var args = "$this.imap_functions.quickSearchMail"; |
---|
[7386] | 1752 | var params = {page: this.page, sortType: this.sort, search: this.value}; |
---|
[5134] | 1753 | |
---|
| 1754 | var selection1 = [], selection2 = []; |
---|
| 1755 | |
---|
| 1756 | for( var i = 0; i < nm_box.length; i++ ) |
---|
| 1757 | if( nm_box[i] === current_folder ) |
---|
| 1758 | continue; |
---|
| 1759 | else if( /^user/.test(nm_box[i]) ) |
---|
| 1760 | selection2[selection2.length] = nm_box[i]; |
---|
| 1761 | else |
---|
| 1762 | selection1[selection1.length] = nm_box[i]; |
---|
| 1763 | |
---|
| 1764 | if( expresso_offline ) |
---|
| 1765 | handler('none'); |
---|
| 1766 | else |
---|
| 1767 | { |
---|
| 1768 | var url = [], labels = []; |
---|
| 1769 | |
---|
| 1770 | params['folder'] = current_folder; |
---|
| 1771 | url[0] = args + "&" + $.param( params ); |
---|
| 1772 | labels[0] = "mensagem na sua pasta atual"; |
---|
| 1773 | |
---|
| 1774 | if(selection1.length) |
---|
| 1775 | { |
---|
| 1776 | params['folder'] = selection1; |
---|
| 1777 | url[1] = args + "&" + $.param( params ); |
---|
| 1778 | labels[1] = "mensagens nas suas outras pastas"; |
---|
| 1779 | } |
---|
| 1780 | if(selection2.length) |
---|
| 1781 | { |
---|
| 1782 | params['folder'] = selection2; |
---|
| 1783 | url[2] = args + "&" + $.param( params ); |
---|
| 1784 | labels[2] = "mensagens nas suas pastas compartilhadas"; |
---|
| 1785 | } |
---|
[7722] | 1786 | var link = ' <a href="#" style="position: relative; z-index: 10000" onclick="searchE.prototype.quickSearchAbort(); clean_msg(); return false;">cancelar<a/>'; |
---|
[5134] | 1787 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
[6232] | 1788 | var keepFilled = false; |
---|
[7414] | 1789 | //Inserida variável de controle para correta manipulação das mensagens locais |
---|
| 1790 | var local_messages_link = true; |
---|
[5134] | 1791 | |
---|
| 1792 | var handler = function( data ) |
---|
| 1793 | { |
---|
[6232] | 1794 | data = $.parseJSON( Base64.decode( connector.unserialize(data)) ); |
---|
| 1795 | //data = $.parseJSON( Base64.decode( data) ); |
---|
[4853] | 1796 | |
---|
[5134] | 1797 | var allMsg = { |
---|
| 1798 | num_msgs: ( data['num_msgs'] || 0 ), |
---|
| 1799 | data: ( data['data'] || data['msgs'] || data ) |
---|
| 1800 | }; |
---|
| 1801 | |
---|
[7414] | 1802 | //MAILARCHIVER |
---|
[7448] | 1803 | if(preferences.use_local_messages != 0){ |
---|
| 1804 | if(local_messages_link){ //Código executado apenas na primeira vez. |
---|
| 1805 | if ( local_folders.length > 0 ){ |
---|
| 1806 | expresso_mail_archive.search_queryresult = null; //Limpa a variável global para não exibir resultados anteriores |
---|
| 1807 | expresso_mail_archive.search(local_folders, "##ALL <=>" + url_encode(value) + "##"); |
---|
| 1808 | tmp = expresso_mail_archive.search_queryresult; |
---|
| 1809 | if(tmp == null){ |
---|
| 1810 | tmp = new Object(); |
---|
| 1811 | tmp.length = 0; |
---|
| 1812 | } |
---|
| 1813 | } |
---|
| 1814 | EsearchE.localResults = tmp.length; |
---|
[5134] | 1815 | |
---|
[7448] | 1816 | if( tmp.length > 0 ) |
---|
| 1817 | { |
---|
| 1818 | allMsg['gears_num_msgs'] = tmp.length ; |
---|
| 1819 | } |
---|
| 1820 | } |
---|
| 1821 | } |
---|
[5134] | 1822 | |
---|
| 1823 | if( allMsg['num_msgs'] ) |
---|
| 1824 | EsearchE.total = allMsg['num_msgs'] = Math.max( (EsearchE.total || 0), allMsg['num_msgs'] ); |
---|
| 1825 | |
---|
| 1826 | EsearchE.mount_result( allMsg, EsearchE.sort, ( keepFilled || border_id === currentTab ), keepFilled, "Foram encontradas " + data['msgs'].length + " "+labels.shift()+"." ); |
---|
[6232] | 1827 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
[5134] | 1828 | keepFilled = true; |
---|
[6232] | 1829 | if( url.length ){ |
---|
| 1830 | xhr = $.ajax({ |
---|
[6612] | 1831 | url: 'controller.php?action='+url.shift(), |
---|
| 1832 | async: true, |
---|
| 1833 | success: function(data){ |
---|
[7414] | 1834 | //Inserida variável de controle para correta manipulação das mensagens locais |
---|
| 1835 | local_messages_link = false; |
---|
[6612] | 1836 | handler(data); |
---|
| 1837 | }, |
---|
| 1838 | beforeSend: function( jqXHR, settings ){ |
---|
| 1839 | connector.showProgressBar(); |
---|
| 1840 | }, |
---|
[7414] | 1841 | complete: function( jqXHR, settings ){ |
---|
[6612] | 1842 | connector.hideProgressBar(); |
---|
| 1843 | } |
---|
| 1844 | }); |
---|
[6232] | 1845 | }else{ |
---|
| 1846 | xhr = false; |
---|
| 1847 | clean_msg(); |
---|
| 1848 | } |
---|
[5134] | 1849 | |
---|
| 1850 | } |
---|
[7414] | 1851 | |
---|
[6232] | 1852 | xhr = $.ajax({ |
---|
| 1853 | url: 'controller.php?action='+url.shift(), |
---|
| 1854 | async: true, |
---|
[6587] | 1855 | success: function(data){handler(data);}, |
---|
| 1856 | beforeSend: function( jqXHR, settings ){ |
---|
| 1857 | connector.showProgressBar(); |
---|
| 1858 | }, |
---|
| 1859 | complete: function( jqXHR, settings ){ |
---|
| 1860 | connector.hideProgressBar(); |
---|
| 1861 | } |
---|
[6232] | 1862 | }); |
---|
[5134] | 1863 | } |
---|
| 1864 | } |
---|
| 1865 | |
---|
[5471] | 1866 | // clean; |
---|
[3842] | 1867 | searchE.prototype.func_clean = function() |
---|
| 1868 | { |
---|
[2] | 1869 | // Limpa os campos; |
---|
[3842] | 1870 | for( var i=0; i < this.txtfields.length; i++ ) |
---|
| 1871 | { |
---|
| 1872 | if( Element(this.txtfields[i]) != null ) |
---|
| 1873 | Element(this.txtfields[i]).value = ""; |
---|
[3380] | 1874 | } |
---|
[1622] | 1875 | |
---|
[3842] | 1876 | for(i = 0; i < this.selectFields.length; i++) |
---|
| 1877 | { |
---|
| 1878 | if (Element(this.selectFields[i])) |
---|
| 1879 | Element(this.selectFields[i]).selectedIndex = 0; |
---|
| 1880 | } |
---|
| 1881 | |
---|
| 1882 | if( Element("check_all_msg") != null ) |
---|
| 1883 | Element("check_all_msg").checked = false; |
---|
[5484] | 1884 | this.elementChecked = false; |
---|
[2] | 1885 | |
---|
| 1886 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
[5480] | 1887 | EsearchE.del_mailboxes(); |
---|
| 1888 | |
---|
| 1889 | $("#since_date, #before_date").datepicker("option", "minDate", ""); |
---|
[5444] | 1890 | $("#since_date, #before_date").datepicker("option", "maxDate", ""); |
---|
[69] | 1891 | } |
---|
[2] | 1892 | |
---|
| 1893 | // close |
---|
[3842] | 1894 | searchE.prototype.func_close = function(type) |
---|
| 1895 | { |
---|
[2] | 1896 | var _this = this; |
---|
| 1897 | _this.name_box_search = ""; |
---|
| 1898 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
| 1899 | _this.type = type; |
---|
| 1900 | _this.searchW['window_search'].close(); |
---|
[5444] | 1901 | $("#since_date, #before_date, #on_date").datepicker( "destroy" ); |
---|
[2] | 1902 | } |
---|
[832] | 1903 | |
---|
[3842] | 1904 | searchE.prototype.aux_local_folder_display = function(folder) |
---|
| 1905 | { |
---|
[1121] | 1906 | if(!expresso_offline) |
---|
| 1907 | return "(Local) " + lang_folder(folder.substr(6)); |
---|
| 1908 | else |
---|
| 1909 | return lang_folder(folder.substr(6)); |
---|
[689] | 1910 | } |
---|
[3380] | 1911 | |
---|
[4821] | 1912 | searchE.prototype.refresh = function(alert_new_msg){ |
---|
| 1913 | var handler_refresh = function(data){ |
---|
| 1914 | var allMsg = [3]; |
---|
| 1915 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
| 1916 | |
---|
| 1917 | if( data['num_msgs'] ) |
---|
| 1918 | { |
---|
| 1919 | allMsg['data'] = data['data']; |
---|
| 1920 | allMsg['num_msgs'] = data['num_msgs']; |
---|
| 1921 | } |
---|
| 1922 | |
---|
| 1923 | if( ( data['num_msgs'] ) == 0 ) |
---|
| 1924 | { |
---|
| 1925 | alert( get_lang("None result was found.") ); |
---|
| 1926 | } |
---|
| 1927 | else |
---|
| 1928 | { |
---|
| 1929 | if( data['num_msgs'] ) |
---|
| 1930 | { |
---|
| 1931 | write_msg( count + " " + get_lang("results found") ); |
---|
| 1932 | EsearchE.mount_result( allMsg, 'SORTDATE', true ); |
---|
| 1933 | } |
---|
| 1934 | } |
---|
| 1935 | } |
---|
| 1936 | |
---|
| 1937 | this.condition = openTab.condition[currentTab]; |
---|
| 1938 | |
---|
| 1939 | var sort_type = (this.sort_type ? this.sort_type : 'SORTDATE'); |
---|
| 1940 | |
---|
| 1941 | if( expresso_offline ) |
---|
| 1942 | handler('none'); |
---|
| 1943 | else |
---|
[7635] | 1944 | if(openTab.condition[currentTab] != '') |
---|
| 1945 | cExecute( "$this.imap_functions.search_msg", handler_refresh, "condition="+openTab.condition[currentTab]+"&page="+EsearchE.page+"&sort_type="+sort_type); |
---|
[4821] | 1946 | } |
---|
| 1947 | |
---|
[2] | 1948 | // Cria o objeto |
---|
[5484] | 1949 | var EsearchE = new searchE(); |
---|
[5533] | 1950 | var EsearchE = new searchE(); |
---|