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

Revision 7043, 2.4 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><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/*
33        method : createTab
34        descrition : create a new tab
35        params : {
36                label : Label of the tab
37                * content : Content of the tab
38                * href : Tab id
39                * callback : a function
40        }
41        comments : {
42                #1 : if the user just set the label, a tab with blank content and a dynamic id is created
43                #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab
44
45        * = Optional
46*/
47
48function createTab(label, content,href, callback){
49        if( !$("#ptabs_"+href).length){
50                tab_content = content ? content : "";
51                $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label));
52                if(typeof(callback) == 'function')
53                        callback();
54        }else{
55                $(ptabs).tabs( "select", indexTab(href) );
56        }
57}
58
59
60/*
61        method : removeTab
62        descrition : remove a tab
63        params : {
64                * href : Tab id
65                * callback : a function
66        }
67        comments : {
68                #1 : if the user doesn't set no parameter, this function just remove the open tab
69
70        * = Optional
71*/
72
73function removeTab(href, callback){
74        ptabs.tabs("remove",
75                (
76                        href ?
77                        indexTab(href) : lastIndexSelected
78                )
79        );
80        if(typeof(callback) == 'function')
81                callback();
82}
83
84
85/*
86        method : indexTab
87        descrition : remove a tab
88        params : {
89                * href : Tab id
90        }
91        comments : {
92                #1 : if the user doesn't set no parameter, this function just return the index of the open tab
93
94        * = Optional
95*/
96
97function indexTab(href){
98        return href ?
99                $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
100}
Note: See TracBrowser for help on using the repository browser.