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