source: sandbox/newExpressoMail/expressoMail1_2/js/abas.js @ 7167

Revision 7167, 3.9 KB checked in by gustavo, 12 years ago (diff)

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

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1var BordersArray = new Array();
2var countBorders = 0;
3var partMsgs = new Array();
4var msgAttachments = new Array();
5var uidsSave = new Array();
6var zebraDiscardEventDialog = false;
7var saveBorderError = new Array();
8var countID = 2;
9var tab_content = "";
10var tab_role = "";
11var lastIndexSelected = 0;
12
13var ptabs = $("#ptabs").tabs({
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>",
16        add: function( event, ui ) {
17                countID++;
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)] = [];
23        },
24        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                }
36                resizeWindow();
37        },
38        cookie: {
39                expires: 1
40        },
41        select: function(event, ui) {
42                lastIndexSelected = ui.index;
43        }
44});
45
46/*
47        method : createTab
48        descrition : create a new tab
49        params : {
50                label : Label of the tab
51                * role : Tab type
52                * content : Content of the tab
53                * href : Tab id
54                * callback : a function
55        }
56        comments : {
57                #1 : if the user just set the label, a tab with blank content and a dynamic id is created
58                #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab
59                #3 : if the role is
60        * = Optional
61*/
62
63function createTab(label, role, content,href, callback){
64        if( !$("#ptabs_"+href).length){
65                tab_content = content ? content : "";
66                tab_role = role ? role : "new";
67                $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label));
68                if(typeof(callback) == 'function')
69                        callback($("#ptabs_"+(href ? href : countID)));
70                else
71                        return $("#ptabs_"+(href ? href : countID));
72        }else{
73                $(ptabs).tabs( "select", indexTab("#ptabs_"+href) );
74        }
75}
76
77/*
78        method : removeTab
79        descrition : remove a tab
80        params : {
81                * href : Tab id
82                * callback : a function
83        }
84        comments : {
85                #1 : if the user doesn't set no parameter, this function just remove the open tab
86
87        * = Optional
88*/
89
90function removeTab(href, callback){
91        ptabs.tabs("remove",
92                (
93                        href ?
94                        indexTab(href) : lastIndexSelected
95                )
96        );
97        if(typeof(callback) == 'function')
98                callback();
99}
100
101/*
102        method : indexTab
103        descrition : return a tab index
104        params : {
105                * href : Tab id
106        }
107        comments : {
108                #1 : if the user doesn't set no parameter, this function just return the index of the open tab
109
110        * = Optional
111*/
112
113function indexTab(href){
114        return href ?
115                $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
116}
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 TracBrowser for help on using the repository browser.