<xf:js>
document.addEventListener('DOMContentLoaded', function ()
{
var unit = document.querySelector('.samCodeUnit[data-position="container_sidebar_below"]');
var stickyPoint = 0;
function isSidebar()
{
return window.matchMedia('(min-width: 900px)').matches;
}
function onScroll()
{
if (!unit || !isSidebar())
{
return;
}
var unitScrollOffset = unit.getBoundingClientRect().top + window.scrollY;
var scrollTop = window.scrollY || document.documentElement.scrollTop;
if (unitScrollOffset - scrollTop <= 0 && stickyPoint == 0)
{
var nav = document.querySelector('.p-nav');
var navHeight = nav ? nav.offsetHeight : 0;
unit.style.position = 'fixed';
unit.style.top = (navHeight + 10) + 'px';
unit.style.width = 'auto';
stickyPoint = scrollTop;
}
else if (stickyPoint >= scrollTop)
{
unit.style.position = '';
unit.style.top = '';
unit.style.width = '';
stickyPoint = 0;
}
}
if (unit && isSidebar())
{
window.addEventListener('scroll', onScroll);
}
window.addEventListener('resize', function ()
{
if (!isSidebar() && unit)
{
unit.style.position = '';
unit.style.top = '';
unit.style.width = '';
}
});
});
</xf:js>