Refactor JavaScript for toggling the footer navigation