{% extends "user_profile/user.html" %}
{% import "macros.html" as macros %}
{% import "user_profile/macros.html" as user_profile_macros %}
<!-- user_stats.html -->
{% block profilesection %}
    {% trans %}overview{% endtrans %}
{% endblock %}
{% block usercontent %}
    {% include "user_profile/user_info.html" %}
    <a name="questions"></a>
    {% spaceless %}
        <h2>
            <span class="count">{{ question_count }}</span>
            {{ settings.WORDS_QUESTIONS_COUNTABLE_FORMS|py_pluralize(question_count)|capitalize }}
        </h2>
    {% endspaceless %}
    {% include "user_profile/users_questions.html" %}
    <a name="answers"></a>
    {% spaceless %}
        <h2 style="clear:both;">
            <span class="count">{{ top_answer_count }}</span>
            {{ settings.WORDS_ANSWERS_COUNTABLE_FORMS|py_pluralize(top_answer_count)|capitalize }}
        </h2>
    {% endspaceless %}
    {% include "user_profile/users_answers.html" %}
    <a name="votes"></a>
    {% spaceless %}
        <h2>{% trans cnt=total_votes %}<span class="count">{{cnt}}</span> Vote{% pluralize %}<span class="count">{{cnt}}</span> Votes {% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table">
        <div class="up-votes">{{ up_votes }}</div>
        <div class="down-votes">{{ down_votes }}</div>
    </div>
    <a name="tags"></a>
    {% spaceless %}
        <h2>{% trans counter=user_tags|length %}<span class="count">{{counter}}</span> Tag{% pluralize %}<span class="count">{{counter}}</span> Tags{% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table">
        <ul id="ab-user-tags" class="tags">
        {% for tag in user_tags %}
            <li>
            {{ macros.tag_widget(
                tag.name,
                html_tag = 'div',
                search_state = search_state,
                truncate_long_tag = True,
                extra_content =
                    '<span class="tag-number">&#215; ' ~
                    tag.user_tag_usage_count|intcomma ~
                    '</span>'
               )
            }}
            </li>
        {% endfor %}
        </ul>
        <div class="clearfix"></div>
    </div>
    {% if interesting_tag_names %}
        {{ user_profile_macros.tag_selection(interesting_tag_names, 'interesting') }}
    {% endif %}
    {% if ignored_tag_names %}
        {{ user_profile_macros.tag_selection(ignored_tag_names, 'ignored') }}
    {% endif %}
    {% if subscribed_tag_names %}
        {{ user_profile_macros.tag_selection(subscribed_tag_names, 'subscribed') }}
    {% endif %}
    {% if settings.BADGES_MODE == 'public' %}
    <a name="badges"></a>
    {% spaceless %}
    <h2>{% trans counter=total_badges %}<span class="count">{{counter}}</span> Badge{% pluralize %}<span class="count">{{counter}}</span> Badges{% endtrans %}</h2>
    {% endspaceless %}
    <div id="medalList">
    <div class="user-stats-table badges">
        {% for badge, badge_user_awards in badges %}
          <div class="medal-box">
            <a
                href="{{badge.get_absolute_url()}}"
                title="{% trans description=badge.get_description() %}{{description}}{% endtrans %}"
                class="medal"><img src="/m/default/media/images/badges/{{badge.get_key()}}.png" />
                <br/>
                <span>{{ badge.get_name() }}</span></a>
            </a>&nbsp;
            <span class="tag-number">&#215;
                <span class="badge-context-toggle">{{ badge_user_awards|length|intcomma }}</span>
            </span>
            <ul id="badge-context-{{ badge.id }}" class="badge-context-list" style="display:none">
                {% for award in badge_user_awards %}
                    {% if award.content_object and award.content_object_is_post %}
                    <li>
                        <a
                            title="{{ award.content_object.get_snippet()|collapse|escape }}"
                            href="{{ award.content_object.get_absolute_url() }}"
                        >{% if award.content_type.post_type == 'answer' %}{% trans %}Answer to:{% endtrans %}{% endif %} {{ award.content_object.thread.title|escape }}</a>
                    </li>
                    {% endif %}
                {% endfor %}
            </ul>
          </div>
        {% endfor %}
    </div>
    </div>
    {% endif %}
{% endblock %}
{% block endjs %}
    {{ super() }}
    <script type="text/javascript">
        askbot['urls']['join_or_leave_group'] = '{% url join_or_leave_group %}';
        $(document).ready(function(){
            setup_badge_details_toggle();
            $.each($('.group-join-btn'), function(idx, elem){
                var group_join_btn = new GroupJoinButton();
                group_join_btn.decorate($(elem));
            });
        });
    </script>
    <script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
{% endblock %}
<!-- end user_stats.html -->
