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

Revision 7064, 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' style='cursor: pointer;'><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                lastIndexSelected = ui.index;
28        }
29});
30
31//$(ptabs).find(".ui-tabs-nav").wrap("<div class='scroll-tabs'></div>");
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($("#ptabs_"+(href ? href : countID)));
54        }else{
55                $(ptabs).tabs( "select", indexTab(href) );
56        }
57}
58
59/*
60        method : removeTab
61        descrition : remove a tab
62        params : {
63                * href : Tab id
64                * callback : a function
65        }
66        comments : {
67                #1 : if the user doesn't set no parameter, this function just remove the open tab
68
69        * = Optional
70*/
71
72function removeTab(href, callback){
73        ptabs.tabs("remove",
74                (
75                        href ?
76                        indexTab(href) : lastIndexSelected
77                )
78        );
79        if(typeof(callback) == 'function')
80                callback();
81}
82
83/*
84        method : indexTab
85        descrition : remove a tab
86        params : {
87                * href : Tab id
88        }
89        comments : {
90                #1 : if the user doesn't set no parameter, this function just return the index of the open tab
91
92        * = Optional
93*/
94
95function indexTab(href){
96        return href ?
97                $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
98}
Note: See TracBrowser for help on using the repository browser.