solo-skins/Bubble/js/common.min.js

1 line
1.4 KiB
JavaScript

var Skin={init:function(){Util.initPjax()},initArticle:function(){page.share();var l=$(".vditor-reset [id^=b3_solo_h]"),s=$(".article__toc"),c=$(".article__progress");1===s.length&&(876<$(window).width()?$(".post__toc").css("left",$(".article .item__content").offset().left+$(".article .item__content").outerWidth()-80):$(".post__toc a").click(function(){$(".post__toc").hide()})),s.find("a").click(function(t){var o=$(this).attr("href");return window.location.hash=o,$(window).scrollTop($(o).offset().top-60),t.preventDefault(),t.stopPropagation(),!1}),$(window).unbind("scroll").scroll(function(t){if(0===c.length)return!1;if(c.attr("value",parseInt($(window).scrollTop())).attr("max",parseInt($("body").outerHeight()-$(window).height())),236<$(window).scrollTop()?$(".article__top").css("top",0):$(".article__top").css("top",-61),0===$(".article__toc li").length)return!1;876<$(window).width()&&(975<$(window).scrollTop()&&$(window).scrollTop()<$(".article").outerHeight()+100?$(".post__toc").show():$(".post__toc").hide());var o=[];l.each(function(t){o.push({id:this.id,offsetTop:$(this).offset().top})});for(var i=$(window).scrollTop(),e=0,r=o.length;e<r;e++)if(i<o[e].offsetTop-61){s.find("li").removeClass("current");var n=0<e?e-1:0;s.find('a[href="#'+o[n].id+'"]').parent().addClass("current");break}i>=o[o.length-1].offsetTop-61&&(s.find("li").removeClass("current"),s.find("li:last").addClass("current"))}),$(window).scroll()}};Skin.init();