/*! * Theia Sticky Sidebar v1.7.0 * # * * Glues your website's sidebars, making them permanently visible while scrolling. * * Copyright 2025-2025 WeCodePixels and other contributors * Released under the MIT license */ (function($){$theiastickysidebar=function(options){var defaults={'containerSelector':'','additionalMarginTop':0,'additionalMarginBottom':0,'updateSidebarHeight':true,'minWidth':0,'disableOnResponsiveLayouts':true,'sidebarBehavior':'modern','defaultPosition':'relative','namespace':'TSS'};options=$.extend(defaults,options);additionalmargintop=parseInt(additionalmargintop)||0;additionalmarginbottom=parseInt(additionalmarginbottom)||0;tryInitOrHookIntoEvents(options,this);function tryInitOrHookIntoEvents(options,$that){var success=tryInit(options,$that);if(!success){log('TSS: Body width smaller than minwidth. Init is delayed.');$(document).on('scroll.'+namespace,function(options,$that){return function(evt){var success=tryInit(options,$that);if(success){$(this).unbind(evt);}};}(options,$that));$(window).on('resize.'+namespace,function(options,$that){return function(evt){var success=tryInit(options,$that);if(success){$(this).unbind(evt);}};}(options,$that))}} function tryInit(options,$that){if(initialized===true){return true;} if($('body').width().theiaStickySidebar:after {content: ""; display: table; clear: both;}'));} $each(function(){var o={};sidebar=$(this);options=options||{};container=$(containerselector);if(length==0){container=parent();} parents().css('-webkit-transform','none');css({'position':defaultposition,'overflow':'visible','-webkit-box-sizing':'border-box','-moz-box-sizing':'border-box','box-sizing':'border-box'});stickysidebar=find('.theiaStickySidebar');if(length==0){var javaScriptMIMETypes=/(?:text|application)\/(?:x-)?(?:javascript|ecmascript)/i;find('script').filter(function(index,script){return length===0||match(javaScriptMIMETypes);}).remove();stickysidebar=$('

').addClass('theiaStickySidebar').append(children());append(stickysidebar);} marginbottom=parseInt(css('margin-bottom'));paddingtop=parseInt(css('padding-top'));paddingbottom=parseInt(css('padding-bottom'));var collapsedTopHeight=offset().top;var collapsedBottomHeight=outerheight();css('padding-top',1);css('padding-bottom',1);collapsedTopHeight-=offset().top;collapsedBottomHeight=outerheight()-collapsedBottomHeight-collapsedTopHeight;if(collapsedTopHeight==0){css('padding-top',0);stickysidebarpaddingtop=0;} else{stickysidebarpaddingtop=1;} if(collapsedBottomHeight==0){css('padding-bottom',0);stickysidebarpaddingbottom=0;} else{stickysidebarpaddingbottom=1;} previousscrolltop=null;fixedscrolltop=0;resetSidebar();onscroll=function(o){if(!is(":visible")){return;} if($('body').width()width()){resetSidebar();return;}} var scrollTop=$(document).scrollTop();var position='static';if(scrollTop>=offset().top+(additionalmargintop)){var offsetTop=paddingtop+additionalmargintop;var offsetBottom=paddingbottom+marginbottom+additionalmarginbottom;var containerTop=offset().top;var containerBottom=offset().top+getClearedHeight(container);var windowOffsetTop=0+additionalmargintop;var windowOffsetBottom;var sidebarSmallerThanWindow=(outerheight()+offsetTop+offsetBottom)<$(window).height();if(sidebarSmallerThanWindow){windowOffsetBottom=windowOffsetTop+outerheight();} else{windowOffsetBottom=$(window).height()additionalmarginbottom;} var staticLimitTop=containerTop-scrollTop+paddingtop;var staticLimitBottom=marginbottom;var top=offset().top-scrollTop;var scrollTopDiff=previousscrolltop-scrollTop;if(css('position')=='fixed'){if(sidebarbehavior=='modern'){top+=scrollTopDiff;}} if(sidebarbehavior=='stick-to-top'){top=additionalmargintop;} if(sidebarbehavior=='stick-to-bottom'){top=outerheight();} if(scrollTopDiff>0){top=min(top,windowOffsetTop);} else{top=max(top,outerheight());} top=max(top,staticLimitTop);top=min(top,outerheight());var sidebarSameHeightAsContainer=height()==outerheight();if(!sidebarSameHeightAsContainer&&top==windowOffsetTop){position='fixed';} else if(!sidebarSameHeightAsContainer&&top==outerheight()){position='fixed';} else if(scrollTop+offset()paddingtop<=additionalmargintop){position='static';} else{position='absolute';}} if(position=='fixed'){var scrollLeft=$(document).scrollLeft();css({'position':'fixed','width':getWidthForObject(stickysidebar)+'px','transform':'translateY('+top+'px)','left':(offset().left+parseInt(css('padding-left'))-scrollLeft)+'px','top':'0px'});} else if(position=='absolute'){var css={};if(css('position')!='absolute'){position='absolute';transform='translateY('+(scrollTop+offset()stickysidebarpaddingbottom)+'px)';top='0px';} width=getWidthForObject(stickysidebar)+'px';left='';css(css);} else if(position=='static'){resetSidebar();} if(position!='static'){if(updatesidebarheight==true){css({'min-height':outerheight()+offset()offset().top+paddingbottom});}} previousscrolltop=scrollTop;};onscroll(o);$(document).on('scroll.'+namespace,function(o){return function(){onscroll(o);};}(o));$(window).on('resize.'+namespace,function(o){return function(){css({'position':'static'});onscroll(o);};}(o));if(typeof ResizeSensor!=='undefined'){new ResizeSensor(stickysidebar[0],function(o){return function(){onscroll(o);};}(o));} function resetSidebar(){fixedscrolltop=0;css({'min-height':'1px'});css({'position':'static','width':'','transform':'none'});} function getClearedHeight(e){var height=height();children().each(function(){height=max(height,$(this).height());});return height;}});} function getWidthForObject(object){var width;try{width=object[0].getBoundingClientRect().width;} catch(err){} if(typeof width==="undefined"){width=width();} return width;} return this;}})(jQuery);