<?php
namespace WikiLingo\Plugin;

use WikiLingo;

/**
 * Class Accordions
 * @package WikiLingo\Plugin
 */
class Accordions extends Base
{
    /**
     *
     */
    public function __construct()
    {
        $this->htmlTagType = 'div';

        $this->label = 'Accordion';
    }

    /**
     * @param WikiLingo\Expression\Plugin $plugin
     * @param string $body
     * @param WikiLingo\Renderer $renderer
     * @param WikiLingo\Parser $parser
     * @return string
     */
    public function render(WikiLingo\Expression\Plugin &$plugin, &$body = '', &$renderer, &$parser)
    {
        $id = $plugin->id();
        $parser->scripts->addScript(<<<JS
$(function() {
	 $( '#$id' ).accordion({
	    header: 'h3'
	 });
});
JS
        );
        $accordions = parent::render($plugin, $body, $renderer, $parser);

        return $accordions;
    }
}