Guest User

Untitled

a guest
Feb 1st, 2012
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. //js
  2.  
  3. $(document).ready(function() {
  4.  
  5. $(".tabcontent").hide();
  6. $("ul.selector li:first").addClass("active").show();
  7. $(".tabcontent:first").show();
  8.  
  9. $("ul.selector li").click(function() {
  10.  
  11. $("ul.selector li").removeClass("active");
  12. $(this).addClass("active");
  13. $(".tabcontent").hide();
  14.  
  15. var activeTab = $(this).find("a").attr("href");
  16. $(activeTab).stop(true, true).fadeIn(0);
  17. return false;
  18. });
  19.  
  20. });
  21.  
  22.  
  23. //shortcode
  24.  
  25. function defaulttab( $atts, $content = null ) {
  26. $GLOBALS['tab_count'] = 0;
  27. do_shortcode($content);
  28. if( is_array( $GLOBALS['tabs'] ) ){
  29. $i = 1;
  30. foreach( $GLOBALS['tabs'] as $tab ){
  31. $tabs[] = '<li class="tab"><a class="tab" href="#">'.$tab['title'].'</a></li>';
  32. $panes[] = '<div id="tab'.$i.'" class="tabcontent">' .$tab['content'].'</div>';
  33. $i++;
  34. }
  35. $return = '<div class="tabcontainer"><ul class="selector">'.implode( "\n", $tabs ).'</ul>
  36. <div class="clear"></div>'.implode( "\n", $panes ).'</div>';
  37. }
  38. return $return;
  39. }
  40.  
  41.  
  42. add_shortcode('tab', 'defaulttab');
  43.  
  44. function defaulttabs( $atts, $content = null ) {
  45. extract( shortcode_atts( array(
  46. 'title' => '',
  47. 'tab' => '1',
  48. ), $atts ) );
  49.  
  50. $i = $GLOBALS['tab_count'];
  51. $GLOBALS['tabs'][$i] = array( 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' => $content );
  52. $GLOBALS['tab_count']++;
  53. }
  54.  
  55. add_shortcode('tabs', 'defaulttabs');
Advertisement
Add Comment
Please, Sign In to add comment