From ff15ab71fbb021bbcec8287051ec2ce0f79b3a12 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 29 Sep 2015 00:22:05 -0500 Subject: [PATCH] Make the notice auto-collapsible with JS. --- static/script.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/static/script.js b/static/script.js index fb1bbfb..2d45863 100644 --- a/static/script.js +++ b/static/script.js @@ -72,6 +72,36 @@ function delete_cookie(name) { set_cookie(name, "", -1); } +function toggle_notice() { + var details = $("#notice-collapse-box"), + trigger = $("#notice-collapse-trigger"); + if (details.is(":hidden")) { + details.show(); + trigger.text("[hide]"); + } + else { + details.hide(); + trigger.text("[show]"); + } +} + +function install_notice() { + var details = $("#notice-collapse-box"), + trigger = $("#notice-collapse-trigger"); + if (details.length >= 0 && trigger.length >= 0) { + trigger.replaceWith($("", { + id: "notice-collapse-trigger", + href: "#", + text: "[show]", + click: function() { + toggle_notice(); + return false; + } + })); + details.hide(); + } +} + $(document).ready(function() { $("#action-search").change(function() { $(".cv-search").prop("disabled", false); @@ -94,7 +124,7 @@ $(document).ready(function() { } }); - if ($("#cv-additional").length) { + if ($("#cv-additional").length >= 0) { $("#cv-additional").css("display", "block"); $(".source-default-hidden").css("display", "none"); $("#show-additional-sources").click(function() { @@ -103,4 +133,6 @@ $(document).ready(function() { return false; }); } + + install_notice(); });