<?php defined("ABSPATH") || die("!");?>

<?php foreach($groups as $kg => $vg){ ?>
    <span class="ts-chl-collapsible"><?php echo $group_names[$vg];?></span>
    <div class="ts-chl-collapsible-content" <?php if ($default_group != $vg) echo 'style="display:none;"'; ?>>
        <div class="eplister<?php if(!$pdflr){ echo ' eplisterfull'; }?>">
            <div class="ephead">
                <div class="eph-num"><?php echo GOV_lang::get('series_episode_volume_chapter'); ?></div>
                <div class="eph-title"><?php echo GOV_lang::get('series_episode_title'); ?></div>
                <div class="eph-date"><?php echo GOV_lang::get('series_episode_date'); ?></div>
                <?php if($pdflr){ ?>
                <div class="eph-pdf"></div>
                <?php } ?>
            </div>
            <ul>
            <?php foreach($chapters[$vg] as $k => $v){ extract($v); ?>
                <li <?php if ($first) echo "class='tseplsfrst' ";?>data-ID="<?php echo $ID;?>">
                    <a href="<?php echo $the_link; ?>">
                        <div class="epl-num"><?php if($chapter_volume){ echo GOV_lang::get('thumbnail_volume_min_label')." ".$chapter_volume." "; } echo GOV_lang::get('thumbnail_chapter_min_label').' '.$chapter_number; ?></div>
                        <div class="epl-title"><?php echo $chapter_title; ?></div>
                        <div class="epl-date"><?php echo $date_format; ?></div>
                    </a>
                    <?php 
                    if ($pdf_link) { ?>
                        <div class="epl-pdf">
                            <a href="<?php echo $pdf_link; ?>" class="dlpdf" target="_blank" aria-label="Download"><i class="fas fa-cloud-download-alt"></i></a>
                        </div>
                    <?php } ?>
                </li>
            <?php } ?>
            </ul>
        </div>
    </div>
<?php } ?>
<script>
jQuery(document).on('click', '.ts-chl-collapsible', function(){
    jQuery(this).next('.ts-chl-collapsible-content').slideToggle('slow');
});
</script>