4 $(document).ready(function() {
5 // Add anchor tag for Show/Hide link
6 $("fieldset.collapse").each(function(i, elem) {
7 // Don't hide if fields in this fieldset have errors
8 if ($(elem).find("div.errors").length === 0) {
9 $(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
10 i + '" class="collapse-toggle" href="#">' + gettext("Show") +
14 // Add toggle to anchor tag
15 $("fieldset.collapse a.collapse-toggle").click(function(ev) {
16 if ($(this).closest("fieldset").hasClass("collapsed")) {
18 $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
21 $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);