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

1 line
1.4 KiB
JavaScript

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