templates/galleries/show.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block stylesheets %}
  3.     <link rel="stylesheet" href="/assets/css/mdb/bootstrap.min.css">
  4.     <link rel="stylesheet" href="/assets/css/mdb/mdb.min.css">
  5.     <link rel="stylesheet" type="text/css" href="/assets/css/galleries.css" />
  6.     <style>
  7.         .lightbox {
  8.             position: fixed;
  9.             top: 0; left: 0; right: 0; bottom: 0;
  10.             background-color: rgba(0,0,0,0.75);
  11.             opacity: 0;
  12.             pointer-events: none;
  13.             z-index: 1055;
  14.             background-size: contain;
  15.             background-repeat: no-repeat;
  16.             background-position: center center;
  17.             font-size: 30px;
  18.         }
  19.         .lightbox .left, .lightbox .right {
  20.             display: flex;
  21.             align-items: center;
  22.             cursor: pointer;
  23.             color: white;
  24.             font-weight: bold;
  25.             opacity: 0.5;
  26.         }
  27.         .lightbox .right {
  28.             flex-direction: row-reverse;
  29.         }
  30.         .lightbox .close {
  31.             display: flex;
  32.             font-weight: bold;
  33.             color: white;
  34.             float: none;
  35.             opacity: 0.5;
  36.             flex-direction: row-reverse;
  37.         }
  38.         .lightbox .close .btn {
  39.             cursor: pointer;
  40.             font-size: 30px;
  41.             border-radius: 5px;
  42.             border: 1px solid white;
  43.             padding: 0 12px;
  44.             box-shadow: 0 0 5px white;
  45.         }
  46.         .lightbox .left:hover,
  47.         .lightbox .right:hover {
  48.             opacity: 1;
  49.             color:white;
  50.         }
  51.         .lightbox .close .btn:hover {
  52.             opacity: 1;
  53.             color:black;
  54.             background-color: ghostwhite;
  55.         }
  56.         .img-fluid {
  57.             cursor: pointer;
  58.         }
  59.         .hidebackground {
  60.             position: fixed;
  61.             top:0;left:0;right:0;bottom:0;
  62.             background: black;
  63.             opacity: 0;
  64.             pointer-events: none;
  65.         }
  66.         .info-background {
  67.             position: fixed;
  68.             bottom:0;
  69.             left:0;right:0;
  70.             padding: 15px;
  71.         }
  72.         .comment, .tags {
  73.             color:white;
  74.             margin: 0;
  75.         }
  76.     </style>
  77. {% endblock %}
  78. {% block background %}{% endblock %}
  79. {% block body %}
  80.     <div class="page galleries">
  81.         <div class="wrap">
  82.             <div class="container-fluid">
  83.                 <div class="row">
  84.                     <div class="col-sm-12 col-md-8">
  85.                         {% for gallery in galleries %}
  86.                         <div class="row">
  87.                             <div class="col col-12">
  88.                                 <h1>{{ gallery.machineName }}</h1>
  89.                             </div>
  90.                         </div>
  91.                         <div class="row">
  92.                             <div class="col col-12">
  93.                                 <p>{{ gallery.description }}</p>
  94.                             </div>
  95.                         </div>
  96.                         <div class="gallery" id="gallery">
  97.                             {% for img in gallery.pictures %}
  98.                             <div class="mb-3 pics animation all 2">
  99.                                 <img class="img-fluid"
  100.                                      src="/galleries/{{ gallery.id }}/{{ img.photo }}"
  101.                                      alt="{{ img.comment }}"
  102.                                      data-comment="{{ img.comment }}"
  103.                                      data-tags="{{ img.tags }}"
  104.                                      width="100%" />
  105.                             </div>
  106.                             {% endfor %}
  107.                         </div>
  108.                         {% endfor %}
  109.                         <div class="lightbox container-fluid">
  110.                             <div class="info-background">
  111.                                 <p class="comment"></p>
  112.                                 <p class="tags"></p>
  113.                             </div>
  114.                             <div class="hidebackground"></div>
  115.                             <div class="row" style="height: 100vh">
  116.                                 <div class="col col-6 left">&lt;</div>
  117.                                 <div class="col col-6 right">&gt;</div>
  118.                             </div>
  119.                             <div class="row" style="position: absolute;top:0;left:0;right:0;">
  120.                                 <div class="col-12 close">
  121.                                     <button class="btn">&times;</button>
  122.                                 </div>
  123.                             </div>
  124.                         </div>
  125.                     </div>
  126.                     <div class="col-sm-12 col-md-4">
  127.                         <div class="grid-varosok">
  128.                             <ul>
  129.                                 {% for gallery in gallery_list %}
  130.                                     <a href="/galleries/{{ gallery.id }}/" rel="bookmark" class="varos {{ gallery.machineName }}"><li>{{ gallery.machineName }}</li></a>
  131.                                 {% endfor %}
  132.                             </ul>
  133.                         </div>
  134.                     </div>
  135.                 </div>
  136.             </div>
  137.         </div>
  138.     </div>
  139. {% endblock %}
  140. {% block javascripts %}
  141.         <script type="text/javascript" src="/assets/js/mdb/popper.min.js"></script>
  142.         <script type="text/javascript" src="/assets/js/mdb/bootstrap.min.js"></script>
  143.         <script type="text/javascript" src="/assets/js/mdb/mdb.min.js"></script>
  144.     <script language="JavaScript">
  145.         $(document).ready(function(){
  146.             var images = $('.img-fluid');
  147.             var box = $('.lightbox');
  148.             var left = $('.lightbox .left');
  149.             var right = $('.lightbox .right');
  150.             var close = $('.lightbox .close .btn');
  151.             var bg = $('.lightbox .hidebackground');
  152.             var bg_info = $('.lightbox .info-background');
  153.             var lastSrc = '', lastComment = '', lastTags = '';
  154.             images.on('click', function(){
  155.                 lastSrc = $(this).attr('src');
  156.                 lastComment = $(this).attr('data-comment');
  157.                 lastTags = $(this).attr('data-tags');
  158.                 setImage();
  159.             });
  160.             left.click(function(){
  161.                 bg.animate({'opacity':1},300,function(){
  162.                     var found = getImage();
  163.                     if (found > -1) {
  164.                         var prev = images[(found - 1) < 0 ? (images.length - 1) : (found - 1)];
  165.                         lastSrc = $(prev).attr('src');
  166.                         lastComment = $(prev).attr('data-comment');
  167.                         lastTags = $(prev).attr('data-tags');
  168.                         setImage();
  169.                     }
  170.                 });
  171.             });
  172.             right.click(function(){
  173.                 bg.animate({'opacity':1},300,function() {
  174.                     var found = getImage();
  175.                     if (found > -1) {
  176.                         var next = images[(found + 1) > images.length - 1 ? 0 : (found + 1)];
  177.                         lastSrc = $(next).attr('src');
  178.                         lastComment = $(next).attr('data-comment');
  179.                         lastTags = $(next).attr('data-tags');
  180.                         setImage();
  181.                     }
  182.                 });
  183.             });
  184.             close.click(function(){
  185.                 bg.animate({'opacity':1},300,function() {
  186.                     box.css({
  187.                         'opacity': 0,
  188.                         'pointer-events': 'none'
  189.                     });
  190.                 });
  191.             });
  192.             function setImage() {
  193.                 box.css({
  194.                     'background-image': 'url('+lastSrc+')',
  195.                     'opacity': 1,
  196.                     'pointer-events': 'all'
  197.                 });
  198.                 bg_info.find('.comment').css({'display': lastComment.trim().length > 0 ? 'block' : 'none'}).html(lastComment);
  199.                 bg_info.find('.tags').css({'display': lastTags.trim().length > 0 ? 'block' : 'none'}).html(lastTags);
  200.                 setTimeout(function(){
  201.                     bg.animate({'opacity': 0}, 500);
  202.                 },100);
  203.             }
  204.             function getImage() {
  205.                 var found = -1;
  206.                 images.each(function(index, img) {
  207.                     if ($(img).attr('src') == lastSrc) {
  208.                         found = index;
  209.                     }
  210.                 });
  211.                 return found;
  212.             }
  213.         });
  214.     </script>
  215. {% endblock %}