templates/front/index.twig line 1

Open in your IDE?
  1. {% extends "front/layouts/default.twig" %}
  2. {% block head_scripts %}
  3. {% endblock %}
  4. {% set pageSections = [] %}
  5. {% set pageBanner = null %}
  6. {# if this page has a banner we will display it separately #}
  7. {% for pageSection in entity.sections|default([])|sort((a, b) => a.ordering <=> b.ordering) %}
  8.     {% if pageSection.section.layout == 'banner-top' %}
  9.         {% set pageBanner = pageSection.section %}
  10.     {% else %}
  11.         {% set pageSections = pageSections|merge([pageSection.section]) %}
  12.     {% endif %}
  13. {% endfor %}
  14. {# display banner #}
  15. {% block topBanner %}
  16.     {% if pageBanner %}
  17.         {% include pageBanner.templatePath with { 'entity' : pageBanner, currentPage: entity } %}
  18.     {% endif %}
  19. {% endblock %}
  20. {# display rest of the content #}
  21. {% block content %}
  22.     {% for index, section in pageSections %}
  23.         {% set isGreySection = (loop.index is odd) %}
  24.         {% include section.templatePath with {
  25.             'entity' : section, currentPage: entity,
  26.             'greySection': isGreySection,
  27.             'isLast': loop.last,
  28.         } %}
  29.     {% endfor %}
  30.     {% include 'front/blocks/block-policy-cookie.twig' %}
  31. {% endblock %}
  32. {% block script %}
  33.     {{ parent() }}
  34.     <script>
  35.         $(document).ready(() => {
  36.             if($('#roomvo-available').length > 0) {
  37.                 setTimeout(function(){ roomvo.startStandaloneVisualizer(); }, 1500);
  38.             }
  39.         });
  40.     </script>
  41.     <script>
  42.     $(".modalForm").submit(
  43.         function(event){
  44.             event.preventDefault();
  45.             let form = $(this);
  46.             let fSectionid = form.data('sectionid');
  47.             let ajaxurl = $("#formButton").data('ajaxurl');
  48.             let shopName = (typeof(form.data('storename')) != 'undefined') ? form.data('storename') : '';
  49.             let shopId = (typeof(form.data('storeid')) != 'undefined') ? form.data('storeid') : '';
  50.             
  51.             let formData = new FormData(form[0]);
  52.             formData.append('sectionid',fSectionid);
  53.             formData.append('storename',shopName);
  54.             formData.append('storeid',shopId);
  55.             
  56.             // throw new Error('test');
  57.             // console.log(shopName);
  58.             // console.log(shopId);
  59.             // return;
  60.             $.ajax({
  61.                 url: ajaxurl,
  62.                 type: 'POST',
  63.                 data: formData,
  64.                 processData: false,
  65.                 contentType: false,
  66.                 success: (documentData) => {
  67.                     $('.form-alert').each(function(){
  68.                         $(this).remove();
  69.                     });
  70.                     $('#form-modal').modal('hide');
  71.                     $('[id*=modal-form]').modal('hide');
  72.                     $('#modal-thanks-form').modal('show');
  73.                     window.location.replace(documentData);
  74.                 },
  75.                 error: (documentData) => {
  76.                     form.prepend('<div class="alert alert-danger form-alert">' + documentData.responseJSON + '</div>');
  77.                     form[0].scrollIntoView({ behavior: 'smooth' });
  78.                 }
  79.             });
  80.         }
  81.     );
  82.     $("#contactForm").submit(
  83.         function(event){
  84.             event.preventDefault();
  85.             let form = $('#contactForm');
  86.             let fSectionid = $("#contactForm").data('sectionid');
  87.             let ajaxurl = $("#formButton").data('ajaxurl');
  88.             let formData = new FormData(form[0]);
  89.             formData.append('sectionid',fSectionid);
  90.             $.ajax({
  91.                 url: ajaxurl,
  92.                 type: 'POST',
  93.                 data: formData,
  94.                 processData: false,
  95.                 contentType: false,
  96.                 success: (documentData) => {
  97.                     
  98.                     $('.form-alert').each(function(){
  99.                         $(this).remove();
  100.                     });
  101.                     window.location.replace(documentData);
  102.                 },
  103.                 error: (documentData) => {
  104.                     console.log(documentData);
  105.                     form.prepend('<div class="alert alert-danger form-alert">' + documentData.responseJSON + '</div>');
  106.                     form[0].scrollIntoView({ behavior: 'smooth' });
  107.                 }
  108.             });
  109.         }
  110.     );
  111.     $('input[id*=select-all-consents]').click(function(){
  112.         var checkboxSelector = '#' + this.form.id + ' input[id*=consent]';
  113.         // console.log(checkboxSelector);
  114.         if ($(this).prop('checked') == false) {
  115.             $(checkboxSelector).prop('checked',false);
  116.         }else if ($(this).prop('checked') == true) {
  117.             $(checkboxSelector).prop('checked',true);
  118.         }
  119.     });
  120.     </script>
  121. {% endblock %}