{% extends "admin/base_site.html" %}

<!-- LOADING -->
{% load adminmedia admin_list i18n grp_tags %}

<!-- JAVASCRIPTS -->
{% block javascripts %}
    {{ block.super }}
    {% if cl.formset %}
        {% url admin:jsi18n as jsi18nurl %}
        <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
    {% endif %}
    {{ media }}
    <script type="text/javascript" src="{% admin_media_prefix %}js/grappelli.change_list.js"></script>
    <script type="text/javascript" charset="utf-8">
        {% if is_popup %}
            var IS_POPUP = true;
        {% else %}
            var IS_POPUP = false;
        {% endif %}
        (function($) {
            $(document).ready(function() {
                {% if is_popup %}
                    // UGLY HACK: REMOVE ACTIONS and LIST_EDITABLES FOR POPUPS
                    // shouldn't be there in the first place, see
                    // http://code.djangoproject.com/ticket/11700
                    $('div#actions').hide();
                    $('input.action-select').parent().hide();
                    $('input#action-toggle').parent().hide();
                    $('div.changelist-results input').attr('disabled', 'disabled');
                    $('div.changelist-results select').attr('disabled', 'disabled');
                    $('div.changelist-results textarea').attr('disabled', 'disabled').addClass("mceNoEditor");
                    $('div#submit').hide();
                    $('.related-lookup, .add-another').attr("onClick", "return false;");
                    // "really" disable datepicker in grappelli.js
                    //$('.vDateField').addClass('disabled');
                {% endif %}
                
                {% if cl.search_fields %}
                    {% get_search_fields_verbose cl.opts as search_fields_verbose %}
                    $('body').change_list({'initialSearchVal': '{% if not cl.query and not search_fields_verbose %}{% trans 'Search' %}{% endif %}{% if search_fields_verbose and not cl.query %}{{ search_fields_verbose }}{% endif %}{% if cl.query %}{{ cl.query }}{% endif %}'});
                {% else %}
                    $('body').change_list();
                {% endif %}
            });
        })(django.jQuery);
    </script>
{% endblock %}

<!-- COLTYPE/BODYCLASS-- >
{% block bodyclass %}change-list{% endblock %}
{% block content-class %}content-flexible{% endblock %}

<!-- BREADCRUMBS -- >
{% block breadcrumbs %}
    {% if not is_popup %}
        <div id="breadcrumbs">
            <a href="../../">{% trans "Home" %}</a> &rsaquo;
            <a href="../">{% trans app_label|capfirst|escape %}</a> &rsaquo;
            {{ cl.opts.verbose_name_plural|capfirst }}
        </div>
    {% endif %}
{% endblock %}

<!-- CONTENT-TITLE -->
{% block content_title %}
    <h1>
        {{ cl.opts.verbose_name_plural|capfirst }}
    </h1>
{% endblock %}

<!-- OBJECT-TOOLS -->
{% block object-tools %}
    {% if has_add_permission %}
        <ul class="tools">
            <li>
                <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="add-handler focus">
                    {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                </a>
            </li>
        </ul>
    {% endif %}
{% endblock %}

<!-- CONTENT -->
{% block content %}
    {% if cl.search_fields or cl.has_filters or cl.date_hierarchy %}
        <div class="module changelist-filters">
            <!-- PAGINATION TOP -->
            {% pagination cl %}
            {% if cl.has_filters or cl.search_fields %}
                <!-- FILTERS -->
                {% if cl.has_filters %}
                    <div id="filters" class="module filter span-6">
                        <div class="pulldown-container">
                            <a href="javascript://" class="button toggle-filters">{% trans 'Filter' %}</a>
                            <div class="filter-pulldown">
                                {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                            </div>
                        </div>
                    </div>
                {% endif %}
                <!-- SEARCH -->
                {% if cl.search_fields %}
                    <div id="search" class="module search span-6">
                        {% block search %}{% search_form cl %}{% endblock %}
                    </div>
                {% endif %}
            {% endif %}
            <br clear="all" />
        </div>
        <!-- DATE HIERARCHY -->
        {% if cl.date_hierarchy %}
            {% date_hierarchy cl %}
        {% endif %}
    {% endif %}
    <form action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
        <div id="changelist" class="container-full{% if cl.list_editable %} editable{% endif %}" style="">
            <!-- POPUP -->
            {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
            <!-- ERRORS -->
            {% if cl.formset.errors %}
                <p class="errornote">
                    {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
                </p>
                {{ cl.formset.non_form_errors }}
            {% endif %}
            <!-- MANAGEMENT FORM -->
            {% if cl.formset %}
                {{ cl.formset.management_form }}
            {% endif %}
            <!-- CHANGELIST-RESULTS -->
            {% block result_list %}
                {% result_list cl %}
            {% endblock %}
            <!-- PAGINATION BOTTOM -->
            {% pagination cl %}
        </div><br clear="all" />
        <!-- CHANGELIST-ACTIONS -->
        {% if action_form and cl.full_result_count and cl.result_count %}
            {% admin_actions %}
        {% endif %}
        <!-- SUBMIT ROW -->
        {% if cl.formset and cl.full_result_count and cl.result_count %}
            <div id="submit" class="module footer">
                <ul class="submit-row">
                    <li class="left delete-link-container"><a href="javascript://" class="cancel-link">Cancel</a></li>
                    <li class="submit-button-container"><input type="submit" class="default" name="_save" value="Save"/></li>
                </ul>
            </div>
        {% endif %}
    </form>
{% endblock %}
