1!function(root,factory){if(typeof define=='function'&&define.amd){define(['jquery'],function($){return factory();});}else if(typeof module!='undefined'&&module.exports){module.exports=factory();}else{window[root]=factory();}}('Scrollspy',function(){'use strict';Scrollspy.VERSION='1.0.0';Scrollspy.DEFAULT={scrollElement:window,offset:10,selector:'.nav a',activeCls:'active',reachSelector:$.noop,leaveSelector:$.noop,reachTarget:$.noop,leaveTarget:$.noop,scrollDown:$.noop,scrollUp:$.noop} 2function Scrollspy(options){this.options=$.extend(Scrollspy.DEFAULT,options);this.$body=$(document.body);this.$scrollElement=$(this.options.scrollElement);this.scrollTopTmp=0;this.selector=this.options.selector;this.selectorTop=$(this.selector).offset().top;this.activeCls=this.options.activeCls;this.activeTarget=null;this.targets=[];this.offsets=[];this.scrollHeight=0;this.$scrollElement.on('scroll',$.proxy(this.process,this));this.refresh();this.process();} 3Scrollspy.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight);} 4Scrollspy.prototype.refresh=function(){var self=this;this.offsets=[];this.targets=[];this.scrollHeight=this.getScrollHeight();this.$body.find(this.selector).map(function(){var $el=$(this);var href=$el.attr('href');href=href.substring(href.indexOf("#"));var $href=/^#./.test(href)&&$(href);return($href&&$href.length&&$href.is(':visible')&&[[$href.offset().top,href]])||null;}).each(function(){self.offsets.push(this[0]);self.targets.push(this[1]);});} 5Scrollspy.prototype.process=function(){var offsets=this.offsets;var targets=this.targets;var scrollTopOrigin=this.$scrollElement.scrollTop();var scrollTop=scrollTopOrigin+this.options.offset;var scrollHeight=this.getScrollHeight();var maxScroll=this.options.offset+scrollHeight-this.$scrollElement.height();var maxTargetScroll=0;var activeTarget=this.activeTarget;var tmp;maxTargetScroll=(function(){var count=$(targets[0]).offset().top;targets.forEach(function(target){count+=$(target).height();});return count;})();if(scrollTopOrigin>this.scrollTopTmp){this.options.scrollDown();}else{this.options.scrollUp();} 6this.scrollTopTmp=scrollTopOrigin;if(this.scrollHeight!=scrollHeight){this.refresh();} 7if(scrollTop>=$(targets[0]).offset().top&&scrollTop<=maxTargetScroll){this.options.reachTarget.call(this);} 8if(scrollTop>=maxTargetScroll){this.options.leaveTarget.call(this);return;} 9if(scrollTop>=maxScroll){activeTarget!=(tmp=targets[targets.length-1])&&this.activate(tmp);return;} 10if(scrollTopOrigin>=this.selectorTop){this.options.reachSelector.call(this);} 11if(scrollTopOrigin<=this.selectorTop){this.options.leaveSelector.call(this);} 12if(activeTarget&&scrollTop<=offsets[0]){this.activeTarget=null;this.clear();} 13for(var i=offsets.length;i--;){activeTarget!=targets[i]&&scrollTop>=offsets[i]&&(offsets[i+1]===undefined||scrollTop<offsets[i+1])&&this.activate(targets[i]);}} 14Scrollspy.prototype.activate=function(target){this.activeTarget=target;this.clear();$(this.selector+'[href$="'+target+'"]').addClass(this.activeCls);} 15Scrollspy.prototype.clear=function(){$(this.selector+'.'+this.activeCls).removeClass(this.activeCls);} 16return Scrollspy;});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.