Ignore:
Timestamp:
07/05/12 10:29:43 (12 years ago)
Author:
gustavo
Message:

Ticket #2939 - Melhorias na exibição das abas e da listagem de email

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/novoExpressoMail/expressoMail1_2/js/draw_api.js

    r6698 r6711  
    10731073        numBox = 0; //As pastas sempre estarão na aba 0 
    10741074         
    1075         openTab.content_id[numBox] = document.getElementById("content_id_"+numBox); 
     1075        openTab.content_id[numBox] = document.getElementById("ptabs_"+numBox); 
    10761076        openTab.content_id[numBox].innerHTML = ""; 
    10771077        openTab.imapBox[numBox] = msg_folder; 
     
    13611361        var tdFolders  =  Element("folderscol"); 
    13621362        tdFolders.style.display = preferences.hide_folders == '1'  ? "none" : ""; 
    1363         if ( !currentTab ) 
    1364                 alternate_border(numBox); 
     1363 
    13651364        draw_footer_box(headers_msgs.num_msgs); 
    13661365        Element('main_table').style.display = ''; 
     
    13681367                setTimeout("resizeWindow()",1); 
    13691368        else 
    1370                 resizeWindow(); 
     1369                //resizeWindow(); 
    13711370        if(debug) { 
    13721371                var _eTime = new Date(); 
     
    14031402                Element('msg_number').value = ''; 
    14041403        } 
     1404        $("#ptabs_0")//.empty().html("<table style='height: 618px;'></table>") 
     1405                .find("table:first").remove();   
     1406                $("#ptabs_0")//.empty().html("<table style='height: 618px;'></table>") 
     1407                .html(DataLayer.render(BASE_PATH + 'api/templates/messagegrid.ejs', {})) 
     1408                .find("#message_attacher_grid") 
     1409                .jqGrid({ 
     1410                        url:BASE_PATH + 'REST.php?q=folder/INBOX/message', 
     1411                        datatype: "json", 
     1412                        mtype: 'GET', 
     1413                        colNames:['#',' ', 'De', 'Assunto', 'Data', 'Tamanho'], 
     1414                        colModel:[ 
     1415                                {name:'msg_number',index:'msg_number', width:"10%", hidden:true, sortable:false}, 
     1416                                {name:'flags',index:'msg_number',edittype: 'image', width:"10%", sortable:false, formatter:pflags2Class, title :false}, 
     1417                                {name:'from.name',index:'msg_number', width:"25%", sortable:false, formatter:pNormaliseFrom}, 
     1418                                {name:'subject',index:'subject', width:"60%", sortable:false,formatter:pNormaliseSubject}, 
     1419                                {name:'timestamp',index:'timestamp', width:"10%", align:"center", sortable:false, formatter:pdate2Time}, 
     1420                                {name:'size',index:'size', width:"10%", align:"center", sortable:false, formatter:pbytes2Size} 
     1421                        ], 
     1422                        jsonReader : { 
     1423                                  root:"rows", 
     1424                                  page: "page", 
     1425                                  total: "total", 
     1426                                  records: "records", 
     1427                                  repeatitems: false, 
     1428                                  id: "0" 
     1429                        }, 
     1430                        rowNum:50, 
     1431                        rowList:[10,25,50], 
     1432                        pager: '#message_attacher_grid_pager', 
     1433                        //sortname: 'id', 
     1434                        //viewrecords: true, 
     1435                        //sortorder: "desc", 
     1436                        multiselect: true, 
     1437                        autowidth: true, 
     1438                        height : '600px', 
     1439                        //shrinkToFit: false, 
     1440                        //width: 1300, 
     1441                        //toppager : true, 
     1442                        loadComplete: function(data) { 
     1443                                var lastLoadedMessages = data.rows; 
     1444                                 
     1445                                // aplica o contador 
     1446                                jQuery('.timable').each(function (i) { 
     1447                                        jQuery(this).countdown({ 
     1448                                                since: new Date(parseInt(this.title)),  
     1449                                                significant: 1, 
     1450                                                layout: 'h&aacute; {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}',  
     1451                                                description: ' atr&aacute;s' 
     1452                                        });                                      
     1453                                }); 
     1454                                /* 
     1455                                // reconstrói a seleção das mensagens mesmo depois da mudança de pasta 
     1456                                if (selectedMessages[selectedFolder.id]) { 
     1457                                        for (var message in selectedMessages[selectedFolder.id]){ 
     1458                                                for (var j=0; j<data.rows.length; j++){  
     1459                                                        if (selectedMessages[selectedFolder.id][message] && message == data.rows[j].msg_number) { 
     1460                                                                jQuery("#message_attacher_grid").setSelection(jQuery("#message_attacher_grid").getDataIDs()[j], false); 
     1461                                                        } 
     1462                                                } 
     1463                                        } 
     1464                                }*/ 
     1465                                $('#cb_message_attacher_grid').css('display', 'none'); 
     1466                                 
     1467                        } 
     1468                }); 
     1469        //$("#ptabs").find(".ui-tabs-nav li:first").addClass("ui-state-disabled"); 
     1470        //$("#ptabs").find(".ui-tabs-nav").sortable({ axis: "x",cancel: ".ui-state-disabled" });                 
     1471        $("#selected_messages_counter").remove(); 
    14051472        var scripts = new Array("InfoContact", 
    14061473                                                        "TreeShow"); 
     
    14171484                ruler_element.className = "table_message_ruler"; 
    14181485                ruler_element.style.top = getColumnPosition(document.getElementById("content_id_0"),"BODY")[1]; 
    1419                 document.getElementById("exmail_main_body").appendChild(ruler_element); 
    1420     } 
    1421                                  
    1422 } 
    1423  
     1486                //document.getElementById("exmail_main_body").appendChild(ruler_element); 
     1487    }    
     1488    resizeWindow(); 
     1489} 
     1490punorphanize = function(root, element) { 
     1491        var ok = false; 
     1492        for (var i=0; i<root.length; i++) { 
     1493                if (root[i].id == element.parentFolder) { 
     1494                        element.children = new Array();  
     1495                        root[i].children.push(element); 
     1496                        return true; 
     1497                } else if (ok = unorphanize(root[i].children, element)) { 
     1498                        break; 
     1499                } 
     1500        } 
     1501 
     1502        return ok; 
     1503} 
     1504 
     1505/* --- helpers --- */ 
     1506pbytes2Size = function(bytes) { 
     1507        var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; 
     1508        if (bytes == 0) return 'n/a'; 
     1509        var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); 
     1510        var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100; 
     1511        return  size + ' ' + sizes[i]; 
     1512} 
     1513 
     1514pflags2Class = function(cellvalue, options, rowObject) { 
     1515        var classes = '';        
     1516        cellvalue = cellvalue.split(','); 
     1517        cell = { 
     1518                        Unseen: parseInt(cellvalue[0])  ? 'Unseen' : 'Seen',  
     1519                        Answered: parseInt(cellvalue[1]) ? 'Answered' : (parseInt(cellvalue[2]) ? 'Forwarded' : ''),  
     1520                        Flagged: parseInt(cellvalue[3]) ? 'Flagged' : '', 
     1521                        Recent: parseInt(cellvalue[4])  ? 'Recent' : '',                         
     1522                        Draft: parseInt(cellvalue[5]) ? 'Draft' : ''             
     1523                }; 
     1524        for(var flag in cell){ 
     1525                classes += '<span class="flags '+ (cell[flag]).toLowerCase() + '"' + (cell[flag] != "" ? 'title="'+ get_lang(cell[flag])+'"' : '')+'> </span>';  
     1526        } 
     1527        if(rowObject.labels){    
     1528                var titles = []; 
     1529                var count = 0; 
     1530                 for(i in rowObject.labels){ 
     1531                        titles[count] = " "+rowObject.labels[i].name; 
     1532                        count++; 
     1533                } 
     1534                titles = titles.join(); 
     1535                classes += '<span class="flags labeled" title="'+titles+'"> </span>'; 
     1536        }else{ 
     1537                classes += '<span class="flags"> </span>'; 
     1538        } 
     1539         
     1540        if(rowObject.followupflagged){           
     1541                if(rowObject.followupflagged.followupflag.id < 7){ 
     1542                        var nameFollowupflag = get_lang(rowObject.followupflagged.followupflag.name); 
     1543                }else{ 
     1544                        var nameFollowupflag = rowObject.followupflagged.followupflag.name; 
     1545                } 
     1546                if(rowObject.followupflagged.isDone == 1){ 
     1547                        classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img style=" margin-left:-3px;" src="../prototype/modules/mail/img/flagChecked.png"></span>'; 
     1548                }else{                   
     1549                        classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img src="../prototype/modules/mail/img/flagEditor.png"></span>'; 
     1550                } 
     1551                 
     1552        } 
     1553 
     1554        return classes; 
     1555} 
     1556 
     1557function numberMonths (months){ 
     1558        switch(months){ 
     1559                case 'Jan': 
     1560                        return 1; 
     1561                case 'Feb': 
     1562                        return 2; 
     1563                case 'Mar': 
     1564                        return 3; 
     1565                case 'Apr': 
     1566                        return 4; 
     1567                case 'May': 
     1568                        return 5; 
     1569                case 'June': 
     1570                        return 6; 
     1571                case 'July': 
     1572                        return 7; 
     1573                case 'Aug': 
     1574                        return 8; 
     1575                case 'Sept': 
     1576                        return 9; 
     1577                case 'Oct': 
     1578                        return 10; 
     1579                case 'Nov': 
     1580                        return 11; 
     1581                case 'Dec': 
     1582                        return 12; 
     1583        }        
     1584} 
     1585 
     1586pNormaliseFrom = function(cellvalue, options, rowObject) { 
     1587        rowObject['flags'] = rowObject['flags'].split(","); 
     1588        if(rowObject['flags'][rowObject['flags'].length-1] ==  1){ 
     1589                return get_lang(special_folders["Drafts"]); 
     1590        } 
     1591        return cellvalue;        
     1592} 
     1593 
     1594pNormaliseSubject = function(cellvalue, options, rowObject) { 
     1595        return html_entities(cellvalue); 
     1596} 
     1597 
     1598pdate2Time = function (timestamp) { 
     1599        date = new Date(); 
     1600        dat = new Date(timestamp); 
     1601        if ((date.getTime() - timestamp) < (24*60*60*1000)) { 
     1602                return '<span class="timable" title="'+dat.getTime()+'"></span>'; 
     1603        } else { 
     1604                date = new Date(timestamp); 
     1605                if(is_ie){ 
     1606                        var b = date.toString().split(' '); 
     1607                        var c = b[2] + "/" + numberMonths(b[1]) + "/" + b[5]; 
     1608                        return '<span class="datable">' + c + '</span>'; 
     1609                }else{ 
     1610                        var b = date.toISOString().split("T")[0].split("-"); 
     1611                        var c = b[2] + "/" + b[1] + "/" + b[0]; 
     1612                        return '<span class="datable">' + c + '</span>'; 
     1613                } 
     1614        } 
     1615} 
    14241616function showEmptyBoxMsg(tbody_element) { 
    14251617        document.getElementById("table_message_header_box_"+numBox).emptyBody = true; 
     
    41874379                });      
    41884380        } 
    4189         var ID = create_border("",border_ID); 
    4190          
    4191         if (ID == 0) 
     4381        //var ID = create_border("",border_ID); 
     4382        tab_content = DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: ID+1}); 
     4383 
     4384        ptabs.tabs("add", "#ptabs_"+(ID+1), "Nova Mensagem"); 
     4385 
     4386 
     4387                //ID = 5; 
     4388        var thisID = ID; 
     4389        if (thisID == 0) 
    41924390                return 0; 
    4193         else if(ID == 'maximo') 
     4391        else if(thisID == 'maximo') 
    41944392                return 'maximo'; 
    41954393                 
     
    41994397                $("#footer_menu").css('display','none'); 
    42004398        } 
    4201         var content = $("#content_id_"+ID).html(DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: ID}));     
    4202         RichTextEditor.loadEditor2(ID); 
     4399        var content = $("#ptabs_"+thisID).html(DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: thisID}));     
     4400        RichTextEditor.loadEditor2(thisID); 
    42034401         
    42044402        //if(!expresso_offline) 
     
    42284426                if(!field.find("textarea").hasClass("track")){ 
    42294427                        field.find("textarea").css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("track");   
    4230                         input_binds(field.find(".email-area"), ID); 
     4428                        input_binds(field.find(".email-area"), thisID); 
    42314429                } 
    42324430        }  
    42334431         
    4234         input_binds(content.find('[name="input_aux_to"]').css("max-width" , parseInt(content.find(".email-area").css("width"))-5).focus().parent().css({"max-height" : "115px", "overflow-y" : "auto"}), ID);    
     4432        input_binds(content.find('[name="input_aux_to"]').css("max-width" , parseInt(content.find(".email-area").css("width"))-5).focus().parent().css({"max-height" : "115px", "overflow-y" : "auto"}), thisID);        
    42354433         
    42364434        //Botão TextoRico/TextoSimples 
    42374435        content.find(".new-msg-head-right-buttons").find(".button").button().filter(".rich-button").click(function(){ 
    4238                 /*Se o texto do botão for "Texto simples" exibirá a mensagem antes de alterar para texto simples*/ 
    4239                 if($(".rich-button").find("span").text() == get_lang("Simple Text")){ 
    4240                         $.Zebra_Dialog(get_lang("Convert this message into plain text can make parts of it are removed. Continue?"), { 
    4241                     'type':     'warning', 
    4242                     'overlay_opacity': '0.5', 
    4243                     'buttons':  ['OK','Cancelar'], 
    4244                     'width' : 380, 
    4245                     'onClose':  function(clicked) { 
    4246                         if(clicked == 'OK'){ 
    4247                                 RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), ID); 
    4248                                 $(".rich-button").find("span").text(get_lang("Rich Text")); 
    4249                         }  
    4250                     } 
    4251                         }) 
    4252                 } 
    4253                 /*Se o texto do botão for "Texto rico" simplesmente altera para texto rico*/ 
    4254                 else{ 
    4255                         RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), ID); 
    4256                         $(".rich-button").find("span").text(get_lang("Simple Text")); 
    4257                 } 
     4436                //RichTextEditor.loadEditor2(ID); 
     4437                RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), thisID); 
     4438                change_text($(this).find(".ui-button-text"), get_lang("Rich Text"), get_lang("Simple Text")); 
    42584439        }) 
    42594440         
     
    42754456                } 
    42764457        }).click(function(){ 
    4277                 send_message(ID,preferences.save_in_folder,null); 
     4458                send_message(thisID,preferences.save_in_folder,null); 
    42784459        }) 
    42794460        //BOTAO SALVAR E ENVIAR 
     
    42834464                } 
    42844465        }).click(function(){ 
    4285                 wfolders.makeWindow(ID,"send_and_file"); 
     4466                wfolders.makeWindow(thisID,"send_and_file"); 
    42864467        }) 
    42874468        //BOTAO SALVAR 
     
    42914472                } 
    42924473        }).click(function(){ 
    4293                 save_msg(ID); 
     4474                save_msg(thisID); 
    42944475        }) 
    42954476        //BOTAO CONF. LEITURA 
     
    43304511        }); 
    43314512         
    4332         content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:ID})); 
    4333         var fileUploadMSG = $('#fileupload_msg'+ID); 
     4513        content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:thisID})); 
     4514        var fileUploadMSG = $('#fileupload_msg'+thisID); 
    43344515        var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 
    43354516         
     
    43614542                        if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize || is_ie) { 
    43624543                                setTimeout(function() { 
    4363                     $('#attDisposition'+ID).val('attachment'); 
     4544                    $('#attDisposition'+thisID).val('attachment'); 
    43644545                                        data.submit(); 
    43654546                                }, 3000); 
     
    43844565                                        var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
    43854566                                        fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]').remove(); 
    4386                                         delAttachment(ID, idAttach) 
     4567                                        delAttachment(thisID, idAttach) 
    43874568                                        $(this).parent().remove(); 
    43884569                                }); 
     
    44064587                                        { 
    44074588                                                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'); 
    4408                                                 addAttachment(ID,newAttach['mailAttachment'][0][0].id); 
     4589                                                addAttachment(thisID,newAttach['mailAttachment'][0][0].id); 
    44094590                                        } 
    44104591                                        else                              
     
    44524633                                                        att.name = Base64.encode(onceOpenedMessages[folder_name][message_number].subject + '.eml'); 
    44534634                                                        var idATT = JSON.stringify(att); 
    4454                                                         addAttachment( ID , idATT);                         
     4635                                                        addAttachment( thisID , idATT);                         
    44554636                                                        var attach = {}; 
    44564637                                                        attach.fileName = onceOpenedMessages[folder_name][message_number].subject + '.eml'; 
     
    44724653                                                                                var idAttach = $(this).parents("li:first").find('input[name="fileId[]"]').val(); 
    44734654                                                                                fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]'); 
    4474                                                                                 delAttachment(ID,idAttach);  
     4655                                                                                delAttachment(thisID,idAttach);  
    44754656                                                                                $(this).parent().remove(); 
    44764657                                                        });      
     
    44894670                }); 
    44904671        }); 
    4491         return ID; 
     4672        return thisID; 
    44924673} 
    44934674 
Note: See TracChangeset for help on using the changeset viewer.