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

Revision 7046, 2.5 KB checked in by gustavo, 12 years ago (diff)

Ticket #2911 - Melhoria na disposição e exibição das abas

  • 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 lastIndexSelected = 0;
11
12var ptabs = $("#ptabs").tabs({
13        tabTemplate: "<li role='tab'><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>",
14        add: function( event, ui ) {
15                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);
19        },
20        show: function(event, ui){
21                resizeWindow();
22        },
23        cookie: {
24                expires: 1
25        },
26        select: function(event, ui) {
27                console.log(ui.index);
28                lastIndexSelected = ui.index;
29        }
30});
31
32//$(ptabs).find(".ui-tabs-nav").wrap("<div class='scroll-tabs'></div>");
33/*
34        method : createTab
35        descrition : create a new tab
36        params : {
37                label : Label of the tab
38                * content : Content of the tab
39                * href : Tab id
40                * callback : a function
41        }
42        comments : {
43                #1 : if the user just set the label, a tab with blank content and a dynamic id is created
44                #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab
45
46        * = Optional
47*/
48
49function createTab(label, content,href, callback){
50        if( !$("#ptabs_"+href).length){
51                tab_content = content ? content : "";
52                $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label));
53                if(typeof(callback) == 'function')
54                        callback($("#ptabs_"+(href ? href : countID)));
55        }else{
56                $(ptabs).tabs( "select", indexTab(href) );
57        }
58}
59
60
61/*
62        method : removeTab
63        descrition : remove a tab
64        params : {
65                * href : Tab id
66                * callback : a function
67        }
68        comments : {
69                #1 : if the user doesn't set no parameter, this function just remove the open tab
70
71        * = Optional
72*/
73
74function removeTab(href, callback){
75        ptabs.tabs("remove",
76                (
77                        href ?
78                        indexTab(href) : lastIndexSelected
79                )
80        );
81        if(typeof(callback) == 'function')
82                callback();
83}
84
85
86/*
87        method : indexTab
88        descrition : remove a tab
89        params : {
90                * href : Tab id
91        }
92        comments : {
93                #1 : if the user doesn't set no parameter, this function just return the index of the open tab
94
95        * = Optional
96*/
97
98function indexTab(href){
99        return href ?
100                $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
101}
Note: See TracBrowser for help on using the repository browser.