Changeset 7913 for trunk


Ignore:
Timestamp:
02/26/13 12:57:02 (11 years ago)
Author:
thiago
Message:

Ticket #3331 - Correção para anexar arquivos.

Location:
trunk/expressoMail1_2/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/abas.js

    r7908 r7913  
    1010function setBorderAttributes(ID) 
    1111{ 
    12         this.border_id = "border_id_"+ID; 
    13         this.sequence = ID;  
     12    this.border_id = "border_id_"+ID; 
     13    this.sequence = ID;  
    1414} 
    1515 
     
    1717function alternate_border(ID) 
    1818{ 
    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 ){ 
     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 ){ 
    4141            var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
    4242            if(search_win){ 
     
    4545            win.close( ); 
    4646        } 
    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') { 
     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') { 
    131131                 numBox = ID; 
    132132         } 
     
    145145             } 
    146146         } 
    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; 
     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; 
    157157} 
    158158 
    159159function create_border(borderTitle, id_value, search) 
    160160{ 
    161         borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 
     161    borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 
    162162    borderTitle = html_entities(borderTitle);     
    163         var resize = false; 
     163    var resize = false; 
    164164        resize = resize_borders(); 
    165165        if (!resize){ 
    166166            var str_continue = ''; 
    167167            var bolContinue = true; 
    168                         str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); 
     168            str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); 
    169169            if (preferences.auto_close_first_tab == 1){ 
    170170                var children = Element('border_tr').childNodes; 
     
    180180                        } 
    181181                        if (bolDelete || bolContinue){ 
    182                                                         str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); 
    183                                                         var confirmacao = confirm(str_fechar); 
     182                            str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); 
     183                            var confirmacao = confirm(str_fechar); 
    184184                            if(confirmacao){ 
    185185                            bolContinue = false; 
    186186                            delete_border(num_child, 'false'); 
    187187                            break; 
    188                                                         }else{ 
    189                                                                 return 'maximo'; 
     188                            }else{ 
     189                                return 'maximo'; 
    190190                        } 
    191191                    } 
    192192                } 
    193193            } 
    194             }else{                       
     194            }else{           
    195195                alert(get_lang('Reached maximum tab limit') + str_continue ); 
    196196                return 'maximo'; 
    197197            } 
    198198        } 
    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                         } 
     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            } 
    206206        }else 
    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"); 
     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"); 
    243243    td.alt = ' '; 
    244244    td.title = borderTitle; 
    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'>" + 
     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'>" + 
    270270                                borderTitle + 
    271271                            "</div>\n\ 
     
    273273                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " + 
    274274                            "</div>\n\ " +  
    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); 
     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); 
    394394    uidsSave[ID] = []; 
    395395    saveBorderError[ID] = false; 
    396         return ID; 
     396    return ID; 
    397397} 
    398398 
    399399function resize_borders() 
    400400{ 
    401         var numBorders = count_borders(); 
    402  
    403         if (numBorders > 8) 
    404                 return false; 
    405  
    406         return redim_borders(numBorders+1); 
     401    var numBorders = count_borders(); 
     402 
     403    if (numBorders > 8) 
     404        return false; 
     405 
     406    return redim_borders(numBorders+1); 
    407407} 
    408408 
    409409function count_borders() 
    410410{ 
    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; 
     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; 
    419419} 
    420420 
    421421function redim_borders(numBorders) 
    422422{ 
    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; 
     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; 
    436436} 
    437437 
     
    446446            border_width = border.clientWidth; 
    447447        } 
    448         var caption = ""; 
     448    var caption = ""; 
    449449    if (border != null){ 
    450                 Element("font_"+border.id).style.width = (border_width - 35)+'px'; 
    451                 Element("font_"+border.id).innerHTML = title; 
    452         } 
    453         return(title); 
     450        Element("font_"+border.id).style.width = (border_width - 35)+'px'; 
     451        Element("font_"+border.id).innerHTML = title; 
     452    } 
     453    return(title); 
    454454} 
    455455 
     
    477477                            'type':     'question', 
    478478                            'overlay_opacity': '0.5', 
    479                                                         'custom_class': 'custom-zebra-filter', 
     479                            'custom_class': 'custom-zebra-filter', 
    480480                            'buttons':  buttons, 
    481481                            'width' : width, 
    482482                            'onClose':  function(clicked) { 
    483                                                                         if(clicked == 'Cancelar'){ 
    484                                                                                 if (RichTextEditor.plain[id] != true)  
    485                                                                                         setTimeout("RichTextEditor.focus("+ID+")",100);                   
    486                                                                                 else   
    487                                                                                         $('#body_'+ID).focus();  
    488                                                                         } 
     483                                    if(clicked == 'Cancelar'){ 
     484                                        if (RichTextEditor.plain[id] != true)  
     485                                            setTimeout("RichTextEditor.focus("+ID+")",100);                   
     486                                        else   
     487                                            $('#body_'+ID).focus();  
     488                                    } 
    489489                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) { 
    490490                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID]) 
     
    512512                                                                $("#cc_"+ID).focus(); 
    513513                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "") 
    514                                                                 $("#cco_"+ID).focus();           
     514                                                                $("#cco_"+ID).focus();       
    515515                                                        else if ($.trim($("#subject_"+ID).val()) == "") 
    516516                                                                $("#subject_"+ID).focus(); 
     
    529529                            }})}, 300);     
    530530        } 
    531          
     531     
    532532} 
    533533 
    534534function editTest(ID){ 
    535535    var body = document.getElementById('body_'+ ID); 
    536         var content = $('#content_id_'+ ID); 
     536    var content = $('#content_id_'+ ID); 
    537537    if (body) 
    538538    { 
     
    572572      
    573573    /*var bolExecuteClose = true; 
    574         var borderElem = Element("border_id_" + ID); 
    575         if (borderElem){ 
     574    var borderElem = Element("border_id_" + ID); 
     575    if (borderElem){ 
    576576            borderElem.onclick = null; // It's avoid a FF3 bug 
    577577        }else{ 
    578578            return false; 
    579579        } 
    580         if (msg_sent == 'false') 
    581         { 
     580    if (msg_sent == 'false') 
     581    { 
    582582            if (editTest(ID)){ 
    583583                bolExecuteClose = false; 
     
    585585                    return(draftTests(ID, msg_sent)); 
    586586            } 
    587         } 
     587    } 
    588588     
    589589         
     
    591591        { 
    592592            close_delete(ID, msg_sent); 
    593                 } 
    594                 delete(openTab.type[ID]); 
     593        } 
     594        delete(openTab.type[ID]); 
    595595        return true;*/ 
    596596          
     
    599599function close_delete(ID, msg_sent) 
    600600{ 
    601         openTab.toPreserve[ID] = false; 
     601    openTab.toPreserve[ID] = false; 
    602602        // Limpa o autosave 
    603603            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null ) 
     
    608608        //////////////////////////////// 
    609609         
    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 ); 
     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 ); 
    639639        delete msgAttachments[ID]; 
    640640        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba 
    641641            var isPartMsg = false; 
    642                         if(!parseInt(id2)) 
    643                                 return; 
     642            if(!parseInt(id2)) 
     643                return; 
    644644            var id2 = ID.replace('_r',''); 
    645645            for(var ii = 0; ii < partMsgs.length; ii++) 
     
    655655        /////////////////////////////////////////////////////////////////////////////////// 
    656656         
    657         return true; 
     657    return true; 
    658658} 
    659659 
    660660function getTabPrefix() { // define o prefixo para os checkboxes das mensagens 
    661         if (typeof(currentTab)!='number') 
    662                 return currentTab+"_"; 
    663         else 
    664                 return ""; 
     661    if (typeof(currentTab)!='number') 
     662        return currentTab+"_"; 
     663    else 
     664        return ""; 
    665665} 
    666666 
    667667function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha 
    668         var p = row_id.search("_s"); 
    669         if (p>0) 
    670                 return row_id.substr(0,p); 
    671         else 
    672                 return row_id; 
     668    var p = row_id.search("_s"); 
     669    if (p>0) 
     670        return row_id.substr(0,p); 
     671    else 
     672        return row_id; 
    673673} 
    674674 
    675675function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab 
    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         } 
     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    } 
    683683} 
    684684 
     
    710710    var imap     = new Array(); 
    711711    var archiver = new Array(); 
    712      
     712    var files    = new Array(); 
     713 
    713714    if(typeof msgAttachments[ID] == "undefined"){ 
    714715        return ""; 
     
    717718    $.each(msgAttachments[ID], function(i, each){ 
    718719        
    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)); 
    723725       } 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           } 
    725731       } 
    726732    }); 
     
    728734    context = { 
    729735        "imap" : imap, 
    730         "archiver" : archiver 
     736        "archiver" : archiver, 
     737        "files" : files 
    731738    }; 
    732739 
    733740   return (typeof(msgAttachments[ID]) == 'undefined') ? '' : context; 
    734741} 
    735  
  • trunk/expressoMail1_2/js/main.js

    r7911 r7913  
    34523452function send_valided_message(ID, folder, folder_name) 
    34533453{  
    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}); 
     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}); 
    34623462 
    34633463    var _subject = trim(content.find(".subject").val()); 
     
    34743474    $.each(array, function(index, value){ 
    34753475        stringReply += $(value).find("input").val() + ","; 
    3476     });  
     3476    });  
    34773477    var stringToEmail = ""; 
    34783478    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")); 
     
    35093509        }); 
    35103510    } 
    3511     stringEmail +=      stringCCEmail; 
     3511    stringEmail +=  stringCCEmail; 
    35123512 
    35133513    var mailData = new Object(); 
     
    35303530    mailData.msg_forward_from = $(content).find('[name="msg_forward_from"]').val(); 
    35313531    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 = []; 
    35363538    // VERIFY IF EXISTS MESSAGE TO ATTACH 
    35373539    if(typeof mailData.attachments == "object"){ 
    35383540 
     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 
    35393551        // VERIFY IF EXISTS MESSAGE OF ARCHIVE 
     3552 
    35403553        if(mailData.attachments.archiver.length){ 
    35413554 
     
    35893602                } 
    35903603 
     3604                if(filesAux.length){ 
     3605                    $.each(filesAux, function(i, each){ 
     3606                        mailData.attachments.push(each); 
     3607                    }); 
     3608                } 
     3609 
    35913610                // GOOD, NOW THE ATTACHMENTS ARE READY TO SEND! 
    35923611                mailData.attachments = JSON.stringify(mailData.attachments); 
    35933612            }; 
    3594         } else { 
     3613        } else if(mailData.attachments.imap.length) { 
    35953614            // 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            } 
    35983632        } 
     3633 
    35993634    } else { 
    36003635        // IF THIS MESSAGE DON'T HAVE ATTACHMENT, CALL READYTOSEND. 
     
    36063641    readyToSend = function(){ 
    36073642     
    3608         if(stringEmail != ""){ 
    3609                 $.ajax({ 
    3610                         url: "controller.php?action=$this.imap_functions.send_mail", 
     3643        if(stringEmail != ""){ 
     3644            $.ajax({ 
     3645                url: "controller.php?action=$this.imap_functions.send_mail", 
    36113646                data:  mailData, 
    36123647                type: 'POST', 
     
    36203655                    // HERE, I NEED TO DELETE THE MESSAGES THAT WERE UNARCHIVE FROM ARCHIVE. 
    36213656                    delete_msgs("INBOX/Trash",expresso_mail_archive.idMsgsToAttach, false, false); 
    3622                         }, 
    3623                         error: function(){ 
    3624                                 write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); 
     3657                }, 
     3658                error: function(){ 
     3659                    write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); 
    36253660                    $(content).find('button.send').button('option', 'disabled', false); 
    36263661                    var interval = setInterval(function(){ 
    3627                                                 send_valided_message(ID,folder,folder_name); 
    3628                                                 clearInterval(interval); 
    3629                                 },15000); 
    3630                                 return; 
    3631                         } 
    3632                 }); 
    3633         }else{ 
    3634                 write_msg(get_lang("message without receiver")); 
    3635                 return; 
    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        } 
    36373672        delete(expresso_mail_archive.idMsgsToAttach); 
    36383673    }; 
Note: See TracChangeset for help on using the changeset viewer.