diff options
author | Jayaram Pai | 2013-11-26 14:40:02 +0530 |
---|---|---|
committer | Jayaram Pai | 2013-11-26 14:40:02 +0530 |
commit | 076faa00fdf06afa409dad04eb9814d49b1a0f20 (patch) | |
tree | 5029f59eeefcdd312813abbbd0babc32dfa9ffb3 /static/admin/js/collapse.js | |
parent | a8d7eed900417f9980f664808140e594641cf062 (diff) | |
download | pyfoss-076faa00fdf06afa409dad04eb9814d49b1a0f20.tar.gz pyfoss-076faa00fdf06afa409dad04eb9814d49b1a0f20.tar.bz2 pyfoss-076faa00fdf06afa409dad04eb9814d49b1a0f20.zip |
adding admin css
Diffstat (limited to 'static/admin/js/collapse.js')
-rw-r--r-- | static/admin/js/collapse.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/static/admin/js/collapse.js b/static/admin/js/collapse.js new file mode 100644 index 0000000..889e1a5 --- /dev/null +++ b/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); |