From 745e506bc8c8fcf65fe16ce2cbf17a6ed43b95bf Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@mail.kvcc.edu>
Date: Sun, 31 Jul 2016 01:03:26 -0400
Subject: [PATCH] Fix a few bugs with new logic

Footer nav would temporarily break if switching from mobile view to desktop view.
Header nav would dissapear even if on desktop view (there was no way to get it back after)
---
 static/javascript/mobileview.js | 43 ++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/static/javascript/mobileview.js b/static/javascript/mobileview.js
index d55342a..05b4b27 100644
--- a/static/javascript/mobileview.js
+++ b/static/javascript/mobileview.js
@@ -134,25 +134,28 @@ $(document).ready(function() {
     
     function ToggleHeaderMenus () {
         
-        // Check if menu or icon has been clicked.
-        if ((clickOnHeaderNav) == true || (clickOnHeaderIcon) == true) {
-            //console.log("clickOnFooterIcon Value: " + clickOnFooterIcon + "    FooterNav Clicked");
-            //console.log("clickOnFooterNav Value: " + clickOnFooterNav + "    FooterMenu Clicked");
-            // Check if HeaderIcon has been clicked.
-            if ((clickOnHeaderIcon) == true) {
-                // If Menu is currently visible.
-                if ($("#header-nav .nav-wrapper").hasClass("display-flex")) {
-                    console.log("Closing Header Menu.");
-                    $("#header-nav .nav-wrapper").addClass("display-none").removeClass("display-flex");
-                } else {
-                    console.log("Opening Header Menu.");
-                    $("#header-nav .nav-wrapper").addClass("display-flex").removeClass("display-none");
-                }
-            } 
-        } else {
-            // Menu has not been clicked on. Closing if open.
-            console.log("Closing Header Menu.");
-            $("#header-nav .nav-wrapper").addClass("display-none").removeClass("display-flex");
+        // Only toggle header if in mobile view.
+        if (isSizeMobile(size)) {
+            // Check if menu or icon has been clicked.
+            if ((clickOnHeaderNav) == true || (clickOnHeaderIcon) == true) {
+                //console.log("clickOnFooterIcon Value: " + clickOnFooterIcon + "    FooterNav Clicked");
+                //console.log("clickOnFooterNav Value: " + clickOnFooterNav + "    FooterMenu Clicked");
+                // Check if HeaderIcon has been clicked.
+                if ((clickOnHeaderIcon) == true) {
+                    // If Menu is currently visible.
+                    if ($("#header-nav .nav-wrapper").hasClass("display-flex")) {
+                        console.log("Closing Header Menu.");
+                        $("#header-nav .nav-wrapper").addClass("display-none").removeClass("display-flex");
+                    } else {
+                        console.log("Opening Header Menu.");
+                        $("#header-nav .nav-wrapper").addClass("display-flex").removeClass("display-none");
+                    }
+                } 
+            } else {
+                // Menu has not been clicked on. Closing if open.
+                console.log("Closing Header Menu.");
+                $("#header-nav .nav-wrapper").addClass("display-none").removeClass("display-flex");
+            }
         }
         
         // Default vars to false once processing has occured.
@@ -289,7 +292,7 @@ $(document).ready(function() {
         $("#header-nav .nav-wrapper").removeClass("display-none display-flex");
 
         // Remove mobile-set classes from nav submenus.
-        $(".nav-sub-menu").removeClass("display-none display-flex");
+        $("#header-nav .nav-sub-menu").removeClass("display-none display-flex");
 
         // Set navigation to horizontal mode.
         $("#header-nav .nav-wrapper").addClass("horiz-nav").removeClass("vert-nav");
-- 
GitLab