Project

General

Profile

Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / django / contrib / admin / static / admin / js / collapse.js @ 1a305335

History | View | Annotate | Download (880 Bytes)

1
(function($) {
2
        $(document).ready(function() {
3
                // Add anchor tag for Show/Hide link
4
                $("fieldset.collapse").each(function(i, elem) {
5
                        // Don't hide if fields in this fieldset have errors
6
                        if ($(elem).find("div.errors").length == 0) {
7
                                $(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
8
                                        i +'" class="collapse-toggle" href="#">' + gettext("Show") +
9
                                        '</a>)');
10
                        }
11
                });
12
                // Add toggle to anchor tag
13
                $("fieldset.collapse a.collapse-toggle").toggle(
14
                        function() { // Show
15
                                $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
16
                                return false;
17
                        },
18
                        function() { // Hide
19
                                $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
20
                                return false;
21
                        }
22
                );
23
        });
24
})(django.jQuery);