!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),o=t(document),s=[],c=n.height(),a=function(){for(var e=n.scrollTop(),i=o.height(),r=i-c,a=e>r?r-e:0,p=0,l=s.length;l>p;p++){var u=s[p],d=u.stickyWrapper.offset().top,h=d-u.topSpacing-a;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-a;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&&me;e++){var r=s[e],o=null;r.getWidthFrom?r.responsiveWidth&&(o=t(r.getWidthFrom).width()):r.widthFromWrapper&&(o=r.stickyWrapper.width()),null!=o&&r.stickyElement.css("width",o)}},l={init:function(e){var i=t.extend({},r,e);return this.each(function(){var e=t(this),n=e.attr("id"),o=e.outerHeight(),c=n?n+"-"+r.wrapperClassName:r.wrapperClassName,a=t("
").attr("id",c).addClass(i.wrapperClassName);e.wrapAll(a);var p=e.parent();i.center&&p.css({width:e.outerWidth(),marginLeft:"auto",marginRight:"auto"}),"right"===e.css("float")&&e.css({"float":"none"}).parent().css({"float":"right"}),p.css("height",o),i.stickyElement=e,i.stickyWrapper=p,i.currentTop=null,s.push(i)})},update:a,unstick:function(){return this.each(function(){for(var e=this,r=t(e),n=-1,o=s.length;o-->0;)s[o].stickyElement.get(0)===e&&(i.call(s,o,1),n=o);-1!==n&&(r.unwrap(),r.css({width:"",position:"",top:"","float":""}))})}};window.addEventListener?(window.addEventListener("scroll",a,!1),window.addEventListener("resize",p,!1)):window.attachEvent&&(window.attachEvent("onscroll",a),window.attachEvent("onresize",p)),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(a,0)})});