templates/project.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Projets{% endblock %}
  3. {% block body %}
  4.     {% set headerContent = content('Projets', 'Header') %}
  5.     {% if headerContent.picture is defined and headerContent.picture is not empty %}
  6.         {% set backgroundImage = headerContent.picture[0].path %}
  7.     {% else %}
  8.         {% set backgroundImage = 'empty' %}
  9.     {% endif %}
  10.     <header class="header-tracol col-lg-8 mx-auto" style="background-image: url({% if backgroundImage != 'empty' %}'/uploads/images/{{ backgroundImage }}'{% else %}{{ asset('img/projets_header.jpg') }}{% endif %});">
  11.         <div class="col-lg-8 mx-auto div-svg-header">
  12.             <div id="header-project" class="header-habiter-div">
  13.                 <svg id="svg-habiter" width="10" height="16" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:avocode="https://avocode.com/" viewBox="0 0 10 16"><defs></defs><desc>Generated with Avocode.</desc><g><g><title>Tracé 76</title><path d="M9.08929,0.51465v0h-9.08929v0v14.77002v0l9.08929,-1.93109v0z" fill="#f6a400" fill-opacity="1"></path></g></g></svg>
  14.                 <h2 class="header-habiter-title col-lg-6">{% if headerContent.name is defined %}{{ headerContent.name }}{% else %}Nos projets{% endif %}</h2>
  15.                 <div class="col-lg-8 header-content">
  16.                     {% if headerContent.content is defined %}{{ headerContent.content|raw }} {% else %}L’immobilier ayant un fort impact, Tracol Immobilier a pour ambition de répondre aux grands enjeux urbains du Luxembourg, tout en développant des projets environnementaux et sociétaux.{% endif %}
  17.                 </div>
  18.             </div>
  19.         </div>
  20.     </header>
  21.     <div class="container-fluid">
  22.         {% set sectionContent1 = content('Projets', 'Section-1') %}
  23.         <div class="col-lg-8 mx-auto div-svg-header pre-section">
  24.             <div class="col-lg-4" style="font-size: 2.3em;display: flex;flex-direction: column;margin-left: 10px;">
  25.                 <svg xmlns="http://www.w3.org/2000/svg" width="9.089" height="14.77" viewBox="0 0 9.089 14.77">
  26.                     <path id="Tracé_76" data-name="Tracé 76" d="M682.759,232.441h-9.089v14.77l9.089-1.931Z" transform="translate(-673.669 -232.441)" fill="#f6a400"/>
  27.                 </svg>
  28.                 {% if projects|length == 0 %}
  29.                     <h1 class="project-title">pas de projet</h1>
  30.                 {% elseif projects|length == 1  %}
  31.                     <h1 class="project-title">{{ projects|length }} projet</h1>
  32.                 {% else %}
  33.                     <h1 class="project-title">{{ projects|length }} projets</h1>
  34.                 {% endif %}
  35.             </div>
  36.             <div class="separator"></div>
  37.             <div id="section-1-project" class="col-lg-6 pre-section-content">
  38.                 {% if headerContent.content is defined %}{{ sectionContent1.content|raw }}{% else %}Développer durable, travailler avec des entreprises locales, maximiser nos impacts positifs (régénération urbaine, emploi local, etc.) et réduire nos impacts négatifs (émissions de CO2, biodiversité, ressources, …) pour apporter du mieux-vivre en ville, voilà comment nous imaginons nos projets !{% endif %}
  39.             </div>
  40.         </div>
  41.         <section class="project filter mt-5" style="margin-bottom: 120px">
  42.             <div id="button-project-page" class="col-lg-8 mx-auto div-svg-header mb-4" style="display: flex; align-items: center; padding-left: 7px">
  43.                 <div class="input-filter">
  44.                     <label for="all-projects">TOUS</label>
  45.                     <input data-id="all" type="radio" name="type" id="all-projects" class="mr-3 projectButton">
  46.                 </div>
  47.                 <div class="input-filter">
  48.                     <label for="futur-projects">A VENIR</label>
  49.                     <input data-id="futur" type="radio" name="type" id="futur-projects" class="mr-3 projectButton">
  50.                 </div>
  51.                 <div class="input-filter">
  52.                     <label for="construction-projects">EN COURS</label>
  53.                     <input data-id="construction" type="radio" name="type" id="construction-projects" class=" projectButton">
  54.                 </div>
  55.                 {#
  56.                 <button data-id="all" class="btn btn-primary all border-radius projectButton"><span class="span-all">TOUS</span></button>
  57.                 <button data-id="futur" class="btn btn-primary come border-radius projectButton"><span class="span-projects">A VENIR</span></button>
  58.                 <button data-id="construction" class="btn btn-primary come border-radius projectButton"><span class="span-projects">EN COURS</span></button>
  59.                 #}
  60.             </div>
  61.             <div id="button-project-page-mobile" class="col-lg-8 mx-auto div-svg-header" style="display: none; align-items: center">
  62.                 <div  class="flicking-viewport">
  63.                     <div class="flicking-camera">
  64.                         <div class="input-filter">
  65.                             <label for="all-projects-mobile">TOUS</label>
  66.                             <input data-id="all" type="radio" name="type" id="all-projects-mobile" class="mr-3 projectButton">
  67.                         </div>
  68.                         <div class="input-filter">
  69.                             <label for="futur-projects-mobile">A VENIR</label>
  70.                             <input data-id="futur" type="radio" name="type" id="futur-projects-mobile" class="mr-3 projectButton">
  71.                         </div>
  72.                         <div class="input-filter">
  73.                             <label for="construction-projects-mobile">EN COURS</label>
  74.                             <input data-id="construction" type="radio" name="type" id="construction-projects-mobile" class=" projectButton">
  75.                         </div>
  76.                         {#
  77.                         <button data-id="all" class="btn btn-primary all border-radius projectButton"><span class="span-all">TOUS</span></button>
  78.                         <button data-id="futur" class="btn btn-primary come border-radius projectButton"><span class="span-projects">A VENIR</span></button>
  79.                         <button data-id="construction" class="btn btn-primary come border-radius projectButton"><span class="span-projects">EN COURS</span></button>
  80.                         #}
  81.                     </div>
  82.                 </div>
  83.             </div>
  84.             <div class="col-lg-8 mx-auto div-svg-header" style="display: flex; justify-content: center; flex-direction: column;">
  85.                 {#
  86.                 <div id="filter-project-desktop">
  87.                     {% for key, subType in getSubTypeProject() %}
  88.                         <button data-id="{{ key }}" class="select-projet">{{ subType }} <i class="fas fa-times"></i></button>
  89.                     {% endfor %}
  90.                 </div>
  91.                 <div id="filter-project-mobile" class="col-lg-3 div-form selectSubFilter" style="display: none">
  92.                     <div class="input-group dropdown show">
  93.                         <label class="label-search-filter" for="location">Filtrer par Type</label>
  94.                         <input style="height: 75px; width: 60px;" type="text" autocomplete="off" name="filters" id="filters"
  95.                                class="form-control" aria-expanded="false">
  96.                         <ul id="form-search-filter-ajax" class="dropdown-menu form-search-filter-ajax" aria-labelledby="">
  97.                             {% for key, subType in getSubTypeProject() %}
  98.                                 <li value="{{ key }}" data-id="{{ key }}" class="select-filter"><i class="fas fa-times"></i>{{ subType }}</li>
  99.                             {% endfor %}
  100.                         </ul>
  101.                     </div>
  102.                 </div>
  103.                 #}
  104.                 {#
  105.                 <div id="loading">
  106.                     <h1 id="showOutput"></h1>
  107.                 </div>
  108.                 #}
  109.                 <div id="projects" class="row">
  110.                     {#
  111.                     {% for key, project in projects|slice(0,5) %}
  112.                         <div onclick="location.href='{{ path('project-detail', {'id': project.id}) }}'" data-id="{{ path('project-detail', {'id': project.id}) }}" class="col-lg-12 div-img-hover-2 project-desktop" style="cursor: pointer">
  113.                             {% if key == 0 %}
  114.                                 <div class="div-hover-2" id="div-hover-2" style="position: absolute; bottom: 8px; left: 8px; background-color: #242424; color: white; width: 291px; height: 85px">
  115.                                     <p class="city">{{ project.city.name }}</p>
  116.                                     <p class="project-name">{{ project.reference }}</p>
  117.                                     {% if project.comments[0].comment is not empty %}
  118.                                         <p class="project-content">
  119.                                             {{ project.comments[0].comment|slice(0, 250) }}</p>
  120.                                         <a  href="{{ path('project-detail', {'id': project.id}) }}" class="project-arrow-2">
  121.                                             <span class="galerry-ref"></span><i class="fas fa-arrow-right project-svg-arrow-2"></i>
  122.                                         </a>
  123.                                     {% else %}
  124.                                         <a style="margin-top: 180px" href="{{ path('project-detail', {'id': project.id}) }}" class="project-arrow-2">
  125.                                             <span class="galerry-ref"></span><i class="fas fa-arrow-right project-svg-arrow-2"></i>
  126.                                         </a>
  127.                                     {% endif %}
  128.                                 </div>
  129.                                 <div class="tag-ref-projet-2"><span class="text-tag-ref">{{ typeProject(project.construction.construction_step) }}</span></div>
  130.                                 {% if project.pictures is not empty %}
  131.                                     {% for picture in project.pictures|slice(0,1) %}
  132.                                         <div class="img" style="background-image: url('{{ picture.url }}')"></div>
  133.                                     {% endfor %}
  134.                                 {% else %}
  135.                                     <div class="img" style="background-image: url('{{ asset('build/Hudson_Ontario2.png') }}')"></div>
  136.                                 {% endif %}
  137.                             {% endif %}
  138.                         </div>
  139.                     {% endfor %}
  140.                     #}
  141.                     <div class="col-lg-12 project-desktop" style="display: flex; flex-wrap: wrap; flex-direction: row">
  142.                         {% for key, property in projects|slice(0,5) %}
  143.                             <div  class="col-12 col-xl-6 col-lg-6 col-md-12 col-sm-12" style="position:relative;cursor: pointer">
  144.                                 {% if property.pictures is not empty %}
  145.                                     <div class="position-relative properties-slide">
  146.                                             <div class="img" style="background-image: url('{{ property.pictures.0.url }}')"  onclick="location.href='{{ path('project-detail', {'id': property.id}) }}'">
  147.                                             </div>
  148.                                     </div>
  149.                                 {% else %}
  150.                                     <div class="img" style="background-image: url('{{ asset('build/Hudson_Ontario2.png') }}')"></div>
  151.                                 {% endif %}
  152.                                 {#
  153.                                 <div class="row col-md-12 justify-content-between">
  154.                                     <ul class="col-md-4 items">
  155.                                         <li class="item surface">
  156.                                             <img src="{{ asset('img/surface.svg') }}" class="surface-logo"> {{ property.area.value == null ? '' : property.area.value ~ areaConversion(property.area.unit) }}
  157.                                         </li>
  158.                                     </ul>
  159.                                     <div class="col-md-8 properties-price d-flex justify-content-end">
  160.                                         {{ property.price.value == null ? '<span style="font-size: 14px !important;">sur demande</span>' : property.price.value|number_format(2, ',', ' ') ~  property.price.currency|replace({"EUR": " €"})  }}
  161.                                     </div>
  162.                                 </div>
  163.                                 #}
  164.                                 <p class="city">{{ property.city.name }}</p>
  165.                                 <p class="project-name">{{ property.reference }}</p>
  166.                                 <div class="tag-ref-projet-2"><span class="text-tag-ref">{{ typeProject(property.construction.construction_step) }}</span></div>
  167.                             </div>
  168.                         {% endfor %}
  169.                     </div>
  170.                 </div>
  171.                 <div class="text-center text-capitalize more-projects">
  172.                     <p>AFFICHER PLUS DE PROJETS</p>
  173.                 </div>
  174.             </div>
  175.             {#
  176.             <div class="col-lg-8 mx-auto div-svg-header content-projet">
  177.                 {% set sectionContent1 = content('Projets', 'Section-2') %}
  178.                 <div id="section-2-project" class="col-lg-6 habiter-content">
  179.                     <svg xmlns="http://www.w3.org/2000/svg" width="9.089" height="14.77" viewBox="0 0 9.089 14.77">
  180.                         <path id="Tracé_76" data-name="Tracé 76" d="M682.759,232.441h-9.089v14.77l9.089-1.931Z" transform="translate(-673.669 -232.441)" fill="#f6a400"/>
  181.                     </svg>
  182.                     <div class="col-lg-9">
  183.                         <h1 class="habiter-title mb-5">
  184.                             {% if sectionContent1.name is defined %}{{ sectionContent1.name }}{% else %}INVESTIR À LUXEMBOURG{% endif %}
  185.                         </h1>
  186.                         {% if sectionContent1.content is defined %}{{ sectionContent1.content|raw }}{% else %}La demande locative est très importante au Luxembourg. En choisissant d’investir dans nos projets, vous avez l’assurance de louer très vite votre bien immobilier sans souci de devoir partir à la recherche de locataires potentiels. Votre investissement devient rapidement rentable. De plus, notre service de gestion locative peut vous accompagner dans votre démarche de A à Z.{% endif %}
  187.                     </div>
  188.                 </div>
  189.                 <div id="display-none-mobile" class="col-lg-6 habiter-img" {% if sectionContent1.picture is defined %}style="background-image: url('/uploads/images/{{ sectionContent1.picture[0].path }}')"{% endif %}>
  190.                 </div>
  191.             </div>
  192.             <div class="col-lg-12 div-svg-header last-section-project">
  193.                 <div id="section-projet-margin" class="offset-lg-2 col-lg-2" style="display: flex; justify-content: flex-start;">
  194.                     <a id="link-more" class="property-span-arrow" href="{{ path('invest') }}">EN SAVOIR PLUS
  195.                         <i class="fas fa-arrow-right property-arrow"></i>
  196.                     </a>
  197.                 </div>
  198.                 <div class="col-lg-3" style="display: flex;justify-content: flex-start;margin-left: 0;">
  199.                     <a href="{{ path('location-management') }}" class="property-span-arrow">LA GESTION LOCATIVE
  200.                         <i class="fas fa-arrow-right property-arrow"></i>
  201.                     </a>
  202.                 </div>
  203.             </div>
  204.             #}
  205.         </section>
  206.     </div>
  207.     <div id="img-property-section" class="container-fluid" style="display: none">
  208.         <div class="col-lg-6 habiter-img">
  209.             <img style="padding: 0px;" height="430px" class="img-100" {% if sectionContent1.picture is defined %}src="/uploads/images/{{ sectionContent1.picture[0].path }}"{% endif %}>
  210.         </div>
  211.     </div>
  212.     <script>
  213.         const futurProjects = document.getElementById('projects')
  214.         let buttons = document.getElementsByClassName('projectButton')
  215.         for (const eElement of buttons) {
  216.             eElement.addEventListener('click', function (e) {
  217.                 e.preventDefault()
  218.                 for (let button of buttons) {
  219.                     if (button.classList.contains('all')){
  220.                         button.classList.remove('all')
  221.                         //button.classList.add('come')
  222.                         //button.querySelector('span').classList.replace('span-all', 'span-projects')
  223.                     }
  224.                 }
  225.                 eElement.classList.remove('come')
  226.                 //eElement.classList.add('all')
  227.                 //eElement.querySelector('span').classList.replace('span-projects', 'span-all')
  228.                 fetch('projects/display/'+this.dataset.id, {
  229.                     method: 'GET',
  230.                 })
  231.                     .then(response => response.json())
  232.                     .then(data => {
  233.                         futurProjects.innerHTML = ''
  234.                         futurProjects.innerHTML = data.data
  235.                         _ww = $(window).width();
  236.                         var lightbox = $('.lightbox'),
  237.                             item = 0;
  238.                         $('.lightbox-on').click(function(e){
  239.                             e.stopPropagation();
  240.                             item = 0;
  241.                             console.log('click btn');
  242.                             var id = $(this).attr('data-id'),
  243.                                 max = 0;
  244.                             $('#'+id).toggle();
  245.                             $('#'+id).animate({opacity: 1}, 300);
  246.                             $('#'+id).find('img').each(function( i ) {
  247.                                 //console.log('h : '+$(this).height());
  248.                                 //console.log('w : '+$(this).width());
  249.                                 max = i;
  250.                                 item = 1;
  251.                                 counter(item, max+1);
  252.                                 itemWidth($(this));
  253.                             });
  254.                         });
  255.                         lightbox.click(function(e) {
  256.                             e.stopPropagation();
  257.                             $(this).animate({opacity: 0}, 300, function(){
  258.                                 $(this).toggle();
  259.                             });
  260.                         });
  261.                         $('.closer').on('click', function (e) {
  262.                             e.stopPropagation();
  263.                             $(this).parent().animate(
  264.                                 {opacity: 0},
  265.                                 300,
  266.                                 function(){
  267.                                     $(this).toggle();
  268.                                 }
  269.                             );
  270.                         });
  271.                         function itemWidth(img){
  272.                             img.closest('.items').width(img.width());
  273.                         }
  274.                         function counter(item, max){
  275.                             $('.counter').text(item + ' / ' + max);
  276.                         }
  277.                         $('.item', lightbox).on('click, swipeleft', function (e) {
  278.                             var wd = $(this).width(),
  279.                                 last = $(this).parent().find('.item').last(),
  280.                                 img = $(this).find('.img');
  281.                             itemWidth(img);
  282.                             $(this).animate(
  283.                                 {marginLeft: -wd, opacity: 0},
  284.                                 500,
  285.                                 'swing',
  286.                                 function(){
  287.                                     $(this).insertAfter(last);
  288.                                     $(this).css({marginLeft: 0, opacity: 1});
  289.                                 }
  290.                             );
  291.                         });
  292.                         $('.item', lightbox).on('swiperight', function (e) {
  293.                             var wd = $(this).width(),
  294.                                 first = $(this).parent().find('.item').first(),
  295.                                 last = $(this).parent().find('.item').last(),
  296.                                 img = $(this).find('.img');
  297.                             itemWidth(img);
  298.                             $(last).insertBefore($(this));
  299.                             $(last).css({marginLeft: -wd, opacity: 0});
  300.                             $(this).parent().find('.item').eq(0).animate(
  301.                                 {marginLeft: 0, opacity: 1},
  302.                                 500,
  303.                                 'swing'
  304.                             );
  305.                         });
  306.                         $('.arrows', lightbox).on('click', function (e) {
  307.                             e.stopPropagation();
  308.                             var wd = $(this).siblings('.items').find('.item').eq(0).width(),
  309.                                 max = $(this)
  310.                                     .siblings('.items').find('.item').length,
  311.                                 first = $(this).siblings('.items').find('.item').first(),
  312.                                 last = $(this).siblings('.items').find('.item').last(),
  313.                                 isRight = $(this).hasClass('right'),
  314.                                 marginL = isRight ? -wd : 0,
  315.                                 marginL0 = isRight ? 0: -wd,
  316.                                 opacOn = isRight ? 1 : 0,
  317.                                 opacOff = isRight ? 0 : 1;
  318.                             if (!isRight){
  319.                                 $(last).insertBefore(first);
  320.                                 $(last).css({marginLeft: -wd, opacity: 0});
  321.                                 item++;
  322.                                 if (item == max+1) {item = 1};
  323.                             } else {
  324.                                 item--;
  325.                                 if (item == 0) {item = max};
  326.                             };
  327.                             counter(item, max);
  328.                             var img = $(this).siblings('.items').find('.item').eq(0).find('.img');
  329.                             itemWidth(img);
  330.                             $(this).siblings('.items').find('.item').eq(1).animate(
  331.                                 {opacity: opacOn},
  332.                                 500,
  333.                                 'swing');
  334.                             $(this).siblings('.items').find('.item').eq(0).animate(
  335.                                 {marginLeft: marginL, opacity: 1},
  336.                                 500,
  337.                                 'swing',
  338.                                 function(){
  339.                                     if (isRight){
  340.                                         $(this).insertAfter(last);
  341.                                         $(this).css({ marginLeft: 0, opacity: 1});
  342.                                     }
  343.                                 }
  344.                             );
  345.                         });
  346.                         if (_ww > 768){
  347.                             $('.div-img-hover-2').hover(function (e) {
  348.                                 $(this).find('.project-arrow-2').animate({opacity: 1}, 150);
  349.                                 var htext = $(this).find('.project-content').height();
  350.                                 if (htext == undefined){htext = 0};
  351.                                 $(this).find('.div-hover-2').animate({height : htext+180}, 150);
  352.                                 $(this).find('.project-content').css({'visibility': 'visible'});
  353.                                 $(this).find('.project-content').animate({opacity: 1}, 150);
  354.                             }, function() {
  355.                                 console.log('down');
  356.                                 $(this).find('.div-hover-2').animate({height : 85}, 150);
  357.                                 $(this).find('.project-arrow-2').animate({opacity: 0}, 150);
  358.                                 $(this).find('.project-content').animate({opacity: 0}, 150, function(){
  359.                                     $(this).find('.project-content').css({'visibility': 'hidden'});
  360.                                 });
  361.                             });
  362.                         } else {
  363.                             $('.div-img-hover-2').on( "tap", function( event ) {
  364.                                 console.log('tap tap');
  365.                                 var opened = $(this).find('.div-hover-2').hasClass('open'),
  366.                                     ht = opened ? 85 : '100%',
  367.                                     vis = opened ? 0 : 1;
  368.                                 $(this).find('.div-hover-2').toggleClass('open');
  369.                                 $(this).find('.div-hover-2').animate({height : ht}, 150);
  370.                                 $(this).find('.project-arrow-2').animate({opacity: vis}, 150);
  371.                             });
  372.                         }
  373.                         $('.div-hover').hover(function (e) {
  374.                             $(this).find('.project-arrow-2').animate({opacity: 1}, 150);
  375.                         }, function() {
  376.                             $(this).find('.project-arrow-2').animate({opacity: 0}, 50);
  377.                         });
  378.                     })
  379.                     .catch((error) => {
  380.                         console.error('Error:', error);
  381.                     });
  382.             })
  383.         }
  384.         if (window.matchMedia("(max-width: 768px)").matches) {
  385.             const test = document.getElementsByClassName('select-filter')
  386.             for (const testElement of test) {
  387.                 testElement.addEventListener('click', function (e) {
  388.                     e.preventDefault()
  389.                     testElement.classList.toggle('select-projet-active')
  390.                     const infos = document.querySelector('.projectButton.all')
  391.                     const dataId = []
  392.                     const tests = document.querySelectorAll('.select-filter.select-projet-active')
  393.                     for (const test1 of tests) {
  394.                         dataId.push(parseFloat(test1.dataset.id))
  395.                     }
  396.                     fetch('projects/display/'+infos.dataset.id+'/params/' + JSON.stringify(dataId), {
  397.                         method: 'GET'
  398.                     })
  399.                         .then(response => response.json())
  400.                         .then(data => {
  401.                             futurProjects.innerHTML = data.data
  402.                         })
  403.                         .catch((error) => {
  404.                             console.error('Error:', error);
  405.                         });
  406.                 })
  407.             }
  408.         } else {
  409.             const test = document.getElementsByClassName('select-projet')
  410.             for (const testElement of test) {
  411.                 testElement.addEventListener('click', function (e) {
  412.                     displayLoading()
  413.                     e.preventDefault()
  414.                     testElement.classList.toggle('select-projet-active')
  415.                     const infos = document.querySelector('.projectButton.all')
  416.                     const dataId = []
  417.                     const tests = document.querySelectorAll('.select-projet.select-projet-active')
  418.                     for (const test1 of tests) {
  419.                         dataId.push(parseFloat(test1.dataset.id))
  420.                     }
  421.                     fetch('projects/display/'+infos.dataset.id+'/params/' + JSON.stringify(dataId), {
  422.                         method: 'GET'
  423.                     })
  424.                         .then(response => response.json())
  425.                         .then(data => {
  426.                             hideLoading()
  427.                             futurProjects.innerHTML = data.data
  428.                             _ww = $(window).width();
  429.                             var lightbox = $('.lightbox'),
  430.                                 item = 0;
  431.                             $('.lightbox-on').click(function(e){
  432.                                 e.stopPropagation();
  433.                                 item = 0;
  434.                                 console.log('click btn');
  435.                                 var id = $(this).attr('data-id'),
  436.                                     max = 0;
  437.                                 $('#'+id).toggle();
  438.                                 $('#'+id).animate({opacity: 1}, 300);
  439.                                 $('#'+id).find('img').each(function( i ) {
  440.                                     //console.log('h : '+$(this).height());
  441.                                     //console.log('w : '+$(this).width());
  442.                                     max = i;
  443.                                     item = 1;
  444.                                     counter(item, max+1);
  445.                                     itemWidth($(this));
  446.                                 });
  447.                             });
  448.                             lightbox.click(function(e) {
  449.                                 e.stopPropagation();
  450.                                 $(this).animate({opacity: 0}, 300, function(){
  451.                                     $(this).toggle();
  452.                                 });
  453.                             });
  454.                             $('.closer').on('click', function (e) {
  455.                                 e.stopPropagation();
  456.                                 $(this).parent().animate(
  457.                                     {opacity: 0},
  458.                                     300,
  459.                                     function(){
  460.                                         $(this).toggle();
  461.                                     }
  462.                                 );
  463.                             });
  464.                             function itemWidth(img){
  465.                                 img.closest('.items').width(img.width());
  466.                             }
  467.                             function counter(item, max){
  468.                                 $('.counter').text(item + ' / ' + max);
  469.                             }
  470.                             $('.item', lightbox).on('click, swipeleft', function (e) {
  471.                                 var wd = $(this).width(),
  472.                                     last = $(this).parent().find('.item').last(),
  473.                                     img = $(this).find('.img');
  474.                                 itemWidth(img);
  475.                                 $(this).animate(
  476.                                     {marginLeft: -wd, opacity: 0},
  477.                                     500,
  478.                                     'swing',
  479.                                     function(){
  480.                                         $(this).insertAfter(last);
  481.                                         $(this).css({marginLeft: 0, opacity: 1});
  482.                                     }
  483.                                 );
  484.                             });
  485.                             $('.item', lightbox).on('swiperight', function (e) {
  486.                                 var wd = $(this).width(),
  487.                                     first = $(this).parent().find('.item').first(),
  488.                                     last = $(this).parent().find('.item').last(),
  489.                                     img = $(this).find('.img');
  490.                                 itemWidth(img);
  491.                                 $(last).insertBefore($(this));
  492.                                 $(last).css({marginLeft: -wd, opacity: 0});
  493.                                 $(this).parent().find('.item').eq(0).animate(
  494.                                     {marginLeft: 0, opacity: 1},
  495.                                     500,
  496.                                     'swing'
  497.                                 );
  498.                             });
  499.                             $('.arrows', lightbox).on('click', function (e) {
  500.                                 e.stopPropagation();
  501.                                 var wd = $(this).siblings('.items').find('.item').eq(0).width(),
  502.                                     max = $(this)
  503.                                         .siblings('.items').find('.item').length,
  504.                                     first = $(this).siblings('.items').find('.item').first(),
  505.                                     last = $(this).siblings('.items').find('.item').last(),
  506.                                     isRight = $(this).hasClass('right'),
  507.                                     marginL = isRight ? -wd : 0,
  508.                                     marginL0 = isRight ? 0: -wd,
  509.                                     opacOn = isRight ? 1 : 0,
  510.                                     opacOff = isRight ? 0 : 1;
  511.                                 if (!isRight){
  512.                                     $(last).insertBefore(first);
  513.                                     $(last).css({marginLeft: -wd, opacity: 0});
  514.                                     item++;
  515.                                     if (item == max+1) {item = 1};
  516.                                 } else {
  517.                                     item--;
  518.                                     if (item == 0) {item = max};
  519.                                 };
  520.                                 counter(item, max);
  521.                                 var img = $(this).siblings('.items').find('.item').eq(0).find('.img');
  522.                                 itemWidth(img);
  523.                                 $(this).siblings('.items').find('.item').eq(1).animate(
  524.                                     {opacity: opacOn},
  525.                                     500,
  526.                                     'swing');
  527.                                 $(this).siblings('.items').find('.item').eq(0).animate(
  528.                                     {marginLeft: marginL, opacity: 1},
  529.                                     500,
  530.                                     'swing',
  531.                                     function(){
  532.                                         if (isRight){
  533.                                             $(this).insertAfter(last);
  534.                                             $(this).css({ marginLeft: 0, opacity: 1});
  535.                                         }
  536.                                     }
  537.                                 );
  538.                             });
  539.                             if (_ww > 768){
  540.                                 $('.div-img-hover-2').hover(function (e) {
  541.                                     $(this).find('.project-arrow-2').animate({opacity: 1}, 150);
  542.                                     var htext = $(this).find('.project-content').height();
  543.                                     if (htext == undefined){htext = 0};
  544.                                     $(this).find('.div-hover-2').animate({height : htext+180}, 150);
  545.                                     $(this).find('.project-content').css({'visibility': 'visible'});
  546.                                     $(this).find('.project-content').animate({opacity: 1}, 150);
  547.                                 }, function() {
  548.                                     console.log('down');
  549.                                     $(this).find('.div-hover-2').animate({height : 85}, 150);
  550.                                     $(this).find('.project-arrow-2').animate({opacity: 0}, 150);
  551.                                     $(this).find('.project-content').animate({opacity: 0}, 150, function(){
  552.                                         $(this).find('.project-content').css({'visibility': 'hidden'});
  553.                                     });
  554.                                 });
  555.                             } else {
  556.                                 $('.div-hover-2').on( "click", function( event ) {
  557.                                     console.log('tap tap');
  558.                                     var opened = $(this).find('.div-hover-2').hasClass('open'),
  559.                                         ht = opened ? 85 : '100%',
  560.                                         vis = opened ? 0 : 1;
  561.                                     $(this).find('.div-hover-2').toggleClass('open');
  562.                                     $(this).find('.div-hover-2').animate({height : ht}, 150);
  563.                                     $(this).find('.project-arrow-2').animate({opacity: vis}, 150);
  564.                                 });
  565.                             }
  566.                             $('.div-hover').hover(function (e) {
  567.                                 $(this).find('.project-arrow-2').animate({opacity: 1}, 150);
  568.                             }, function() {
  569.                                 $(this).find('.project-arrow-2').animate({opacity: 0}, 50);
  570.                             });
  571.                         })
  572.                         .catch((error) => {
  573.                             console.error('Error:', error);
  574.                         });
  575.                 })
  576.             }
  577.         }
  578.         const buttonFilter = document.getElementsByClassName('select-projet')
  579.         for (const buttonFilterElement of buttonFilter) {
  580.             buttonFilterElement.addEventListener('click', function () {
  581.             })
  582.         }
  583.         if (window.matchMedia("(max-width: 768px)").matches) {
  584.             new Flicking("#flick4", {
  585.                 moveType: "freeScroll",
  586.                 bound: true
  587.             });
  588.         }
  589.         const filter = document.getElementById('filters')
  590.         const filterElement = document.getElementById('form-search-filter-ajax')
  591.         filter.addEventListener('click', function (e) {
  592.             e.preventDefault()
  593.             filterElement.classList.toggle('show')
  594.         })
  595.         const loader = document.querySelector("#loading");
  596.         function displayLoading() {
  597.             loader.classList.add("display");
  598.             // to stop loading after some time
  599.             setTimeout(() => {
  600.                 loader.classList.remove("display");
  601.             }, 5000);
  602.         }
  603.         // hiding loading
  604.         function hideLoading() {
  605.             loader.classList.remove("display");
  606.         }
  607.     </script>
  608. {% endblock %}