Project

General

Profile

1
(function(a){if(typeof module!=="undefined"&&typeof exports=="object"){if(typeof window!="undefined"){module.exports=a()}else{module.exports=a}}else{window.Affix=a()}})(function(){var a=function(g,h){h=h||{};this.element=typeof g==="object"?g:document.querySelector(g);this.options={};this.options.target=h.target?((typeof(h.target)==="object")?h.target:document.querySelector(h.target)):null;this.options.offsetTop=h.offsetTop&&h.offsetTop?(h.offsetTop==="function"?h.offsetTop():parseInt(h.offsetTop,0)):0;this.options.offsetBottom=h.offsetBottom&&h.offsetBottom?(h.offsetBottom==="function"?h.offsetBottom():parseInt(h.offsetBottom,0)):null;if(this.element&&(this.options.target||this.options.offsetTop||this.options.offsetBottom)){this.init()}};a.prototype={init:function(){this.affixed=false;this.affixedBottom=false;this.getPinOffsetTop=0;this.getPinOffsetBottom=null;this.checkPosition();this.updateAffix();this.scrollEvent();this.resizeEvent()},processOffsetTop:function(){if(this.options.target!==null){return this.targetRect().top+this.scrollOffset()}else{if(this.options.offsetTop!==null){return this.options.offsetTop}}},processOffsetBottom:function(){if(this.options.offsetBottom!==null){var g=this.getMaxScroll();return g-this.elementHeight()-this.options.offsetBottom}},offsetTop:function(){return this.processOffsetTop()},offsetBottom:function(){return this.processOffsetBottom()},checkPosition:function(){this.getPinOffsetTop=this.offsetTop;this.getPinOffsetBottom=this.offsetBottom},scrollOffset:function(){return window.pageYOffset||document.documentElement.scrollTop},pinTop:function(){if(!/affix/.test(this.element.className)){this.element.className+=" affix";this.affixed=true}},unPinTop:function(){if(/affix/.test(this.element.className)){this.element.className=this.element.className.replace(" affix","");this.affixed=false}},pinBottom:function(){if(!/'affix-bottom'/.test(this.element.className)){this.element.className+=" affix-bottom";this.affixedBottom=true}},unPinBottom:function(){if(/'affix-bottom'/.test(this.element.className)){this.element.className=this.element.className.replace(" affix-bottom","");this.affixedBottom=false}},updatePin:function(){if(this.affixed===false&&(parseInt(this.offsetTop(),0)-parseInt(this.scrollOffset(),0)<0)){this.pinTop()}else{if(this.affixed===true&&(parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetTop(),0))){this.unPinTop()}}if(this.affixedBottom===false&&(parseInt(this.offsetBottom(),0)-parseInt(this.scrollOffset(),0)<0)){this.pinBottom()}else{if(this.affixedBottom===true&&(parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetBottom(),0))){this.unPinBottom()}}},updateAffix:function(){this.unPinTop();this.unPinBottom();this.checkPosition();this.updatePin()},elementHeight:function(){return this.element.offsetHeight},targetRect:function(){return this.options.target.getBoundingClientRect()},getMaxScroll:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)},scrollEvent:function(){var g=this;window.addEventListener("scroll",function(){g.updatePin()},false)},resizeEvent:function(){var i=this,h=(new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)!=null)?parseFloat(RegExp.$1):false,g=(h&&h<10)?500:50;window.addEventListener("resize",function(){setTimeout(function(){i.updateAffix()},g)},false)}};var b=document.querySelectorAll('[data-spy="affix"]'),d=0,c=b.length;for(d;d<c;d++){var e=b[d],f={};f.offsetTop=e.getAttribute("data-offset-top");f.offsetBottom=e.getAttribute("data-offset-bottom");f.target=e.getAttribute("data-target");if(e&&(f.offsetTop!==null||f.offsetBottom!==null||f.target!==null)){new a(e,f)}}return a});
(1-1/11)