2026-03-31 11:30:59 +02:00
|
|
|
import { mountMenuLevel, isMegaMenuCustomWidthCentered } from './menu'
|
2025-08-27 08:44:30 +02:00
|
|
|
|
|
|
|
|
export const mount = (menu) => {
|
|
|
|
|
if (window.wp && wp && wp.customize && wp.customize('active_theme')) {
|
2026-03-31 11:30:59 +02:00
|
|
|
const maybeMegaMenuWithCustomWidth = [...menu.children].find(
|
|
|
|
|
(el) =>
|
|
|
|
|
el.matches('.ct-mega-menu:not(.ct-mega-menu-custom-width)') &&
|
|
|
|
|
!isMegaMenuCustomWidthCentered(el)
|
2025-08-27 08:44:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (maybeMegaMenuWithCustomWidth) {
|
|
|
|
|
const submenu =
|
|
|
|
|
maybeMegaMenuWithCustomWidth.querySelector('.sub-menu')
|
|
|
|
|
|
|
|
|
|
submenu.style.left = `${
|
|
|
|
|
Math.round(
|
|
|
|
|
maybeMegaMenuWithCustomWidth
|
|
|
|
|
.closest('[class*="ct-container"]')
|
|
|
|
|
.firstElementChild.getBoundingClientRect().x
|
|
|
|
|
) -
|
|
|
|
|
Math.round(
|
|
|
|
|
maybeMegaMenuWithCustomWidth
|
|
|
|
|
.closest('nav')
|
|
|
|
|
.getBoundingClientRect().x
|
|
|
|
|
)
|
|
|
|
|
}px`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mountMenuLevel(menu, { startPosition: 'left' })
|
|
|
|
|
}
|