{% load wagtailadmin_tags %}
{% load i18n l10n %}
{% if videos %}
    {% if is_searching %}
        <h2 role="alert">
            {% blocktrans trimmed count counter=videos.paginator.count %}
                There is {{ counter }} match
            {% plural %}
                There are {{ counter }} matches
            {% endblocktrans %}
        </h2>

        {% search_other %}
    {% endif %}

    {# Used below for the checkbox aria_labelledby #}
    <p class="visuallyhidden" id="select-video-label">{% trans "Select video" %}</p>

    <ul class="listing horiz videos">
        {% for video in videos %}
            <li>
                {% include "wagtailadmin/bulk_actions/listing_checkbox_cell.html" with obj_type="video" obj=video aria_labelledby_prefix="select-video-label video_" aria_labelledby=video.pk|unlocalize aria_labelledby_suffix="_title" %}
                <a class="video-choice" title="{% if collections %}{{ video.collection.name }} » {% endif %}{{ video.title }}" href="{% url 'wideo:edit' video.id %}{% if next %}?next={{ next|urlencode }}{% endif %}">
                    <figure>
                        {% include "wideo/videos/results_video.html" %}
                        {% trans "pixels" as translated_pixels %}
                        <figcaption id="video_{{ video.pk|unlocalize }}_title">
                            {{ video.title|ellipsistrim:60 }}
                            <span class="visuallyhidden">{{ video.width }} {{ translated_pixels  }} &#215; {{ video.height }} {{ translated_pixels}}</span>
                        </figcaption>
                    </figure>
                </a>
            </li>
        {% endfor %}
    </ul>

    {% include "wagtailadmin/shared/pagination_nav.html" with items=videos %}

{% else %}
    {% if is_searching %}
        <h2 role="alert">{% blocktrans trimmed %}Sorry, no videos match "<em>{{ query_string }}</em>"{% endblocktrans %}</h2>

        {% search_other %}
    {% else %}
        {% url 'wideo:add' as wideo_add_video_url %}
        {% with wideo_add_video_url|add:querystring as wideo_add_video_url %}
            {% if current_collection %}
                <p>{% blocktrans trimmed %}You haven't uploaded any videos in this collection. Why not <a href="{{ wideo_add_video_url }}">upload one now</a>?{% endblocktrans %}</p>
            {% else %}
                <p>{% blocktrans trimmed %}You haven't uploaded any videos. Why not <a href="{{ wideo_add_video_url }}">upload one now</a>?{% endblocktrans %}</p>
            {% endif %}
        {% endwith %}
    {% endif %}
{% endif %}
