{% load static i18n %}
{% load django_listing %}
<div id="listing-popup-container"></div>
<script type="text/javascript">
    var csrf_token = "{{ csrf_token }}";
    var no_choice_msg = "{% trans "Please choose..." %}";
    $(document).ready(function () {
        $.ajaxSetup({
            data: {'csrfmiddlewaretoken': csrf_token}
        });
    });
</script>
{% if AUTO_DECLARE_JS %}
    <script src="{% static 'django_listing/js/django_listing.min.js' %}?{{ STATIC_FILES_VERSION }}"></script>
    <script src="{% static 'django_listing/js/js.cookie.min.js' %}?{{ STATIC_FILES_VERSION }}"></script>
{% endif %}
{% if need_media_for.datetimepicker and DATETIMEPICKER_JS_URL %}
    {% block django_listing_datepicker %}
        {% if AUTO_DECLARE_JS %}
            <script src="{{ DATETIMEPICKER_JS_URL }}?{{ STATIC_FILES_VERSION }}"></script>
        {% endif %}
        {% get_dict_list "datetimepickers" as dict_list %}
        <script type="text/javascript">
            $(document).ready(function () {
                {% for dct in dict_list %}
                    $('#{{dct.div_id}} .edit-datecolumn').datetimepicker({
                        timepicker: false,
                        format: '{{dct.listing.datetimepicker_date_format}}'
                    });
                    $('#{{dct.div_id}} .edit-datetimecolumn').datetimepicker({format: '{{dct.listing.datetimepicker_datetime_format}}'});
                    $('#{{dct.div_id}} .edit-timecolumn').datetimepicker({
                        datepicker: false,
                        format: '{{dct.listing.datetimepicker_time_format}}'
                    });
                {% endfor %}
            });
        </script>
    {% endblock %}
{% endif %}

{% if need_media_for.dropzone and DROPZONE_JS_URL %}
    {% if AUTO_DECLARE_JS %}
        <script src="{{ DROPZONE_JS_URL }}?{{ STATIC_FILES_VERSION }}"></script>
    {% endif %}
    {% get_dict_list "dropzones" as dict_list %}
    <script type="text/javascript">
        var listing_div_id = '{{ listing.css_id }}';
        {% for dct in dict_list %}
            Dropzone.options.{{ dct.dz_camel_name}} = {{ dct.options|json_options }};
        {% endfor %}
    </script>

{% endif %}

{% if need_media_for.autocomplete and AUTOCOMPLETE_JS_URLS %}
    {% block django_listing_autocomplete %}
        {% if AUTO_DECLARE_JS %}
            {% for url in AUTOCOMPLETE_JS_URLS %}
                <script src="{{ url }}?{{ STATIC_FILES_VERSION }}"></script>
            {% endfor %}
        {% endif %}
    {% endblock %}
{% endif %}

{% if need_media_for.dual_listbox and DUAL_LISTBOX_JS_URL %}
    {% block django_listing_dual_listbox %}
        {% if AUTO_DECLARE_JS %}
            <script src="{{ DUAL_LISTBOX_JS_URL }}?{{ STATIC_FILES_VERSION }}"></script>
        {% endif %}
    {% endblock %}
{% endif %}

{% footer_snippets %}

{% if request.django_listing_onready_snippets %}
    <script type="text/javascript">
        $(document).ready(function () {
            {% onready_snippets %}
        });
    </script>
{% endif %}