File: /home4/narrativ/wp.narrativa.mx/wp-content/themes/jnews/assets/js/theia-sticky-sidebar.js
/*!
* Theia Sticky Sidebar v1.3.0
* https://github.com/WeCodePixels/theia-sticky-sidebar
*
* Glues your website's sidebars, making them permanently visible while scrolling.
*
* Copyright 2013-2014 WeCodePixels and other contributors
* Released under the MIT license
*/
!function(i){"use strict";i.fn.theiaStickySidebar=function(t){(t=i.extend({containerSelector:"",additionalMarginTop:0,additionalMarginBottom:0,updateSidebarHeight:!0,minWidth:0,sidebarBehavior:"modern",wrap:"",exclude:".elementor-element-overlay, .ui-resizable-handle",active:!0},t)).additionalMarginTop=parseInt(t.additionalMarginTop)||0,t.additionalMarginBottom=parseInt(t.additionalMarginBottom)||0;var o=t.additionalMarginTop;function e(t,e){return!0===t.initialized||!(i("body").width()<t.minWidth)&&(function(t,e){t.initialized=!0,i("head").append(i('<style>.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>')),e.each((function(){var e={};e.sidebar=i(this),e.options=t||{},e.container=i(e.options.containerSelector),0==e.container.size()&&(e.container=e.sidebar.parent()),e.sidebar.parents().css("-webkit-transform","none"),e.sidebar.css({position:"relative",overflow:"visible","-webkit-box-sizing":"border-box","-moz-box-sizing":"border-box","box-sizing":"border-box"}),e.stickySidebar=e.sidebar.find(".theiaStickySidebar"),0==e.stickySidebar.length&&(e.sidebar.find("script").remove(),e.stickySidebar=i("<div>").addClass("theiaStickySidebar"),i(e.sidebar.children(t.wrap)).each((function(o,a){i(a).is(t.exclude)||e.stickySidebar.append(a)})),e.sidebar.append(i("<div>").addClass("jegStickyHolder").append(e.stickySidebar))),e.marginTop=parseInt(e.sidebar.css("margin-top")),e.marginBottom=parseInt(e.sidebar.css("margin-bottom")),e.paddingTop=parseInt(e.sidebar.css("padding-top")),e.paddingBottom=parseInt(e.sidebar.css("padding-bottom"));var a=e.stickySidebar.offset().top,n=e.stickySidebar.outerHeight();function d(){e.fixedScrollTop=0,e.sidebar.css({"min-height":"1px"}),e.stickySidebar.css({position:"static",width:""})}e.stickySidebar.css("padding-top",1),e.stickySidebar.css("padding-bottom",1),a-=e.stickySidebar.offset().top,n=e.stickySidebar.outerHeight()-n-a,0==a?(e.stickySidebar.css("padding-top",0),e.stickySidebarPaddingTop=0):e.stickySidebarPaddingTop=1,0==n?(e.stickySidebar.css("padding-bottom",0),e.stickySidebarPaddingBottom=0):e.stickySidebarPaddingBottom=1,e.previousScrollTop=null,e.fixedScrollTop=0,d(),e.onScroll=function(o){if(t.active){if(!o.stickySidebar.is(":visible"))return;if(i("body").width()<o.options.minWidth)return void d();if(o.sidebar.outerWidth(!0)+50>o.container.width())return void d();var e=i(document).scrollTop(),a="static";if(e>=o.container.offset().top+(o.paddingTop+o.marginTop-o.options.additionalMarginTop)){var n,r=o.paddingTop+o.marginTop+t.additionalMarginTop,s=o.paddingBottom+o.marginBottom+t.additionalMarginBottom,c=o.container.offset().top,p=o.container.offset().top+(u=o.container,m=u.height(),u.children().each((function(){m=Math.max(m,i(this).height())})),m),b=0+t.additionalMarginTop;n=o.stickySidebar.outerHeight()+r+s<i(window).height()?b+o.stickySidebar.outerHeight():i(window).height()-o.marginBottom-o.paddingBottom-t.additionalMarginBottom;var l=c-e+o.paddingTop+o.marginTop,g=p-e-o.paddingBottom-o.marginBottom,h=o.stickySidebar.offset().top-e,f=o.previousScrollTop-e;"fixed"==o.stickySidebar.css("position")&&"modern"==o.options.sidebarBehavior&&(h+=f),"legacy"==o.options.sidebarBehavior&&(h=n-o.stickySidebar.outerHeight(),h=Math.max(h,n-o.stickySidebar.outerHeight())),h=f>0?Math.min(h,b):Math.max(h,n-o.stickySidebar.outerHeight()),h=Math.max(h,l),h=Math.min(h,g-o.stickySidebar.outerHeight());var S=o.container.height()==o.stickySidebar.outerHeight();a=(S||h!=b)&&(S||h!=n-o.stickySidebar.outerHeight())?e+h-o.sidebar.offset().top-o.paddingTop<=t.additionalMarginTop?"static":"absolute":"fixed"}}else a="static";var u,m;if("fixed"==a)o.stickySidebar.css({position:"fixed",width:o.sidebar.width(),top:h,left:o.sidebar.offset().left+parseInt(o.sidebar.css("padding-left"))});else if("absolute"==a){var y={};"absolute"!=o.stickySidebar.css("position")&&(y.position="absolute",y.top=e+h-o.sidebar.offset().top-o.stickySidebarPaddingTop-o.stickySidebarPaddingBottom),y.width=o.sidebar.width(),y.left="",o.stickySidebar.css(y)}else"static"==a&&d();"static"!=a&&1==o.options.updateSidebarHeight&&o.sidebar.css({"min-height":o.stickySidebar.outerHeight()+o.stickySidebar.offset().top-o.sidebar.offset().top+o.paddingBottom}),o.previousScrollTop=e},e.onScroll(e),i(document).scroll(function(i){return function(){i.onScroll(i)}}(e)),i(window).resize(function(i){return function(){i.stickySidebar.css({position:"static"}),i.onScroll(i)}}(e)),i(window).bind("jnews_additional_sticky_margin",(function(i,a){t.additionalMarginTop=a+o,e.options.additionalMarginTop=a+o}))}))}(t,e),!0)}!function(t,o){e(t,o)||(console.log("TST: Body width smaller than options.minWidth. Init is delayed."),i(document).scroll(function(t,o){return function(a){e(t,o)&&i(this).unbind(a)}}(t,o)),i(window).resize(function(t,o){return function(a){e(t,o)&&i(this).unbind(a)}}(t,o)))}(t,this),i(this).bind("theiaStickySidebarDeactivate",(function(){t.active=!1})),i(this).bind("theiaStickySidebarActivate",(function(){t.active=!0}))}}(jQuery);