summaryrefslogtreecommitdiff
path: root/website/static/admin/js/collapse.js
diff options
context:
space:
mode:
authorprashantsinalkar2019-11-28 11:44:18 +0530
committerprashantsinalkar2019-11-28 11:44:18 +0530
commit06653abddb801782ef2fc9c7bd2ea097fd4c61c6 (patch)
tree31083a2fa059262370e3fb0825ce3e5c2cd0c4f2 /website/static/admin/js/collapse.js
parentc43a784c26da8fba39b4d017c1c596587a6255a6 (diff)
downloadpyfoss-06653abddb801782ef2fc9c7bd2ea097fd4c61c6.tar.gz
pyfoss-06653abddb801782ef2fc9c7bd2ea097fd4c61c6.tar.bz2
pyfoss-06653abddb801782ef2fc9c7bd2ea097fd4c61c6.zip
added static files in app
Diffstat (limited to 'website/static/admin/js/collapse.js')
-rw-r--r--website/static/admin/js/collapse.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/website/static/admin/js/collapse.js b/website/static/admin/js/collapse.js
new file mode 100644
index 0000000..889e1a5
--- /dev/null
+++ b/website/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);