templates/FrontBundle/Page/spectacle-prev.html.twig line 1

Open in your IDE?
  1. {% extends 'FrontBundle/layout.html.twig' %}
  2. {% block title %}{{ app_sitename }} - {{ post.metaTitle }}{% endblock %}
  3. {% block description %}{{ post.metaDescription }}{% endblock %}
  4. {% block extra_class %}stack{% endblock %}
  5. {% block stylesheets %}
  6.     <link href="/front/css/owl.carousel.min.css" rel="stylesheet">
  7.     <link href="/front/css/owl.theme.default.min.css" rel="stylesheet">
  8.     <link href="/plugins/photoswipe/photoswipe.css" rel="stylesheet">
  9.     <link href="/plugins/photoswipe/default-skin/default-skin.css" rel="stylesheet" type="text/css"/>
  10. {% endblock %}
  11. {% block body %}
  12.       <section class="espace-content news-content spectacle-content full mt-5">
  13.         <div class="content pb-4">
  14.         <div class="row">
  15.           <div class="col-md-12 mb-3">
  16.             <a href="/{{app.request.locale }}/{{ 'spectacles-precedents'|getUrl(app.request.locale) }}" class="back mt-5">{{ 'precedents_back'|tr(tr)|raw }}</a>
  17.           </div>
  18.           {# <div class="col-md-8 main-image" style="background-image: url('/uploads/spectacles/{{post.id}}/{{post.getMainImage}}');"> #}
  19.           <div class="col-md-8 main-image" >
  20.           {% if post.getInfo('video') != "" %}
  21.             <iframe width="652" height="367" src="https://www.youtube.com/embed/{{ post.getInfo('video')}}?controls=0&autoplay=1&mute=1&showinfo=0&loop=1" allow="autoplay" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  22.           {% endif %}
  23.           {% if post.slug == 'talents' %}
  24.             <img src="/front/img/talents_main.jpg" alt="Talents" style="width:auto; max-width: 100%;" />
  25.           {% endif %}
  26.           </div>
  27.           <div class="col-md-4">
  28.             <div class="pl-5">
  29.               <h1>{{ post.metaTitle }}</h1>
  30.               <h2>{{ post.tags }}</h2>
  31.                 <p class="p-0 mt-5 text-dark">
  32.                     {{ post.content|raw }}
  33.                 </p>
  34.             </div>
  35.           </div>
  36.         </div>
  37.       </div>
  38.     </section>
  39.     <section class="espace-content news-content spectacle-content full mt-5 p-0">
  40.       <div class="slider mt-5 pt-5 pb-5 mb-0">
  41.         <div class="content">
  42.           <div class="row">
  43.             <div class="col-md-12">
  44.               <div class="owl-carousel images mt-4 mb-0 p-0">
  45.                 {% for image in post.allImages %}
  46.                   <a id="{{'now'|date('U')}}{{loop.index}}" href="/uploads/spectacles/{{post_id}}/{{image}}" itemprop="contentUrl" data-size="" class="item" style="background-image: url(/uploads/spectacles/{{post_id}}/{{image}});" source="{{ app.request.getSchemeAndHttpHost() }}/uploads/spectacles/{{post_id}}/{{image}}">
  47.                     <img src="/uploads/spectacles/{{post_id}}/{{image}}" style="display:none;" itemprop="thumbnail" alt="{{image}}" />
  48.                   </a>
  49.                 {% endfor %}
  50.               </div>
  51.             </div>
  52.           </div>
  53.           <div class="horizontal-bar-container">
  54.             <div class="horizontal-bar"></div>
  55.             <div class="horizontal-bar-ctrl"></div>
  56.           </div>
  57.         </div>
  58.       </div>
  59.     </section>
  60.         {% include 'FrontBundle/Partial/footer.html.twig' %}
  61. <!-- Root element of PhotoSwipe. Must have class pswp. -->
  62. <div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
  63.   <!-- Background of PhotoSwipe. 
  64.     It's a separate element as animating opacity is faster than rgba(). -->
  65.   <div class="pswp__bg"></div>
  66.   <!-- Slides wrapper with overflow:hidden. -->
  67.   <div class="pswp__scroll-wrap">
  68.     <!-- Container that holds slides. 
  69.       PhotoSwipe keeps only 3 of them in the DOM to save memory.
  70.       Don't modify these 3 pswp__item elements, data is added later on. -->
  71.     <div class="pswp__container">
  72.       <div class="pswp__item"></div>
  73.       <div class="pswp__item"></div>
  74.       <div class="pswp__item"></div>
  75.     </div>
  76.     <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
  77.     <div class="pswp__ui pswp__ui--hidden">
  78.       <div class="pswp__top-bar">
  79.         <!--  Controls are self-explanatory. Order can be changed. -->
  80.         <div class="pswp__counter"></div>
  81.         <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
  82.         <button class="pswp__button pswp__button--share" title="Share"></button>
  83.         <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
  84.         <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
  85.         <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR -->
  86.         <!-- element will get class pswp__preloader--active when preloader is running -->
  87.         <div class="pswp__preloader">
  88.           <div class="pswp__preloader__icn">
  89.             <div class="pswp__preloader__cut">
  90.               <div class="pswp__preloader__donut"></div>
  91.             </div>
  92.           </div>
  93.         </div>
  94.       </div>
  95.       <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
  96.         <div class="pswp__share-tooltip"></div>
  97.       </div>
  98.       <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
  99.       </button>
  100.       <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
  101.       </button>
  102.       <div class="pswp__caption">
  103.         <div class="pswp__caption__center"></div>
  104.       </div>
  105.     </div>
  106.   </div>
  107. </div>
  108. {% endblock %}
  109. {% block javascripts %}
  110.   <script src="/front/js/owl.carousel.min.js"></script>
  111.     <script src="/plugins/photoswipe/photoswipe.min.js"></script>
  112.     <script src="/plugins/photoswipe/photoswipe-ui-default.min.js"></script>
  113.   <script type="text/javascript">
  114.     $( document ).ready(function() {
  115.             $('.owl-carousel.images a').each(function(index, value) {
  116.                 img = new Image();
  117.                 size = 0;
  118.                 const ident = $(this).attr('id').toString();
  119.                 img.onload = function() {
  120.                   $('#'+ident).attr('data-size', this.width + 'x' + this.height);
  121.                 }
  122.                 img.src = $(this).attr('source');
  123.             }).promise().done( function(){ 
  124.                     setTimeout( function(){
  125.                       initPhotoSwipeFromDOM('.my-gallery'); 
  126.                     }, 1000);
  127.     
  128.             } );
  129.     });
  130.         var owl = $('.owl-carousel.images');
  131.     owl.owlCarousel({
  132.             loop: false,
  133.             nav: true,
  134.             dots: true,
  135.             itemElement: 'figure',
  136.             navText: ['',''],
  137.             margin: 52,
  138.         responsive:{
  139.             0:{
  140.                 items:1
  141.             },
  142.             414:{
  143.                 items:1
  144.             },
  145.           768:{
  146.               items:3
  147.           },
  148.           1024:{
  149.               items:4
  150.           },
  151.             1920:{
  152.                 items:5
  153.             }
  154.         }
  155.         });
  156.     owl.on('changed.owl.carousel', function(event) {
  157.       var itemsNbr = owl.data()['owl.carousel'].settings.items;
  158.       var itemsTotal = event.item.count;
  159.       var itemsIndex = event.item.index;
  160.       var pagesNbr = itemsTotal - itemsNbr;
  161.       var horizontalBar = $('.horizontal-bar').outerWidth();
  162.       var horizontalBarCtrl = $('.horizontal-bar-ctrl').outerWidth();
  163.       var courseLength = $('.horizontal-bar').outerWidth() - $('.horizontal-bar-ctrl').outerWidth();
  164.       var left = itemsIndex * 100 / pagesNbr; // percent
  165.       left = left * courseLength / 100;
  166.       $('.horizontal-bar-ctrl').css('left', left+'px');
  167.     
  168.     });
  169.         $('.owl-carousel.images .owl-stage').addClass('my-gallery');
  170.         $('.owl-carousel.images .owl-stage').attr('itemscope');
  171.         $('.owl-carousel.images .owl-stage').attr('itemtype', 'http://schema.org/ImageGallery');
  172.         $('.owl-carousel.images .owl-item ').attr('itemscope');
  173.         $('.owl-carousel.images .owl-item ').attr('itemprop', 'associatedMedia');
  174.         $('.owl-carousel.images .owl-item ').attr('itemtype', 'http://schema.org/ImageObject');
  175.     </script>
  176.     <script type="text/javascript">
  177.   
  178.   
  179.   var initPhotoSwipeFromDOM = function(gallerySelector) {
  180.   
  181.   // parse slide data (url, title, size ...) from DOM elements 
  182.   // (children of gallerySelector)
  183.   var parseThumbnailElements = function(el) {
  184.   
  185.       console.log(el.childNodes);
  186.   
  187.       var thumbElements = el.childNodes,
  188.           numNodes = thumbElements.length,
  189.           items = [
  190.            // {
  191.            //     src: 'https://dummyimage.com/1000x1000/ccc/5cac22',
  192.            //   w: '1024',
  193.            //   h: '1024'
  194.            // },
  195.            // {
  196.            //     src: 'https://dummyimage.com/1000x1000/5cac22/fff',
  197.            //   w: '1024',
  198.            //   h: '1024'
  199.            // }
  200.           ],
  201.           figureEl,
  202.           linkEl,
  203.           size,
  204.           item;
  205.   
  206.   
  207.   
  208.       for(var i = 0; i < numNodes; i++) {
  209.   
  210.           figureEl = thumbElements[i]; // <figure> element
  211.   
  212.           // include only element nodes 
  213.           if(figureEl.nodeType !== 1) {
  214.               continue;
  215.           }
  216.   
  217.           linkEl = figureEl.children[0]; // <a> element
  218.   
  219.           size = linkEl.getAttribute('data-size').split('x');
  220.   
  221.           // create slide object
  222.           item = {
  223.               src: linkEl.getAttribute('href'),
  224.               w: parseInt(size[0], 10),
  225.               h: parseInt(size[1], 10)
  226.           };
  227.   
  228.   
  229.   
  230.   
  231.           if(figureEl.children.length > 1) {
  232.               // <figcaption> content
  233.               item.title = figureEl.children[1].innerHTML; 
  234.           }
  235.   
  236.           if(linkEl.children.length > 0) {
  237.               // <img> thumbnail element, retrieving thumbnail url
  238.               item.msrc = linkEl.children[0].getAttribute('src');
  239.           } 
  240.   
  241.           item.el = figureEl; // save link to element for getThumbBoundsFn
  242.           items.push(item);
  243.       }
  244.   
  245.       return items;
  246.   };
  247.   
  248.   // find nearest parent element
  249.   var closest = function closest(el, fn) {
  250.       return el && ( fn(el) ? el : closest(el.parentNode, fn) );
  251.   };
  252.   
  253.   // triggers when user clicks on thumbnail
  254.   var onThumbnailsClick = function(e) {
  255.       e = e || window.event;
  256.       e.preventDefault ? e.preventDefault() : e.returnValue = false;
  257.   
  258.       var eTarget = e.target || e.srcElement;
  259.   
  260.       // find root element of slide
  261.       var clickedListItem = closest(eTarget, function(el) {
  262.           return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
  263.       });
  264.   
  265.       if(!clickedListItem) {
  266.           return;
  267.       }
  268.   
  269.       // find index of clicked item by looping through all child nodes
  270.       // alternatively, you may define index via data- attribute
  271.       var clickedGallery = clickedListItem.parentNode,
  272.           childNodes = clickedListItem.parentNode.childNodes,
  273.           numChildNodes = childNodes.length,
  274.           nodeIndex = 0,
  275.           index;
  276.   
  277.       for (var i = 0; i < numChildNodes; i++) {
  278.           if(childNodes[i].nodeType !== 1) { 
  279.               continue; 
  280.           }
  281.   
  282.           if(childNodes[i] === clickedListItem) {
  283.               index = nodeIndex;
  284.               break;
  285.           }
  286.           nodeIndex++;
  287.       }
  288.   
  289.   
  290.   
  291.       if(index >= 0) {
  292.           // open PhotoSwipe if valid index found
  293.           openPhotoSwipe( index, clickedGallery );
  294.       }
  295.       return false;
  296.   };
  297.   
  298.   // parse picture index and gallery index from URL (#&pid=1&gid=2)
  299.   var photoswipeParseHash = function() {
  300.       var hash = window.location.hash.substring(1),
  301.       params = {};
  302.   
  303.       if(hash.length < 5) {
  304.           return params;
  305.       }
  306.   
  307.       var vars = hash.split('&');
  308.       for (var i = 0; i < vars.length; i++) {
  309.           if(!vars[i]) {
  310.               continue;
  311.           }
  312.           var pair = vars[i].split('=');  
  313.           if(pair.length < 2) {
  314.               continue;
  315.           }           
  316.           params[pair[0]] = pair[1];
  317.       }
  318.   
  319.       if(params.gid) {
  320.           params.gid = parseInt(params.gid, 10);
  321.       }
  322.   
  323.       return params;
  324.   };
  325.   
  326.   var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
  327.       var pswpElement = document.querySelectorAll('.pswp')[0],
  328.           gallery,
  329.           options,
  330.           items;
  331.   
  332.       items = parseThumbnailElements(galleryElement);
  333.   
  334.       // define options (if needed)
  335.       options = {
  336.   
  337.           // define gallery index (for URL)
  338.           galleryUID: galleryElement.getAttribute('data-pswp-uid'),
  339.   
  340.           getThumbBoundsFn: function(index) {
  341.               // See Options -> getThumbBoundsFn section of documentation for more info
  342.               var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
  343.                   pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
  344.                   rect = thumbnail.getBoundingClientRect(); 
  345.   
  346.               return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
  347.           }
  348.   
  349.       };
  350.   
  351.       // PhotoSwipe opened from URL
  352.       if(fromURL) {
  353.           if(options.galleryPIDs) {
  354.               // parse real index when custom PIDs are used 
  355.               // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
  356.               for(var j = 0; j < items.length; j++) {
  357.                   if(items[j].pid == index) {
  358.                       options.index = j;
  359.                       break;
  360.                   }
  361.               }
  362.           } else {
  363.               // in URL indexes start from 1
  364.               options.index = parseInt(index, 10) - 1;
  365.           }
  366.       } else {
  367.           options.index = parseInt(index, 10);
  368.       }
  369.   
  370.       // exit if index not found
  371.       if( isNaN(options.index) ) {
  372.           return;
  373.       }
  374.   
  375.       if(disableAnimation) {
  376.           options.showAnimationDuration = 0;
  377.       }
  378.   
  379.       // Pass data to PhotoSwipe and initialize it
  380.       gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
  381.       gallery.init();
  382.   };
  383.   
  384.   // loop through all gallery elements and bind events
  385.   var galleryElements = document.querySelectorAll( gallerySelector );
  386.   
  387.   for(var i = 0, l = galleryElements.length; i < l; i++) {
  388.       galleryElements[i].setAttribute('data-pswp-uid', i+1);
  389.       galleryElements[i].onclick = onThumbnailsClick;
  390.   }
  391.   
  392.   // Parse URL and open gallery if it contains #&pid=3&gid=1
  393.   var hashData = photoswipeParseHash();
  394.   if(hashData.pid && hashData.gid) {
  395.       openPhotoSwipe( hashData.pid ,  galleryElements[ hashData.gid - 1 ], true, true );
  396.   }
  397.   };
  398.   
  399.   // // execute above function
  400.   // initPhotoSwipeFromDOM('.my-gallery');
  401.   
  402.     </script>
  403. {% endblock %}