format and consolidate code in navigation script
authorDan Allen <dan@opendevise.com>
Sun, 4 Feb 2018 02:17:02 +0000 (19:17 -0700)
committerSarah White <sarah@opendevise.com>
Mon, 5 Feb 2018 01:16:08 +0000 (01:16 +0000)
src/js/01-navigation.js

index 96150a0..c0bb5a9 100644 (file)
@@ -50,9 +50,7 @@
 
   if (currentPageItem) {
     activateCurrentPath(currentPageItem).forEach(function (itemId) {
-      if (expandedItems.indexOf(itemId) < 0) {
-        expandedItems.push(itemId)
-      }
+      if (expandedItems.indexOf(itemId) < 0) expandedItems.push(itemId)
     })
   }
 
@@ -81,9 +79,7 @@
   }
 
   function toggleNavigation (e) {
-    if (navToggle.classList.contains('is-active')) {
-      return closeNavigation(e)
-    }
+    if (navToggle.classList.contains('is-active')) return closeNavigation(e)
     document.documentElement.classList.add('is-clipped--nav')
     navToggle.classList.add('is-active')
     navContainer.classList.add('is-active')
 
   function getState (component, version) {
     var data = window.sessionStorage.getItem('nav-state')
-    if (data) {
-      return JSON.parse(data)
-    }
+    if (data) return JSON.parse(data)
   }
 
   function saveState () {
     if (!el) return (parent.scrollTop = scrollPosition)
 
     var margin = 10
-
     var overTheTop = el.offsetTop - scrollPosition < 0
     var belowTheBottom = el.offsetTop - scrollPosition + el.offsetHeight > parent.offsetHeight