Ignore:
Timestamp:
09/04/12 18:07:11 (12 years ago)
Author:
gustavo
Message:

Ticket #2939 - Melhorias na exibicao das abas e da listagem de email

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/newExpressoMail/expressoMail1_2/js/abas.js

    r7064 r7167  
    88var countID = 2; 
    99var tab_content = ""; 
     10var tab_role = ""; 
    1011var lastIndexSelected = 0; 
    1112 
    1213var ptabs = $("#ptabs").tabs({  
    13         tabTemplate: "<li role='tab' style='cursor: pointer;'><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>",  
     14        tabTemplate: "<li role='tab' style='cursor: pointer;'><a href='#{href}'>#{label}</a> <span class='ui-icon tab-close ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>",  
     15        panelTemplate: "<div></div>", 
    1416        add: function( event, ui ) {  
    1517                countID++;  
    16                 $(ptabs).tabs('select', '#' + ui.panel.id);  
    17                 $.cookie('open_tabs', ($.cookie('open_tabs') ? $.cookie('open_tabs')+"," : "") +ui.panel.id.substring(6)); 
    18                 $( ui.panel ).addClass("conteudo").append(tab_content);  
     18                $(ptabs).tabs('select', '#' + $(ptabs).find("div:last").attr("id"));  
     19                $(ptabs).find("span.tab-close:last").hover(function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");}, function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");}) 
     20                $(ptabs).find("div:last").addClass("conteudo").attr("role", tab_role).append(tab_content);  
     21                if(tab_role == "new") 
     22                        uidsSave[indexTab("#"+ui.panel.id)] = []; 
    1923        }, 
    2024        show: function(event, ui){ 
     25                switch($( ui.panel ).attr("role")){ 
     26                        case "new": 
     27                        case "search": 
     28                                $("#footer_menu").hide(); 
     29                                break; 
     30                        case "message": 
     31                        case "draft": 
     32                        case "folder": 
     33                                $("#footer_menu").show(); 
     34                                break; 
     35                } 
    2136                resizeWindow(); 
    2237        }, 
     
    2944}); 
    3045 
    31 //$(ptabs).find(".ui-tabs-nav").wrap("<div class='scroll-tabs'></div>"); 
    3246/*  
    3347        method : createTab 
     
    3549        params : { 
    3650                label : Label of the tab 
     51                * role : Tab type 
    3752                * content : Content of the tab 
    3853                * href : Tab id  
     
    4257                #1 : if the user just set the label, a tab with blank content and a dynamic id is created 
    4358                #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab  
    44  
     59                #3 : if the role is  
    4560        * = Optional 
    4661*/ 
    4762 
    48 function createTab(label, content,href, callback){ 
     63function createTab(label, role, content,href, callback){ 
    4964        if( !$("#ptabs_"+href).length){ 
    5065                tab_content = content ? content : ""; 
     66                tab_role = role ? role : "new"; 
    5167                $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); 
    5268                if(typeof(callback) == 'function')  
    5369                        callback($("#ptabs_"+(href ? href : countID))); 
     70                else 
     71                        return $("#ptabs_"+(href ? href : countID)); 
    5472        }else{ 
    55                 $(ptabs).tabs( "select", indexTab(href) ); 
     73                $(ptabs).tabs( "select", indexTab("#ptabs_"+href) ); 
    5674        } 
    5775} 
     
    83101/*  
    84102        method : indexTab 
    85         descrition : remove a tab 
     103        descrition : return a tab index 
    86104        params : { 
    87105                * href : Tab id  
     
    97115                $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected; 
    98116} 
     117 
     118/* 
     119 method : idTab 
     120 descrition : remove a tab id 
     121 params : { 
     122 * index : Tab index 
     123 } 
     124 comments : { 
     125 #1 : if the user doesn't set no parameter, this function just return the id of the open tab 
     126 
     127 * = Optional 
     128 */ 
     129 
     130function idTab(index){ 
     131    return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id"); 
     132} 
     133 
     134function getTabData(index){ 
     135        return { 
     136                id : parseInt(idTab(index).substring(6).split("_r_")[0]), 
     137                folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]), 
     138                role : getTabRole(index), 
     139                header : getTabHeader(index), 
     140                content : getTabContent(index) 
     141        }; 
     142} 
     143 
     144function getTabHeader(index){ 
     145    return $( ptabs ).find('[href="#'+$( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id")+'"]').parent(); 
     146} 
     147 
     148function getTabRole(index){ 
     149        return getTabContent(index).attr("role"); 
     150} 
     151 
     152function getTabContent(index){ 
     153        return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())); 
     154} 
Note: See TracChangeset for help on using the changeset viewer.