skipv1_0_0Accordion

The Facebook Fanpage Import skip v1 0 Accordion class.

Defined (1)

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

/includes/skip/elements/animated/accordion.php  
  1. class Accordion extends HTML_Element{ 
  2.  
  3. var $title_tag; 
  4. var $content_tag; 
  5.  
  6. /** 
  7. * Accordion constructor 
  8. * @param array $args Optional 
  9. * @package Skip 
  10. * @since 1.0 
  11. */ 
  12. function __construct( $args = array() ) { 
  13.  
  14. /** 
  15. * Additional parent args: 
  16. * 'id' 
  17. * 'classes' 
  18. * 'before_element' 
  19. * 'after_element' 
  20. * 'params' 
  21. */ 
  22. $defaults = array( 
  23. 'tag' => 'div',  
  24. 'title_tag' => 'h3',  
  25. 'content_tag' => 'div' 
  26. ); 
  27.  
  28. $args = wp_parse_args( $args, $defaults ); 
  29. extract( $args , EXTR_SKIP ); 
  30.  
  31. parent::__construct( $tag, $args ); 
  32.  
  33. $this->title_tag = $title_tag; 
  34. $this->content_tag = $content_tag; 
  35.  
  36. /** 
  37. * Adding section to accordion 
  38. * @package Skip 
  39. * @since 1.0 
  40. *  
  41. * @param string $title Title of the tab 
  42. * @param string $content Content in the tab 
  43. * @param array $args Array of [ 'id' ], [ 'classes' ], [ 'params_title' ] and [ 'params_content' ] 
  44. */ 
  45. public function add_element( $title, $content, $args = array() ) { 
  46. $defaults = array( 
  47. 'id' => id(),  
  48. 'classes' => '',  
  49. 'params_title' => array(),  
  50. 'params_content' => array() 
  51. ); 
  52.  
  53. $args = wp_parse_args( $args, $defaults ); 
  54. extract( $args , EXTR_SKIP ); 
  55.  
  56. $element = array( 
  57. 'title' => $title,  
  58. 'content' => $content,  
  59. 'id' => $id,  
  60. 'classes'=> $classes,  
  61. 'params_title' => $params_title,  
  62. 'params_content' => $params_content 
  63. ); 
  64.  
  65. parent::add_element( $element ); 
  66.  
  67. /** 
  68. * Getting the accordion html 
  69. * @package Skip 
  70. * @since 1.0 
  71. *  
  72. * @return string $html The accordion as html 
  73. */ 
  74. public function render( $hide = FALSE ) { 
  75. global $skip_javascripts; 
  76.  
  77. $skip_javascripts[] = ' 
  78. var cookieName_' . $this->params[ 'id' ] . ' = "stickyAccordion_' . $this->params[ 'id' ] . '"; 
  79.  
  80. $( "#' . $this->params[ 'id' ] . '" ).accordion({ 
  81. header: "' . $this->title_tag . '",  
  82. autoHeight: false,  
  83. collapsible:true,  
  84. active: ( $.cookies.get( cookieName_' . $this->params[ 'id' ] . ' ) || 0 ),  
  85. change: function( e, ui ) 
  86. $.cookies.set( cookieName_' . $this->params[ 'id' ] . ', $( this ).find( "' . $this->title_tag . '" ).index ( ui.newHeader[0] ) ); 
  87. });'; 
  88.  
  89. $html = '<' . $this->tag . $this->params() . '>'; 
  90.  
  91. foreach( $this->elements AS $element ): 
  92.  
  93. /** 
  94. * Title 
  95. */ 
  96. $html.= '<' . $this->title_tag . $this->params( $element[ 'params_title' ] ) . '>'; 
  97. $html.= '<a href="#">'; 
  98. $html.= display( $element['title'] ); 
  99. $html.= '</a>'; 
  100. $html.= '</' . $this->title_tag . '>'; 
  101.  
  102. /** 
  103. * Content 
  104. */ 
  105. $html.= '<' . $this->content_tag . $this->params( $element[ 'params_content' ] ) . '>'; 
  106. $html.= display( $element['content'] ); 
  107. $html.= '</' . $this->content_tag . '>'; 
  108.  
  109. endforeach; 
  110.  
  111. $html.= '</' . $this->tag . '>'; 
  112.  
  113. return $html;