Skip to content

Commit

Permalink
Removing gnav source function
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 committed Jan 17, 2025
1 parent 984a908 commit f7498dc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
loadIms,
decorateLinks,
loadScript,
getGnavSource,
} from '../../utils/utils.js';
import {
closeAllDropdowns,
Expand Down Expand Up @@ -43,7 +44,6 @@ import {
closeAllTabs,
disableMobileScroll,
enableMobileScroll,
getGnavSource,
} from './utilities/utilities.js';
import { getFedsPlaceholderConfig } from '../../utils/federated.js';

Expand Down
16 changes: 4 additions & 12 deletions libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,10 @@ export const dropWhile = (xs, f) => {
return xs;
};

export async function getGnavSource() {
const { locale, dynamicNavKey } = getConfig();
let url = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`;
if (dynamicNavKey) {
const { default: dynamicNav } = await import('../features/dynamic-navigation/dynamic-navigation.js');
url = dynamicNav(url, dynamicNavKey);
}
return url;
}

export async function isLocalNav() {
const gnavSource = await getGnavSource();
export function isLocalNav() {
if (isDesktop.matches) return false;
const { locale } = getConfig();
const gnavSource = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`;
const newNavEnabled = new URLSearchParams(window.location.search).get('newNav') || getMetadata('mobile-gnav-v2') !== 'off';
return gnavSource.split('/').pop().startsWith('localnav-') && newNavEnabled;
}
Expand Down
12 changes: 2 additions & 10 deletions libs/blocks/section-metadata/sticky-section.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { createTag } from '../../utils/utils.js';
import { getMetadata, getDelayTime } from './section-metadata.js';
import { getGnavHeight } from '../global-navigation/utilities/utilities.js';

function handleTopHeight(section) {
let topHeight = document.querySelector('header')?.offsetHeight ?? 0;
const localNav = document.querySelector('.feds-localnav');
const fedsPromo = document.querySelector('.feds-promo-wrapper');
if (localNav && localNav.offsetHeight > 0) {
topHeight = localNav.offsetHeight;
}
if (fedsPromo) {
topHeight += fedsPromo.offsetHeight;
}

const topHeight = getGnavHeight();
section.style.top = `${topHeight}px`;
}

Expand Down
12 changes: 2 additions & 10 deletions libs/mep/ace0861/section-metadata/sticky-section.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { createTag } from '../../../utils/utils.js';
import { getMetadata, getDelayTime } from './section-metadata.js';
import { getGnavHeight } from '../../../blocks/global-navigation/utilities/utilities.js';

function handleTopHeight(section) {
let topHeight = document.querySelector('header').offsetHeight;
const localNav = document.querySelector('.feds-localnav');
const fedsPromo = document.querySelector('.feds-promo-wrapper');
if (localNav) {
topHeight = localNav.offsetHeight;
}
if (fedsPromo) {
topHeight += fedsPromo.offsetHeight;
}

const topHeight = getGnavHeight();
section.style.top = `${topHeight}px`;
}

Expand Down

0 comments on commit f7498dc

Please sign in to comment.