{% extends "django_cradmin/base.django.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load cradmin_icon_tags %}

{% block bodyclass %}
    {{ block.super }}
    django-cradmin-formview-page
{% endblock %}

{% block title %}
    {{ pagetitle }}
{% endblock title %}

{% block pageheader-inner %}
    <h1>
        {% block heading %}
            {{ pageheading }}
        {% endblock heading %}
    </h1>
{% endblock pageheader-inner %}

{% block content %}
    {% block pre_form %}{% endblock pre_form %}
    {% block form %}
        <div class="container">
            {% crispy form formhelper %}
        </div>

        {% comment %}
            NOTE: This will probably break when https://github.com/maraujop/django-crispy-forms/issues/263 is fixed
        {% endcomment %}
        {{ form.media }}
    {% endblock form %}
    {% block post_form %}{% endblock post_form %}
{% endblock content %}

{% block outside-bodycontentwrapper %}
    {{ block.super }}
    {% if enable_modelchoicefield_support %}
        <div class="django-cradmin-floating-fullsize-iframe-wrapper django-cradmin-modelchoicefield-iframe-wrapper"
             django-cradmin-model-choice-field-iframe-wrapper="{{ fieldid }}">
            <a href="#" class="django-cradmin-floating-fullsize-iframe-closebutton"
                    django-cradmin-model-choice-field-iframe-closebutton>
                <span aria-hidden="true"
                        class="{% cradmin_icon 'close-overlay-right-to-left' %}
                            django-cradmin-floating-fullsize-iframe-closebutton-icon"></span>
                <span class="sr-only">{% trans "Close window" %}</span>
            </a>
            <div class="django-cradmin-floating-fullsize-content">
                <div class="ng-hide django-cradmin-floating-fullsize-loadspinner"
                        django-cradmin-model-choice-field-load-spinner>
                    <span class="{% cradmin_icon 'loadspinner' %}"></span>
                </div>
                <div class="django-cradmin-floating-fullsize-iframe-inner"
                        django-cradmin-model-choice-field-iframe-wrapper-inner>
                    <iframe django-cradmin-model-choice-field-iframe></iframe>
                </div>
            </div>
        </div>
    {% endif %}
    {% block handle_preview %}
        {% if show_preview %}
            <div django-cradmin-page-preview-wrapper>
                {% include "django_cradmin/pagepreview/includes/pagepreview-fullsize-iframe-wrapper.django.html" %}
                <div django-cradmin-page-preview-open-on-page-load='{
                    "urls": [
                        {
                            "label": "unused",
                            "url": "{{ preview_url }}"
                        }
                    ]
                }'></div>
            </div>
        {% endif %}
    {% endblock handle_preview %}
{% endblock outside-bodycontentwrapper %}
