From c2c9ed4a6c9d5c5a0c4ba62f17498d3ce80df7b5 Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Mon, 12 Sep 2016 11:57:43 +1200 Subject: [PATCH] Add documentation for header drop-down open/closed. --- mediagoblin/static/js/header_dropdown.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mediagoblin/static/js/header_dropdown.js b/mediagoblin/static/js/header_dropdown.js index c9a2d8a9..979d2690 100644 --- a/mediagoblin/static/js/header_dropdown.js +++ b/mediagoblin/static/js/header_dropdown.js @@ -17,8 +17,12 @@ */ $(document).ready(function(){ - var panelclosed = localStorage.getItem("panelclosed"); - if (panelclosed === "true"){ + // The header drop-down header panel defaults to open until you explicitly + // close it. After that, the panel open/closed setting will persist across + // page loads. + + // Initialise the panel status when page is loaded. + if (localStorage.getItem("panel_closed")) { $("#header_dropdown").hide(); $(".header_dropdown_up").hide(); } @@ -26,18 +30,16 @@ $(document).ready(function(){ $(".header_dropdown_down").hide(); } - $(".header_dropdown_down,.header_dropdown_up").click(function() { - if (localStorage.getItem("panelclosed") === "true") { - localStorage.setItem("panelclosed", "false"); + // Toggle and persist the panel status. + $(".header_dropdown_down, .header_dropdown_up").click(function() { + if (localStorage.getItem("panel_closed")) { + localStorage.removeItem("panel_closed"); } else { - localStorage.setItem("panelclosed", "true"); + localStorage.setItem("panel_closed", "true"); } $(".header_dropdown_down").toggle(); $(".header_dropdown_up").toggle(); $("#header_dropdown").slideToggle(); }); }); - - - -- 2.25.1