<?php
$cpanelHelper = $this->helper('Solwin\Cpanel\Helper\Data');
$header_type = $cpanelHelper->getCpanelConfigValue('cpanelsection/headergroup/headertype');
$ishome = $cpanelHelper->getIsHomePage();
$enable = $this->getEnableModule();
if ($enable) {
    $animationType = $this->getAnimationType();
    $controlNav = $this->getControlNav();
    $slideshowSpeed = $this->getSlideshowSpeed();
    $direction = $this->getDirection();
    $animationLoop = $this->getAnimationLoop();
    $smoothHeight = $this->getSmoothHeight();
    $startAt = $this->getStartAt();
    $slideshow = $this->getSlideshow();
    $animationSpeed = $this->getAnimationSpeed();
    $initDelay = $this->getInitDelay();
    $pauseOnHover = $this->getPauseOnHover();
    $touch = $this->getTouch();
    $directionNav = $this->getDirectionNav();
    $keyboard = $this->getKeyboard();
    $mousewheel = $this->getMousewheel();
    $prevText = $this->getPrevText();
    $nextText = $this->getNextText();

    $mediaUrl = $this->getBaseUrl() . 'pub/media/';
    $bannerData = $this->getBannerData();
    $size = $bannerData->getSize();

    if ($size > 0) {
        ?>
        <div class="flexslider flexslider-8">
            <ul class="slides"> 
                <?php foreach ($bannerData as $banner): ?>
                    <li data-thumb="<?php echo $mediaUrl . $banner->getImage(); ?>">
                        <a href="<?php echo $banner->getUrl(); ?>" target="<?php echo $banner->getTarget(); ?>">
                            <img alt="<?php echo $banner->getTitle(); ?>" title="<?php echo $banner->getTitle(); ?>" src="<?php echo $mediaUrl . $banner->getImage(); ?>"/>
                        </a>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
        <script type="text/javascript">
            require(['jquery', 'cpflexslider', 'cpmousewheel'], function () {
                jQuery(document).ready(function () {
                    jQuery('.flexslider-8').flexslider({
                        animation: "<?php echo $animationType; ?>",
                        controlNav: "<?php echo $controlNav; ?>",
                        slideshowSpeed: <?php echo $slideshowSpeed; ?>,
                        direction: "<?php echo $direction; ?>",
                        animationLoop: <?php echo ($animationLoop == 1) ? "true" : "false"; ?>,
                        smoothHeight: <?php echo ($smoothHeight == 1) ? "true" : "false"; ?>,
                        startAt: <?php echo $startAt; ?>,
                        slideshow: <?php echo ($slideshow == 1) ? "true" : "false"; ?>,
                        animationSpeed: <?php echo $animationSpeed; ?>,
                        initDelay: <?php echo $initDelay; ?>,
                        pauseOnHover: <?php echo ($pauseOnHover == 1) ? "true" : "false"; ?>,
                        touch: <?php echo ($touch == 1) ? "true" : "false"; ?>,
                        directionNav: <?php echo ($directionNav == 1) ? "true" : "false"; ?>,
                        keyboard: <?php echo ($keyboard == 1) ? "true" : "false"; ?>,
                        mousewheel: <?php echo ($mousewheel == 1) ? "true" : "false"; ?>,
                        prevText: '<?php echo $prevText; ?>',
                        nextText: '<?php echo $nextText; ?>'
                    });
                });
            });
        </script>
    <?php }
    ?>
    <?php if ($controlNav == "false") { ?>
        <style>
            .flex-control-paging {
                display:none;
            }
        </style>
        <?php
    }
}
?>