Add documentation for header drop-down open/closed.
authorBen Sturmfels <ben@sturm.com.au>
Sun, 11 Sep 2016 23:57:43 +0000 (11:57 +1200)
committerBen Sturmfels <ben@sturm.com.au>
Sun, 11 Sep 2016 23:57:43 +0000 (11:57 +1200)
mediagoblin/static/js/header_dropdown.js

index c9a2d8a9668934aa2e971cc36e58191e2320ca82..979d26908107fd09ea2d3a0f38e74d5de8c25291 100644 (file)
  */
 
 $(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();
   });
 });
-
-
-