Changeset 7043 for sandbox/newExpressoMail/expressoMail1_2/js/abas.js
- Timestamp:
- 08/16/12 17:21:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/newExpressoMail/expressoMail1_2/js/abas.js
r6997 r7043 8 8 var countID = 2; 9 9 var tab_content = ""; 10 var lastIndexSelected = 0; 10 11 11 12 var ptabs = $("#ptabs").tabs({ 12 tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' >Remover Aba</span></li>",13 tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>", 13 14 add: function( event, ui ) { 14 15 countID++; 15 16 $(ptabs).tabs('select', '#' + ui.panel.id); 16 17 $.cookie('open_tabs', ($.cookie('open_tabs') ? $.cookie('open_tabs')+"," : "") +ui.panel.id.substring(6)); 17 $( ui.panel ).a ppend("<p>"+tab_content+"</p>");18 $( ui.panel ).addClass("conteudo").append(tab_content); 18 19 }, 19 20 show: function(event, ui){ … … 22 23 cookie: { 23 24 expires: 1 25 }, 26 select: function(event, ui) { 27 console.log(ui.index); 28 lastIndexSelected = ui.index; 24 29 } 25 30 }); 26 31 27 //CREATE A NEW TAB 28 function createTab(href, label, conteudo, callback){ 32 /* 33 method : createTab 34 descrition : create a new tab 35 params : { 36 label : Label of the tab 37 * content : Content of the tab 38 * href : Tab id 39 * callback : a function 40 } 41 comments : { 42 #1 : if the user just set the label, a tab with blank content and a dynamic id is created 43 #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab 44 45 * = Optional 46 */ 47 48 function createTab(label, content,href, callback){ 29 49 if( !$("#ptabs_"+href).length){ 30 tab_content = conte udo;31 $(ptabs).tabs("add", "#ptabs_"+ href, (label.length > 21 ? label.substring(0, 15)+"..." : label));32 if( callback)50 tab_content = content ? content : ""; 51 $(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); 52 if(typeof(callback) == 'function') 33 53 callback(); 34 54 }else{ 35 var index = $( "li", $(ptabs) ).index( $('[href="#ptabs_'+ href +'"]').parent() ); 36 $(ptabs).tabs( "select", index ); 55 $(ptabs).tabs( "select", indexTab(href) ); 37 56 } 38 57 } 58 59 60 /* 61 method : removeTab 62 descrition : remove a tab 63 params : { 64 * href : Tab id 65 * callback : a function 66 } 67 comments : { 68 #1 : if the user doesn't set no parameter, this function just remove the open tab 69 70 * = Optional 71 */ 72 73 function removeTab(href, callback){ 74 ptabs.tabs("remove", 75 ( 76 href ? 77 indexTab(href) : lastIndexSelected 78 ) 79 ); 80 if(typeof(callback) == 'function') 81 callback(); 82 } 83 84 85 /* 86 method : indexTab 87 descrition : remove a tab 88 params : { 89 * href : Tab id 90 } 91 comments : { 92 #1 : if the user doesn't set no parameter, this function just return the index of the open tab 93 94 * = Optional 95 */ 96 97 function indexTab(href){ 98 return href ? 99 $( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected; 100 }
Note: See TracChangeset
for help on using the changeset viewer.