templates/front/default/stores.html.twig line 1

Open in your IDE?
  1. {% extends "front/_common/_base.html.twig" %}
  2. {% block linkcanonical %}
  3.     <link rel="canonical" href="{{ absolute_url(path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params'))) }}">
  4. {% endblock %}
  5. {% block cssadicional %}{% endblock %}
  6. {% block classbody %}{% endblock %}
  7. {% block content %}
  8. <section class="banner-general">
  9.     <div class="wancho">
  10.         <div class="general_breadcrumbs">
  11.             <ul>
  12.                 <li><a href="{{ path('home') }}">INICIO</a></li>
  13.                 <li><a href="{{ path('stores') }}" aria-selected="true">LOCALES</a></li>
  14.             </ul>
  15.         </div>
  16.         <div class="main_title_layout">
  17.             <h2>{{ home.mainPrefix }}</h2>
  18.             <h1 class="general_title">{{ home.mainTitle|block_title|raw }}</h1>
  19.         </div>
  20.     </div>
  21. </section>
  22. <div>
  23.     <div class="wancho">
  24.         <ul class="list-locales flex">
  25.             {% for item in stores %}
  26.             <li class="list-locales__item" aria-selected="{{ item.slug == detail.slug ? 'true': 'false'}}"><a href="{{ path('store_detail', {'slug': item.slug}) }}">{{item.title}}</a></li>
  27.             {% endfor %}
  28.         </ul>
  29.     </div>
  30. </div>
  31. {% if detail.type == 'type2' %}
  32.     {% include 'front/default/store_type2.html.twig' %}
  33. {% else %}
  34.     {% include 'front/default/store_type1.html.twig' %}
  35. {% endif %}
  36. {% endblock %} 
  37. {% block jsfinal %}
  38. {% if detail.type == 'type2' %}
  39. <script type="text/javascript">
  40.     setInfo(document.getElementsByClassName('locales__list__item')[0]);
  41.     const listItem = document.getElementsByClassName('locales__list')[0];
  42.     listItem.addEventListener('click', event => {
  43.         if (event.target.className == 'locales__list__item') {
  44.             setInfo(event.target);
  45.             const docs = document.querySelectorAll('.locales__list__item');
  46.             docs.forEach(element => {
  47.                 element.classList.remove('active');
  48.             });
  49.             event.target.classList.add('active');
  50.         }
  51.     });
  52.     function setValue(element, value, mode) {
  53.         if(value) {
  54.             element.css({'display':mode});
  55.         } else {
  56.             element.css({'display':'none'});
  57.         }
  58.     }
  59.     function setInfo(item) {
  60.         const getTaller = item.dataset.taller;
  61.         const getCorreo = item.dataset.correo;
  62.         const getTelefono = item.dataset.telefono;
  63.         const getDir = item.dataset.direccion;
  64.         const getDirurl = item.dataset.direccionurl;
  65.         const getMaps = item.dataset.maps;
  66.         const getWaze = item.dataset.waze;
  67.         const getImg = item.dataset.img;
  68.         document.getElementById('locales__title').innerText = getTaller;
  69.         document.getElementById('locales_mail').innerText = getCorreo;
  70.         document.getElementById('locales_mail').parentElement.setAttribute('href', `mailto:${getCorreo}`);
  71.         document.getElementById('locales_phone').innerText = getTelefono;
  72.         document.getElementById('locales_phone').parentElement.setAttribute('href', `tel:${getTelefono}`);
  73.         document.getElementById('locales_dir').innerText = getDir;
  74.         document.getElementById('locales_dir').parentElement.setAttribute('href', `${getDirurl}`);
  75.         document.getElementById('mapsBtn').setAttribute('href', getMaps);
  76.         document.getElementById('mapsWaze').setAttribute('href', getWaze);
  77.         if( getImg ) {
  78.             document.getElementById('locales_img').setAttribute('src', getImg);
  79.             document.getElementById('locales_img').style.display = 'block';
  80.         } else {
  81.             document.getElementById('locales_img').style.display = 'none';
  82.         }
  83.         setValue($('#mapsBtn'), getMaps, 'flex');
  84.         setValue($('#mapsWaze'), getWaze, 'flex');
  85.         setValue($('#locales_mail').parent(), getCorreo, 'flex');
  86.         setValue($('#locales_phone').parent(), getTelefono, 'flex');
  87.         setValue($('#locales_dir').parent(), getDir, 'flex');
  88.     }
  89.     WidthChange(768, () => {
  90.         const appendSucursales = () => {
  91.             const sucursales = document.querySelectorAll('.locales__list__item');
  92.             sucursales.forEach((sucursal, index) => {
  93.                 const sucursal_info = document.createElement('div');
  94.                 sucursal_info.classList.add('locales__principal__info');
  95.                 sucursal.appendChild(sucursal_info);
  96.                 styleForImg = sucursal.dataset.img ? 'block': 'none' ;
  97.                 styleForImg = sucursal.dataset.img ? 'block': 'none' ;
  98.                 styleForCorreo = sucursal.dataset.correo ? 'flex': 'none' ;
  99.                 styleForTelefono = sucursal.dataset.telefono ? 'flex': 'none' ;
  100.                 styleForDir = sucursal.dataset.direccion ? 'flex': 'none' ;
  101.                 styleForMaps = sucursal.dataset.maps ? 'flex': 'none' ;
  102.                 styleForWaze = sucursal.dataset.waze ? 'flex': 'none' ;
  103.                 sucursal_info.innerHTML = `
  104.     
  105.                     <h4 id="locales__title">${sucursal.dataset.taller}</h4>
  106.                     <a class="locales__icon" href="mailto:${sucursal.dataset.correo}" style="display:${styleForCorreo}"
  107.                         ><i class="icon-mail"></i><span id="locales_mail">${sucursal.dataset.correo}</span
  108.                     ></a>
  109.                     <a class="locales__icon" href="tel:${sucursal.dataset.telefono}" style="display:${styleForTelefono}"
  110.                         ><i class="icon-phone1"></i><span id="locales_phone">${sucursal.dataset.telefono}</span
  111.                     ></a>
  112.                     <a class="locales__icon" target="_blank" href="${sucursal.dataset.direccionurl}" style="display:${styleForDir}"
  113.                         ><i class="icon-placeholder"></i><span id="locales_dir">${sucursal.dataset.direccion}</span
  114.                     ></a>
  115.                     <div class="flex locales__buttons">
  116.                         <a href="${sucursal.dataset.maps}" target="_blank" id="mapsBtn" class="button--gray" style="display:${styleForMaps}"
  117.                             ><img src="{{STATIC_URL}}img/maps.png" alt="" />Google Maps</a
  118.                         >
  119.                         <a href="${sucursal.dataset.waze}" target="_blank" id="mapsWaze" class="button--gray" style="display:${styleForWaze}"
  120.                             ><img src="{{STATIC_URL}}img/waze.png" alt="" />Waze</a
  121.                         >
  122.                     </div>
  123.                     <img src="${sucursal.dataset.img}" style="display:${styleForImg}" alt="foto de sucursal" id="locales_img" />
  124.     
  125.                 `;
  126.             });
  127.         };
  128.         appendSucursales();
  129.         $('.locales__list__item div:first-child').click(function (e) {
  130.             $(this).next('.locales__principal__info').slideToggle(400);
  131.             $(this).toggleClass('activeToggle');
  132.         });
  133.         $('.locales__list__item div:first-child')[0].click();
  134.     });
  135.     function changeLocals(provincia, distrito) {
  136.         if(!provincia && !distrito) {
  137.             $('.locales__list__item').css({'display': 'flex'});
  138.         } else {
  139.             if(provincia && !distrito) {
  140.                 $('.locales__list__item').css({'display': 'none'});
  141.                 $('.locales__list__item[data-provincia="'+ provincia + '"]').css({'display': 'flex'});
  142.             }
  143.             if(distrito && provincia) {
  144.                 $('.locales__list__item').css({'display': 'none'});
  145.                 $('.locales__list__item[data-distrito="'+ distrito + '"][data-provincia="'+ provincia + '"]').css({'display': 'flex'});
  146.             }
  147.             if(distrito && !provincia) {
  148.                 $('.locales__list__item').css({'display': 'none'});
  149.                 $('.locales__list__item[data-distrito="'+ distrito + '"]').css({'display': 'flex'});
  150.             }
  151.         }
  152.     }
  153.     $('#select_provincia').change(function() {
  154.         let provincia = $('#select_provincia').val();
  155.         let distrito = $('#select_distrito').val();
  156.         if(provincia) {
  157.             $('#select_distrito option').css({'display': 'none'});
  158.             $('#select_distrito option[data-provincia='+ provincia+']').css({'display': 'block'});
  159.             $('#select_distrito').val('');
  160.         }
  161.         changeLocals(provincia, distrito);
  162.         
  163.     });
  164.     $('#select_distrito').change(function() {
  165.         let provincia = $('#select_provincia').val();
  166.         let distrito = $('#select_distrito').val();
  167.         changeLocals(provincia, distrito);
  168.     });
  169.     
  170. </script>
  171. {% endif %}
  172. {% endblock %}