Changeset 7897 for trunk/expressoMail1_2


Ignore:
Timestamp:
02/19/13 16:20:49 (11 years ago)
Author:
antonio
Message:

Ticket #3343 - Corrido problema ao anexar mensagens que não estão no cache.

File:
1 edited

Legend:

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

    r7892 r7897  
    47584758*/  
    47594759function attach_message (folder_name, message_number) {  
    4760         var ID = currentTab;  
    4761         var fileUploadMSG = $('#fileupload_msg'+ID);  
    4762         fileUploadMSG.find(' .attachments-list').show();  
    4763         var att = new Object();  
    4764         att.folder = folder_name;  
    4765         att.uid = message_number;  
    4766         att.type = 'imapMSG';  
    4767         /* Substituída a variável onceOpenedMessages por onceOpenedHeadersMessages,  
    4768            porque essa última contem as mesmas informações da primeira, e está em escopo global.*/  
    4769         att.name = Base64.encode(onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml');  
    4770         var idATT = JSON.stringify(att);  
    4771         addAttachment(ID, idATT);  
    4772         var attach = {};  
    4773         attach.fileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml';  
    4774         attach.fullFileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml';  
    4775         if(attach.fileName.length > 20)   
    4776         {  
    4777                 attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length - 9, attach.fileName.length);  
    4778         }  
    4779   
    4780         attach.error = false;  
    4781         attach.OK = true;  
    4782         attach.fileSize = formatBytes(onceOpenedHeadersMessages[folder_name][message_number].Size);  
    4783         var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {  
    4784                 file: attach  
    4785         }));  
    4786         $("#content_id_" + currentTab + " .save").button("enable");  
    4787         upload.find('.att-box-loading').remove();  
    4788         upload.append('<input type="hidden" name="fileId[]" value=\'' + idATT + '\'/>');  
    4789   
    4790         upload.find('.att-box-delete').click(function()  
    4791         {  
    4792                 $("#content_id_" + currentTab + " .save").button("enable");  
    4793                 var idAttach = $(this).parent().find('input[name="fileId[]"]').val();  
    4794                 fileUploadMSG.find(' .attachments-list').find('input[value="' + idAttach + '"]').remove();  
    4795                 delAttachment(ID, idAttach);  
    4796                 $(this).parent().qtip("destroy");  
    4797                 $(this).parent().remove();  
    4798                 if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length)  
    4799                 {  
    4800                         fileUploadMSG.find(' .attachments-list').hide();  
    4801                 }  
    4802         });  
    4803   
    4804         fileUploadMSG.find('.attachments-list').append(upload);  
    4805   
    4806         upload.find('.att-box-loading').remove();  
    4807   
    4808         fileUploadMSG.find('.attachments-list .att-box:last').qtip(  
    4809         {  
    4810                 content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {  
    4811                         attach: attach  
    4812                 }),  
    4813                 position: {  
    4814                         corner: {  
    4815                                 tooltip: 'bottomMiddle',  
    4816                                 target: 'topMiddle'  
    4817                         },  
    4818                         adjust: {  
    4819                                 resize: true,  
    4820                                 scroll: true  
    4821                         }  
    4822                 },  
    4823                 show: {  
    4824                         when: 'mouseover',  
    4825                         // Don't specify a show event  
    4826                         ready: false // Show the tooltip when ready  
    4827                 },  
    4828                 hide: 'mouseout',  
    4829                 // Don't specify a hide event  
    4830                 style: {  
    4831                         border: {  
    4832                                 width: 1,  
    4833                                 radius: 5  
    4834                         },  
    4835                         width: {  
    4836                                 min: 75,  
    4837                                 max: 1000  
    4838                         },  
    4839                         padding: 5,  
    4840                         textAlign: 'center',  
    4841                         tip: true,  
    4842                         // Give it a speech bubble tip with automatic corner detection  
    4843                         name: 'blue' // Style it according to the preset 'cream' style  
    4844                 }  
    4845         });  
     4760 
     4761    // Callback para caso seja necessário a mensagem não esteja no cache. 
     4762    var handler_attach_message = function (message) { 
     4763        var ID = currentTab;  
     4764        var fileUploadMSG = $('#fileupload_msg'+ID);  
     4765        fileUploadMSG.find(' .attachments-list').show();  
     4766        var att = new Object();  
     4767        att.folder = folder_name;  
     4768        att.uid = message_number;  
     4769        att.type = 'imapMSG';  
     4770        att.name = Base64.encode(message.subject + '.eml');  
     4771        var idATT = JSON.stringify(att);  
     4772        addAttachment(ID, idATT);  
     4773        var attach = {};  
     4774        attach.fileName = message.subject + '.eml';  
     4775        attach.fullFileName = message.subject + '.eml';  
     4776        if(attach.fileName.length > 20)   
     4777        {  
     4778            attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length - 9, attach.fileName.length);  
     4779        }  
     4780      
     4781        attach.error = false;  
     4782        attach.OK = true;  
     4783        attach.fileSize = formatBytes(message.Size);  
     4784        var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {  
     4785            file: attach  
     4786        }));  
     4787        $("#content_id_" + currentTab + " .save").button("enable");  
     4788        upload.find('.att-box-loading').remove();  
     4789        upload.append('<input type="hidden" name="fileId[]" value=\'' + idATT + '\'/>');  
     4790      
     4791        upload.find('.att-box-delete').click(function()  
     4792        {  
     4793            $("#content_id_" + currentTab + " .save").button("enable");  
     4794            var idAttach = $(this).parent().find('input[name="fileId[]"]').val();  
     4795            fileUploadMSG.find(' .attachments-list').find('input[value="' + idAttach + '"]').remove();  
     4796            delAttachment(ID, idAttach);  
     4797            $(this).parent().qtip("destroy");  
     4798            $(this).parent().remove();  
     4799            if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length)  
     4800            {  
     4801                fileUploadMSG.find(' .attachments-list').hide();  
     4802            }  
     4803        });  
     4804      
     4805        fileUploadMSG.find('.attachments-list').append(upload);  
     4806      
     4807        upload.find('.att-box-loading').remove();  
     4808      
     4809        fileUploadMSG.find('.attachments-list .att-box:last').qtip(  
     4810        {  
     4811            content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {  
     4812                attach: attach  
     4813            }),  
     4814            position: {  
     4815                corner: {  
     4816                    tooltip: 'bottomMiddle',  
     4817                    target: 'topMiddle'  
     4818                },  
     4819                adjust: {  
     4820                    resize: true,  
     4821                    scroll: true  
     4822                }  
     4823            },  
     4824            show: {  
     4825                when: 'mouseover',  
     4826                // Don't specify a show event  
     4827                ready: false // Show the tooltip when ready  
     4828            },  
     4829            hide: 'mouseout',  
     4830            // Don't specify a hide event  
     4831            style: {  
     4832                border: {  
     4833                    width: 1,  
     4834                    radius: 5  
     4835                },  
     4836                width: {  
     4837                    min: 75,  
     4838                    max: 1000  
     4839                },  
     4840                padding: 5,  
     4841                textAlign: 'center',  
     4842                tip: true,  
     4843                // Give it a speech bubble tip with automatic corner detection  
     4844                name: 'blue' // Style it according to the preset 'cream' style  
     4845            }  
     4846        });  
     4847    } 
     4848 
     4849    /* Substituída a variável onceOpenedMessages por onceOpenedHeadersMessages,  
     4850       porque essa última contem as mesmas informações da primeira, e está em escopo global.*/  
     4851 
     4852    // Caso a mensagem ainda não esteja no cache: 
     4853    if ((onceOpenedHeadersMessages[folder_name] === undefined) || (onceOpenedHeadersMessages[folder_name][message_number] === undefined)) 
     4854    { 
     4855        proxy_mensagens.get_msg(message_number, folder_name, '', function (data) { handler_attach_message(data); }); 
     4856    } else  
     4857    { 
     4858        handler_attach_message(onceOpenedHeadersMessages[folder_name][message_number]); 
     4859    } 
     4860 
    48464861} 
    48474862                 
Note: See TracChangeset for help on using the changeset viewer.