templates/frontend/monografiecataloghi.documento.html.twig line 1

Open in your IDE?
  1. {% extends "base.html.twig" %}
  2. {% block pageTitle %} {{ document.titolo }} {% endblock %}
  3. {% block pageStyle %}
  4.     
  5.     {{ parent() }} 
  6.     <!-- Core CSS file -->
  7.     <link rel="stylesheet" href="{{ asset("vendor/PhotoSwipe/dist-old/photoswipe.css") }}"> 
  8.     <!-- Skin CSS file (styling of UI - buttons, caption, etc.)
  9.          In the folder of skin CSS file there are also:
  10.          - .png and .svg icons sprite, 
  11.          - preloader.gif (for browsers that do not support CSS animations) -->
  12.     <link rel="stylesheet" href="{{ asset("vendor/PhotoSwipe/dist-old/default-skin/default-skin.css") }}"> 
  13.     
  14. {% endblock %}
  15. {% block pageScriptsHeader %} 
  16.     
  17.     {{ parent() }} 
  18.     
  19.     <!-- Core JS file -->
  20.     <script src="{{ asset("vendor/PhotoSwipe/dist-old/photoswipe.min.js") }}"></script> 
  21.     <!-- UI JS file -->
  22.     <script src="{{ asset("vendor/PhotoSwipe/dist-old/photoswipe-ui-default.min.js") }}"></script>
  23. {% endblock %}
  24. {% block navigation %} {{ parent() }} {% endblock %}
  25. {% block upperMainContainer %}
  26.     
  27. {% endblock %}
  28. {% block mainContainer %}
  29.     
  30.     <!-- Root element of PhotoSwipe. Must have class pswp. -->
  31.     <div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
  32.         <!-- Background of PhotoSwipe. 
  33.              It's a separate element as animating opacity is faster than rgba(). -->
  34.         <div class="pswp__bg"></div>
  35.         <!-- Slides wrapper with overflow:hidden. -->
  36.         <div class="pswp__scroll-wrap">
  37.             <!-- Container that holds slides. 
  38.                 PhotoSwipe keeps only 3 of them in the DOM to save memory.
  39.                 Don't modify these 3 pswp__item elements, data is added later on. -->
  40.             <div class="pswp__container">
  41.                 <div class="pswp__item"></div>
  42.                 <div class="pswp__item"></div>
  43.                 <div class="pswp__item"></div>
  44.             </div>
  45.             <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
  46.             <div class="pswp__ui pswp__ui--hidden">
  47.                 <div class="pswp__top-bar">
  48.                     <!--  Controls are self-explanatory. Order can be changed. -->
  49.                     <div class="pswp__counter"></div>
  50.                     <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
  51.                     <button class="pswp__button pswp__button--share" title="Share"></button>
  52.                     <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
  53.                     <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
  54.                     <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
  55.                     <!-- element will get class pswp__preloader--active when preloader is running -->
  56.                     <div class="pswp__preloader">
  57.                         <div class="pswp__preloader__icn">
  58.                           <div class="pswp__preloader__cut">
  59.                             <div class="pswp__preloader__donut"></div>
  60.                           </div>
  61.                         </div>
  62.                     </div>
  63.                 </div>
  64.                 <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
  65.                     <div class="pswp__share-tooltip"></div> 
  66.                 </div>
  67.                 <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
  68.                 </button>
  69.                 <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
  70.                 </button>
  71.                 <div class="pswp__caption">
  72.                     <div class="pswp__caption__center"></div>
  73.                 </div>
  74.             </div>
  75.         </div>
  76.     </div>
  77.     
  78.     <div class="container cortelazzo-font-regular">
  79.         
  80.         <!-- All data -->
  81.         <div class="row">
  82.             <div class="col-xl-12">
  83.                 <span><a href="{{ path("monografieCataloghi") }}">Torna a Monografie e Cataloghi</a></span>
  84.                 {% if app.user and is_granted('IS_AUTHENTICATED_FULLY') %}
  85.                 <span> | </span>
  86.                 <span><a href="{{ path("modifyDocument", {iddocument: document.id}) }}">Modifica documento</a></span>
  87.                 {% endif %}
  88.             </div>
  89.             <div class="col-xl-12 mb-3 mt-3">
  90.                 <p class="h1 cortelazzo-titles cortelazzo-font-bold">{{ document.titolo }}</p>
  91.             </div>
  92.             {% if document.cover is not null %}
  93.                 <div class="my-gallery col-xl-12" itemscope itemtype="http://schema.org/ImageGallery">
  94.                     <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
  95.                         <a href="{{ asset(uploaded_img_big ~ document.cover.fileref ~ '.' ~ document.cover.estensione) }}" itemprop="contentUrl" data-size="{{ document.cover.widthbig }}x{{ document.cover.heightbig }}">
  96.                             <img style="max-width: 500px" class="img-fluid" src="{{ asset(uploaded_img_normal ~ document.cover.fileref ~ '.' ~ document.cover.estensione) }}" alt="{{ document.cover.nome }}">
  97.                         </a>
  98.                     </figure>
  99.                 </div>
  100.             {% else %}
  101.                 <img class="col-xl-2" src="{{ asset("images/picture.png") }}" alt="{{ document.titolo }}">
  102.             {% endif %}
  103.             <div class="col-xl-12">
  104.                 <div class="container p-0 mt-4">
  105.                     <div class="row">
  106.                         {% if document.titolo | length > 0 %}
  107.                         <div class="col-xl-12">
  108.                             <h3>{{ document.titolo }}</h3>
  109.                         </div>
  110.                         {% endif %}
  111.                         {% if document.autore | length > 0 %}
  112.                             <div class="col-xl-12">
  113.                                 Autore: {{ document.autore }}
  114.                             </div>
  115.                         {% endif %}
  116.                         {% if document.luogo | length > 0 %}
  117.                             <div class="col-xl-12">
  118.                                 Luogo: {{ document.luogo }}
  119.                             </div>
  120.                         {% endif %}
  121.                         {% if document.anno | length > 0 %}
  122.                         <div class="col-xl-12">
  123.                             Anno: {{ document.anno }}
  124.                         </div>
  125.                         {% endif %}
  126.                         {% if document.editore | length > 0 %}
  127.                         <div class="col-xl-12">
  128.                             Editore: {{ document.editore }}
  129.                         </div>
  130.                         {% endif %}
  131.                         {% if document.tipo | length > 0 %}
  132.                         <div class="col-xl-12">
  133.                             Tipo: {{ document.tipo }}
  134.                         </div>
  135.                         {% endif %}
  136.                         {% if document.file %}
  137.                             {% if document.file.tipo == 'image' %}
  138.                                 <div class='my-gallery col-xl-12' itemscope itemtype="http://schema.org/ImageGallery">
  139.                                     <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
  140.                                         <a href="{{ asset(uploaded_img_big ~ document.file.fileref ~ '.' ~ document.file.estensione) }}" itemprop="contentUrl" data-size="{{ document.file.widthnormal }}x{{ document.file.heightnormal }}">
  141.                                             <img src="{{ asset(uploaded_img_thumbnail ~ document.file.fileref ~ '.' ~ document.file.estensione) }}" itemprop="thumbnail" alt="{{ document.file.nome }}" />
  142.                                         </a>
  143.                                         <figcaption itemprop="caption description">{{ document.file.nome }}</figcaption>
  144.                                     </figure>
  145.                                 </div>
  146.                             {% elseif document.file.tipo == 'document' %}
  147.                                 <figure class='col-xl-2'>
  148.                                     <a href="{{ asset(uploaded_documents ~ document.file.fileref ~ '.' ~ document.file.estensione) }}">
  149.                                         <img class="img-fluid" src="{{ asset('administrator/img/glyphicons-filetypes-65-pdf@3x.png') }}" />
  150.                                     </a>
  151.                                     <figcaption itemprop="caption description">{{ document.file.nome | slice(0, 10) ~ '...' }}</figcaption>
  152.                                 </figure>
  153.                             {% endif %}
  154.                         {% endif %}
  155.                     </div>
  156.                 </div>
  157.             </div>
  158.         </div>
  159.         
  160.     </div>
  161.                     
  162.     <script type="text/javascript">
  163.         var initPhotoSwipeFromDOM = function(gallerySelector) {
  164.             // parse slide data (url, title, size ...) from DOM elements 
  165.             // (children of gallerySelector)
  166.             var parseThumbnailElements = function(el) {
  167.                 var thumbElements = el.childNodes,
  168.                     numNodes = thumbElements.length,
  169.                     items = [],
  170.                     figureEl,
  171.                     linkEl,
  172.                     size,
  173.                     item;
  174.                 for(var i = 0; i < numNodes; i++) {
  175.                     figureEl = thumbElements[i]; // <figure> element
  176.                     // include only element nodes 
  177.                     if(figureEl.nodeType !== 1) {
  178.                         continue;
  179.                     }
  180.                     linkEl = figureEl.children[0]; // <a> element
  181.                     size = linkEl.getAttribute('data-size').split('x');
  182.                     // create slide object
  183.                     item = {
  184.                         src: linkEl.getAttribute('href'),
  185.                         w: parseInt(size[0], 10),
  186.                         h: parseInt(size[1], 10)
  187.                     };
  188.                     if(figureEl.children.length > 1) {
  189.                         // <figcaption> content
  190.                         item.title = figureEl.children[1].innerHTML; 
  191.                     }
  192.                     if(linkEl.children.length > 0) {
  193.                         // <img> thumbnail element, retrieving thumbnail url
  194.                         item.msrc = linkEl.children[0].getAttribute('src');
  195.                     } 
  196.                     item.el = figureEl; // save link to element for getThumbBoundsFn
  197.                     items.push(item);
  198.                 }
  199.                 return items;
  200.             };
  201.             // find nearest parent element
  202.             var closest = function closest(el, fn) {
  203.                 return el && ( fn(el) ? el : closest(el.parentNode, fn) );
  204.             };
  205.             // triggers when user clicks on thumbnail
  206.             var onThumbnailsClick = function(e) {
  207.                 e = e || window.event;
  208.                 e.preventDefault ? e.preventDefault() : e.returnValue = false;
  209.                 var eTarget = e.target || e.srcElement;
  210.                 // find root element of slide
  211.                 var clickedListItem = closest(eTarget, function(el) {
  212.                     return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
  213.                 });
  214.                 if(!clickedListItem) {
  215.                     return;
  216.                 }
  217.                 // find index of clicked item by looping through all child nodes
  218.                 // alternatively, you may define index via data- attribute
  219.                 var clickedGallery = clickedListItem.parentNode,
  220.                     childNodes = clickedListItem.parentNode.childNodes,
  221.                     numChildNodes = childNodes.length,
  222.                     nodeIndex = 0,
  223.                     index;
  224.                 for (var i = 0; i < numChildNodes; i++) {
  225.                     if(childNodes[i].nodeType !== 1) { 
  226.                         continue; 
  227.                     }
  228.                     if(childNodes[i] === clickedListItem) {
  229.                         index = nodeIndex;
  230.                         break;
  231.                     }
  232.                     nodeIndex++;
  233.                 }
  234.                 if(index >= 0) {
  235.                     // open PhotoSwipe if valid index found
  236.                     openPhotoSwipe( index, clickedGallery );
  237.                 }
  238.                 return false;
  239.             };
  240.             // parse picture index and gallery index from URL (#&pid=1&gid=2)
  241.             var photoswipeParseHash = function() {
  242.                 var hash = window.location.hash.substring(1),
  243.                 params = {};
  244.                 if(hash.length < 5) {
  245.                     return params;
  246.                 }
  247.                 var vars = hash.split('&');
  248.                 for (var i = 0; i < vars.length; i++) {
  249.                     if(!vars[i]) {
  250.                         continue;
  251.                     }
  252.                     var pair = vars[i].split('=');  
  253.                     if(pair.length < 2) {
  254.                         continue;
  255.                     }           
  256.                     params[pair[0]] = pair[1];
  257.                 }
  258.                 if(params.gid) {
  259.                     params.gid = parseInt(params.gid, 10);
  260.                 }
  261.                 return params;
  262.             };
  263.             var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
  264.                 var pswpElement = document.querySelectorAll('.pswp')[0],
  265.                     gallery,
  266.                     options,
  267.                     items;
  268.                 items = parseThumbnailElements(galleryElement);
  269.                 // define options (if needed)
  270.                 options = {
  271.                     // define gallery index (for URL)
  272.                     galleryUID: galleryElement.getAttribute('data-pswp-uid'),
  273.                     getThumbBoundsFn: function(index) {
  274.                         // See Options -> getThumbBoundsFn section of documentation for more info
  275.                         var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
  276.                             pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
  277.                             rect = thumbnail.getBoundingClientRect(); 
  278.                         return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
  279.                     }
  280.                 };
  281.                 // PhotoSwipe opened from URL
  282.                 if(fromURL) {
  283.                     if(options.galleryPIDs) {
  284.                         // parse real index when custom PIDs are used 
  285.                         // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
  286.                         for(var j = 0; j < items.length; j++) {
  287.                             if(items[j].pid == index) {
  288.                                 options.index = j;
  289.                                 break;
  290.                             }
  291.                         }
  292.                     } else {
  293.                         // in URL indexes start from 1
  294.                         options.index = parseInt(index, 10) - 1;
  295.                     }
  296.                 } else {
  297.                     options.index = parseInt(index, 10);
  298.                 }
  299.                 // exit if index not found
  300.                 if( isNaN(options.index) ) {
  301.                     return;
  302.                 }
  303.                 if(disableAnimation) {
  304.                     options.showAnimationDuration = 0;
  305.                 }
  306.                 // Pass data to PhotoSwipe and initialize it
  307.                 gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
  308.                 gallery.init();
  309.             };
  310.             // loop through all gallery elements and bind events
  311.             var galleryElements = document.querySelectorAll( gallerySelector );
  312.             for(var i = 0, l = galleryElements.length; i < l; i++) {
  313.                 galleryElements[i].setAttribute('data-pswp-uid', i+1);
  314.                 galleryElements[i].onclick = onThumbnailsClick;
  315.             }
  316.             // Parse URL and open gallery if it contains #&pid=3&gid=1
  317.             var hashData = photoswipeParseHash();
  318.             if(hashData.pid && hashData.gid) {
  319.                 openPhotoSwipe( hashData.pid ,  galleryElements[ hashData.gid - 1 ], true, true );
  320.             }
  321.         };
  322.         // execute above function
  323.         initPhotoSwipeFromDOM('.my-gallery');
  324.     </script>
  325.     
  326. {% endblock %}