Login

Accordion changelist admin

Author:
djm
Posted:
December 16, 2010
Language:
HTML/template
Version:
1.2
Tags:
filter hide collapse changelist list_filter accordion collapsible
Score:
2 (after 2 ratings)

This is adapted from rodnsi's version to work with Django 1.2 (as django.contrib.admin came with jQuery built in as of 1.2).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{% block extrahead %}
    {{ block.super }}
    {{ media.js }}
    {% if action_form %}{% if actions_on_top or actions_on_bottom %}
    <script type="text/javascript">
    (function($) {
        $(document).ready(function($) {
            $("tr input.action-select").actions();
        });
    })(django.jQuery);
    </script>
    {% endif %}{% endif %}

    {# Adds a collapsible filter interface, adapted from http://djangosnippets.org/snippets/1818/ #}
    <style type="text/css">
        #changelist-filter h2 span{
            padding-right:15px;
        }
        #changelist-filter h2 span.slidedown{
            background: transparent url({% load adminmedia %}{% admin_media_prefix %}img/admin/arrow-up.gif) no-repeat scroll right 0.4em
        }     

        #changelist-filter h2 span.slideup {
            background: transparent url({% admin_media_prefix %}img/admin/arrow-down.gif) no-repeat scroll right 0.4em

        }

        #changelist-filter h2 {
            cursor:pointer;
        }

    </style>

    <script type="text/javascript" charset="utf-8">
    (function($) {
        $(document).ready(function($){
            $("#changelist-filter h2").append('<span class="slidedown">&nbsp;</span>');
            $("#changelist-filter h2").bind("click",function(){
                if ($("#changelist-filter ul, #changelist-filter h3").is(":hidden")) {
                    $("#changelist-filter h2 span").removeClass("slideup");
                    $("#changelist-filter h2 span").addClass("slidedown");
                    $("#changelist-filter ul, #changelist-filter h3").show("slow");
                } else {
                    $("#changelist-filter h2 span").removeClass("slidedown");
                    $("#changelist-filter h2 span").addClass("slideup");
                    $("#changelist-filter ul, #changelist-filter h3").slideUp();
                }
            });
        });
    })(django.jQuery);
    </script>
{% endblock %}

More like this

  1. Initially open collapsable fieldset class in admin by ralfzen 4 years, 9 months ago
  2. Save Admin ChangeList Filter by msaron 3 years, 5 months ago
  3. model save memos by depaolim 2 years ago
  4. Accordion changelist admin by rodnsi 5 years, 7 months ago
  5. Admin Save and view next button html by ungenio41 5 years, 2 months ago

Comments

Please login first before commenting.