Ignore:
Timestamp:
08/03/12 15:32:43 (12 years ago)
Author:
gustavo
Message:

Ticket #2954 - Merge de algumas novas funcionalidades da nova versão, #2953, #2971

File:
1 edited

Legend:

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

    r6410 r6930  
    125125                }, 
    126126                add: function (e, data) { 
    127       
     127            var iterator = idattachbycontent; 
    128128                        if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize || is_ie) { 
    129129                                setTimeout(function() { 
    130130                                        $('#attDisposition'+ID).val('embedded'); 
    131                                         data.submit(); 
    132                                 }, 5000); 
     131                                        jqXHR[iterator] = data.submit(); 
     132                                }, 100); 
    133133                        } 
    134  
     134            fileUploadMSG.find(' .attachments-list').show(); 
    135135                        $.each(data.files, function (index, file) {      
    136136                                var attach = {}; 
    137137                                attach.fullFileName = file.name; 
    138138                                attach.fileName = file.name; 
    139                                 if(file.name.length > 10) 
    140                                         attach.fileName = file.name.substr(0, 18) + "..." + file.name.substr(file.name.length-9, file.name.length); 
     139                                if(file.name.length > 20) 
     140                                        attach.fileName = file.name.substr(0, 17) + "..." + file.name.substr(file.name.length-9, file.name.length); 
    141141                                attach.fileSize = formatBytes(file.size); 
    142142                                if(maxAttachmentSize && file.size > maxAttachmentSize) 
    143143                                        attach.error = 'Tamanho de arquivo nao permitido!!' 
    144                                                                  
     144                                else 
     145                    attach.error = true; 
    145146                                var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach}));    
    146147 
    147                                 upload.find('.button.close').button({ 
    148                                         icons: { 
    149                                                 primary: "ui-icon-close" 
    150                                         }, 
    151                                         text: false 
    152                                 }).click(function(){ 
     148                                upload.find('.att-box-delete').click(function(){ 
    153149                                        var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
    154150                         
     
    165161                    $('.attachments-list').find('input[value="'+idAttach+'"]').remove(); 
    166162                    delAttachment(ID, idAttach); 
    167                                         $(this).parent().remove(); 
     163                                        $(this).parent().qtip("destroy"); 
     164                    $(this).parent().remove(); 
     165                    if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){ 
     166                        fileUploadMSG.find(' .attachments-list').hide(); 
     167                    } 
     168                    if(jqXHR){ 
     169                        jqXHR[iterator].abort(); 
     170                    } 
    168171                                }); 
    169172                                 
    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                                                                  
     173                fileUploadMSG.find('.attachments-list').append(upload); 
     174                fileUploadMSG.find('.attachments-list .att-box:last').qtip({ 
     175                    content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}), 
     176                    position: { 
     177                        corner: { 
     178                            tooltip: 'bottomMiddle', 
     179                            target: 'topMiddle' 
     180                        }, 
     181                        adjust: { 
     182                           resize: true, 
     183                           scroll: true, 
     184                           screen: show 
     185                        } 
     186                    }, 
     187                    show: { 
     188                        when: 'mouseover', // Don't specify a show event 
     189                        ready: false // Show the tooltip when ready 
     190                    }, 
     191                    hide: 'mouseout', // Don't specify a hide event 
     192                    style: { 
     193                        border: { 
     194                            width: 1, 
     195                            radius: 5 
     196                        }, 
     197                        width: { 
     198                             min: 75, 
     199                             max : 1000 
     200                        }, 
     201                        padding: 3,  
     202                        textAlign: 'left', 
     203                        tip: true, // Give it a speech bubble tip with automatic corner detection 
     204                        name: (typeof(attach.error) == 'boolean' ? 'light' : 'red') // Style it according to the preset 'cream' style 
     205                    } 
     206                }); 
     207                        if(!maxAttachmentSize || file.size < maxAttachmentSize){ 
     208                                if(data.fileInput){ 
     209                                        fileUploadMSG.find('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
     210                                        fileUploadMSG.find('.attachments-list').find('[type=file]').addClass('hidden');  
     211                                } 
     212                        }else{ 
     213                                fileUploadMSG.find(' .fileinput-button.new').removeClass('new'); 
     214                        }                                        
    180215                CKEDITOR.instances['body_'+ID].insertHtml('<img src=""/>'); 
    181  
     216                idattachbycontent++;  
    182217                        }); 
    183218                 
    184219            CKEDITOR.dialog.getCurrent().hide();         
    185                          
     220                        
    186221                }, 
    187222                done: function(e, data){ 
    188                         if(!!data.result && data.result != "[]"){ 
    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 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');    
     223            var attach_box = fileUploadMSG.find('.att-box-loading:first').parents('.att-box'); 
     224            var attach = { 
     225                fullFileName : attach_box.find(".att-box-fullfilename").text(), 
     226                fileSize : attach_box.find(".att-box-filesize").text(), 
     227                OK : true, 
     228                error : false 
     229            }; 
     230            if(!!data.result && data.result != "[]" ){ 
     231                var newAttach = data.result;                              
     232                if(!newAttach.mailAttachment.error || newAttach.rollback !== false){ 
     233                                        attach_box.append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>'); 
     234                                        addAttachment(ID,newAttach['mailAttachment'][0][0].id); 
     235                                        var content_body  = RichTextEditor.getData('body_'+ID); 
     236                                        var rex = new RegExp('<img src="" [^\/>]*\/>', 'i');  
     237                                        var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />';  
     238                                        content_body = content_body.replace(rex,newImg);  
     239                                        RichTextEditor.setData('body_'+ID,content_body);  
    203240                                }else{ 
    204                                         fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append(newAttach.mailAttachment.error).addClass('message-attach-error');    
    205                                 } 
    206                         }else  
    207                         { 
    208                 fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');    
    209                         } 
    210                         fileUploadMSG.find('.in-progress:first').remove(); 
    211                      
     241                                        attach_box.addClass('invalid-email-box'); 
     242                    attach.error = newAttach.mailAttachment.error ? newAttach.mailAttachment.error : 'Erro ao anexar...'; 
     243                } 
     244                        }else { 
     245                attach_box.addClass('invalid-email-box'); 
     246                attach.error = 'Erro ao anexar...'; 
     247            } 
     248            attach_box.qtip("destroy").qtip({ 
     249                content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}), 
     250                position: { 
     251                    corner: { 
     252                        tooltip: 'bottomMiddle', 
     253                        target: 'topMiddle' 
     254                    }, 
     255                    adjust: { 
     256                       resize: true, 
     257                       scroll: true, 
     258                       screen: show 
     259                    } 
     260                }, 
     261                show: { 
     262                    when: 'mouseover', // Don't specify a show event 
     263                    ready: false // Show the tooltip when ready 
     264                }, 
     265                hide: 'mouseout', // Don't specify a hide event 
     266                style: { 
     267                    border: { 
     268                        width: 1, 
     269                        radius: 5 
     270                    }, 
     271                    width: { 
     272                         min: 75, 
     273                         max : 1000 
     274                    }, 
     275                    padding: 3,  
     276                    textAlign: 'left', 
     277                    tip: true, // Give it a speech bubble tip with automatic corner detection 
     278                    name: (attach.error == false ? 'blue' : 'red')// Style it according to the preset 'cream' style 
     279                } 
     280            }); 
     281            fileUploadMSG.find(' .att-box-loading:first').remove(); 
    212282                } 
    213283        }); 
Note: See TracChangeset for help on using the changeset viewer.