Ignore:
Timestamp:
05/13/11 18:21:58 (13 years ago)
Author:
adriano
Message:

Ticket #1888 - Problemas ao anexar um arquivo na composicao de um email

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/expressoMail1_2/js/main.js

    r4364 r4413  
    33// tempo do auto save (em milisegundos) 
    44// 20000 = 20 segundos 
    5 var autosave_time = 20000; 
     5var autosave_time = 5000; 
    66 
    77var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>';  
     
    17451745        } 
    17461746        else 
     1747        { 
    17471748                cExecuteForm("$this.imap_functions.send_mail", form, handler_send_message, ID); 
     1749        } 
    17481750} 
    17491751function change_tr_properties(tr_element, newUid, newSubject){ 
     
    17651767} 
    17661768 
    1767 function return_save(data,border_id,folder_name,folder_id,message_id) 
    1768 { 
     1769function return_save(data,border_id,folder_name,folder_id,message_id){ 
    17691770        Element("send_button_"+border_id).style.visibility="visible"; 
    1770         var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); }; 
    1771  
    1772         if (data.append != true || !data) 
     1771        var handler_delete_msg = function(data){refresh(preferences.alert_new_msg);}; 
     1772 
     1773        if (data == null || data.append != true ) 
    17731774        { 
    1774                 RichTextEditor.saveFlag = -1; 
     1775 
     1776                RichTextEditor.saveFlag = -1; 
    17751777                if (! data.append) 
    1776                         if(data == 'Post-Content-Length') 
    1777                                 write_msg(get_lang('The size of this message has exceeded  the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value)); 
    1778                         else 
    1779                                 write_msg(get_lang('ERROR saving your message.')); 
     1778                        write_msg('ERROR saving your message.'); 
    17801779                else 
    17811780                { 
     
    17981797                openTab.imapUid[border_id] = data.msg_no; 
    17991798                openTab.imapBox[border_id] = data.folder_id; 
    1800  
     1799                 
    18011800                var newTitle = document.getElementById('subject_'+border_id).value; 
    1802                 if (newTitle == '') 
     1801                if (newTitle.length > 18) 
     1802                        newTitle = newTitle.substr(18) + '...'; 
     1803                else if (newTitle == '') 
    18031804                        newTitle = get_lang("No subject"); 
    1804                 set_border_caption('border_id_'+border_id, newTitle); 
    1805  
     1805                document.getElementById('font_border_id_'+border_id).innerHTML = newTitle; 
     1806                 
    18061807                // Replace the embedded images for new uids 
    1807                 var mainField = document.getElementById('body_'+border_id).contentWindow; 
    1808                 var content_body =  mainField.document.getElementsByTagName('body').item(0).innerHTML; 
    1809                 var body_images = content_body.match(/msg_num=\d*/g); 
    1810                 var images_part = content_body.match(/msg_part=\d*/g); 
    1811                 if (body_images) 
     1808                var mainField     = document.getElementById('body_'+border_id).contentWindow; 
     1809                var content_body  = mainField.document.getElementsByTagName('body').item(0).innerHTML; 
     1810                var body_images   = content_body.match(/msg_num=\d*/g); 
     1811                var folder_images = content_body.match(/msg_folder=[^&]*&/g);            
     1812                 
     1813                if (body_images != null) 
    18121814                { 
    1813                         for (var i=0; i<body_images.length; i++){ 
    1814                                 content_body =  content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); 
    1815                         } 
    1816                         var allImgs = new Array (images_part.length); 
    1817                                 var j=-1; 
    1818                                 for (var i in images_part){ 
    1819  
    1820                                         if (is_ie) 
    1821                                                 if (i == 0) 
    1822                                                         var image_number = parseInt(images_part[i].substr(9)); 
    1823                                                 else 
    1824                                                         image_number = "null"; 
    1825                                         else 
    1826                                                 var image_number = parseInt(images_part[i].substr(9)); 
    1827  
    1828                                 if (! isNaN(image_number)) 
    1829                                         { 
    1830                                                 if (! allImgs[image_number]) 
    1831                                                 { 
    1832                                                         allImgs[image_number] = true; 
    1833                                                         j--; 
    1834                                                 } 
    1835                                         content_body = content_body.replace(images_part[i],'msg_part='+j); 
    1836                                         } 
    1837                                 } 
    1838                         content_body = content_body.replace(/msg_part=-/g,'msg_part='); 
    1839  
    1840                         mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; 
    1841                 } 
    1842  
     1815                    for (var i=0; i<body_images.length; i++) 
     1816                    { 
     1817                        if( folder_images != null) 
     1818                           content_body = content_body.replace(folder_images[i], "msg_folder=INBOX" + cyrus_delimiter + draftsfolder +"&"); 
     1819 
     1820                        content_body = content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); 
     1821                    } 
     1822 
     1823                    var images_part   = content_body.match(/msg_part=[0-9.]*/g); 
     1824 
     1825                    if(images_part != null) 
     1826                    { 
     1827                        for (var x = 0; x < images_part.length; x++) 
     1828                        { 
     1829                            var position = images_part[x].substr(9,images_part[x].length); 
     1830                            content_body = content_body.replace(images_part[x],'msg_part(||.|||.||)='+data.imagesParts[position]); 
     1831                        } 
     1832 
     1833                    } 
     1834                    content_body = content_body.replace(/msg_part\(\|\|\.\|\|\|\.\|\|\)=/g,'msg_part='); 
     1835 
     1836                    mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; 
     1837                 }        
     1838                 
     1839 
     1840         
    18431841                //Replace all files to new files 
    18441842                var divFiles = Element("divFiles_"+border_id); 
    1845                 elFiles = divFiles.getElementsByTagName("input"); 
    1846                 var countCheck =0; 
    1847                 for (var i=0; i<elFiles.length; i++) { 
    1848                         if(elFiles[i].value !=""){ 
    1849                                 if (elFiles[i].type == "checkbox") { 
    1850                                         countCheck++; 
    1851                                 } 
    1852                                 else { 
    1853                                         elFiles[i].value =""; 
    1854                                         parantNodeFile = elFiles[i].parentNode.parentNode; 
    1855                                         parantNodeFile.removeChild(elFiles[i].parentNode); 
    1856                                         i--; 
    1857                                 } 
    1858  
    1859                         } 
    1860                 }; 
    1861  
     1843                divFiles.innerHTML = ''; 
     1844                 
    18621845                var attach_files = connector.unserialize(data.files); 
    18631846                if (attach_files != null) { 
    18641847                        openTab.countFile[border_id] = attach_files.length; 
    1865                         att_index = countCheck; 
    1866                 for (att_index; att_index < attach_files.length; att_index++){ 
    1867  
    1868                         var link_attachment = document.createElement("A"); 
    1869                         var fileName = attach_files[att_index].substr(0,attach_files[att_index].indexOf('_SIZE_')); 
    1870                         var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].indexOf('_SIZE_')+6))/1024 
    1871                         link_attachment.innerHTML = fileName + " ("+borkb((parseInt(fileSize)*1024))+")"; 
    1872  
    1873                         var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','"+(att_index+2)+"','base64'"; 
    1874  
    1875                         link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); 
    1876  
    1877                         var a_tmp = href.split(','); 
    1878                         a_tmp[2] = fileName; 
    1879                         s_tmp = escape(connector.serialize(a_tmp)); 
    1880  
    1881                         var check_attachment = document.createElement("INPUT"); 
    1882                         check_attachment.type = 'CHECKBOX'; 
    1883                         check_attachment.name = 'forwarding_attachments[]'; 
    1884                         check_attachment.value = trim(s_tmp); 
    1885  
    1886                         if (!divFiles.childNodes[0]) 
    1887                         { 
    1888                             divFiles.appendChild(document.createElement("BR")); 
    1889                         } 
    1890                         else 
    1891                             { 
    1892                                 divFiles.insertBefore(document.createElement("BR"),divFiles.childNodes[0]); 
    1893                             } 
    1894  
    1895                         divFiles.insertBefore(link_attachment,divFiles.childNodes[0]); 
    1896                         divFiles.insertBefore(check_attachment,divFiles.childNodes[0]); 
    1897  
    1898                         check_attachment.checked = true; 
    1899                 } 
    1900         } 
     1848                        for (att_index = 0; att_index < attach_files.length; att_index++){ 
     1849                 
     1850                                var link_attachment = document.createElement("a"); 
     1851                                var fileName = attach_files[att_index].substr(0, attach_files[att_index].lastIndexOf('_SIZE_')); 
     1852                                var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].lastIndexOf('_SIZE_')+6))/1024 
     1853                                link_attachment.innerHTML = fileName + " ("+parseInt(fileSize)+" kb)"; 
     1854 
     1855                                var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','0."+(att_index+1)+"','base64'"; 
     1856 
     1857                                link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); 
     1858 
     1859                                var a_tmp = href.split(','); 
     1860                                a_tmp[2] = fileName; 
     1861                                s_tmp = escape(connector.serialize(a_tmp)); 
     1862                                                 
     1863                                var check_attachment = document.createElement("input"); 
     1864                                check_attachment.type = 'checkbox'; 
     1865                                check_attachment.name = 'forwarding_attachments[]'; 
     1866                                check_attachment.value = s_tmp; 
     1867                                 
     1868                                check_attachment.checked = true; 
     1869                                check_attachment.setAttribute("checked", "checked"); 
     1870                                 
     1871                                divFiles.appendChild(check_attachment); 
     1872                                divFiles.appendChild(link_attachment); 
     1873                                divFiles.appendChild(document.createElement("br")); 
     1874                        }                        
     1875                } 
     1876                 
     1877                 
    19011878                if (message_id) 
    19021879                { 
    19031880                        cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[border_id]+"&msgs_number="+message_id,handler_delete_msg); 
    1904                         if (openTab.imapBox[0] == "INBOX/"+draftsfolder) 
     1881                        if (openTab.imapBox[0] == "INBOX" + cyrus_delimiter + draftsfolder) 
    19051882                        { 
    19061883                                //Update mailbox 
    1907                                                 var tr_msg = document.getElementById(message_id); 
     1884                                var tr_msg = document.getElementById(message_id); 
    19081885                                change_tr_properties(tr_msg, data.msg_no, data.subject); 
    19091886                        } 
    1910                 } else { 
    1911                         refresh(); 
    1912                 } 
    1913  
     1887                 
     1888                } 
    19141889                var save_link = Element("save_message_options_"+border_id); 
    19151890                save_link.onclick = ''; 
     
    19171892                watch_changes_in_msg(border_id); 
    19181893                write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name))); 
    1919         } 
     1894        }                
    19201895} 
    19211896 
Note: See TracChangeset for help on using the changeset viewer.