Changeset 7167 for sandbox/newExpressoMail/expressoMail1_2/js/abas.js
- Timestamp:
- 09/04/12 18:07:11 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/newExpressoMail/expressoMail1_2/js/abas.js
r7064 r7167 8 8 var countID = 2; 9 9 var tab_content = ""; 10 var tab_role = ""; 10 11 var lastIndexSelected = 0; 11 12 12 13 var 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 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>", 14 16 add: function( event, ui ) { 15 17 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); 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)] = []; 19 23 }, 20 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 } 21 36 resizeWindow(); 22 37 }, … … 29 44 }); 30 45 31 //$(ptabs).find(".ui-tabs-nav").wrap("<div class='scroll-tabs'></div>");32 46 /* 33 47 method : createTab … … 35 49 params : { 36 50 label : Label of the tab 51 * role : Tab type 37 52 * content : Content of the tab 38 53 * href : Tab id … … 42 57 #1 : if the user just set the label, a tab with blank content and a dynamic id is created 43 58 #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab 44 59 #3 : if the role is 45 60 * = Optional 46 61 */ 47 62 48 function createTab(label, content,href, callback){63 function createTab(label, role, content,href, callback){ 49 64 if( !$("#ptabs_"+href).length){ 50 65 tab_content = content ? content : ""; 66 tab_role = role ? role : "new"; 51 67 $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); 52 68 if(typeof(callback) == 'function') 53 69 callback($("#ptabs_"+(href ? href : countID))); 70 else 71 return $("#ptabs_"+(href ? href : countID)); 54 72 }else{ 55 $(ptabs).tabs( "select", indexTab( href) );73 $(ptabs).tabs( "select", indexTab("#ptabs_"+href) ); 56 74 } 57 75 } … … 83 101 /* 84 102 method : indexTab 85 descrition : re move a tab103 descrition : return a tab index 86 104 params : { 87 105 * href : Tab id … … 97 115 $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected; 98 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 }
Note: See TracChangeset
for help on using the changeset viewer.