<?php
/* @var $slider Slider*/
use common\models\Slider;
use yii\helpers\Html;
use yii\helpers\Url;

?>
<div class="carousel">
    <?php foreach($slider->sliderImage as $image):
    $img = \common\components\artboximage\ArtboxImageHelper::getImageSrc($image->imageUrl , 'slider');
    $htm = <<<HTML

            <div style="background:url($img ) center center no-repeat;width:100%;height:480px;position:absolute;">
            </div>
            <div class="content">

HTML;

    if(!empty($image->price)) {
        $htm .= <<<HTML
                <div class="price_round_border">
                    <div class="price_round">
                        <div class="title">Супер цена</div>
                        <div class="desc">$image->price
                            <div>грн.</div>
                        </div>
                    </div>
                </div>
HTML;
    }

    $htm .= <<<HTML
            </div>

HTML;
        ?>

    <div class="slide">
        <?= Html::a($htm, Url::toRoute($image->url)); ?>
    </div>
<?php endforeach; ?>
</div>

<div style="clear:both;"></div>
<?php
$dur = $slider->duration ?  $slider->duration : 5000;
$speed = $slider->speed ?  $slider->speed : 500;
$js="	$(\".carousel\").owlCarousel({
        items: 1,
        loop: true,
        nav: true,
		startPosition: 2,
		mouseDrag: false,
		navSpeed: 800,
		autoplay:true,
		autoplayTimeout: $dur,
		autoplaySpeed: $speed,
		autoplayHoverPause:true,
        navText: ['<a class=\"prev\"></a>', '<a class=\"next\"></a>']
     });";

$this->registerJs($js);

?>
