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

{% block extrahead %}
{{ block.super }}
{{ media.js }}
{% if action_form %}{% if actions_on_top or actions_on_bottom %}
<!-- Snippet from http://djangosnippets.org/snippets/2630/ -->
<script type="text/javascript">

(function ($) {

    function fix_actions() {
        var container = $('div.actions');

        if (container.find('option').length < 10) {
            container.find('label, button').hide();

            var buttons = $('<div></div>')
                .prependTo(container)
                .css('display', 'inline')
                .addClass('class', 'action-buttons');

            container.find('option:gt(0)').each(function () {
                $('<button>')
                    .appendTo(buttons)
                    .attr('name', this.value)
                    .addClass('button ' + this.text)
                    .text(this.text)
                    .click(function () {
                        container.find('select')
                            .find(':selected').attr('selected', '').end()
                            .find('[value=' + this.name + ']').attr('selected', 'selected');
                        $('#changelist-form button[name="index"]').click();
                    });
            });
        }
    };

    $(function () {
        fix_actions();
    });
})(django.jQuery);

</script>
{% endif %}{% endif %}
{% endblock %}
