Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "(develop) Clean up Javascript; Refactor headers on Boston.gov"" #800

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/components/header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
// This module controls the City of Boston newsletter component
// This module controls the City of Boston header component
// ---------------------------
var BostonHeader = (function () {
var guideTitle;
Expand Down Expand Up @@ -78,6 +78,15 @@ var BostonHeader = (function () {

if (burgerckbx) {
burgerckbx.setAttribute("tabIndex", "0");
burgerckbx.addEventListener("click", function (element) {
if (document.getElementById("cob-content").classList.contains('brg-tr--active')) {
document.getElementById("cob-content").classList.remove('brg-tr--active');
}
else {
document.getElementById("cob-content").classList.add('brg-tr--active');
}
});

}

if (searchckbx) {
Expand Down
52 changes: 34 additions & 18 deletions scripts/components/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

// This module controls the City of Boston Main RHS Menu
// ---------------------------
var BostonMenu = (function () {
// Set height
var secondaryNavs;
Expand All @@ -9,21 +10,22 @@ var BostonMenu = (function () {
var backTriggers;
var burger;
var placeholder;
var navMainmenu;
var sticky;
// var navMainmenu;
// var sticky;
var navLogo;
var navFirstItem;
var siteBanner;

// activate class for sticky menu
function mainMenuonScroll() {
sticky = navMainmenu.offsetTop;

if (window.pageYOffset > sticky) {
navMainmenu.classList.add("sticky");
} else {
navMainmenu.classList.remove("sticky");
}
}
// function mainMenuonScroll() {
// sticky = navMainmenu.offsetTop;
//
// if (window.pageYOffset > sticky) {
// navMainmenu.classList.add("sticky");
// } else {
// navMainmenu.classList.remove("sticky");
// }
// }

function handleTrigger(ev, method) {

Expand Down Expand Up @@ -69,7 +71,8 @@ var BostonMenu = (function () {

// Update the title
title.innerHTML = trigger.innerHTML;
} else {
}
else {
for (var i = 0; i < listItems.length; i++) {
if (parentItem != listItems[i]) {
listItems[i].classList.remove('nv-m-c-l-i--h');
Expand All @@ -92,13 +95,14 @@ var BostonMenu = (function () {

function start() {
burger = document.getElementById('brg-tr');
siteBanner = document.querySelector('.dr-h');
navLogo = document.getElementById('logoImg');
listItems = document.querySelectorAll('.nv-m-c-l-i');
backTriggers = document.querySelectorAll('.nv-m-c-b');
secondaryTriggers = document.querySelectorAll('.nolink');
secondaryNavs = document.querySelectorAll('.nv-m-c-l-l');
secondaryNavItems = document.querySelectorAll('.nv-m-c-a--s');
navMainmenu = document.getElementById("main-menu");
// navMainmenu = document.getElementById("main-menu");
navFirstItem = document.querySelector('.nv-m-h-i');

var title = document.getElementById('nv-m-h-t');
Expand Down Expand Up @@ -159,12 +163,24 @@ var BostonMenu = (function () {
secondaryNavItems[i].classList.add('nv-m-c-a--p');
}

if (navMainmenu) {
window.onscroll = function() {
mainMenuonScroll()
};
// Note when the site_banner is expanded.
if (siteBanner) {
siteBanner.addEventListener("click", function (element) {
if (document.getElementById("cob-content").classList.contains('site-banner--expanded')) {
document.getElementById("cob-content").classList.remove('site-banner--expanded');
}
else {
document.getElementById("cob-content").classList.add('site-banner--expanded');
}
});
}

// if (navMainmenu) {
// window.onscroll = function() {
// mainMenuonScroll()
// };
// }

}

return {
Expand Down