gallery.php 1.54 KB
<?php

use yii\helpers\Html;
use frontend\components\ImageResizer;

/**
 *
 * @author FilamentV <vortex.filament@gmail.com>
 * @copyright (c), Thread
 *
 * @var $model \frontend\modules\map\models\Item
 */
$gallery = $model->getGalleryItemsPath();
?>
    <div class="tab-pane fade" id="galery" style="height: 600px;">
    </div>
    <div class="gallery_slide_block" style="position: absolute; left: -10000px; top: 70px;">
        <ul class="bxslider">
            <?php
            foreach ($gallery as $img) {
                echo Html::beginTag('li')
                    . Html::img(ImageResizer::getThumb($img['image_path'], 600, 400), [
                        'alt' => ($img['title']) ? $img['title'] : $model['lang']['title']
                    ])
                    . Html::tag('p', $img['title'], [
                            'class' => 'gallery_title'
                    ])
                    . Html::endTag('li');
            }
            ?>
        </ul>
    </div>
<?php
$this->registerJs("
    $(document).ready(function () {
        $('.bxslider').bxSlider({
            auto: true,
            infiniteLoop: true,
            autoControls: true,
            stopAutoOnClick: true,
            pager: true,
            slideWidth: 600
        });

        $('.nav-tabs li').on('click', function () {
            if ($(this).find('a').attr('href') == '#galery') {
                $('.gallery_slide_block').css('left', \"40px\");
            } else {
                $('.gallery_slide_block').css('left', \"-10000px\");
            }
        });
    });
");