[2] | 1 | var BordersArray = new Array(); |
---|
[5083] | 2 | var countBorders = 0; |
---|
[5134] | 3 | var partMsgs = new Array(); |
---|
[5604] | 4 | var msgAttachments = new Array(); |
---|
| 5 | var uidsSave = new Array(); |
---|
[5637] | 6 | var zebraDiscardEventDialog = false; |
---|
[6085] | 7 | var saveBorderError = new Array(); |
---|
[6997] | 8 | var countID = 2; |
---|
| 9 | var tab_content = ""; |
---|
[7167] | 10 | var tab_role = ""; |
---|
[7043] | 11 | var lastIndexSelected = 0; |
---|
[6085] | 12 | |
---|
[6997] | 13 | var ptabs = $("#ptabs").tabs({ |
---|
[7167] | 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>", |
---|
[6997] | 16 | add: function( event, ui ) { |
---|
| 17 | countID++; |
---|
[7167] | 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)] = []; |
---|
[6997] | 23 | }, |
---|
| 24 | show: function(event, ui){ |
---|
[7167] | 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 | } |
---|
[6181] | 36 | resizeWindow(); |
---|
[6997] | 37 | }, |
---|
| 38 | cookie: { |
---|
| 39 | expires: 1 |
---|
[7043] | 40 | }, |
---|
| 41 | select: function(event, ui) { |
---|
| 42 | lastIndexSelected = ui.index; |
---|
[3336] | 43 | } |
---|
[7064] | 44 | }); |
---|
[3336] | 45 | |
---|
[7043] | 46 | /* |
---|
| 47 | method : createTab |
---|
| 48 | descrition : create a new tab |
---|
| 49 | params : { |
---|
| 50 | label : Label of the tab |
---|
[7167] | 51 | * role : Tab type |
---|
[7043] | 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 |
---|
[7167] | 59 | #3 : if the role is |
---|
[7043] | 60 | * = Optional |
---|
| 61 | */ |
---|
| 62 | |
---|
[7167] | 63 | function createTab(label, role, content,href, callback){ |
---|
[6997] | 64 | if( !$("#ptabs_"+href).length){ |
---|
[7043] | 65 | tab_content = content ? content : ""; |
---|
[7167] | 66 | tab_role = role ? role : "new"; |
---|
[7043] | 67 | $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); |
---|
| 68 | if(typeof(callback) == 'function') |
---|
[7046] | 69 | callback($("#ptabs_"+(href ? href : countID))); |
---|
[7167] | 70 | else |
---|
| 71 | return $("#ptabs_"+(href ? href : countID)); |
---|
[6997] | 72 | }else{ |
---|
[7167] | 73 | $(ptabs).tabs( "select", indexTab("#ptabs_"+href) ); |
---|
[2] | 74 | } |
---|
[7043] | 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 |
---|
[7167] | 103 | descrition : return a tab index |
---|
[7043] | 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; |
---|
[7167] | 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 | } |
---|