{% load i18n %}
{% load hk_generic %}

{% if show_dropdown %}
<a href="" id="navbarMonthsListDrop" class="dropdown-toggle {% if pagename == 'overview' %}btn btn-default{% endif %}" data-toggle="dropdown">
  <span class="hidden-tn hidden-xs">{% trans "Threads by" %}</span>{% trans " month" %} <b class="caret"></b>
</a>
<ul class="dropdown-menu right" role="menu" aria-labelledby="navbarMonthsListDrop">
    {% for year, months in months_list|sort %}
    <li role="presentation" class="dropdown-header disabled">
        <a href="">----- {{ year }} -----</a>
    </li>
    {% for ar_month in months %}
    <li>
        <a href="{% url 'hk_archives_with_month' year=year mlist_fqdn=mlist.name month=ar_month %}"
           >{{ ar_month|monthtodate:year|date:"F" }}</a>
    </li>
    {% endfor %}
    {% endfor %}
</ul>
{% elif show_select %}
<select id="months-list" class="form-control">
    {% for year, months in months_list|sort %}
    <option disabled>----- {{ year }} -----</option>
    {% for ar_month in months %}
    <option{% if month and year == month.year and ar_month == month.month %} selected="selected"{% endif %}>{{ ar_month|monthtodate:year|date:"F Y" }}</option>
    {% endfor %}
    {% endfor %}
</select>

{% else %}
<div class="hidden-tn hidden-xs col-sm-2">
<div class="row">
    <div class="panel-group" id="months-list">
        {% for year, months in months_list|sort %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <a data-toggle="collapse" data-parent="#months-list" href="#collapse{{forloop.counter0}}">
                        {{ year }}
                    </a>
                </h3>
            </div>
            <div id="collapse{{forloop.counter0}}" class="panel-collapse
                {% if month %}
                    {% if year == month.year %} in {% else %} collapse {% endif %}
                {% else %}
                    {% if forloop.counter == 1 %} in {% else %} collapse {% endif %}
                {% endif %}
                ">
                <div class="panel-body">
                    <ul class="list-unstyled">
                        {% for ar_month in months %}
                        <li class="{% if month and year == month.year and ar_month == month.month %}current{% endif %}">
                            <a href="{% url 'hk_archives_with_month' year=year mlist_fqdn=mlist.name month=ar_month %}"
                               >{{ ar_month|monthtodate:year|date:"F" }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>

{% include 'hyperkitty/fragments/thread_left_nav.html' with pagename=pagename %}


</div>
{% endif %}
