1 | var BordersArray = new Array(); |
---|
2 | var countBorders = 0; |
---|
3 | var partMsgs = new Array(); |
---|
4 | var msgAttachments = new Array(); |
---|
5 | var uidsSave = new Array(); |
---|
6 | var zebraDiscardEventDialog = false; |
---|
7 | var saveBorderError = new Array(); |
---|
8 | var countID = 2; |
---|
9 | var tab_content = ""; |
---|
10 | var tab_role = ""; |
---|
11 | var lastIndexSelected = 0; |
---|
12 | |
---|
13 | var ptabs = $("#ptabs").tabs({ |
---|
14 | tabTemplate: "<li role='tab' style='cursor: pointer;'><a href='#{href}'>#{label}</a> <span class='ui-icon tab-close ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>", |
---|
15 | panelTemplate: "<div></div>", |
---|
16 | add: function( event, ui ) { |
---|
17 | countID++; |
---|
18 | $(ptabs).tabs('select', '#' + $(ptabs).find("div:last").attr("id")); |
---|
19 | $(ptabs).find("span.tab-close:last").hover(function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");}, function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");}) |
---|
20 | $(ptabs).find("div:last").addClass("conteudo").attr("role", tab_role).append(tab_content); |
---|
21 | if(tab_role == "new") |
---|
22 | uidsSave[indexTab("#"+ui.panel.id)] = []; |
---|
23 | }, |
---|
24 | show: function(event, ui){ |
---|
25 | switch($( ui.panel ).attr("role")){ |
---|
26 | case "new": |
---|
27 | case "search": |
---|
28 | $("#footer_menu").hide(); |
---|
29 | break; |
---|
30 | case "message": |
---|
31 | case "draft": |
---|
32 | case "folder": |
---|
33 | $("#footer_menu").show(); |
---|
34 | break; |
---|
35 | } |
---|
36 | resizeWindow(); |
---|
37 | }, |
---|
38 | cookie: { |
---|
39 | expires: 1 |
---|
40 | }, |
---|
41 | select: function(event, ui) { |
---|
42 | lastIndexSelected = ui.index; |
---|
43 | } |
---|
44 | }); |
---|
45 | |
---|
46 | /* |
---|
47 | method : createTab |
---|
48 | descrition : create a new tab |
---|
49 | params : { |
---|
50 | label : Label of the tab |
---|
51 | * role : Tab type |
---|
52 | * content : Content of the tab |
---|
53 | * href : Tab id |
---|
54 | * callback : a function |
---|
55 | } |
---|
56 | comments : { |
---|
57 | #1 : if the user just set the label, a tab with blank content and a dynamic id is created |
---|
58 | #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab |
---|
59 | #3 : if the role is |
---|
60 | * = Optional |
---|
61 | */ |
---|
62 | |
---|
63 | function createTab(label, role, content,href, callback){ |
---|
64 | if( !$("#ptabs_"+href).length){ |
---|
65 | tab_content = content ? content : ""; |
---|
66 | tab_role = role ? role : "new"; |
---|
67 | $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); |
---|
68 | if(typeof(callback) == 'function') |
---|
69 | callback($("#ptabs_"+(href ? href : countID))); |
---|
70 | else |
---|
71 | return $("#ptabs_"+(href ? href : countID)); |
---|
72 | }else{ |
---|
73 | $(ptabs).tabs( "select", indexTab("#ptabs_"+href) ); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | /* |
---|
78 | method : removeTab |
---|
79 | descrition : remove a tab |
---|
80 | params : { |
---|
81 | * href : Tab id |
---|
82 | * callback : a function |
---|
83 | } |
---|
84 | comments : { |
---|
85 | #1 : if the user doesn't set no parameter, this function just remove the open tab |
---|
86 | |
---|
87 | * = Optional |
---|
88 | */ |
---|
89 | |
---|
90 | function removeTab(href, callback){ |
---|
91 | ptabs.tabs("remove", |
---|
92 | ( |
---|
93 | href ? |
---|
94 | indexTab(href) : lastIndexSelected |
---|
95 | ) |
---|
96 | ); |
---|
97 | if(typeof(callback) == 'function') |
---|
98 | callback(); |
---|
99 | } |
---|
100 | |
---|
101 | /* |
---|
102 | method : indexTab |
---|
103 | descrition : return a tab index |
---|
104 | params : { |
---|
105 | * href : Tab id |
---|
106 | } |
---|
107 | comments : { |
---|
108 | #1 : if the user doesn't set no parameter, this function just return the index of the open tab |
---|
109 | |
---|
110 | * = Optional |
---|
111 | */ |
---|
112 | |
---|
113 | function indexTab(href){ |
---|
114 | return href ? |
---|
115 | $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected; |
---|
116 | } |
---|
117 | |
---|
118 | /* |
---|
119 | method : idTab |
---|
120 | descrition : remove a tab id |
---|
121 | params : { |
---|
122 | * index : Tab index |
---|
123 | } |
---|
124 | comments : { |
---|
125 | #1 : if the user doesn't set no parameter, this function just return the id of the open tab |
---|
126 | |
---|
127 | * = Optional |
---|
128 | */ |
---|
129 | |
---|
130 | function idTab(index){ |
---|
131 | return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id"); |
---|
132 | } |
---|
133 | |
---|
134 | function getTabData(index){ |
---|
135 | return { |
---|
136 | id : parseInt(idTab(index).substring(6).split("_r_")[0]), |
---|
137 | folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]), |
---|
138 | role : getTabRole(index), |
---|
139 | header : getTabHeader(index), |
---|
140 | content : getTabContent(index) |
---|
141 | }; |
---|
142 | } |
---|
143 | |
---|
144 | function getTabHeader(index){ |
---|
145 | return $( ptabs ).find('[href="#'+$( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id")+'"]').parent(); |
---|
146 | } |
---|
147 | |
---|
148 | function getTabRole(index){ |
---|
149 | return getTabContent(index).attr("role"); |
---|
150 | } |
---|
151 | |
---|
152 | function getTabContent(index){ |
---|
153 | return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())); |
---|
154 | } |
---|