gallery.php 2.75 KB
<?php
    use common\models\User;
    use yii\widgets\ListView;

    /**
     * @var $this yii\web\View
     */

    $this->params[ 'user' ] = $user;
    $this->title = 'Proektant.net';
    
    if(empty( $videos ) && empty( $gallery->getModels() )) {
        ?>
        <div class="gallery-performer-wrapper style">
            <div class="gallery-performer-margin">
                Галерей к просмотру не найдено
            </div>
        </div>
        <?php
    } else {
        if(!empty( $videos )) {
            ?>
            <div class="video-performer-wrapper style">
                <div class="gallery-title">Видео: <?= count($videos) ?></div>
                <div class="slider-video-wr">
                    <div id="demo5" class="scroll-img video-slider">
                        <ul>
                            <?php foreach($videos as $video): ?>
                                <li>
                                    <div class="iframe-video">
                                        <iframe width="560" height="320" src="<?= $video[ 'youtube' ] ?>" frameborder="0" allowfullscreen></iframe>
                                    </div>
                                    <a href="#"></a><span></span>
                                </li>
                            <?php endforeach; ?>

                        </ul>
                    </div>
                    <div id="demo5-btn" class="text-center">
                        <button class="btn" id="demo5-backward"></button>
                        <button class="btn" id="demo5-forward"></button>
                    </div>
                </div>
            </div>
            <?php
        }
        ?>
        <div class="gallery-performer-wrapper style">
            <div class="gallery-performer-margin">
                <?= ListView::widget([
                    'dataProvider' => $gallery,
                    'itemView'     => '_gallery_list_view',
                    'summary'      => '',
                    'layout'       => "{summary}\n{items}\n<div class='navi-buttons-wr style gallery-style'>{pager}</div>",
                ]); ?>
            </div>
        </div>
        <?php
    }

?>
<script>
    $(
        function()
        {
            $('#demo5').scrollbox(
                {
                    direction : 'h',
                    distance : 220,
                    autoPlay : false
                }
            );
            $('#demo5-backward').click(
                function()
                {
                    $('#demo5').trigger('backward');
                }
            );
            $('#demo5-forward').click(
                function()
                {
                    $('#demo5').trigger('forward');
                }
            );
        }
    );
</script>