{% extends "admin/base_site_nav.html" %}
{% load i18n admin_modify %}

{% block extrahead %}{{block.super}}
{{media}}
{% endblock %}

{% block extrastyle %}
<link rel="stylesheet" href="{{STATIC_URL}}admin/css/forms.css" />
<style>

li, dt, dd {
  font-size: inherit;
  line-height: inherit;
}

#content-main .form-control {
  display: inline-block;
}

#content-main .form-control-inline {
  width: 100%;
}

.glyphicon:before  {
    font: normal normal normal 14px/1 FontAwesome;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    content: "\f067";
}

#content-main .related-widget-wrapper {
  float: none;
}

#content-main select.form-control {
  display: inline-block;
}

#content-main .vDateField, .row .vTimeField {
  width: calc(100% - 100px);
  max-width: 150px;
}

.form-row p, td, th {
  font-family: inherit
}

.inline-related fieldset {
  background: none;
}

fieldset th {
  font-weight: normal;
}

._inline-group .form-control {
  width: 100% !important;
  font-weight: normal;
}

._inline-group input[type=number], ._inline-group .vDateField, ._inline-group .vTimeField {
  width: 100% !important;
  max-width: 400px !important;
}

.selector, .selector-filter {
  width: 100% !important;
}

.selector select {
  width: 100%;
}

.selector-available, .selector-chosen {
  width: calc(100% - 11px) !important;
}

.selector .selector-available input, .selector .selector-chosen input {
  width: calc(100% - 30px) !important;
}

.field-passwordlink a {
  font-weight: bold;
  text-decoration: underline;
}

@media (min-width: 992px) {
  #content-main .col-form-label {
    text-align: right;
  }
}
</style>
{{block.super}}{% endblock %}

{% block tabs %}{% if object_id %}{% tabs opts %}{% endif %}{% endblock %}

{% block tools %}
{% include "common/snippet_follow.html" %}
{% endblock %}

{% block content %}<div id="content-main" class="row"><div class="col-md-12">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
{% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
{% if errors %}
    <div class="row mt-3"><div class="col"><div class="alert alert-danger">
    {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}
    {% trans "Please correct the errors below." %}{% endif %}
    {{ adminform.form.non_field_errors }}
    </div></div></div>
{% endif %}

<div class="row">
{% block field_sets %}
{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}
{% endblock %}

{% block after_field_sets %}{% endblock %}

{% block inline_field_sets %}
{% for inline_admin_formset in inline_admin_formsets %}
    {% include inline_admin_formset.opts.template %}
{% endfor %}
{% endblock %}
</div>

{% block after_related_objects %}{% endblock %}

{% block admin_change_form_document_ready %}
    <script>
        (function($) {
            $(document).ready(function() {
                $("#content-main form input[type='submit']").prop("disabled", true);
                $("#content-main form").on("change input", ":input", function() {
                  $("#content-main form input[type='submit']").prop("disabled", false);
                });
                $('.add-another').click(function(e) {
                    e.preventDefault();
                    showAddAnotherPopup(this);
                });
                $('.related-lookup').click(function(e) {
                    e.preventDefault();
                    showRelatedObjectLookupPopup(this);
                });
            {% if adminform and add %}
                $('form#{{ opts.model_name }}_form :input:visible:enabled:first').focus()
            {% endif %}
            });
        })(django.jQuery);
    </script>
{% endblock %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</form>
</div></div>
{% endblock %}
