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

        {% search_other %}
    {% else %}
        <h2>{% trans "Latest videos" %}</h2>
    {% endif %}

    <ul class="listing horiz images">
        {% for embed_video in embed_videos %}
            <li>
                <a class="image-choice" href="{% url 'wagtail_embed_videos:edit' embed_video.id %}">
                    {% include "wagtail_embed_videos/embed_videos/results_video.html" %}
                    <h3>{{ embed_video.title|ellipsistrim:60 }}</h3>
                </a>
            </li>
        {% endfor %}
    </ul>

    {% include "wagtailadmin/shared/pagination_nav.html" with items=embed_videos is_searching=is_searching query_string=query_string %}

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

        {% search_other %}
    {% else %}
        {% url 'wagtail_embed_videos:add' as wagtail_embedvideos_add_embed_video_url %}
        {% if current_collection %}
            <p>{% blocktrans %}You haven't uploaded any videos in this collection. Why not <a href="{{ wagtail_embedvideos_add_embed_video_url }}">add one now</a>?{% endblocktrans %}</p>
        {% else %}
            <p>{% blocktrans %}You haven't uploaded any videos. Why not <a href="{{ wagtal_embedvideos_add_embed_video_url }}">add one now</a>?{% endblocktrans %}</p>
        {% endif %}
    {% endif %}
{% endif %}
