1. Shlomi Fish
  2. shlomi-fish-homepage

Commits

Shlomi Fish  committed bd6766b

Expand some of the navigation menu branches by default.

With some detection of localStorage - quick and dirty code, but a simple one.

  • Participants
  • Parent commits 4543b7b
  • Branches default

Comments (0)

Files changed (2)

File TODO

View file
 Pressing:
 ---------
 
+* Make sure the AJAX-read jqTree navigation menu expands the top-level
+categories ("Homour", "Essays", "Lectures", etc.) at first.
+    - only when it closes.
+
 Not so pressing:
 ----------------
 

File common/js/to-jqtree-2.js

View file
         }),
         function(json_input) {
             var nav_menu = $('#nav_menu');
+            var has_ls = (typeof localStorage !== "undefined" && localStorage !== null);
+            var storage_key = 'shlomifish.org_main_nav_menu_data';
+            var was_storage_already_populated = false;
+            if (has_ls) {
+                was_storage_already_populated = (localStorage.getItem(storage_key) ? true : false);
+            }
             nav_menu.tree({
                 autoEscape: false,
                 autoOpen: false,
-                saveState: true,
+                saveState: storage_key,
                 data: calc_jqtree_data_from_html_w_nav_menu_json(
                     {
                         input: json_input,
                     }
                 )
             });
-            var about_myself_node_id = "2";
-            var meta_node_id = "311";
-            [meta_node_id].forEach(function (node_id) {
-                var node = nav_menu.tree('getNodeById', node_id);
-                nav_menu.tree('openNode', node, false);
-            });
+
+            if (! was_storage_already_populated) {
+                var about_myself_node_id = "2";
+                var art_node_id = "120";
+                var essays_node_id = "235";
+                var humour_node_id = "13";
+                var lectures_node_id = "193";
+                var meta_node_id = "311";
+                var soft_node_id = "127";
+
+                [about_myself_node_id, art_node_id, essays_node_id, humour_node_id, lectures_node_id, meta_node_id, soft_node_id].forEach(function (node_id) {
+                    var node = nav_menu.tree('getNodeById', node_id);
+                    nav_menu.tree('openNode', node, false);
+                });
+            }
         }
     );
 }