/*! * toc - jQuery Table of Contents Plugin * v0.3.2 * http://projects.jga.me/toc/ * copyright Greg Allen 2014 * MIT License */ !function(t){t.fn.smoothScroller=function(e){e=t.extend({},t.fn.smoothScroller.defaults,e);var o=t(this);return t(e.scrollEl).animate({scrollTop:o.offset().top-t(e.scrollEl).offset().top-e.offset},e.speed,e.ease,function(){var t=o.attr("id");t.length&&(history.pushState?history.pushState(null,null,"#"+t):document.location.hash=t),o.trigger("smoothScrollerComplete")}),this},t.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},t("body").on("click","[data-smoothscroller]",function(e){e.preventDefault();var o=t(this).attr("href");0===o.indexOf("#")&&t(o).smoothScroller()})}(jQuery),function(t){var e={};t.fn.toc=function(e){var o,r=this,l=t.extend({},jQuery.fn.toc.defaults,e),n=t(l.container),i=t(l.selectors,n),s=[],a=l.activeClass,c=function(e,o){if(l.smoothScrolling&&"function"==typeof l.smoothScrolling){e.preventDefault();var n=t(e.target).attr("href");l.smoothScrolling(n,l,o)}t("li",r).removeClass(a),t(e.target).parent().addClass(a)},f=function(e){o&&clearTimeout(o),o=setTimeout(function(){for(var e,o=t(window).scrollTop(),n=Number.MAX_VALUE,i=0,c=0,f=s.length;f>c;c++){var h=Math.abs(s[c]-o);n>h&&(i=c,n=h)}t("li",r).removeClass(a),e=t("li:eq("+i+")",r).addClass(a),l.onHighlight(e)},50)};return l.highlightOnScroll&&(t(window).bind("scroll",f),f()),this.each(function(){var e=t(this),o=t(l.listType);i.each(function(r,n){var i=t(n);s.push(i.offset().top-l.highlightOffset);var a=l.anchorName(r,n,l.prefix);if(n.id!==a){t("").attr("id",a).insertBefore(i)}var h=t("").text(l.headerText(r,n,i)).attr("href","#"+a).bind("click",function(o){t(window).unbind("scroll"),c(o,function(){t(window).bind("scroll",f)}),e.trigger("selected",t(this).attr("href"))}),u=t("
  • ").addClass(l.itemClass(r,n,i,l.prefix)).append(h);o.append(u)}),e.html(o)})},jQuery.fn.toc.defaults={container:"body",listType:'