Changeset 4854


Ignore:
Timestamp:
07/25/11 11:06:55 (13 years ago)
Author:
roberto.santosjunior
Message:

Ticket #1820 - Salvar rascunho não grava imagem inserida.r4848

File:
1 edited

Legend:

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

    r4852 r4854  
    18371837        if (data == null || data.append != true ) 
    18381838        { 
    1839                 RichTextEditor.saveFlag = -1; 
     1839                RichTextEditor.saveFlag = 0; 
    18401840                if (! data.append) 
    1841                         write_msg('ERROR saving your message.'); 
     1841                    if(data == 'Post-Content-Length') 
     1842                        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)); 
     1843                else 
     1844                    write_msg(get_lang('ERROR saving your message.')); 
    18421845                else 
    18431846                { 
     
    18611864 
    18621865                var newTitle = document.getElementById('subject_'+border_id).value; 
    1863                 if (newTitle.length > 18) 
    1864                     newTitle = newTitle.substr(18) + '...'; 
    1865                 else if (newTitle == '') 
     1866                if (newTitle == '') 
    18661867                    newTitle = get_lang("No subject"); 
    1867                 document.getElementById('font_border_id_'+border_id).innerHTML = newTitle;  
     1868                set_border_caption('border_id_'+border_id, newTitle); 
    18681869 
    18691870                // Replace the embedded images for new uids 
    1870                 var mainField     = document.getElementById('body_'+border_id).contentWindow; 
    1871                 var content_body  = mainField.document.getElementsByTagName('body').item(0).innerHTML; 
    1872                 var body_images   = content_body.match(/msg_num=\d*/g); 
    1873                 var folder_images = content_body.match(/msg_folder=[^&]*&/g); 
    1874  
    1875                 if (body_images != null) 
     1871                var mainField = document.getElementById('body_'+border_id).contentWindow; 
     1872                var content_body =  mainField.document.getElementsByTagName('body').item(0).innerHTML; 
     1873                var body_images = content_body.match(/msg_num=\d*/g); 
     1874                var images_part = content_body.match(/msg_part=\d*/g); 
     1875                if (body_images) 
    18761876                { 
    1877                     for (var i=0; i<body_images.length; i++) 
    1878                     { 
    1879                         if( folder_images != null) 
    1880                             content_body = content_body.replace(folder_images[i], "msg_folder=INBOX" + cyrus_delimiter + draftsfolder +"&"); 
    1881  
     1877                    for (var i=0; i<body_images.length; i++){ 
    18821878                        content_body = content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); 
    18831879                    } 
    18841880 
    1885                     var images_part   = content_body.match(/msg_part=[0-9.]*/g); 
    1886  
    1887                     if(images_part != null) 
    1888                     { 
    1889                         for (var x = 0; x < images_part.length; x++) 
     1881                    var allImgs = new Array (images_part.length); 
     1882                    var j=-1; 
     1883                    for (var i in images_part){ 
     1884 
     1885                        if (is_ie) 
     1886                            if (i == 0) 
     1887                                var image_number = parseInt(images_part[i].substr(9)); 
     1888                            else 
     1889                                image_number = "null"; 
     1890                        else 
     1891                            var image_number = parseInt(images_part[i].substr(9)); 
     1892 
     1893                        if (! isNaN(image_number)) 
    18901894                        { 
    1891                             var position = images_part[x].substr(9,images_part[x].length); 
    1892                             content_body = content_body.replace(images_part[x],'msg_part(||.|||.||)='+data.imagesParts[position]); 
     1895                            if (! allImgs[image_number]) 
     1896                            { 
     1897                                allImgs[image_number] = true; 
     1898                                j--; 
     1899                            } 
     1900                            content_body = content_body.replace(images_part[i],'msg_part='+j); 
    18931901                        } 
    1894  
     1902                        content_body = content_body.replace(/msg_part=-/g,'msg_part='); 
    18951903                    } 
    1896                     content_body = content_body.replace(/msg_part\(\|\|\.\|\|\|\.\|\|\)=/g,'msg_part='); 
    1897  
    18981904                    mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; 
    18991905                } 
     
    19011907                //Replace all files to new files 
    19021908                var divFiles = Element("divFiles_"+border_id); 
    1903                 divFiles.innerHTML = ''; 
     1909                elFiles = divFiles.getElementsByTagName("input"); 
     1910                var countCheck =0; 
     1911                for (var i=0; i<elFiles.length; i++) { 
     1912                    if(elFiles[i].value !=""){ 
     1913                        if (elFiles[i].type == "checkbox") { 
     1914                            countCheck++; 
     1915                        } 
     1916                        else { 
     1917                            elFiles[i].value =""; 
     1918                            parantNodeFile = elFiles[i].parentNode.parentNode; 
     1919                            parantNodeFile.removeChild(elFiles[i].parentNode); 
     1920                            i--; 
     1921                        } 
     1922                    } 
     1923                } 
    19041924 
    19051925                var attach_files = connector.unserialize(data.files); 
    19061926                if (attach_files != null) { 
    19071927                    openTab.countFile[border_id] = attach_files.length; 
    1908                     for (att_index = 0; att_index < attach_files.length; att_index++){ 
     1928                    att_index = countCheck; 
     1929                    for (att_index; att_index < attach_files.length; att_index++) 
     1930                    { 
    19091931 
    19101932                        var link_attachment = document.createElement("a"); 
    1911                         var fileName = attach_files[att_index].substr(0, attach_files[att_index].lastIndexOf('_SIZE_')); 
    1912                         var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].lastIndexOf('_SIZE_')+6))/1024 
    1913                         link_attachment.innerHTML = fileName + " ("+parseInt(fileSize)+" kb)"; 
    1914  
    1915                         var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','0."+(att_index+1)+"','base64'"; 
     1933                        var fileName = attach_files[att_index].substr(0,attach_files[att_index].indexOf('_SIZE_')); 
     1934                        var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].indexOf('_SIZE_')+6))/1024 
     1935                        link_attachment.innerHTML = fileName + " ("+borkb((parseInt(fileSize)*1024))+")"; 
     1936 
     1937                        var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','"+(att_index+2)+"','base64'"; 
    19161938 
    19171939                        link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); 
     
    19211943                        s_tmp = escape(connector.serialize(a_tmp)); 
    19221944 
    1923                         var check_attachment = document.createElement("input"); 
    1924                         check_attachment.type = 'checkbox'; 
    1925                         check_attachment.name = 'forwarding_attachments[]'; 
    1926                         check_attachment.value = s_tmp; 
     1945                        var check_attachment = document.createElement("INPUT"); 
     1946                        check_attachment.type = 'CHECKBOX'; 
     1947                        check_attachment.name = 'forwarding_attachments[]'; 
     1948                        check_attachment.value = trim(s_tmp); 
     1949 
     1950                        if (!divFiles.childNodes[0]) 
     1951                        { 
     1952                            divFiles.appendChild(document.createElement("BR")); 
     1953                        } 
     1954                        else 
     1955                            { 
     1956                                divFiles.insertBefore(document.createElement("BR"),divFiles.childNodes[0]); 
     1957                            } 
     1958 
     1959                        divFiles.insertBefore(link_attachment,divFiles.childNodes[0]); 
     1960                        divFiles.insertBefore(check_attachment,divFiles.childNodes[0]); 
    19271961 
    19281962                        check_attachment.checked = true; 
     
    19441978                        change_tr_properties(tr_msg, data.msg_no, data.subject); 
    19451979                    } 
    1946                  
     1980                } else { 
     1981                    refresh(); 
    19471982                } 
    19481983 
Note: See TracChangeset for help on using the changeset viewer.