{% extends "wagtailadmin/base.html" %}
{% load compress embed_video_tags static wagtailadmin_tags wagtailimages_tags %}
{% load i18n %}
{% block titletag %}{% blocktrans with title=embed_video.title %}Editing video {{ title }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}menu-embed-videos{% endblock %}
{% block extra_css %}
    {% include "wagtailadmin/shared/tag_field_css.html" %}
{% endblock %}

{% block extra_js %}
    {% include "wagtailadmin/shared/tag_field_js.html" %}

    {# TODO: Find a way to inject page editor handler in the return of the view and not injecting it here #}
    <script type="text/javascript" src="{% static 'wagtailimages/js/image-chooser.js' %}"></script>
    <script type="text/javascript" src="{% static 'wagtailadmin/js/modal-workflow.js' %}"></script>
    <script type="text/javascript">
        window.chooserUrls = {
            'pageChooser': '{% url "wagtailadmin_choose_page" %}'
        };
        window.chooserUrls.imageChooser = "{% url 'wagtailimages:chooser' %}";
    </script>

{% endblock %}

{% block content %}
    {% trans "Editing" as editing_str %}
    {% include "wagtailadmin/shared/header.html" with title=editing_str subtitle=embed_video.title icon="media" usage_object=embed_video %}

    <div class="row row-flush nice-padding">

        <div class="col6">
            <form action="{% url 'wagtail_embed_videos_edit_embed_video' embed_video.id %}" method="POST" enctype="multipart/form-data">
                {% csrf_token %}
                <ul class="fields">
                    {% for field in form %}
                        {% include "wagtailadmin/shared/field_as_li.html" %}
                    {% endfor %}
                    <li><input type="submit" value="{% trans 'Save' %}" /><a href="{% url 'wagtail_embed_videos_delete_embed_video' embed_video.id %}" class="button button-secondary no">{% trans "Delete video" %}</a></li>
                </ul>
            </form>
        </div>
        <div class="col6 divider-before">
            {% video embed_video.url as my_video %}
                {% video my_video "small" %}
                <br />
                <strong>Backend</strong>: {{ my_video.backend }}
            {% endvideo %}
        </div>
    </div>
{% endblock %}
