Archived
1
0
Fork 0
This repository has been archived on 2026-04-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
httpcb/app/views/_partials/pagination.volt
2017-09-01 17:10:27 +02:00

61 lines
1.4 KiB
Text

{%- macro max(a, b) %}
{% return a > b ? a : b %}
{%- endmacro %}
{%- macro min(a, b) %}
{% return a < b ? a : b %}
{%- endmacro %}
{% set pagination_slider = 2 %}
{% if (page.total_pages > 1) %}
<ul class="pagination">
{% if page.current !== page.before %}
<li>
<a href="{{ pagination_url ~ page.before }}">
{{ icon('android-arrow-back') }} Previous
</a>
</li>
{% endif %}
{% if page.total_pages > pagination_slider and page.current > pagination_slider %}
<li>
<a href="{{ pagination_url ~ 1 }}">1</a>
</li>
<li class="middle">
...
</li>
{% endif %}
{% for n in max(page.current - pagination_slider, 1)..min(page.current + pagination_slider, page.total_pages) %}
{% if (n == page.current) %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="{{ pagination_url ~ n }}">{{ n }}</a>
</li>
{% endfor %}
{% if page.total_pages > pagination_slider and page.current < page.total_pages - pagination_slider %}
<li class="middle">
...
</li>
<li>
<a href="{{ pagination_url ~ page.total_pages }}">{{ page.total_pages }}</a>
</li>
{% endif %}
{% if page.current !== page.next %}
<li>
<a href="{{ pagination_url ~ page.next }}">
Next {{ icon('android-arrow-forward') }}
</a>
</li>
{% endif %}
</ul>
{% endif %}