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