Changeset 6073


Ignore:
Timestamp:
05/02/12 17:02:36 (12 years ago)
Author:
gustavo
Message:

Ticket #2676 - Falha ao anexar imagens no expresso mail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/library/ckeditor/plugins/expresso/plugin.js

    r5984 r6073  
    9999}); 
    100100function bindFileUpload(e) { 
    101         var ID = currentTab; 
    102         var newImageId = new Date().getTime(); 
    103         var fileUploadIMG = $('#fileupload_img'+ID); 
    104         var fileUploadMSG = $('#fileupload_msg'+ID); 
    105         var maxAttachmentSise = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 
     101        var ID = currentTab; 
     102        var newImageId = new Date().getTime(); 
     103        var fileUploadIMG = $('#fileupload_img'+ID); 
     104        var fileUploadMSG = $('#fileupload_msg'+ID); 
     105        var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 
    106106        fileUploadIMG.fileupload({ 
    107                 sequentialUploads: true, 
     107                type: 'post', 
     108                dataType : 'json', 
     109                url: "../prototype/post.php", 
     110                forceIframeTransport: true, 
     111                formData: function(form) { 
     112                        return [ 
     113                                { 
     114                                        name : "mailAttachment[0][source]", 
     115                                        value : "files0" 
     116                                }, 
     117                                { 
     118                                        name : "mailAttachment[0][disposition]", 
     119                                        value : $('#attDisposition'+ID).val() 
     120                                }, 
     121                                { 
     122                                        name: "MAX_FILE_SIZE", 
     123                                        value : maxAttachmentSize 
     124                                } 
     125                        ]; 
     126                }, 
    108127                add: function (e, data) { 
    109128      
    110                         if(!maxAttachmentSise || data.files[0].size < maxAttachmentSise) { 
     129                        if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize) { 
    111130                                setTimeout(function() { 
    112131                                        $('#attDisposition'+ID).val('embedded'); 
     
    124143                                        attach.fileName = file.name.substr(0, 18) + "..." + file.name.substr(file.name.length-9, file.name.length); 
    125144                                attach.fileSize = formatBytes(file.size); 
    126                                 if(maxAttachmentSise && file.size > maxAttachmentSise) 
     145                                if(maxAttachmentSize && file.size > maxAttachmentSize) 
    127146                                        attach.error = 'Tamanho de arquivo nao permitido!!' 
    128147                                                                 
    129148                                fileUploadMSG.find('.attachments-list').append(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 
    130149 
    131                                 if(!maxAttachmentSise || file.size < maxAttachmentSise){ 
     150                                if(!maxAttachmentSize || file.size < maxAttachmentSize){ 
    132151                                        fileUploadMSG.find(' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
    133152                                        fileUploadMSG.find(' .attachments-list').find('[type=file]').addClass('hidden'); 
     
    168187                done: function(e, data){ 
    169188                        if(!!data.result && data.result != "[]"){ 
    170                                 var newAttach = jQuery.parseJSON(data.result); 
    171                                  
    172                                 //Compatibilidade com Firefox3.6 
    173                                     if(newAttach === null ) newAttach = jQuery.parseJSON(data.result.text()); 
    174                                  
    175                                 if(newAttach.rollback !== false) 
    176                                 { 
    177                                     fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check'); 
    178                                     addAttachment(ID,newAttach['mailAttachment'][0][0].id); 
    179                                     var content_body  = RichTextEditor.getData('body_'+ID); 
    180                                     var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i');  
    181                                     var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />';  
    182                                     content_body = content_body.replace(rex,newImg);  
    183                                     RichTextEditor.setData('body_'+ID,content_body);  
    184                                 } 
    185                                 else 
    186                                     fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
    187        
     189                                var newAttach = data.result; 
     190                                if(!newAttach.mailAttachment.error){ 
     191                                        if(newAttach.rollback !== false) 
     192                                        { 
     193                                                fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check'); 
     194                                                addAttachment(ID,newAttach['mailAttachment'][0][0].id); 
     195                                                var content_body  = RichTextEditor.getData('body_'+ID); 
     196                                                var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i');  
     197                                                var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />';  
     198                                                content_body = content_body.replace(rex,newImg);  
     199                                                RichTextEditor.setData('body_'+ID,content_body);  
     200                                        } 
     201                                        else 
     202                                                fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
     203                                }else{ 
     204                                        fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append(newAttach.mailAttachment.error).addClass('message-attach-error');    
     205                                } 
    188206                        }else { 
    189207                                    fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
Note: See TracChangeset for help on using the changeset viewer.