- Timestamp:
- 02/26/13 12:57:02 (11 years ago)
- Location:
- trunk/expressoMail1_2/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/abas.js
r7908 r7913 10 10 function setBorderAttributes(ID) 11 11 { 12 13 12 this.border_id = "border_id_"+ID; 13 this.sequence = ID; 14 14 } 15 15 … … 17 17 function alternate_border(ID) 18 18 { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 19 msg_selected = false;//Controle da seleção de mensagens 20 if(isNaN(ID)) 21 if(preferences.use_shortcuts == "1") 22 select_msg((ID.split("_"))[0]); 23 if( document.getElementById("div_menu_c3") != null ) 24 { 25 //div que contém divs de paginação de todas abas de listagem possíveis (listagem de pasta e listagem de pesquisa) 26 var node = document.getElementById("div_menu_c3").firstChild; 27 //Se for diferente da aba de listagem, remove a paginação 28 if(currentTab != 0){ 29 //Enquanto node for true (retorna false se não houver mais elementos) 30 while ( node ) { 31 node.style.display = "none"; 32 node = node.nextSibling; 33 } 34 } 35 36 if( document.getElementById("span_paging"+ID) != null ) 37 document.getElementById("span_paging"+ID).style.display = "block"; 38 } 39 40 if ( typeof win == 'object' && win.close && win.close.constructor == Function ){ 41 41 var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 42 42 if(search_win){ … … 45 45 win.close( ); 46 46 } 47 48 49 50 51 52 53 54 55 var footer_menu = Element("footer_menu"); 56 57 58 59 60 61 62 63 if((openTab.imapBox[ID].indexOf("local_") >= 0)){ 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)'); 80 81 82 83 } 84 85 86 87 88 89 90 91 92 93 footer_menu.style.display = 'none'; 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 47 48 if (! Element('border_id_'+ID)) 49 return false; // Not possible to alternate 50 show_hide_span_paging(ID); 51 spanD = Element("span_D"); 52 if (spanD) 53 spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); 54 55 var footer_menu = Element("footer_menu"); 56 var aba = Element('border_id_'+ID); 57 if (footer_menu != null) { 58 footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none'); 59 var alternate_menu = document.getElementById('localOption'); 60 61 if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail 62 if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem 63 if((openTab.imapBox[ID].indexOf("local_") >= 0)){ 64 alternate_menu.title = get_lang("Unarchive"); 65 alternate_menu.removeAttribute("onclick"); 66 if(!is_ie) 67 alternate_menu.setAttribute("onclick", 'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)'); 68 else{ 69 alternate_menu.onclick = function(){ 70 expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null); 71 } 72 } 73 alternate_menu.innerHTML = get_lang("Unarchive"); 74 75 }else{ 76 alternate_menu.title = get_lang("Archive"); 77 alternate_menu.removeAttribute("onclick"); 78 if(!is_ie) 79 alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)'); 80 else{ 81 alternate_menu.onclick = function(){ 82 archive_msgs(openTab.imapBox[ID], null); 83 } 84 } 85 alternate_menu.innerHTML = get_lang("Archive"); 86 } 87 88 } 89 } 90 91 if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){ 92 spanD.style.display = 'none'; 93 footer_menu.style.display = 'none'; 94 } 95 } 96 97 98 var len = BordersArray.length; 99 for (var i=0; i < len; i++) 100 { 101 m = document.getElementById(BordersArray[i].border_id); 102 if ((m)&&(m.className == 'menu-sel')) 103 { 104 m.className = 'menu'; 105 c = document.getElementById("content_id_"+BordersArray[i].sequence); 106 c.style.display = 'none'; 107 if(Element("font_border_id_"+BordersArray[i].sequence)) 108 Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; 109 110 } 111 } 112 113 m = Element("border_id_"+ID); 114 if (m) 115 m.className = 'menu-sel'; 116 if(Element("font_border_id_" + ID)) 117 Element("font_border_id_" + ID).className = 'font-menu-sel'; 118 var c = Element("content_id_"+ID) 119 if (c) 120 c.style.display = ''; 121 122 123 // hide the DropDrowContact, if necessary 124 window_DropDownContacts = Element('tipDiv'); 125 if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ 126 window_DropDownContacts.style.visibility = 'hidden'; 127 } 128 129 numBox = getNumBoxFromTabId(ID); 130 if (typeof(ID)=='number') { 131 131 numBox = ID; 132 132 } … … 145 145 } 146 146 } 147 148 149 150 151 152 153 154 155 156 147 currentTab=ID; 148 if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){ 149 document.getElementById('to_'+ID).focus(); 150 } 151 if (ID == 0){ 152 updateSelectedMsgs(); 153 } 154 RichTextEditor.setEditable(ID); 155 resizeWindow(); 156 return ID; 157 157 } 158 158 159 159 function create_border(borderTitle, id_value, search) 160 160 { 161 161 borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 162 162 borderTitle = html_entities(borderTitle); 163 163 var resize = false; 164 164 resize = resize_borders(); 165 165 if (!resize){ 166 166 var str_continue = ''; 167 167 var bolContinue = true; 168 168 str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); 169 169 if (preferences.auto_close_first_tab == 1){ 170 170 var children = Element('border_tr').childNodes; … … 180 180 } 181 181 if (bolDelete || bolContinue){ 182 183 182 str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); 183 var confirmacao = confirm(str_fechar); 184 184 if(confirmacao){ 185 185 bolContinue = false; 186 186 delete_border(num_child, 'false'); 187 187 break; 188 189 188 }else{ 189 return 'maximo'; 190 190 } 191 191 } 192 192 } 193 193 } 194 }else{ 194 }else{ 195 195 alert(get_lang('Reached maximum tab limit') + str_continue ); 196 196 return 'maximo'; 197 197 } 198 198 } 199 200 201 202 203 204 205 199 200 if (! id_value){ // Is new message? 201 var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; 202 if(isNaN(ID)){ 203 var aux = BordersArray[(BordersArray.length-1)].sequence.split("_"); 204 ID = parseInt(aux[1]) + 1; 205 } 206 206 }else 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 207 { 208 if (Element("border_id_"+id_value)) // It's opened already! 209 return alternate_border(id_value); 210 211 var ID = id_value; 212 if(isNaN(ID) && ID.indexOf("search_local") >= 0){ 213 if(current_folder.indexOf("local") >= 0) 214 openTab.imapBox[ID] = current_folder; 215 else 216 openTab.imapBox[ID] = 'local_search'; 217 }else if(isNaN(ID) && ID.indexOf("search_") >= 0){ 218 if(current_folder.indexOf("local") < 0) 219 openTab.imapBox[ID] = current_folder; 220 else 221 openTab.imapBox[ID] = 'search'; 222 }else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) { 223 var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); 224 ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r")); 225 var tr = Element(ID_TR) ? Element(ID_TR) : Element(ID_TR+"_s"+id_border); 226 openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); 227 }else 228 openTab.imapBox[ID] = current_folder; 229 } 230 td = document.createElement("TD"); 231 td.id="border_id_" + ID; 232 if(resize) 233 { 234 td.setAttribute("width", parseInt(resize)+"px"); 235 td.style.width = parseInt(resize)+"px"; 236 } 237 else 238 td.setAttribute("width", "200px"); 239 240 td.setAttribute("align", "right"); 241 td.onclick = function(){alternate_border(ID);resizeWindow()}; 242 td.setAttribute("noWrap","true"); 243 243 td.alt = ' '; 244 244 td.title = borderTitle; 245 borderTitle = borderTitle ? borderTitle : id_value ? get_lang("No Subject") : " ";246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 245 borderTitle = borderTitle ? borderTitle : id_value ? get_lang("No Subject") : " " ; 246 td.value = borderTitle; 247 if (borderTitle.length > 21) 248 borderTitle = borderTitle.substring(0,21) + "..."; 249 250 if ( resize ) 251 borderTitle = borderTitle.substring(0, resize*0.08); 252 253 var cc = search; 254 if(!cc){ 255 if(isNaN(ID)){ 256 var is_local = ID.match('.*_local_.*'); 257 if(!is_local) 258 cc = document.getElementById("em_message_search").value; 259 else{ 260 if (currentTab == 0) 261 cc = ""; 262 else 263 cc = document.getElementsByName(currentTab)[0].value; 264 } 265 }else{ 266 cc =""; 267 } 268 } 269 td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" + 270 270 borderTitle + 271 271 "</div>\n\ … … 273 273 <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " + 274 274 "</div>\n\ " + 275 "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>"; 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 over : function(a, b){ 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 } 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 if(borderTitle.length > 18 )369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 275 "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>"; 276 bb = document.getElementById("border_blank"); 277 parent_bb = bb.parentNode; //Pego o tbody 278 parent_bb.insertBefore(td, bb); 279 280 if((typeof(id_value) == 'string') && id_value.match(/_r/)){ 281 $(td).draggable({ 282 start : function(){ 283 $('.upper, .lower').show(); 284 $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); 285 /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável, 286 ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ 287 var current_tab_type = openTab.type[currentTab]; 288 if (current_tab_type != 0 && current_tab_type != 2){ 289 var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); 290 dropzone.show(); 291 dropzone.prev().hide(); 292 dropzone.droppable({ 293 over: function (event, ui){ 294 dropzone.addClass('hover in'); 295 $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); 296 }, 297 out: function (event, ui) { 298 dropzone.removeClass('hover in'); 299 $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", ""); 300 }, 301 drop: function (event, ui) { 302 var border_id = ui.draggable.find("input[type=hidden]").attr("name"); 303 var id_msg = border_id.split("_")[0]; 304 var folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); 305 attach_message(folder, id_msg, onceOpenedHeadersMessages); /* Anexa a mensagem especificada (por folder e id_msg) 306 na mensagem sendo criada.*/ 307 } 308 }); 309 } 310 if($(".shared-folders").length){ 311 $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ 312 over : function(a, b){ 313 //SETA BORDA EM VOLTA DA PASTA 314 $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); 315 over = $(this); 316 $(this).addClass("folder-over"); 317 if(($(this)[0] != $(this).parent().find(".head_folder")[0])) 318 if($(this).prev()[0]) 319 if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ 320 setTimeout(function(){ 321 if(over.hasClass("folder-over")) 322 over.prev().trigger("click"); 323 }, 500); 324 325 } 326 //$("#content_folders").stop().scrollTo($(this), {axis:'y', margin:true, offset:-50, duration:400}); 327 }, 328 out : function(a,b){ 329 //RETIRA BORDA EM VOLTA DA PASTA 330 $(b.helper).find(".draggin-folder,.draggin-mail").css("color", ""); 331 $(this).removeClass("folder-over"); 332 }, 333 //accept: ".draggin_mail", 334 drop : function(event, ui){ 335 $(this).css("border", ""); 336 if($(this).parent().attr('id') == undefined){ 337 var folder_to = 'INBOX'; 338 var to_folder_title = get_lang("Inbox"); 339 }else{ 340 var folder_to = $(this).parent().attr('id'); 341 var to_folder_title = $(this).attr('title'); 342 } 343 var folder_to_move = ui.draggable.parent().attr('id'); 344 var border_id = ui.draggable.find("input[type=hidden]").attr("name"); 345 if(folder_to_move == "border_tr"){ 346 var id_msg = border_id.split("_")[0]; 347 folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); 348 move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true); 349 return refresh(); 350 } 351 } 352 }); 353 } 354 }, 355 stop :function(){ 356 $('.upper, .lower').hide(); 357 $(".shared-folders").parent().find(".folder").droppable("destroy"); 358 /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável, 359 ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ 360 var current_tab_type = openTab.type[currentTab]; 361 if (current_tab_type != 0 && current_tab_type != 2){ 362 var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); 363 dropzone.hide(); 364 dropzone.prev().show(); 365 } 366 }, 367 helper: function(event){ 368 if( borderTitle.length > 18 ) 369 return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>"); 370 else 371 return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>"); 372 }, 373 delay: 150, 374 cursorAt: {top: 5, left: 56}, 375 refreshPositions: true , 376 containment: "#divAppbox" 377 }); 378 } 379 //_dragArea.makeDragged(td, id_value,td.value); 380 381 BordersArray[BordersArray.length] = new setBorderAttributes(ID); 382 383 var div = document.createElement("DIV"); 384 div.id = "content_id_" + ID; 385 div.className = "conteudo"; 386 div.style.display=''; 387 388 div.style.overflow = "hidden"; 389 390 Element("exmail_main_body").insertBefore(div,Element("footer_menu")); 391 if (!is_ie) 392 resizeWindow(); 393 alternate_border(ID); 394 394 uidsSave[ID] = []; 395 395 saveBorderError[ID] = false; 396 396 return ID; 397 397 } 398 398 399 399 function resize_borders() 400 400 { 401 402 403 404 405 406 401 var numBorders = count_borders(); 402 403 if (numBorders > 8) 404 return false; 405 406 return redim_borders(numBorders+1); 407 407 } 408 408 409 409 function count_borders() 410 410 { 411 412 413 414 415 416 417 418 411 var numBorders = 0; 412 var children = Element('border_tr').childNodes; 413 for (var i=0; i<children.length; i++) { 414 if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) 415 numBorders++; 416 } 417 418 return numBorders; 419 419 } 420 420 421 421 function redim_borders(numBorders) 422 422 { 423 424 425 426 427 428 429 430 431 432 433 434 435 423 var children = Element('border_tr').childNodes; 424 var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30; 425 var newWidthTD = (clientWidth/numBorders)-6; 426 newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD); 427 children = Element('border_tr').childNodes; 428 for (var i=0; i<children.length; i++) { 429 if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ 430 $(children[i]).css("width", newWidthTD); 431 $(children[i]).find('div:first').css("width", newWidthTD); 432 set_border_caption(children[i].id, children[i].title, newWidthTD); 433 } 434 } 435 return newWidthTD; 436 436 } 437 437 … … 446 446 border_width = border.clientWidth; 447 447 } 448 448 var caption = ""; 449 449 if (border != null){ 450 451 452 453 450 Element("font_"+border.id).style.width = (border_width - 35)+'px'; 451 Element("font_"+border.id).innerHTML = title; 452 } 453 return(title); 454 454 } 455 455 … … 477 477 'type': 'question', 478 478 'overlay_opacity': '0.5', 479 479 'custom_class': 'custom-zebra-filter', 480 480 'buttons': buttons, 481 481 'width' : width, 482 482 'onClose': function(clicked) { 483 484 485 486 487 488 483 if(clicked == 'Cancelar'){ 484 if (RichTextEditor.plain[id] != true) 485 setTimeout("RichTextEditor.focus("+ID+")",100); 486 else 487 $('#body_'+ID).focus(); 488 } 489 489 if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) { 490 490 if (openTab.imapBox[ID] && !openTab.toPreserve[ID]) … … 512 512 $("#cc_"+ID).focus(); 513 513 else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "") 514 $("#cco_"+ID).focus(); 514 $("#cco_"+ID).focus(); 515 515 else if ($.trim($("#subject_"+ID).val()) == "") 516 516 $("#subject_"+ID).focus(); … … 529 529 }})}, 300); 530 530 } 531 531 532 532 } 533 533 534 534 function editTest(ID){ 535 535 var body = document.getElementById('body_'+ ID); 536 536 var content = $('#content_id_'+ ID); 537 537 if (body) 538 538 { … … 572 572 573 573 /*var bolExecuteClose = true; 574 575 574 var borderElem = Element("border_id_" + ID); 575 if (borderElem){ 576 576 borderElem.onclick = null; // It's avoid a FF3 bug 577 577 }else{ 578 578 return false; 579 579 } 580 581 580 if (msg_sent == 'false') 581 { 582 582 if (editTest(ID)){ 583 583 bolExecuteClose = false; … … 585 585 return(draftTests(ID, msg_sent)); 586 586 } 587 587 } 588 588 589 589 … … 591 591 { 592 592 close_delete(ID, msg_sent); 593 594 593 } 594 delete(openTab.type[ID]); 595 595 return true;*/ 596 596 … … 599 599 function close_delete(ID, msg_sent) 600 600 { 601 601 openTab.toPreserve[ID] = false; 602 602 // Limpa o autosave 603 603 if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null ) … … 608 608 //////////////////////////////// 609 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 610 hold_session = false; 611 if (exist_className(Element('border_id_'+ID),'menu-sel')) 612 { 613 if (BordersArray[BordersArray.length-2].sequence == ID) 614 this.alternate_border(0); 615 else 616 this.alternate_border(BordersArray[BordersArray.length-2].sequence); 617 } 618 619 // Remove TD, title 620 border = Element('border_id_' + ID); 621 border.parentNode.removeChild(border); 622 var j=0; 623 var new_BordersArray = new Array(); 624 for (i=0;i<BordersArray.length;i++) 625 if (document.getElementById(BordersArray[i].border_id) != null){ 626 new_BordersArray[j] = BordersArray[i]; 627 j++; 628 } 629 if(j == 1) 630 Element("footer_menu").style.display = ''; 631 BordersArray = new_BordersArray; 632 633 // Remove Div Content 634 content = Element('content_id_' + ID); 635 content.parentNode.removeChild(content); 636 if(is_webkit) 637 resizeWindow(); 638 RichTextEditor.destroy( 'body_'+ID ); 639 639 delete msgAttachments[ID]; 640 640 //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba 641 641 var isPartMsg = false; 642 643 642 if(!parseInt(id2)) 643 return; 644 644 var id2 = ID.replace('_r',''); 645 645 for(var ii = 0; ii < partMsgs.length; ii++) … … 655 655 /////////////////////////////////////////////////////////////////////////////////// 656 656 657 657 return true; 658 658 } 659 659 660 660 function getTabPrefix() { // define o prefixo para os checkboxes das mensagens 661 662 663 664 661 if (typeof(currentTab)!='number') 662 return currentTab+"_"; 663 else 664 return ""; 665 665 } 666 666 667 667 function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha 668 669 670 671 672 668 var p = row_id.search("_s"); 669 if (p>0) 670 return row_id.substr(0,p); 671 else 672 return row_id; 673 673 } 674 674 675 675 function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab 676 677 678 679 680 681 682 676 if (typeof(tab_id)=='number') { 677 return tab_id; 678 } 679 else { 680 var p = tab_id.search(/[0-9]/); 681 return tab_id.substr(p); 682 } 683 683 } 684 684 … … 710 710 var imap = new Array(); 711 711 var archiver = new Array(); 712 712 var files = new Array(); 713 713 714 if(typeof msgAttachments[ID] == "undefined"){ 714 715 return ""; … … 717 718 $.each(msgAttachments[ID], function(i, each){ 718 719 719 if(typeof(each) == "undefined") return true; 720 721 if($.parseJSON(each).folder.indexOf("local_messages_") != -1){ 722 archiver.push($.parseJSON(each)); 720 if(typeof(each) == "undefined") return true; 721 722 if(typeof $.parseJSON(each) == "number"){ 723 724 files.push(parseInt(each)); 723 725 } else { 724 imap.push(each); 726 if($.parseJSON(each).folder.indexOf("local_messages_") != -1){ 727 archiver.push($.parseJSON(each)); 728 } else { 729 imap.push(each); 730 } 725 731 } 726 732 }); … … 728 734 context = { 729 735 "imap" : imap, 730 "archiver" : archiver 736 "archiver" : archiver, 737 "files" : files 731 738 }; 732 739 733 740 return (typeof(msgAttachments[ID]) == 'undefined') ? '' : context; 734 741 } 735 -
trunk/expressoMail1_2/js/main.js
r7911 r7913 3452 3452 function send_valided_message(ID, folder, folder_name) 3453 3453 { 3454 3455 3456 3457 3458 3459 3460 3461 3454 if (preferences.auto_save_draft == 1) 3455 autoSaveControl.status[ID] = true; 3456 3457 var content = $("#content_id_"+ID); 3458 var save_link = $("#content_id_"+ID).find(".save"); 3459 var onClick = save_link.onclick; 3460 save_link.onclick = ''; 3461 save_link.button({disabled: true}); 3462 3462 3463 3463 var _subject = trim(content.find(".subject").val()); … … 3474 3474 $.each(array, function(index, value){ 3475 3475 stringReply += $(value).find("input").val() + ","; 3476 }); 3476 }); 3477 3477 var stringToEmail = ""; 3478 3478 draw_email_box(content.find(".to-tr").find("textarea:first").val() || content.find(".to-tr").find("input:visible").val(), content.find(".to-tr").find("textarea:first")); … … 3509 3509 }); 3510 3510 } 3511 stringEmail += 3511 stringEmail += stringCCEmail; 3512 3512 3513 3513 var mailData = new Object(); … … 3530 3530 mailData.msg_forward_from = $(content).find('[name="msg_forward_from"]').val(); 3531 3531 mailData.msg_reply_from = $(content).find('[name="msg_reply_from"]').val(); 3532 3533 if ($(content).find('select[name="input_from"]').val()) 3534 mailData.input_from = $(content).find('select[name="input_from"]').val(); 3535 3532 3533 if ($(content).find('select[name="input_from"]').val()) 3534 mailData.input_from = $(content).find('select[name="input_from"]').val(); 3535 3536 3537 var filesAux = []; 3536 3538 // VERIFY IF EXISTS MESSAGE TO ATTACH 3537 3539 if(typeof mailData.attachments == "object"){ 3538 3540 3541 3542 if(mailData.attachments.files.length){ 3543 var files = mailData.attachments.files; 3544 var filesAux = new Array(); 3545 3546 $.each(files, function(i, each){ 3547 filesAux.push(JSON.stringify(each)); 3548 }); 3549 } 3550 3539 3551 // VERIFY IF EXISTS MESSAGE OF ARCHIVE 3552 3540 3553 if(mailData.attachments.archiver.length){ 3541 3554 … … 3589 3602 } 3590 3603 3604 if(filesAux.length){ 3605 $.each(filesAux, function(i, each){ 3606 mailData.attachments.push(each); 3607 }); 3608 } 3609 3591 3610 // GOOD, NOW THE ATTACHMENTS ARE READY TO SEND! 3592 3611 mailData.attachments = JSON.stringify(mailData.attachments); 3593 3612 }; 3594 } else {3613 } else if(mailData.attachments.imap.length) { 3595 3614 // IF THIS MESSAGE JUST HAVE IMAP MESSAGES 3596 mailData.attachments = JSON.stringify(mailData.attachments.imap); 3597 setTimeout(function(){ readyToSend() }, 30); 3615 mailData.attachments = mailData.attachments.imap; 3616 if(filesAux.length){ 3617 $.each(filesAux, function(i, each){ 3618 mailData.attachments.push(each); 3619 }); 3620 } 3621 mailData.attachments = JSON.stringify(mailData.attachments); 3622 setTimeout(function(){ readyToSend() }, 30); 3623 } else if(mailData.attachments.files.length){ 3624 if(filesAux.length){ 3625 mailData.attachments = []; 3626 $.each(filesAux, function(i, each){ 3627 mailData.attachments.push(each); 3628 }); 3629 mailData.attachments = JSON.stringify(mailData.attachments); 3630 setTimeout(function(){ readyToSend() }, 30); 3631 } 3598 3632 } 3633 3599 3634 } else { 3600 3635 // IF THIS MESSAGE DON'T HAVE ATTACHMENT, CALL READYTOSEND. … … 3606 3641 readyToSend = function(){ 3607 3642 3608 3609 3610 3643 if(stringEmail != ""){ 3644 $.ajax({ 3645 url: "controller.php?action=$this.imap_functions.send_mail", 3611 3646 data: mailData, 3612 3647 type: 'POST', … … 3620 3655 // HERE, I NEED TO DELETE THE MESSAGES THAT WERE UNARCHIVE FROM ARCHIVE. 3621 3656 delete_msgs("INBOX/Trash",expresso_mail_archive.idMsgsToAttach, false, false); 3622 3623 3624 3657 }, 3658 error: function(){ 3659 write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); 3625 3660 $(content).find('button.send').button('option', 'disabled', false); 3626 3661 var interval = setInterval(function(){ 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3662 send_valided_message(ID,folder,folder_name); 3663 clearInterval(interval); 3664 },15000); 3665 return; 3666 } 3667 }); 3668 }else{ 3669 write_msg(get_lang("message without receiver")); 3670 return; 3671 } 3637 3672 delete(expresso_mail_archive.idMsgsToAttach); 3638 3673 };
Note: See TracChangeset
for help on using the changeset viewer.