source: sandbox/newExpressoMail/prototype/modules/newMail2/js/tabs.js @ 7210

Revision 7210, 3.2 KB checked in by gustavo, 12 years ago (diff)

Ticket #0000 - Criado novo modulo para o desenvolvimento do novo ExpressoMail?

  • Property svn:executable set to *
Line 
1var countID = 2;
2var tab_content = "";
3var tab_role = "";
4var lastIndexSelected = 0;
5/*
6        method : createTab
7        descrition : create a new tab
8        params : {
9                label : Label of the tab
10                * role : Tab type
11                * content : Content of the tab
12                * href : Tab id
13                * callback : a function
14        }
15        comments : {
16                #1 : if the user just set the label, a tab with blank content and a dynamic id is created
17                #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab
18                #3 : if the role is
19        * = Optional
20*/
21
22function createTab(label, role, content,href, callback){
23        if( !$("#tabs-"+href).length){
24                tab_content = content ? content : "";
25                tab_role = role ? role : "new";
26                countID++;
27                $tabs.wijtabs("add", "#tabs-"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label));
28                if(typeof(callback) == 'function')
29                        callback($("#ptabs_"+(href ? href : countID)));
30                else
31                        return $("#tabs-"+(href ? href : countID));
32        }else{
33                $tabs.wijtabs( "select", indexTab("#tabs-"+href) );
34        }
35}
36
37/*
38        method : removeTab
39        descrition : remove a tab
40        params : {
41                * href : Tab id
42                * callback : a function
43        }
44        comments : {
45                #1 : if the user doesn't set no parameter, this function just remove the open tab
46
47        * = Optional
48*/
49
50function removeTab(href, callback){
51        $tabs.wijtabs("remove",
52                (
53                        href ?
54                        indexTab(href) : lastIndexSelected
55                )
56        );
57        if(typeof(callback) == 'function')
58                callback();
59}
60
61/*
62        method : indexTab
63        descrition : return a tab index
64        params : {
65                * href : Tab id
66        }
67        comments : {
68                #1 : if the user doesn't set no parameter, this function just return the index of the open tab
69
70        * = Optional
71*/
72
73function indexTab(href){
74        return href ?
75                $( "li", $tabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
76}
77
78/*
79 method : idTab
80 descrition : remove a tab id
81 params : {
82 * index : Tab index
83 }
84 comments : {
85 #1 : if the user doesn't set no parameter, this function just return the id of the open tab
86
87 * = Optional
88 */
89
90function idTab(index){
91    return $( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab())).attr("id");
92}
93
94function getTabData(index){
95        return {
96                id : parseInt(idTab(index).substring(6).split("_r_")[0]),
97                folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]),
98                role : getTabRole(index),
99                header : getTabHeader(index),
100                content : getTabContent(index)
101        };
102}
103
104function getTabHeader(index){
105    return $( $tabs ).find('[href="#'+$( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab())).attr("id")+'"]').parent();
106}
107
108function getTabRole(index){
109        return getTabContent(index).attr("role");
110}
111
112function getTabContent(index){
113        return $( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab()));
114}
115
116function setFolderTabTotal(value){
117        getTabHeader(0).find(".folder-tab-total-msgs-number").html(parseInt(value) ? value : 0);
118}
119
120function setFolderTabTotalUnread(value){
121        getTabHeader(0).find(".folder-tab-new-msgs-number").html(parseInt(value) ? value : 0); 
122        if(parseInt(value))
123                $("title").html($("title").html() +" ("+value+")");
124}
125
126function setFolderTabName(value){
127        getTabHeader(0).find(".folder-tab-name").html(value);   
128        $("title").html(value);
129}
Note: See TracBrowser for help on using the repository browser.