0
|
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"); |
|
8 |
$(elem).find("h2").first().append(' (<a id="fieldsetcollapser' + |
|
9 |
i +'" class="collapse-toggle" href="#">' + gettext("Show") + |
|
10 |
'</a>)'); |
|
11 |
} |
|
12 |
}); |
|
13 |
// Add toggle to anchor tag |
|
14 |
$("fieldset.collapse a.collapse-toggle").toggle( |
|
15 |
function() { // Show |
|
16 |
$(this).text(gettext("Hide")); |
|
17 |
$(this).closest("fieldset").removeClass("collapsed"); |
|
18 |
return false; |
|
19 |
}, |
|
20 |
function() { // Hide |
|
21 |
$(this).text(gettext("Show")); |
|
22 |
$(this).closest("fieldset").addClass("collapsed"); |
|
23 |
return false; |
|
24 |
} |
|
25 |
); |
|
26 |
}); |
|
27 |
})(django.jQuery); |