From b2997aae076d833a3e60284443cc5d246e20e74c Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Fri, 2 Feb 2024 11:13:33 -0800 Subject: [PATCH] Remove unused javascript from nav --- app/javascript/src/handle-click.js | 16 ------- app/javascript/src/mobile-nav.js | 70 ------------------------------ app/javascript/src/popup-nav.js | 22 ---------- 3 files changed, 108 deletions(-) delete mode 100644 app/javascript/src/handle-click.js delete mode 100644 app/javascript/src/mobile-nav.js delete mode 100644 app/javascript/src/popup-nav.js diff --git a/app/javascript/src/handle-click.js b/app/javascript/src/handle-click.js deleted file mode 100644 index c1cac780c37..00000000000 --- a/app/javascript/src/handle-click.js +++ /dev/null @@ -1,16 +0,0 @@ -export function handleClick( - event, - nav, - removeNavExpandedClass, - addNavExpandedClass -) { - var isMobileNavExpanded = nav.popUp.hasClass(nav.expandedClass); - - event.preventDefault(); - - if (isMobileNavExpanded) { - removeNavExpandedClass(); - } else { - addNavExpandedClass(); - } -} diff --git a/app/javascript/src/mobile-nav.js b/app/javascript/src/mobile-nav.js deleted file mode 100644 index bb821db4643..00000000000 --- a/app/javascript/src/mobile-nav.js +++ /dev/null @@ -1,70 +0,0 @@ -import $ from "jquery"; -import { handleClick } from "src/handle-click"; - -$(function() { - // cache jQuery lookups into variables - // so we don't have to traverse the DOM every time - var sandwichIcon = $('.header__club-sandwich'); - var header = $('.header'); - var main = $('main'); - var footer = $('.footer'); - var signUpLink = $('.header__nav-link.js-sign-up-trigger'); - var navExpandedClass = 'mobile-nav-is-expanded'; - var headerSearch = $('.header__search'); - var headerLogo = $('.header__logo-wrap'); - - // variable to support mobile nav tab behaviour - // * skipSandwichIcon is for skipping sandwich icon - // when you tab from "gem" icon - // * tabDirection is for hiding and showing navbar - // when you tab in and out - var skipSandwichIcon = true; - var tabDirection = true; - - function removeNavExpandedClass() { - header.removeClass(navExpandedClass); - main.removeClass(navExpandedClass); - footer.removeClass(navExpandedClass); - } - - function addNavExpandedClass() { - header.addClass(navExpandedClass); - main.addClass(navExpandedClass); - footer.addClass(navExpandedClass); - } - - function handleFocusIn() { - if (skipSandwichIcon) { - addNavExpandedClass(); - headerSearch.focus(); - skipSandwichIcon = false; - } else { - removeNavExpandedClass(); - headerLogo.focus(); - skipSandwichIcon = true; - } - } - - sandwichIcon.click(function(e){ - var nav = {expandedClass: navExpandedClass, popUp: header} - handleClick(e, nav, removeNavExpandedClass, addNavExpandedClass); - }); - - sandwichIcon.on('focusin', handleFocusIn); - - signUpLink.on('focusin', function() { - if (!tabDirection) { - addNavExpandedClass(); - } - }); - - signUpLink.on('focusout', function() { - if (tabDirection) { - tabDirection = false; - removeNavExpandedClass(); - } else { - tabDirection = true; - addNavExpandedClass(); - } - }); -}); diff --git a/app/javascript/src/popup-nav.js b/app/javascript/src/popup-nav.js deleted file mode 100644 index ba76d451edf..00000000000 --- a/app/javascript/src/popup-nav.js +++ /dev/null @@ -1,22 +0,0 @@ -import $ from "jquery"; -import { handleClick } from "src/handle-click"; - -$(function() { - var arrowIcon = $('.header__popup-link'); - var popupNav = $('.header__popup__nav-links'); - - var navExpandedClass = 'is-expanded'; - - function removeNavExpandedClass() { - popupNav.removeClass(navExpandedClass); - } - - function addNavExpandedClass() { - popupNav.addClass(navExpandedClass); - } - - arrowIcon.click(function(e){ - var nav = {expandedClass: navExpandedClass, popUp: popupNav} - handleClick(e, nav, removeNavExpandedClass, addNavExpandedClass); - }); -});