<?php defined('C5_EXECUTE') or die("Access Denied.");
$navigationTypeText = (0 == $navigationType) ? 'arrows' : 'pages';
$c = Page::getCurrentPage();
if ($c->isEditMode()) {
    $loc = Localization::getInstance();
    $loc->pushActiveContext(Localization::CONTEXT_UI); ?>
    <div class="ccm-edit-mode-disabled-item" style="<?php echo isset($width) ? "width: $width;" : ''; ?><?php echo isset($height) ? "height: $height;" : ''; ?>">
        <div style="padding: 40px 0px 40px 0px"><?php echo t('Image Slider disabled in edit mode.'); ?></div>
    </div>
    <?php
    $loc->popActiveContext();
} else {
    ?>

<div data-transparency="element" class="ccm-image-slider-container ccm-image-slider-hero-image ccm-block-image-slider-<?=$navigationTypeText; ?>" >
    <div class="ccm-image-slider">
        <div class="ccm-image-slider-inner">

        <?php if (count($rows) > 0) {
        ?>
        <ul class="rslides" id="ccm-image-slider-<?php echo $bID; ?>">
            <?php foreach ($rows as $row) {
            ?>
                <li>
                <?php if ($row['linkURL']) {
                ?>
                    <a href="<?php echo $row['linkURL']; ?>" class="mega-link-overlay"></a>
                <?php
            } ?>
                <?php
                $f = File::getByID($row['fID']); ?>
                <?php if (is_object($f)) {
                    $tag = Core::make('html/image', ['f' => $f])->getTag();
                    if ($row['title']) {
                        $tag->alt(h($row['title']));
                    } else {
                        $tag->alt("slide");
                    }
                    echo $tag; ?>
                <?php
                } ?>
                <div class="ccm-image-slider-hero-image-text">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12 text-center">
                                <h1><?php echo h($row['title']); ?></h1>
                                <h3><?php echo $row['description']; ?></h3>
                            </div>
                        </div>
                    </div>
                </div>
                </li>
            <?php
        } ?>
        </ul>
        <?php
    } else {
        ?>
        <div class="ccm-image-slider-placeholder">
            <p><?php echo t('No Slides Entered.'); ?></p>
        </div>
        <?php
    } ?>
        </div>

    </div>
</div>
<?php
} ?>

<script>
    $(document).ready(function(){
        $(function () {
            $("#ccm-image-slider-<?php echo $bID; ?>").responsiveSlides({
                prevText: "",   // String: Text for the "previous" button
                nextText: "",
                <?php if (0 == $navigationType) {
                ?>
                nav:true,
                <?php
                } elseif (1 == $navigationType) {
                ?>
                pager: true,
                <?php
                } elseif (2 == $navigationType) {
                ?>
                nav: true,
                pager: true,
                <?php
                } else {
                ?>
                nav:false,
                pager: false,
                <?php
                } ?>
                <?php if ($timeout) {
                    echo "timeout: $timeout,";
                } ?>
                <?php if ($speed) {
                    echo "speed: $speed,";
                } ?>
                <?php if ($pause) {
                    echo "pause: true,";
                } ?>
                <?php if ($noAnimate) {
                    echo "auto: false,";
                } ?>
                <?php if ($maxWidth) {
                    echo "maxwidth: $maxWidth,";
                } ?>
            });
        });
    });
</script>
