{% extends "userprofile/base.html" %}
{% load i18n %}
{% load avatars %}
{% load txcommontags %}
{% load pagination_tags %}

{% block title %}{{ profile.user }}'s public profile{% endblock %}
{% block robots %}noindex,nofollow{% endblock %}

{% block extrajs %}
    {% if profile.latitude and profile.longitude %}
    <script type="text/javascript" src="http://www.google.com/jsapi?key={{ GOOGLE_MAPS_API_KEY }}"></script>
    <script type="text/javascript">google.load("maps", "2");</script>
    <script type="text/javascript">
        $(function() {
        if (google.maps.BrowserIsCompatible()) {
            var map = new google.maps.Map2(document.getElementById("map"));
            map.disableDragging();
            map.setCenter(new google.maps.LatLng({{ profile.latitude }}, {{ profile.longitude }}), 2);
            var marker = new google.maps.Marker(new google.maps.LatLng({{ profile.latitude }}, {{ profile.longitude }}), {clickable: false });
            map.addOverlay(marker);
        }
        });
    </script>
    {% endif %}
{% endblock %}

{% block breadcrumb %}{% homelink %} &raquo; {% trans "Profile" %} &raquo; {{ profile.user }}{% endblock %}

{% block content_title %}
<h2 class="pagetitle">{% blocktrans with profile.user as user %}Public profile of {{ user }}{% endblocktrans %}</h2>
{% endblock %}

{% block userprofile_content %}
    <div class="vcard public_profile">
        {% if profile.latitude and profile.longitude %}
        <div class="{{ css_classes.public_vcard_map }} map">
            <div id="map"></div>
        </div>
        {% endif %}
        <div class="avatar">
            <img class="border top" alt="{{ profile.user }}" src="{% avatar 96 profile.user %}" />
            {% if profile.about %}
                <span>{{ profile.about }}</span>
            {% endif %}
            {% url user_nudge profile.user as user_nudge_url %}
            {% if request.user.is_authenticated and user_nudge_url %}
            {% ifnotequal profile.user request.user %}
            <form action="{{ user_nudge_url }}" class="microform">
                <input class="i16 nudge" value="{% blocktrans with profile.user as user %}Nudge {{ user }} {% endblocktrans %}" type="submit">
            </form>
            {% endifnotequal %}
            {% endif %}
        </div>
        <div class="{{ css_classes.public_vcard_content }} details separate">

            <table class="definition">
                {% if profile.firstname %}
                <tr>
                    <th class="i16 person_details">{% trans "Name" %}:</th>
                    <td>{{ profile.firstname }} {{ profile.surname }}</td>
                </tr>
                {% endif %}
                {% if profile.native_language %}
                <tr>
                    <th class="i16 language">{% trans "Native language" %}:</th>
                    <td><a href="{% url language_detail profile.native_language.code %}">{{ profile.native_language }}</a></td>
                </tr>
                {% endif %}
                {% if profile.blog %}
                <tr>
                    <th class="i16 homepage">{% trans "Blog/Site" %}:</th>
                    <td><a target="_black" href="{{ profile.blog }}">{{ profile.blog }}</a></td>
                </tr>
                {% endif %}
                {% if profile.twitter %}
                <tr>
                    <th class="i16 twitter">{% trans "Twitter" %}:</th>
                    <td><a target="_black" href="{{ profile.blog }}">{{ profile.twitter }}</a></td>
                </tr>
                {% endif %}
                {% if profile.linked_in %}
                <tr>
                    <th class="i16 linkedin">{% trans "LinkedIn" %}:</th>
                    <td><a target="_black" href="{{ profile.linked_in }}">{{ profile.linked_in }}</a></td>
                </tr>
                {% endif %}
                {% if profile.location %}
                <tr>
                    <th class="i16 location">{% trans "Location" %}:</th>
                    <td>{{ profile.location }} - {{ profile.get_country_display }}</td>
                </tr>
                {% endif %}
            </table>
        </div>

        {% with profile.user as user %}

        {% with profile.user.team_coordinators.all as teams %}
        {% if teams %}
        {% autopaginate teams 20 %}
        <div class="list">
        <h4>
        {% blocktrans count teams|length as counter %}
            Coordinator of the following team:
        {% plural %}
            Coordinator of the following teams:
        {% endblocktrans %}
        </h4>
        <ul>
        {% for team in teams|dictsort:"language.name" %}
            <li class="i16 team">
                {% url team_detail team.project.slug team.language.code as team_url %}
                {% url project_detail team.project.slug as project_url %}
                {% blocktrans with team.language.name as team_name and team.project.name as project_name %}
                <a class="name" href="{{ team_url }}">{{ team_name }}</a> team of the <a class="name" href="{{ project_url }}">{{ project_name }}</a> project
                {% endblocktrans %}
            </li>
        {% endfor %}
        </ul>
        <div class="pagination bottom">{% paginate %}</div>
        </div>
        {% endif %}
        {% endwith %}

        {% with profile.user.team_members.all as teams %}
        {% if teams %}
        {% autopaginate teams 20 %}
        <div class="list">
        <h4>
        {% blocktrans count teams|length as counter %}
            Member of the following team:
        {% plural %}
            Members of the following teams:
        {% endblocktrans %}
        </h4>
        <ul>
        {% for team in teams|dictsort:"language.name" %}
            <li class="i16 team">
                {% url team_detail team.project.slug team.language.code as team_url %}
                {% url project_detail team.project.slug as project_url %}
                {% blocktrans with team.language.name as team_name and team.project.name as project_name %}
                <a class="name" href="{{ team_url }}">{{ team_name }}</a> team of the <a class="name" href="{{ project_url }}">{{ project_name }}</a> project
                {% endblocktrans %}
            </li>
        {% endfor %}
        </ul>
        <div class="pagination bottom">{% paginate %}</div>
        </div>
        {% endif %}
        {% endwith %}

        {% endwith %}

    </div>
{% endblock %}
