{% extends "cranefly/profiles/profile.html" %}
{% import "_forms.html" as form_theme with context %}
{% import "cranefly/macros.html" as macros with context %}

{% block title %}{{ macros.page_title(_('Follows'), profile.username) }}{% endblock %}

{% block tab %}
<h2>{% if items_total %}
    {%- trans count=items_total, total=items_total|intcomma, username=profile.username -%}
    {{ username }} is following one member
    {%- pluralize -%}
    {{ username }} is following {{ total }} members
    {%- endtrans -%}
    {%- else -%}
    {% trans username=profile.username %}{{ username }} is not following anybody{% endtrans %}
    {%- endif %}</h2>

{% if items_total %}
<div class="user-list user-follows">
  <table class="table table-striped">
    <thead>
      <tr>
        <th colspan="4">{% trans username=profile.username %}Users {{ username }} is following{% endtrans %}</th>
      </tr>
    </thead>
    <tbody>
      {% for row in items|batch(4, '') %}
      <tr>
        {% for user in row %}
        <td class="span3 user-cell">
          {% if user %}
          <a href="{% url 'user' username=user.username_slug, user=user.pk %}" class="user-avatar"><img src="{{ user.get_avatar(36) }}" alt=""></a>
          <a href="{% url 'user' username=user.username_slug, user=user.pk %}" class="user-name">{{ user.username }}</a>
          {% else %}
          &nbsp;
          {% endif %}
        </td>
        {% endfor %}
      </tr>
      {% endfor %}
    </tbody>
  </table>
  {{ pager() }}
</div>
{% endif %}
{% endblock %}

{% macro pager() -%}
{% if pagination['total'] > 1 %}
<div class="pagination">
  <ul>
    <li class="count">{{ macros.pager_label(pagination) }}</li>
    {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'user_follows' user=profile.id, username=profile.username_slug, page=pagination['prev'] %}{% else %}{% url 'user_follows' user=profile.id, username=profile.username_slug %}{% endif %}" class="tooltip-top" title="{% trans %}Previous Page{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
    {%- if pagination['next'] > 0 %}<li><a href="{% url 'user_follows' user=profile.id, username=profile.username_slug, page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Next Page{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  </ul>
</div>
{% endif %}
{%- endmacro %}
