{% extends "wagtailadmin/base.html" %}
{% load i18n static %}
{% block titletag %}{% trans "Add a video" %}{% endblock %}

{% block extra_js %}
    {{ block.super }}
    {% include "wagtailadmin/pages/_editor_js.html" %}

    {{ form.media.js }}

    {% url 'wagtailadmin_tag_autocomplete' as autocomplete_url %}
    <script>
        $(function() {
            $('#id_tags').tagit({
                autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
            });
        });
    </script>
{% endblock %}

{% block extra_css %}
    {{ block.super }}
    {% include "wagtailadmin/pages/_editor_css.html" %}
    {{ form.media.css }}
{% endblock %}

{% block content %}
    {% trans "Add video" as add_str %}
    {% include "wagtailadmin/shared/header.html" with title=add_str icon="media" %}

    <div class="nice-padding">
        {% include "wagtailadmin/shared/non_field_errors.html" %}

        <form action="{% url 'wagtail_embed_videos:add' %}" method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            <ul class="fields">
                {% for field in form %}
                    {% if field.is_hidden %}
                        {{ field }}
                    {% else %}
                        {% include "wagtailadmin/shared/field_as_li.html" with field=field %}
                    {% endif %}
                {% endfor %}
                <li><input type="submit" value="{% trans 'Save' %}" class="button" /></li>
            </ul>
        </form>
    </div>
{% endblock %}
