Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sky/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sky/Collapse.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\Sky;

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

class Collapse extends Bootstrap
{
    public $id;

    public function display()
    {
        // $data - button_text, data
        // $config - collpase_class
        
        $this->id = $this->get_id();
        
        $this->get_trigger();

        $this->get_content();

        // Add JavaScript
        $this->include_bsjs('collapse');

        return $this->output;
    }

    public function get_trigger()
    {
        $url = '#' . $this->id;
        
        $btn = new Button(array('title' => $this->data['button_text'], 'url' => $url), array('button_class' => $this->config['button_class'], 'icon' => $this->config['icon']));

        $attribs = array(
            'data-bs-toggle' => 'collapse',
            'role' => 'button',
            'aria-expanded' => 'false',
        );

        $btn->set_attributes($attribs);
        
        $this->output .= $btn->display();
    }

    public function get_content()
    {
        $this->output .= '<div class="collapse" id="' . $this->id . '">';
            $this->output .= '<div>';
                $this->output .= $this->data['data'];
            $this->output .= '</div>';
        $this->output .= '</div>';
    }
}