';
}
function init() { document.querySelectorAll('[data-af-cs]:not([data-ready])').forEach(render); }
init();
if (window.afCsBound) return;
window.afCsBound = true;
function setOpen(root, open) {
if (open) {
root.classList.remove('af-cs--left');
if (root.querySelector('.af-cs__menu').getBoundingClientRect().left < 16) root.classList.add('af-cs--left');
}
root.classList.toggle('is-open', open);
root.querySelector('.af-cs__btn').setAttribute('aria-expanded', open);
}
function closeOthers(target) {
document.querySelectorAll('.af-cs.is-open').forEach(function (root) {
if (!root.contains(target)) setOpen(root, false);
});
}
document.addEventListener('click', function (e) {
closeOthers(e.target);
var btn = e.target.closest && e.target.closest('.af-cs__btn');
if (btn) {
var root = btn.closest('.af-cs');
setOpen(root, !root.classList.contains('is-open'));
}
});
document.addEventListener('focusin', function (e) { closeOthers(e.target); });
document.addEventListener('keydown', function (e) {
if (e.key !== 'Escape') return;
document.querySelectorAll('.af-cs.is-open').forEach(function (root) {
var hadFocus = root.contains(document.activeElement);
setOpen(root, false);
if (hadFocus) root.querySelector('.af-cs__btn').focus();
});
});
if (window.jQuery) window.jQuery(document).on('elementor/popup/show', init);
})();
News
Insights, updates, and on-farm stories from Advantage Feeders as we work with livestock producers around the world to deliver smarter, more controlled feeding systems.