Commits

Wilson Xu committed e49a67b

Added bootstrap style pagination.

  • Participants
  • Parent commits 839e5a3

Comments (0)

Files changed (2)

File fbone/static/js/script.js

 }
 
 $(document).ready(function() {
+    /* Show and hide flash message. */
     $('#flash_message_container').slideDown(function() {
         setTimeout(hide_flask_message_container, 3000);
     });
+
+    /* Disable anchor in pagination. */
+    $('div.pagination li.disabled a').click(function() {
+        return false;
+    });
 })

File fbone/templates/macros/_misc.html

 
 {% macro render_pagination(pagination, endpoint) %}
     {% if pagination.pages > 1 %}
-        <ul class='pagination_list card_container lh32'>
-            {% for page in pagination.iter_pages() %}
-                {% if page %}
-                    {% if page != pagination.page %}
-                    <li>
-                        <a href='{{ url_for(endpoint, page=page) }}'>{{ page }}</a>
-                    </li>
+        <div class='pagination'>
+            <ul>
+                <li class="prev {% if not pagination.has_prev %}disabled{% endif %}"><a href="{{ url_for(endpoint, page=pagination.page-1) }}">&larr; Previous</a></li>
+                {% for page in pagination.iter_pages() %}
+                    {% if page %}
+                        <li class='{% if page == pagination.page %}active{% endif %}'>
+                            <a href='{{ url_for(endpoint, page=page) }}'>{{ page }}</a>
+                        </li>
                     {% else %}
-                    <li class='current_page'>
-                        <span><strong>{{ page }}</strong></span>
-                    </li>
+                        <li>
+                            <a href='#'>...</a>
+                        </li>
                     {% endif %}
-                {% else %}
-                    <li>
-                        <span>…</span>
-                    </li>
-                {% endif %}
-            {% endfor %}
-        </ul>
+                {% endfor %}
+                <li class="next {% if not pagination.has_next %}disabled{% endif %}"><a href="{{ url_for(endpoint, page=pagination.page+1) }}">Next &rarr;</a></li>
+            </ul>
+        </div>
     {% endif %}
 {% endmacro %}