summaryrefslogtreecommitdiff
path: root/www/static/admin/js/collapse.js
diff options
context:
space:
mode:
authorroot <root@lalalizard.com>2012-11-26 12:06:35 -0500
committerroot <root@lalalizard.com>2012-11-26 12:06:35 -0500
commite0bc5e67f0be025aa54fbac3d25065b4b8c00f40 (patch)
treeb6da444ba40190fa2a8aece52daedad82c65aab3 /www/static/admin/js/collapse.js
parentef51b60c6481254d88c5fc3c34f4127b7f881a58 (diff)
www/ folder
Diffstat (limited to 'www/static/admin/js/collapse.js')
-rwxr-xr-xwww/static/admin/js/collapse.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/www/static/admin/js/collapse.js b/www/static/admin/js/collapse.js
new file mode 100755
index 0000000..889e1a5
--- /dev/null
+++ b/www/static/admin/js/collapse.js
@@ -0,0 +1,24 @@
+(function($) {
+ $(document).ready(function() {
+ // Add anchor tag for Show/Hide link
+ $("fieldset.collapse").each(function(i, elem) {
+ // Don't hide if fields in this fieldset have errors
+ if ($(elem).find("div.errors").length == 0) {
+ $(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
+ i +'" class="collapse-toggle" href="#">' + gettext("Show") +
+ '</a>)');
+ }
+ });
+ // Add toggle to anchor tag
+ $("fieldset.collapse a.collapse-toggle").toggle(
+ function() { // Show
+ $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
+ return false;
+ },
+ function() { // Hide
+ $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
+ return false;
+ }
+ );
+ });
+})(django.jQuery);