skipv1_0_0Tabs

The Facebook Fanpage Import skip v1 0 Tabs class.

Defined (1)

The class is defined in the following location(s).

/includes/skip/elements/animated/tabs.php  
  1. class Tabs extends HTML_Element{ 
  2.  
  3. /** 
  4. * Tabs constructor 
  5. * @param array $args Array of [ 'id' ], [ 'classes' ] and [ 'params' ] 
  6. * @package Skip 
  7. * @since 1.0 
  8. */ 
  9. function __construct( $args = array() ) { 
  10. /** 
  11. * Additional parent args: 
  12. * 'id' 
  13. * 'classes' 
  14. * 'before_element' 
  15. * 'after_element' 
  16. * 'params' 
  17. */ 
  18. parent::__construct( 'div', $args ); 
  19.  
  20. /** 
  21. * Adding tab 
  22. * @package Skip 
  23. * @since 1.0 
  24. *  
  25. * @param string $title Title of the tab 
  26. * @param string $content Content which appears in the tab 
  27. * @param array $args Array of [ 'id' ], [ 'classes' ], [ 'params_title' ] and [ 'params_content' ] 
  28. *  
  29. */ 
  30. public function add_element( $title, $content, $args = array() ) { 
  31. $defaults = array( 
  32. 'id' => id(),  
  33. 'classes' => '',  
  34. 'params_title' => array(),  
  35. 'params_content' => array() 
  36. ); 
  37.  
  38. $args = wp_parse_args( $args, $defaults ); 
  39. extract( $args , EXTR_SKIP ); 
  40.  
  41. $element = array( 
  42. 'id' => $id,  
  43. 'title' => $title,  
  44. 'content' => $content,  
  45. 'classes'=> $classes,  
  46. 'params_title' => $params_title,  
  47. 'params_content' => $params_content 
  48. ); 
  49.  
  50. parent::add_element( $element ); 
  51.  
  52. /** 
  53. * Getting the tabs html 
  54. * @package Skip 
  55. * @since 1.0 
  56. *  
  57. * @return string $html The tabs as html 
  58. *  
  59. */ 
  60. public function render() { 
  61. global $skip_javascripts; 
  62.  
  63. // Creating elements 
  64. $skip_javascripts[] = ' 
  65. var cookieName_' . $this->params[ 'id' ] . ' = "stickyTabs_' . $this->params[ 'id' ] . '"; 
  66.  
  67. $( "#' . $this->params[ 'id' ] . '" ).tabs({ 
  68. selected: ( $.cookies.get( cookieName_' . $this->params[ 'id' ] . ' ) || 0 ),  
  69. show: function( event, ui ) { 
  70. $.cookies.set( cookieName_' . $this->params[ 'id' ] . ', $( "#' . $this->params[ 'id' ] . '" ).tabs( "option", "selected" ) ); 
  71. });'; 
  72.  
  73. $html = '<' . $this->tag . $this->params() . '>'; 
  74.  
  75. $html.= '<ul>'; 
  76. // Creting navigation elements 
  77. foreach( $this->elements AS $element ): 
  78. // Show tab 
  79. $html.= '<li' . $this->params( $element[ 'params_title' ] ) . '><a href="#' . $element['id'] . '" >'; 
  80. $html.= display( $element['title'] ); 
  81. $html.= '</a></li>'; 
  82. endforeach; 
  83. $html.= '</ul>'; 
  84.  
  85. // Creting content elements 
  86. foreach( $this->elements AS $element ): 
  87.  
  88. // Show tab content 
  89. $html.= '<div' . $this->params( $element[ 'params_content' ] ) . ' id="' . $element['id'] . '">'; 
  90. $html.= display( $element['content'] ); 
  91. $html.= '</div>'; 
  92. endforeach; 
  93.  
  94. $html.= '</' . $this->tag . '>'; 
  95.  
  96. return $html;