75 lines
3.6 KiB
Twig
75 lines
3.6 KiB
Twig
{% set _currentPage = paginator.currentPage ?: 1 %}
|
|
{% set _lastPage = paginator.lastPage %}
|
|
{% set _showingPerPage = (_currentPage == _lastPage) ? paginator.total - (this.perPage * (_lastPage - 1)) : ("query" in paginator.items) ? paginator.items.query.maxResults %}
|
|
|
|
<p class="text-white mt-1">{{ paginator.getShowing() }}</p>
|
|
|
|
{% if paginator.lastPage > 1 %}
|
|
<nav>
|
|
<ul class="mt-2 flex flex-row justify-content-center gap-1 py-1 text-white text-sm">
|
|
<li class="page-item{{ _currentPage <= 1 ? ' disabled' : '' }}">
|
|
<button
|
|
{% if _currentPage > 1 %}
|
|
{{ stimulus_action('tv-episode-list', 'paginate', 'click', {page: _currentPage - 1}) }}
|
|
{% endif %}
|
|
class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle"
|
|
aria-label="Previous"
|
|
>
|
|
«
|
|
</button>
|
|
</li>
|
|
{% set startPage = max(1, _currentPage - 2) %}
|
|
{% set endPage = min(_lastPage, startPage + 4) %}
|
|
{% if startPage > 1 %}
|
|
<li class="page-item">
|
|
<button
|
|
{{ stimulus_action('tv-episode-list', 'paginate', 'click', {page: 1}) }}
|
|
class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle"
|
|
aria-label="Next"
|
|
|
|
>1</button>
|
|
</li>
|
|
{% if startPage > 2 %}
|
|
<li class="page-item disabled">
|
|
<span class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle inline-flex items-stretch">...</span>
|
|
</li>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% for i in startPage..endPage %}
|
|
<li class="page-item">
|
|
<button
|
|
{{ stimulus_action('tv-episode-list', 'paginate', 'click', {page: i}) }}
|
|
class="page-link px-2.5 py-1 rounded-lg bg-orange-500 text-white align-middle"
|
|
{% if i == _currentPage %}style="background-color: #fff; color: darkorange; font-weight: bold;"{% endif %}
|
|
>{{ i }}</button>
|
|
</li>
|
|
{% endfor %}
|
|
{% if endPage < _lastPage %}
|
|
{% if endPage < _lastPage - 1 %}
|
|
<li class="page-item disabled">
|
|
<span class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle inline-flex items-stretch">...</span>
|
|
</li>
|
|
{% endif %}
|
|
<li class="page-item">
|
|
<button
|
|
{{ stimulus_action('tv-episode-list', 'paginate', 'click', {page: _lastPage}) }}
|
|
class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle"
|
|
aria-label="Next"
|
|
>{{ _lastPage }}</button>
|
|
</li>
|
|
{% endif %}
|
|
<li class="page-item {{ _currentPage >= paginator.lastPage ? ' disabled' : '' }}">
|
|
<button
|
|
{% if _currentPage < _lastPage %}
|
|
{{ stimulus_action('tv-episode-list', 'paginate', 'click', {page: _currentPage + 1}) }}
|
|
{% endif %}
|
|
class="page-link px-2.5 py-1 rounded-lg bg-orange-500 align-middle"
|
|
aria-label="Next"
|
|
>
|
|
»
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|