{% load i18n sekizai_tags staticfiles %}

{% include 'leprikon/filter_form.html' %}

{% for course in courses %}
{% include 'leprikon/course_preview.html' %}
{% empty %}
<p>{{ message_empty }}</p>
{% endfor %}

{% include 'leprikon/static/bootstrap-multiselect.html' %}

{% addtoblock "js" %}
<script type="text/javascript">
$(document).ready(function() {
    $('#list_filter_form select[data-type=ModelMultipleChoiceField]').multiselect({
        nonSelectedText: '',
        allSelectedText: false,
        numberDisplayed: 2,
        nSelectedText: '{% trans 'selected' %}',
        onDropdownHide: function(element, checked) {
            $('#list_filter_form').submit();
        },
        disableIfEmpty: true,
    });
    $('#list_filter_form select[data-type=MultipleChoiceField]').multiselect({
        nonSelectedText: '',
        allSelectedText: false,
        numberDisplayed: 2,
        nSelectedText: '{% trans 'selected' %}',
        onDropdownHide: function(element, checked) {
            $('#list_filter_form').submit();
        },
        disableIfEmpty: true,
    });
    $('#list_filter_form input[data-type=CharField]').change(function() {
        $('#list_filter_form').submit();
    });
    $('#list_filter_form input[data-type=BooleanField]').change(function() {
        $('#list_filter_form').submit();
    });
});
</script>
{% endaddtoblock %}

