source: sandbox/newExpressoMail/prototype/modules/newMail/js/tabs.js @ 7265

Revision 7265, 3.9 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 tab_content = "";
2var tab_role = "";
3
4var Tab = {
5
6    /*
7     method : createTab
8     descrition : create a new tab
9     params : {
10     label : Label of the tab
11     * role : Tab type
12     * content : Content of the tab
13     * href : Tab id
14     * callback : a function
15     }
16     comments : {
17     #1 : if the user just set the label, a tab with blank content and a dynamic id is created
18     #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab
19     #3 : if the role is
20     * = Optional
21     */
22    create : function(label, role, content,href, callback){
23        if( !$("#tabs-"+href).length){
24            tab_content = content ? content : "";
25            tab_role = role ? role : "new";
26            Tab.count++;
27            $tabs.wijtabs("add", "#tabs-"+(href ? href : Tab.count), (label.length > 21 ? label.substring(0, 18)+"..." : label));
28            if(typeof(callback) == 'function')
29                callback($("#ptabs_"+(href ? href : Tab.count)));
30            else
31                return $("#tabs-"+(href ? href : Tab.count));
32        }else{
33            $tabs.wijtabs( "select", Tab.index("#tabs-"+href) );
34        }
35    },
36
37
38    /*
39     method : removeTab
40     descrition : remove a tab
41     params : {
42     * href : Tab id
43     * callback : a function
44     }
45     comments : {
46     #1 : if the user doesn't set no parameter, this function just remove the open tab
47
48     * = Optional
49     */
50    remove : function(href, callback){
51        $tabs.wijtabs("remove",
52            (
53                href ?
54                    Tab.index(href) : Tab.lastIndexSelected
55                )
56        );
57        if(typeof(callback) == 'function')
58            callback();
59    },
60
61    /*
62     method : Tab.index
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
73    index : function(href){
74        return href ?
75            $( "li", $tabs ).index( $('[href="'+href+'"]').parent() ) : Tab.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
90    id : function(index){
91        return $( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index())).attr("id");
92    },
93
94    getData : function(index){
95        return {
96            id : parseInt(Tab.id(index).substring(6).split("_r_")[0]),
97            folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]),
98            role : Tab.getRole(index),
99            header : Tab.getHeader(index),
100            content : Tab.getContent(index)
101        };
102    },
103
104    getHeader : function(index){
105        return $( $tabs ).find('[href="#'+$( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index())).attr("id")+'"]').parent();
106    },
107
108    getRole: function(index){
109        return Tab.getContent(index).attr("role");
110    },
111
112    getContent: function(index){
113        return $( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index()));
114    },
115
116    setFolderTotal: function(value){
117        Tab.getHeader(0).find(".folder-tab-total-msgs-number").html(parseInt(value) ? value : 0);
118    },
119
120    setFolderUnread: function(value){
121        Tab.getHeader(0).find(".folder-tab-new-msgs-number").html(parseInt(value) ? value : 0);
122        if(parseInt(value))
123            $("title").html($("title").html() +" ("+value+")");
124    },
125
126    setFolderName: function(value){
127        Tab.getHeader(0).find(".folder-tab-name").html(value);
128        $("title").html(value);
129    },
130
131    lastIndexSelected : 0,
132
133    count: 2,
134
135    roles : [
136        "new", "draft", "search", "message", "folder"
137    ]
138}
Note: See TracBrowser for help on using the repository browser.