{% load i18n %}

{% if has_descriptions %}
    <div class="track-select-with-descriptions">
        <div class="input-group">
            {% include "django/forms/widgets/select.html" %}

            <div class="input-group-append">
                <button type="button" class="btn btn-primary" title="{% translate "Track descriptions" %}">
                    <i class="fa fa fa-info-circle"></i>
                </button>
            </div>
        </div>
        <div class="form-text text-muted description">
            <!-- Placeholder is filled with JavaScript, when an item is selected -->
        </div>

        <div class="modal" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">{% translate "Track descriptions" %}</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        {% for track in tracks %}
                            <h2>{{ track.name }}</h2>
                            <p>
                                {{ track.description }}
                                {% if not track.description %}
                                    <em>{% translate "No description provided." %}</em>
                                {% endif %}
                            </p>
                        {% endfor %}
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">
                            {% translate "Close" %}
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% else %}
    {% include "django/forms/widgets/select.html" %}
{% endif %}
