Skip to content

Commit

Permalink
Pagination now takes 'size' and 'align' parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Jul 11, 2013
1 parent 64fd122 commit 7326232
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bootstrap_toolkit/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.14.0'
__version__ = '2.15.0'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% with bootstrap_pagination_url=bootstrap_pagination_url|default:"?" %}

<div class="pagination {{ css_class_extra }}">
<div class="{{ pagination_css_classes }}">
<ul>

<li class="prev{% if current_page == 1 %} disabled{% endif %}">
Expand Down
12 changes: 10 additions & 2 deletions bootstrap_toolkit/templatetags/bootstrap_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def bootstrap_pagination(page, **kwargs):
return get_pagination_context(**pagination_kwargs)


def get_pagination_context(page, pages_to_show=11, url=None, css_class_extra="", extra=None):
def get_pagination_context(page, pages_to_show=11, url=None, size=None, align=None, extra=None):
"""
Generate Bootstrap pagination context from a page object
"""
Expand Down Expand Up @@ -352,6 +352,14 @@ def get_pagination_context(page, pages_to_show=11, url=None, css_class_extra="",
url += unicode(extra) + u'&'
if url:
url = url.replace(u'?&', u'?')
# Set CSS classes, see http://twitter.github.io/bootstrap/components.html#pagination
pagination_css_classes = ['pagination']
if size in ['small', 'large', 'mini']:
pagination_css_classes.append('pagination-%s' % size)
if align == 'center':
pagination_css_classes.append('pagination-centered')
elif align == 'right':
pagination_css_classes.append('pagination-right')
# Build context object
return {
'bootstrap_pagination_url': url,
Expand All @@ -362,5 +370,5 @@ def get_pagination_context(page, pages_to_show=11, url=None, css_class_extra="",
'pages_shown': pages_shown,
'pages_back': pages_back,
'pages_forward': pages_forward,
'css_class_extra': css_class_extra,
'pagination_css_classes': ' '.join(pagination_css_classes),
}
4 changes: 2 additions & 2 deletions demo_project/demo_app/templates/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ <h1>Pagination</h1>

<hr>

{% bootstrap_pagination lines url="/pagination?page=1&flop=flip" extra="q=foo" %}
{% bootstrap_pagination lines url="/pagination?page=1&flop=flip" extra="q=foo" size="mini" align="right" %}

{% bootstrap_pagination lines url="/pagination?page=1" %}
{% bootstrap_pagination lines url="/pagination?page=1" align="center" size="large" %}

{% endblock %}

0 comments on commit 7326232

Please sign in to comment.