bih/spotify-ruby

View on GitHub
docs/theme/assets/js/scripts.min.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(e){"use strict";e.fn.reduce=function(e,t){var n=this,r=t;return n.each(function(t,l){r=e.call(l,r,l,t,n)}),r},e(":header[id]").each(function(){var t=e(this);t.html('<a href="#'+t.attr("id")+'" class="title-anchor-link">#</a> '+t.html())});var t=function(e){var t=e.prop("tagName").toLowerCase();return t&&-1!==["h1","h2","h3","h4","h5","h6"].indexOf(t)?parseInt(t.replace("h",""),10):!1},n=e(":header[id]").reduce(function(n,r){var l={childrens:[]};return l.$el=e(r),l.level=t(l.$el),l.$el.length&&l.level!==!1?(n.push(l),n):n},[]),r=function(e,t){if(!t.$el.length||t.level===!1)return e;if(e.length<1)return[t];var n=e[e.length-1].level;return t.level>n?e[e.length-1].childrens.push(t):e.push(t),e},l=function(e){e=e.reduce(r,[]);var t;for(t=0;t<e.length;t+=1)e[t].childrens&&e[t].childrens.length&&(e[t].childrens=l(e[t].childrens));return e},a=function(t,n){var r=e("<ul></ul>");r.addClass("level-"+t[0].level),!0===n&&r.addClass("nav");var l,i;for(l=0;l<t.length;l+=1)i=e("<li></li>"),i.append('<a href="#'+t[l].$el.attr("id")+'">'+t[l].$el.text().replace(/^#\ /,"")+"</a>"),t[l].childrens&&t[l].childrens.length&&(i.append(a(t[l].childrens)),i.addClass("has-submenu")),r.append(i);return r};n.length&&(n=l(n),a(n,!0).appendTo(".js-sections"));var i=e(".js-smooth-scroll");i.click(function(){return e("html, body").animate({scrollTop:e(e(this).attr("href")).offset().top},1200),!1});var o=function(){e(".sections-list").css("width",e(".sections-list-wrapper").width())};o(),e(window).on("resize",o),e(window).on("load",function(){e(".js-affix").affix({offset:{top:function(){return this.top=e(".hero-subheader").outerHeight(!0)+100},bottom:function(){return this.bottom=e(".js-footer-area").outerHeight(!0)+80}}})}),e(".offcanvas-toggle").on("click",function(){e("body").toggleClass("offcanvas-expanded")})}(jQuery);