{% if profiles|length > 0 %}
<div class="mb-3">
<h2>{% trans %}Девушки в салоне{% endtrans %}</h2>
<div id="saloon-profile-list" class="row mb-3">
{% include 'SaloonPreview/_profiles_list.html.twig' with { profiles: profiles } %}
</div>
{% if total_count > per_page %}
<a href="javascript:void(0);" id="saloon-profiles-show-more">Показать еще</a>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
let currentPage = 1;
const totalPages = {{ (total_count / per_page)|round(0, 'ceil') }};
const button = document.querySelector('#saloon-profiles-show-more');
const container = document.querySelector('#saloon-profile-list');
const urlTemplate = '{{ path('saloon_preview.profiles', {
city: saloon.city.uriIdentity,
saloon: saloon.uriIdentity,
page: 999999
}) }}?rotation={{ rotation_offset }}';
button.addEventListener('click', function () {
if (currentPage >= totalPages) {
button.style.display = 'none';
return;
}
button.style.display = 'none';
ajax({
url: urlTemplate.replace('999999', currentPage + 1),
method: 'GET',
callback: function (response) {
const wrapper = document.createElement('div');
wrapper.innerHTML = response;
Array.prototype.slice.call(wrapper.children).forEach(function (child) {
container.appendChild(child);
});
currentPage++;
button.style.display = currentPage >= totalPages ? 'none' : 'inline';
},
dataType: 'json',
responseType: 'text/html',
});
});
});
</script>
{% endif %}
</div>
{% endif %}