kopia lustrzana https://github.com/wagtail/wagtail
Split ajax pagination nav into its own include
rodzic
b2eee20e1b
commit
188c731e2c
|
@ -0,0 +1,18 @@
|
|||
{% load i18n %}
|
||||
{% load wagtailadmin_tags %}
|
||||
|
||||
<div class="pagination">
|
||||
<p>{% blocktrans with page_num=items.number total_pages=items.paginator.num_pages %}Page {{ page_num }} of {{ total_pages }}.{% endblocktrans %}</p>
|
||||
<ul>
|
||||
<li class="prev">
|
||||
{% if items.has_previous %}
|
||||
<a href="#" data-page="{{ items.previous_page_number }}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="next">
|
||||
{% if items.has_next %}
|
||||
<a href="#" data-page="{{ items.next_page_number }}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -1,21 +1,20 @@
|
|||
{% load i18n %}
|
||||
{% load wagtailadmin_tags %}
|
||||
{% if not is_ajax %}
|
||||
{% comment %}
|
||||
HACK: This template expects to be passed a 'linkurl' parameter, containing a URL name
|
||||
that can be reverse-resolved by the {% url %} tag with no further parameters.
|
||||
Views that have parameters in their URL can work around this by passing a bogus
|
||||
(but non-blank) URL name, which will return an empty string and produce a final URL
|
||||
of the form "?q=123", implicitly preserving the current URL path.
|
||||
Using the {% url ... as ... %} form of the tag ensures that this fails silently,
|
||||
rather than throwing a NoReverseMatch exception.
|
||||
|
||||
If 'linkurl' is not passed, it will instead preserve the current URL and parameters,
|
||||
just replacing the 'p' parameter.
|
||||
{% endcomment %}
|
||||
{% if linkurl %}
|
||||
{% url linkurl as url_to_use %}
|
||||
{% endif %}
|
||||
{% comment %}
|
||||
HACK: This template expects to be passed a 'linkurl' parameter, containing a URL name
|
||||
that can be reverse-resolved by the {% url %} tag with no further parameters.
|
||||
Views that have parameters in their URL can work around this by passing a bogus
|
||||
(but non-blank) URL name, which will return an empty string and produce a final URL
|
||||
of the form "?q=123", implicitly preserving the current URL path.
|
||||
Using the {% url ... as ... %} form of the tag ensures that this fails silently,
|
||||
rather than throwing a NoReverseMatch exception.
|
||||
|
||||
If 'linkurl' is not passed, it will instead preserve the current URL and parameters,
|
||||
just replacing the 'p' parameter.
|
||||
{% endcomment %}
|
||||
{% if linkurl %}
|
||||
{% url linkurl as url_to_use %}
|
||||
{% endif %}
|
||||
|
||||
<div class="pagination">
|
||||
|
@ -23,9 +22,7 @@
|
|||
<ul>
|
||||
<li class="prev">
|
||||
{% if items.has_previous %}
|
||||
{% if is_ajax %}
|
||||
<a href="#" data-page="{{ items.previous_page_number }}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
{% elif is_searching %}
|
||||
{% if is_searching %}
|
||||
<a href="{{ url_to_use }}?q={{ query_string|urlencode }}&p={{ items.previous_page_number }}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
{% elif not linkurl %}
|
||||
<a href="?{% replace_page_param request.META.QUERY_STRING items.previous_page_number %}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
|
@ -36,9 +33,7 @@
|
|||
</li>
|
||||
<li class="next">
|
||||
{% if items.has_next %}
|
||||
{% if is_ajax %}
|
||||
<a href="#" data-page="{{ items.next_page_number }}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
{% elif is_searching %}
|
||||
{% if is_searching %}
|
||||
<a href="{{ url_to_use }}?q={{ query_string|urlencode }}&p={{ items.next_page_number }}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
{% elif not linkurl %}
|
||||
<a href="?{% replace_page_param request.META.QUERY_STRING items.next_page_number %}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
{% include "wagtaildocs/documents/list.html" with choosing=1 %}
|
||||
|
||||
{% include "wagtailadmin/shared/pagination_nav.html" with items=documents is_ajax=1 %}
|
||||
{% include "wagtailadmin/shared/ajax_pagination_nav.html" with items=documents %}
|
||||
{% else %}
|
||||
{% if documents_exist %}
|
||||
<p>{% blocktrans %}Sorry, no documents match "<em>{{ query_string }}</em>"{% endblocktrans %}</p>
|
||||
|
|
|
@ -24,5 +24,5 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% include "wagtailadmin/shared/pagination_nav.html" with items=images is_ajax=1 %}
|
||||
{% include "wagtailadmin/shared/ajax_pagination_nav.html" with items=images %}
|
||||
{% endif %}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
{% include "wagtailsnippets/snippets/list.html" with choosing=1 %}
|
||||
|
||||
{% include "wagtailadmin/shared/pagination_nav.html" with items=items is_ajax=1 %}
|
||||
{% include "wagtailadmin/shared/ajax_pagination_nav.html" with items=items %}
|
||||
{% else %}
|
||||
{% if is_searching %}
|
||||
<p>{% blocktrans %}Sorry, no snippets match "<em>{{ query_string }}</em>"{% endblocktrans %}</p>
|
||||
|
|
Ładowanie…
Reference in New Issue