Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
/**
|
2022-09-09 06:26:42 +00:00
|
|
|
* @file
|
|
|
|
* Controls the visibility of desktop navigation.
|
|
|
|
*
|
|
|
|
* Shows and hides the desktop navigation based on scroll position and controls
|
|
|
|
* the functionality of the button that shows/hides the navigation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* eslint-disable no-inner-declarations */
|
|
|
|
((Drupal) => {
|
|
|
|
/**
|
|
|
|
* Olivero helper functions.
|
|
|
|
*
|
|
|
|
* @namespace
|
|
|
|
*/
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
Drupal.olivero = {};
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Checks if the mobile navigation button is visible.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if navButtons is hidden, false if not.
|
|
|
|
*/
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
function isDesktopNav() {
|
2022-09-09 06:26:42 +00:00
|
|
|
const navButtons = document.querySelector(
|
|
|
|
'[data-drupal-selector="mobile-buttons"]',
|
|
|
|
);
|
|
|
|
return navButtons
|
|
|
|
? window.getComputedStyle(navButtons).getPropertyValue('display') ===
|
|
|
|
'none'
|
|
|
|
: false;
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Drupal.olivero.isDesktopNav = isDesktopNav;
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
const stickyHeaderToggleButton = document.querySelector(
|
|
|
|
'[data-drupal-selector="sticky-header-toggle"]',
|
|
|
|
);
|
|
|
|
const siteHeaderFixable = document.querySelector(
|
|
|
|
'[data-drupal-selector="site-header-fixable"]',
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the sticky header is enabled.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if sticky header is enabled, false if not.
|
|
|
|
*/
|
2021-04-08 14:41:01 +00:00
|
|
|
function stickyHeaderIsEnabled() {
|
|
|
|
return stickyHeaderToggleButton.getAttribute('aria-checked') === 'true';
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Save the current sticky header expanded state to localStorage, and set
|
|
|
|
* it to expire after two weeks.
|
|
|
|
*
|
|
|
|
* @param {boolean} expandedState
|
|
|
|
* Current state of the sticky header button.
|
|
|
|
*/
|
2021-04-08 14:41:01 +00:00
|
|
|
function setStickyHeaderStorage(expandedState) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const now = new Date();
|
2022-09-09 06:26:42 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
const item = {
|
2021-04-08 14:41:01 +00:00
|
|
|
value: expandedState,
|
2022-09-09 06:26:42 +00:00
|
|
|
expiry: now.getTime() + 20160000, // 2 weeks from now.
|
2021-04-08 14:41:01 +00:00
|
|
|
};
|
2022-09-09 06:26:42 +00:00
|
|
|
localStorage.setItem(
|
|
|
|
'Drupal.olivero.stickyHeaderState',
|
|
|
|
JSON.stringify(item),
|
|
|
|
);
|
2021-04-08 14:41:01 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Toggle the state of the sticky header between always pinned and
|
|
|
|
* only pinned when scrolled to the top of the viewport.
|
|
|
|
*
|
|
|
|
* @param {boolean} pinnedState
|
|
|
|
* State to change the sticky header to.
|
|
|
|
*/
|
2021-04-08 14:41:01 +00:00
|
|
|
function toggleStickyHeaderState(pinnedState) {
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
if (isDesktopNav()) {
|
2022-09-23 11:55:38 +00:00
|
|
|
siteHeaderFixable.classList.toggle('is-expanded', pinnedState);
|
2021-04-08 14:41:01 +00:00
|
|
|
stickyHeaderToggleButton.setAttribute('aria-checked', pinnedState);
|
|
|
|
setStickyHeaderStorage(pinnedState);
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Return the sticky header's stored state from localStorage.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* Stored state of the sticky header.
|
|
|
|
*/
|
2021-04-08 14:41:01 +00:00
|
|
|
function getStickyHeaderStorage() {
|
2022-09-09 06:26:42 +00:00
|
|
|
const stickyHeaderState = localStorage.getItem(
|
|
|
|
'Drupal.olivero.stickyHeaderState',
|
|
|
|
);
|
|
|
|
|
2021-04-28 12:14:29 +00:00
|
|
|
if (!stickyHeaderState) return false;
|
2022-09-09 06:26:42 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
const item = JSON.parse(stickyHeaderState);
|
|
|
|
const now = new Date();
|
2021-04-08 14:41:01 +00:00
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
// Compare the expiry time of the item with the current time.
|
2021-04-08 14:41:01 +00:00
|
|
|
if (now.getTime() > item.expiry) {
|
2022-09-09 06:26:42 +00:00
|
|
|
// If the item is expired, delete the item from storage and return null.
|
2021-04-08 14:41:01 +00:00
|
|
|
localStorage.removeItem('Drupal.olivero.stickyHeaderState');
|
2021-04-28 12:14:29 +00:00
|
|
|
return false;
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
2021-04-08 14:41:01 +00:00
|
|
|
return item.value;
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
// Only enable scroll interactivity if the browser supports Intersection
|
|
|
|
// Observer.
|
|
|
|
// @see https://github.com/w3c/IntersectionObserver/blob/master/polyfill/intersection-observer.js#L19-L21
|
|
|
|
if (
|
|
|
|
'IntersectionObserver' in window &&
|
|
|
|
'IntersectionObserverEntry' in window &&
|
|
|
|
'intersectionRatio' in window.IntersectionObserverEntry.prototype
|
|
|
|
) {
|
|
|
|
const fixableElements = document.querySelectorAll(
|
|
|
|
'[data-drupal-selector="site-header-fixable"], [data-drupal-selector="social-bar-inner"]',
|
|
|
|
);
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
|
|
|
|
function toggleDesktopNavVisibility(entries) {
|
|
|
|
if (!isDesktopNav()) return;
|
2022-09-09 06:26:42 +00:00
|
|
|
|
|
|
|
entries.forEach((entry) => {
|
|
|
|
// Firefox doesn't seem to support entry.isIntersecting properly,
|
|
|
|
// so we check the intersectionRatio.
|
2022-09-23 11:55:38 +00:00
|
|
|
fixableElements.forEach((el) =>
|
|
|
|
el.classList.toggle('is-fixed', entry.intersectionRatio < 1),
|
|
|
|
);
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Gets the root margin by checking for various toolbar classes.
|
|
|
|
*
|
|
|
|
* @return {string}
|
|
|
|
* Root margin for the Intersection Observer options object.
|
|
|
|
*/
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
function getRootMargin() {
|
2021-12-18 06:12:16 +00:00
|
|
|
let rootMarginTop = 72;
|
2022-09-09 06:26:42 +00:00
|
|
|
const { body } = document;
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
|
|
|
|
if (body.classList.contains('toolbar-fixed')) {
|
|
|
|
rootMarginTop -= 39;
|
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
if (
|
|
|
|
body.classList.contains('toolbar-horizontal') &&
|
|
|
|
body.classList.contains('toolbar-tray-open')
|
|
|
|
) {
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
rootMarginTop -= 40;
|
|
|
|
}
|
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
return `${rootMarginTop}px 0px 0px 0px`;
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Monitor the navigation position.
|
|
|
|
*/
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
function monitorNavPosition() {
|
2022-09-09 06:26:42 +00:00
|
|
|
const primaryNav = document.querySelector(
|
|
|
|
'[data-drupal-selector="site-header"]',
|
|
|
|
);
|
2021-12-18 06:12:16 +00:00
|
|
|
const options = {
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
rootMargin: getRootMargin(),
|
2022-09-09 06:26:42 +00:00
|
|
|
threshold: [0.999, 1],
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
};
|
2022-09-09 06:26:42 +00:00
|
|
|
|
|
|
|
const observer = new IntersectionObserver(
|
|
|
|
toggleDesktopNavVisibility,
|
|
|
|
options,
|
|
|
|
);
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
|
|
|
|
if (primaryNav) {
|
|
|
|
observer.observe(primaryNav);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stickyHeaderToggleButton) {
|
2021-12-18 06:12:16 +00:00
|
|
|
stickyHeaderToggleButton.addEventListener('click', () => {
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
toggleStickyHeaderState(!stickyHeaderIsEnabled());
|
|
|
|
});
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
// If header is pinned open and a header element gains focus, scroll to the
|
|
|
|
// top of the page to ensure that the header elements can be seen.
|
|
|
|
const siteHeaderInner = document.querySelector(
|
|
|
|
'[data-drupal-selector="site-header-inner"]',
|
|
|
|
);
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
if (siteHeaderInner) {
|
2021-12-18 06:12:16 +00:00
|
|
|
siteHeaderInner.addEventListener('focusin', () => {
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
if (isDesktopNav() && !stickyHeaderIsEnabled()) {
|
2022-09-09 06:26:42 +00:00
|
|
|
const header = document.querySelector(
|
|
|
|
'[data-drupal-selector="site-header"]',
|
|
|
|
);
|
|
|
|
const headerNav = header.querySelector(
|
|
|
|
'[data-drupal-selector="header-nav"]',
|
|
|
|
);
|
2021-12-18 06:12:16 +00:00
|
|
|
const headerMargin = header.clientHeight - headerNav.clientHeight;
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
if (window.scrollY > headerMargin) {
|
|
|
|
window.scrollTo(0, headerMargin);
|
|
|
|
}
|
2021-04-08 14:41:01 +00:00
|
|
|
}
|
Issue #3194560 by Sakthivel M, Gauravmahlawat, mherchel, rikki_iki, kostyashupenko, ranjith_kumar_k_u, hinal05, chetanbharambe, Rinku Jacob 13, vikashsoni, zetagraph, lauriii: Style maintenance page for Olivero
2021-09-30 07:26:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
monitorNavPosition();
|
2021-04-08 14:41:01 +00:00
|
|
|
setStickyHeaderStorage(getStickyHeaderStorage());
|
|
|
|
toggleStickyHeaderState(getStickyHeaderStorage());
|
Issue #3111409 by mherchel, proeung, larowlan, alexpott, lauriii, Gábor Hojtsy, andrewmacpherson, catch, xjm, andypost, rahulrasgon, rabbitlair, mrconnerton, poojakural, boulaffasae, jerseycheese, shimpy, Indrajith KB, DuneBL, kiran.kadam911, komalkolekar, keboca, hawkeye.twolf, andrewozone, Maithri Shetty, alexdmccabe, sd9121, Sreenivas Bttv, katannshaw, mgifford, nod_, webchick, mtift, rainbreaw, Berdir, brianperry, thejimbirch, Dom., q0rban, nitesh624, hansa11, himanshu_sindhwani, kostyashupenko, shaktik, bnjmnm, sharma.amitt16, sonam.chaturvedi, steinmb, shaal, ressa, Ramya Balasubramanian, Sebacic, pradeepjha, tanmaykadam, thedrupalkid, vinitk, volkswagenchick, viappidu, vebrovski, Ujval Shah, Webbeh, Yuri, trebormc, msuthars, mrinalini9, bash247, chetanbharambe, ellenoise, anevins, andriyun, CocoM, JayKandari, ambuj_gupta, hussainweb, jhodgdon, Pooja Ganjage, ju.vanderw, jwitkowski79, MaxPah, Lokender Singh2, jponch, KarenS, KarinG, Lal_: Add new Olivero frontend theme to Drupal 9.1 core as beta; later make it stable and the default
2020-10-16 09:43:55 +00:00
|
|
|
}
|
2022-09-09 06:26:42 +00:00
|
|
|
})(Drupal);
|