Changeset 6410 for trunk


Ignore:
Timestamp:
06/04/12 16:28:29 (12 years ago)
Author:
cristiano
Message:

Ticket #2832 - Erro ao anexar imagens embarcadas, abrindo e fechando a mesma aba

File:
1 edited

Legend:

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

    r6074 r6410  
    6363                CKEDITOR.dialog.add( 'imgDialog', function( api ) 
    6464                { 
    65                         var ID = currentTab; 
     65            var ID = currentTab; 
    6666                        // CKEDITOR.dialog.definition 
    6767                        var dialogDefinition = 
    6868                        { 
    6969                                 
    70                                 title : 'Inserir Imagem', 
     70                title : 'Inserir Imagem', 
    7171                                minWidth : 400, 
    7272                                minHeight : 70, 
     
    8282                                                        { 
    8383                                                                type : 'html', 
    84                                                                 html :  '<form id="fileupload_img'+ID+'" class="fileupload" action="mailAttachment:img" method="POST">    <input type="file" name="files[]" multiple="" onclick="bindFileUpload();" style="margin-left:10px"></form>'  
     84                                                                html :  '<form id="fileupload_img'+ID+'" class="fileupload" action="mailAttachment:img" method="POST">    <input type="file" name="files[]"  onclick="bindFileUpload(this);" style="margin-left:10px"></form>'  
    8585                                                        } 
    8686                                                ] 
     
    100100function bindFileUpload(e) { 
    101101        var ID = currentTab; 
    102         var newImageId = new Date().getTime(); 
    103         var fileUploadIMG = $('#fileupload_img'+ID); 
     102        var fileUploadIMG = $(e).parents('form'); 
    104103        var fileUploadMSG = $('#fileupload_msg'+ID); 
    105104        var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 
     
    133132                                }, 5000); 
    134133                        } 
    135                          
    136                 }, 
    137                 change: function (e, data) { 
     134 
    138135                        $.each(data.files, function (index, file) {      
    139136                                var attach = {}; 
     
    146143                                        attach.error = 'Tamanho de arquivo nao permitido!!' 
    147144                                                                 
    148                                 fileUploadMSG.find('.attachments-list').append(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 
    149  
    150                                 if(!maxAttachmentSize || file.size < maxAttachmentSize){ 
    151                                         fileUploadMSG.find(' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
    152                                         fileUploadMSG.find(' .attachments-list').find('[type=file]').addClass('hidden'); 
    153                                          
    154                                 }else 
    155                                         fileUploadMSG.find(' .fileinput-button.new').removeClass('new'); 
    156                                  
    157                                  
    158                                 fileUploadMSG.find(' .attachments-list').find('.button.close').button({ 
     145                                var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach}));    
     146 
     147                                upload.find('.button.close').button({ 
    159148                                        icons: { 
    160149                                                primary: "ui-icon-close" 
     
    164153                                        var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
    165154                         
    166                                         var content_body = RichTextEditor.getData('body_'+ID); 
    167                                         var imagens = content_body.match(/<img[^>]*>/g); 
     155                    var content_body = RichTextEditor.getData('body_'+ID); 
     156                    var imagens = content_body.match(/<img[^>]*>/g); 
    168157        
    169                                         if(imagens != null) 
    170                                             for (var x = 0; x < imagens.length; x++) 
    171                                                 if(imagens[x].indexOf('src="../prototype/getArchive.php?mailAttachment='+idAttach+'"') !== -1) 
    172                                                         content_body = content_body.replace(imagens[x],''); 
     158                    if(imagens != null) 
     159                        for (var x = 0; x < imagens.length; x++) 
     160                            if(imagens[x].indexOf('src="../prototype/getArchive.php?mailAttachment='+idAttach+'"') !== -1) 
     161                                content_body = content_body.replace(imagens[x],''); 
    173162          
    174                                         RichTextEditor.setData('body_'+ID,content_body);    
     163                    RichTextEditor.setData('body_'+ID,content_body);    
    175164                                         
    176                                         $('.attachments-list').find('input[value="'+idAttach+'"]').remove(); 
    177                                         delAttachment(ID, idAttach); 
     165                    $('.attachments-list').find('input[value="'+idAttach+'"]').remove(); 
     166                    delAttachment(ID, idAttach); 
    178167                                        $(this).parent().remove(); 
    179168                                }); 
    180169                                 
    181                                 CKEDITOR.instances['body_'+ID].insertHtml('<img id="'+newImageId+'" src=""/>'); 
    182  
    183                 }); 
     170            fileUploadMSG.find('.attachments-list').append(upload); 
     171 
     172                        if(!maxAttachmentSize || file.size < maxAttachmentSize){ 
     173                                if(data.fileInput){ 
     174                                        fileUploadMSG.find('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
     175                                        fileUploadMSG.find('.attachments-list').find('[type=file]').addClass('hidden');  
     176                                } 
     177                        }else 
     178                                fileUploadMSG.find(' .fileinput-button.new').removeClass('new'); 
     179                                                                 
     180                CKEDITOR.instances['body_'+ID].insertHtml('<img src=""/>'); 
     181 
     182                        }); 
    184183                 
    185                     CKEDITOR.dialog.getCurrent().hide(); 
    186                 }, 
     184            CKEDITOR.dialog.getCurrent().hide();         
     185                         
     186                }, 
    187187                done: function(e, data){ 
    188188                        if(!!data.result && data.result != "[]"){ 
     
    194194                                                addAttachment(ID,newAttach['mailAttachment'][0][0].id); 
    195195                                                var content_body  = RichTextEditor.getData('body_'+ID); 
    196                                                 var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i');  
     196                                                var rex = new RegExp('<img src="" [^\/>]*\/>', 'i');  
    197197                                                var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />';  
    198198                                                content_body = content_body.replace(rex,newImg);  
     
    204204                                        fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append(newAttach.mailAttachment.error).addClass('message-attach-error');    
    205205                                } 
    206                         }else { 
    207                                     fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
     206                        }else  
     207                        { 
     208                fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
    208209                        } 
    209210                        fileUploadMSG.find('.in-progress:first').remove(); 
Note: See TracChangeset for help on using the changeset viewer.