templates/SaloonPreview/_profiles.html.twig line 1

Open in your IDE?
  1. {% if profiles|length > 0 %}
  2.     <div class="mb-3">
  3.         <h2>{% trans %}Девушки в салоне{% endtrans %}</h2>
  4.         <div id="saloon-profile-list" class="row mb-3">
  5.             {% include 'SaloonPreview/_profiles_list.html.twig' with { profiles: profiles } %}
  6.         </div>
  7.         {% if total_count > per_page %}
  8.             <a href="javascript:void(0);" id="saloon-profiles-show-more">Показать еще</a>
  9.             <script type="text/javascript">
  10.                 document.addEventListener('DOMContentLoaded', function () {
  11.                     let currentPage = 1;
  12.                     const totalPages = {{ (total_count / per_page)|round(0, 'ceil') }};
  13.                     const button = document.querySelector('#saloon-profiles-show-more');
  14.                     const container = document.querySelector('#saloon-profile-list');
  15.                     const urlTemplate = '{{ path('saloon_preview.profiles', {
  16.                         city: saloon.city.uriIdentity,
  17.                         saloon: saloon.uriIdentity,
  18.                         page: 999999
  19.                     }) }}?rotation={{ rotation_offset }}';
  20.                     button.addEventListener('click', function () {
  21.                         if (currentPage >= totalPages) {
  22.                             button.style.display = 'none';
  23.                             return;
  24.                         }
  25.                         button.style.display = 'none';
  26.                         ajax({
  27.                             url: urlTemplate.replace('999999', currentPage + 1),
  28.                             method: 'GET',
  29.                             callback: function (response) {
  30.                                 const wrapper = document.createElement('div');
  31.                                 wrapper.innerHTML = response;
  32.                                 Array.prototype.slice.call(wrapper.children).forEach(function (child) {
  33.                                     container.appendChild(child);
  34.                                 });
  35.                                 currentPage++;
  36.                                 button.style.display = currentPage >= totalPages ? 'none' : 'inline';
  37.                             },
  38.                             dataType: 'json',
  39.                             responseType: 'text/html',
  40.                         });
  41.                     });
  42.                 });
  43.             </script>
  44.         {% endif %}
  45.     </div>
  46. {% endif %}