!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=Array.prototype.slice,i=Array.prototype.splice,r={topSpacing:0,bottomSpacing:0,className:"is-sticky",wrapperClassName:"sticky-wrapper",center:!1,getWidthFrom:"",widthFromWrapper:!0,responsiveWidth:!1},n=t(window),s=t(document),o=[],c=n.height(),p=function(){for(var e=n.scrollTop(),i=s.height(),r=i-c,p=e>r?r-e:0,a=0,l=o.length;l>a;a++){var u=o[a],d=u.stickyWrapper.offset().top,h=d-u.topSpacing-p;if(u.stickyWrapper.css("height",u.stickyElement.outerHeight()),h>=e)null!==u.currentTop&&(u.stickyElement.css({width:"",position:"",top:""}),u.stickyElement.parent().removeClass(u.className),u.stickyElement.trigger("sticky-end",[u]),u.currentTop=null);else{var m=i-u.stickyElement.outerHeight()-u.topSpacing-u.bottomSpacing-e-p;if(0>m?m+=u.topSpacing:m=u.topSpacing,u.currentTop!==m){var y;u.getWidthFrom?y=t(u.getWidthFrom).width()||null:u.widthFromWrapper&&(y=u.stickyWrapper.width()),null==y&&(y=u.stickyElement.width()),u.stickyElement.css("width",y).css("position","fixed").css("top",m),u.stickyElement.parent().addClass(u.className),null===u.currentTop?u.stickyElement.trigger("sticky-start",[u]):u.stickyElement.trigger("sticky-update",[u]),u.currentTop===u.topSpacing&&u.currentTop>m||null===u.currentTop&&m=g.offset().top+g.outerHeight()&&u.stickyElement.offset().top<=u.topSpacing;f?u.stickyElement.css("position","absolute").css("top","").css("bottom",0):u.stickyElement.css("position","fixed").css("top",m).css("bottom","")}}},a=function(){c=n.height();for(var e=0,i=o.length;i>e;e++){var r=o[e],s=null;r.getWidthFrom?r.responsiveWidth&&(s=t(r.getWidthFrom).width()):r.widthFromWrapper&&(s=r.stickyWrapper.width()),null!=s&&r.stickyElement.css("width",s)}},l={init:function(e){var i=t.extend({},r,e);return this.each(function(){var e=t(this),n=e.attr("id"),s=e.outerHeight(),c=n?n+"-"+r.wrapperClassName:r.wrapperClassName,p=t("
").attr("id",c).addClass(i.wrapperClassName);e.wrapAll(p);var a=e.parent();i.center&&a.css({width:e.outerWidth(),marginLeft:"auto",marginRight:"auto"}),"right"===e.css("float")&&e.css({"float":"none"}).parent().css({"float":"right"}),a.css("height",s),i.stickyElement=e,i.stickyWrapper=a,i.currentTop=null,o.push(i)})},update:p,unstick:function(e){return this.each(function(){for(var e=this,r=t(e),n=-1,s=o.length;s-- >0;)o[s].stickyElement.get(0)===e&&(i.call(o,s,1),n=s);-1!==n&&(r.unwrap(),r.css({width:"",position:"",top:"","float":""}))})}};window.addEventListener?(window.addEventListener("scroll",p,!1),window.addEventListener("resize",a,!1)):window.attachEvent&&(window.attachEvent("onscroll",p),window.attachEvent("onresize",a)),t.fn.sticky=function(i){return l[i]?l[i].apply(this,e.call(arguments,1)):"object"!=typeof i&&i?void t.error("Method "+i+" does not exist on jQuery.sticky"):l.init.apply(this,arguments)},t.fn.unstick=function(i){return l[i]?l[i].apply(this,e.call(arguments,1)):"object"!=typeof i&&i?void t.error("Method "+i+" does not exist on jQuery.sticky"):l.unstick.apply(this,arguments)},t(function(){setTimeout(p,0)})});