templates/Nordinfo/Main/agenda.html.twig line 1

Open in your IDE?
  1. {% extends 'Nordinfo/Main/base.html.twig' %}
  2. {% block title %}{{ title }} - Nord Info{% endblock %}
  3. {% block body_class %}
  4.   {% if is_favorites_page is defined and is_favorites_page == 1 %}body-favorites
  5.   {% endif %}
  6. {% endblock %}
  7. {% set show_btt = true %}
  8. {% block body %}
  9.   <main data-aria-hidden-by-modal tabindex="-1" id="mainContent" class="pBXL">
  10.     <h1 class="sr-only">{{ title }}</h1>
  11.     {% if tagbar == true %}
  12.       {{ include('Nordinfo/Main/parts/tags.html.twig') }}
  13.     {% endif %}
  14.     {% if show_date_bar is defined and show_date_bar == 1 %}
  15.       {% include 'Nordinfo/Main/parts/date_bar.html.twig' %}
  16.     {% endif %}
  17.     {% if cookie_search is defined and cookie_search == true %}
  18.       {{ include('Nordinfo/Main/parts/add_tags_bar.html.twig', {'is_agenda' : true}) }}
  19.       {% if false %}
  20.         <div class="addTagsBar">
  21.           <ul>
  22.             <li>
  23.               <a href="{{ path('vos_lieux') }}"
  24.                  aria-label="lieu(x) de vie :{% if cookie_territories is null %}Tous{% else %}{% for c in cookie_territories %}{{ c }}{% if loop.last == false %},{% endif %}{% endfor %}{% endif %} - Ajouter ou supprimer des lieux de vie">
  25.                 <div class="container">
  26.                   <div class="row">
  27.                     <div class="col">
  28.                       <div class="__inner">
  29.                         <p class="__text">
  30.                           <span class="text-secondary">Lieu(x) de vie :</span>
  31.                           {% if cookie_territories is null %}
  32.                             Tous
  33.                           {% else %}
  34.                             {% for c in cookie_territories %}
  35.                               {{ c }}{% if loop.last == false %}, {% endif %}
  36.                             {% endfor %}
  37.                           {% endif %}
  38.                         </p>
  39.                         <div class="__icon">
  40.                           <svg aria-hidden="true" focusable="false" data-name="Calque 1"
  41.                                xmlns="http://www.w3.org/2000/svg" viewbox="0 0 121.6 121.6">
  42.                             <g id="add">
  43.                               <path id="add-2" class="" d="M55.6,0V55.6H0V66H55.6v55.6H66V66h55.6V55.6H66V0Z"/>
  44.                             </g>
  45.                           </svg>
  46.                         </div>
  47.                       </div>
  48.                     </div>
  49.                   </div>
  50.                 </div>
  51.               </a>
  52.             </li>
  53.           </ul>
  54.         </div>
  55.       {% endif %}
  56.     {% endif %}
  57.     {% if show_agenda_filters is defined %}
  58.       {% if show_agenda_filters == 1 %}
  59.         <div class="filtersBar">
  60.           <div class="container">
  61.             <ul>
  62.               <li {% if app.request.query.get('date') == 'today' %}class="active"{% endif %}>
  63.                 <a href="{{ path('agenda') }}{% if app.request.query.get('date') != 'today' %}?date=today{% endif %}"
  64.                    {% if app.request.query.get('date') == 'today' %}aria-current="true"{% endif %}>
  65.                   <span>Aujourd'hui</span>
  66.                 </a>
  67.               </li>
  68.               <li {% if app.request.query.get('date') == 'weekend' %}class="active"{% endif %}>
  69.                 <a
  70.                   href="{{ path('agenda') }}{% if app.request.query.get('date') != 'weekend' %}?date=weekend{% endif %}"
  71.                   {% if app.request.query.get('date') == 'weekend' %}aria-current="true"{% endif %}>
  72.                   <span>Ce Week-end</span>
  73.                 </a>
  74.               </li>
  75.               <li
  76.                 {% if app.request.query.get('date') != 'weekend' and app.request.query.get('date') != 'today' and app.request.query.get('date') != null %}class="active"{% endif %}>
  77.                 <button data-toggle="modal" data-target="#modalAgendaDateFilter"
  78.                         {% if app.request.query.get('date') != 'weekend' and app.request.query.get('date') != 'today' and app.request.query.get('date') != null %}aria-current="true"{% endif %}>
  79.                   <span>À partir du</span>
  80.                 </button>
  81.               </li>
  82.             </ul>
  83.           </div>
  84.         </div>
  85.       {% endif %}
  86.     {% endif %}
  87.     {% if show_date_bar_agenda is defined and posts is not empty %}
  88.       <div class="dateBar dateBar-dynamic" id="dateBarDynamic" aria-hidden="true">
  89.         <div class="container">
  90.           <div class="row">
  91.             <div class="col" data-date-bar-value>
  92.               <p>À partir du
  93.                 <span class="textTransformCapitalize">{{ show_date_bar_agenda }}</span>
  94.               </p>
  95.             </div>
  96.           </div>
  97.         </div>
  98.       </div>
  99.     {% endif %}
  100.     {% if is_favorites_page is defined and is_favorites_page == 1 %}
  101.       {{ include('Nordinfo/Main/parts/breadcrumb.html.twig') }}
  102.       {% if referer is not null %}
  103.         {% set url_back = referer %}
  104.       {% else %}
  105.         {% set url_back = path('info') %}
  106.       {% endif %}
  107.       {% include 'Nordinfo/Main/parts/back_btn.html.twig' with {'back_btn_class':'_list-page'} %}
  108.       <div class="container pb-4 pt-5">
  109.         <div class="containerPageHeader">
  110.           <h1>Mes favoris</h1>
  111.         </div>
  112.       </div>
  113.     {% endif %}
  114.     {% if app.request.query.get('date') == 'weekend' or app.request.query.get('date') == 'today' or app.request.query.get('date') != null %}
  115.       <h2 class="headingSection mt-6 mBMd--imp --agenda" id="headingAgenda">
  116.         {% if app.request.query.get('date') == 'today' %}
  117.           Aujourd’hui
  118.         {% elseif app.request.query.get('date') == 'weekend' %}
  119.           Ce week-end
  120.         {% elseif app.request.query.get('date') != 'weekend' and app.request.query.get('date') != 'today' and app.request.query.get('date') != null %}
  121.           À partir du {{ show_date_bar_agenda }}
  122.         {% endif %}
  123.       </h2>
  124.     {% endif %}
  125.     <div class="container _masonry pt-5">
  126.       {% if posts is empty and title == 'Favoris' %}
  127.         <div class="text-center">
  128.           Vous n’avez pas encore de favoris.
  129.         </div>
  130.       {% endif %}
  131.       {% if posts is empty and title == 'Agenda' %}
  132.         <div class="text-center">
  133.           Il n'y a aucun évènement correspondant à vos
  134.           <a href="{{ path('vos_lieux') }}">Lieux de vie</a>
  135.         </div>
  136.       {% endif %}
  137.       {% if posts is not empty %}
  138.         <div class="gridMasonry" id="gridMasonry">
  139.           <div class="grid-sizer"></div>
  140.           {% for post in posts %}
  141.             {{ include('Nordinfo/Main/parts/item_list_agenda.html.twig') }}
  142.           {% endfor %}
  143.         </div>
  144.       {% endif %}
  145.       {% if items_total > initial_limit %}
  146.         {% include 'Nordinfo/Main/parts/loader_ajax.html.twig' %}
  147.       {% endif %}
  148.     </div>
  149.     <div class="modal fade modalCustom" id="modalAgendaDateFilter" tabindex="-1" role="dialog"
  150.          aria-labelledby="modalAgendaDateFilterLabel" aria-hidden="true">
  151.       <div class="modal-dialog" role="document">
  152.         <button type="button" class="close" data-dismiss="modal">
  153.           <span aria-hidden="true">&times;</span>
  154.           <span class="sr-only">Fermer À partir du</span>
  155.         </button>
  156.         <div class="modal-content">
  157.           <div class="modal-header">
  158.             <h1 class="modal-title" id="modalAgendaDateFilterLabel">À partir du</h1>
  159.           </div>
  160.           <div class="modal-body">
  161.             <form action="#" id="formAgendaDateFilter">
  162.               <div class="form-group">
  163.                 <input type="hidden" id="inputDate" value="">
  164.               </div>
  165.               <div class="text-right">
  166.                 <button type="submit" class="btn btnSubmit">
  167.                   <span class="__text">Rechercher</span>
  168.                 </button>
  169.               </div>
  170.             </form>
  171.           </div>
  172.         </div>
  173.       </div>
  174.     </div>
  175.   </main>
  176. {% endblock %}
  177. {% block javascripts %}
  178.   <script src="{{ asset('plugins/jquery-date-dropdowns/dist/jquery.date-dropdowns.min.js') }}"></script>
  179.   <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
  180.   <script type="text/javascript">
  181.     $(function () {
  182.       // Helper to get URL parameters
  183.       var getUrlParameter = function getUrlParameter(sParam) {
  184.         var sPageURL = window.location.search.substring(1),
  185.           sURLVariables = sPageURL.split('&'),
  186.           sParameterName,
  187.           i;
  188.         for (i = 0; i < sURLVariables.length; i++) {
  189.           sParameterName = sURLVariables[i].split('=');
  190.           if (sParameterName[0] === sParam) {
  191.             return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
  192.           }
  193.         }
  194.         return false;
  195.       };
  196.       var today = new Date();
  197.       var currentYear = today.getFullYear();
  198.       // 1. Check for date in URL
  199.       var urlDate = getUrlParameter('date');
  200.       var defaultDateValue;
  201.       // 2. Logic to set default date
  202.       if (urlDate && urlDate.indexOf('/') > -1) {
  203.         // Assuming format dd/mm/yyyy
  204.         var parts = urlDate.split('/');
  205.         // Note: Month is 0-indexed in JS Date object, so parts[1] - 1
  206.         var parsedDate = new Date(parts[2], parts[1] - 1, parts[0]);
  207.         // Convert to Unix timestamp for the plugin
  208.         defaultDateValue = Math.round(parsedDate.getTime() / 1000);
  209.       } else {
  210.         // Fallback to today
  211.         defaultDateValue = Math.round((new Date()).getTime() / 1000);
  212.       }
  213.       
  214.       $('#formAgendaDateFilter').on('submit', function (event) {
  215.         event.preventDefault();
  216.         var dateVal = $("#inputDate").val();
  217.         var notTimestamp = dateVal.includes("/");
  218.         var date = dateVal;
  219.         if (!notTimestamp) {
  220.           date = new Date(dateVal * 1000);
  221.           var day = date.getDate();
  222.           var month = date.getMonth() + 1;
  223.           var year = date.getFullYear();
  224.           date = day + "/" + month + "/" + year;
  225.         }
  226.         window.location.href = '/agenda?date=' + date;
  227.         return false;
  228.       });
  229.       $("#inputDate").dateDropdowns({
  230.         monthLongValues: [
  231.           'Janvier',
  232.           'Février',
  233.           'Mars',
  234.           'Avril',
  235.           'Mai',
  236.           'Juin',
  237.           'Juillet',
  238.           'Aout',
  239.           'Septembre',
  240.           'Octobre',
  241.           'Novembre',
  242.           'Décembre'
  243.         ],
  244.         submitFormat: 'dd/mm/yyyy',
  245.         minYear: currentYear,
  246.         maxYear: currentYear + 2,
  247.         yearLabel: 'Année',
  248.         daySuffixes: false,
  249.         monthLabel: 'Mois',
  250.         dayLabel: 'Jour',
  251.         dropdownClass: 'form-control',
  252.         required: true,
  253.         defaultDateFormat: 'unix',
  254.         defaultDate: defaultDateValue
  255.       })
  256.       var selectsDay = document.querySelector('select.day');
  257.       var selectsMonth = document.querySelector('select.month');
  258.       var selectsYear = document.querySelector('select.year');
  259.       if (document.body.contains(selectsDay)) {
  260.         selectsDay.setAttribute('title', 'jour');
  261.         selectsDay.setAttribute('aria-describedby', 'modalAgendaDateFilterLabel');
  262.       }
  263.       if (document.body.contains(selectsMonth)) {
  264.         selectsMonth.setAttribute('title', 'mois');
  265.         selectsMonth.setAttribute('aria-describedby', 'modalAgendaDateFilterLabel');
  266.       }
  267.       if (document.body.contains(selectsYear)) {
  268.         selectsYear.setAttribute('title', 'année');
  269.         selectsYear.setAttribute('aria-describedby', 'modalAgendaDateFilterLabel');
  270.       }
  271.     })
  272.   </script>
  273.   {{ include('Nordinfo/Main/parts/cookieManager.js.html.twig') }}
  274.   {{ parent() }}
  275. {% endblock %}
  276. {% block footer_top %}
  277.   {% if sites is defined %}
  278.     {% include 'Nordinfo/Main/parts/our-websites.html.twig' %}
  279.   {% endif %}
  280.   {% include 'Nordinfo/Main/parts/preFooter.html.twig' with {prefooter_template: 'nordinfo'} %}
  281. {% endblock %}