for SalesPlatformServicesBlog for SalesPlatformServicesBlog
(function() {
let ITEM_GAP = 32;
let menuElement = document.getElementById("menu-left-bBC1ygoAAPdmGNRVP0TA9");
let currentColElement = menuElement.parentElement;
let rowElement = menuElement.parentElement.parentElement;
if (!menuElement || !currentColElement || !rowElement) {
return;
}
function calc() {
let availableSpace = rowElement.offsetWidth;
let colsWidth = Array.from(rowElement.children)
.reduce((acc, _colElem) => {
return acc + Array.from(_colElem.children).reduce((_acc, _elem) => _acc + _elem.offsetWidth, 0)
}, 0);
let menuMoreElement = menuElement.querySelector('.con-kit-component-menu-more');
let menuMoreElementsElement = menuElement.querySelector('.con-kit-component-menu-more__elements');
let menuMoreWidth = menuMoreElement.offsetWidth;
let menuElementShowedList = Array.from(menuElement.querySelectorAll('.con-kit-component-menu__elements .con-kit-component-button:not(.con-kit-component-menu--hide)'));
let menuShowedWidth = menuElementShowedList.reduce((acc, element) => acc + element.offsetWidth + ITEM_GAP, 0);
let menuFullWidth = colsWidth;
if (availableSpace >= menuFullWidth) {
let firstHiddenElement = menuElement.querySelector('.con-kit-component-menu__elements .con-kit-component-menu--hide');
if (firstHiddenElement && availableSpace >= (firstHiddenElement.offsetWidth + menuFullWidth + ITEM_GAP)) {
firstHiddenElement.classList.remove('con-kit-component-menu--hide');
}
} else {
let lastMenuElement = menuElementShowedList[ menuElementShowedList.length - 1 ];
if (lastMenuElement) {
lastMenuElement.classList.add('con-kit-component-menu--hide');
}
}
let menuMoreElementList = Array.from(menuElement.querySelectorAll('.con-kit-component-menu-more__elements .con-kit-component-button'));
menuMoreElementList.forEach((element) => {
// Hide all elements in the more section
element.classList.add('con-kit-component-menu--hide');
});
Array.from(menuElement.querySelectorAll('.con-kit-component-menu__elements .con-kit-component-menu--hide')).forEach((hiddenElement) => {
menuMoreElementList[ +hiddenElement.dataset.position ].classList.remove('con-kit-component-menu--hide');
});
// Hide the more button
if (menuMoreElementsElement.offsetHeight > 16) {
menuMoreElement.classList.remove('con-kit-component-menu--hide');
} else {
menuMoreElement.classList.add('con-kit-component-menu--hide');
}
}
// Init
calc();
let resizeObserver = new ResizeObs