Files
iblog2/public/dist/js/article.js
2018-11-19 20:30:53 +08:00

1 line
2.3 KiB
JavaScript

"use strict";$(function(){($(".my-nav-pills li:eq(0)").addClass("active").siblings().removeClass("active"),"false"===expandMenu&&($(".btn-menu").css("margin-left",$(".post-content").width()+31+"px"),$(".btn-menu").show()),contentType)||$("#main-context pre").each(function(n,t){$(t).html($("<code></code>").html($(t).html()))});hljs.initHighlightingOnLoad(),$("#main-context").find("img").wrap(function(n){return'<a href="'+this.src+'" data-lightbox="'+n+'"></a>'}),$("#main-context").scrollNav({sections:"h2",subSections:"h3",showHeadline:!0,headlineText:"文章目录",showTopLink:!1,scrollOffset:70,arrowKeys:!0,insertTarget:"#control-wrap",insertLocation:"prependTo"}),$(".close-menu").on("click",function(){$("#control-wrap").hide(),$(".post-content").removeClass("col-md-9").addClass("col-md-12"),$(".post-content").on("transitionend webkitTransitionEnd oTransitionEnd",function(){$("#control-wrap").hide(),$(".btn-menu").css("margin-left",$(".post-content").width()+31+"px"),$(".btn-menu").show()})}),$(".btn-menu").on("click",function(){$(".btn-menu").hide(),$(".post-content").removeClass("col-md-12").addClass("col-md-9"),$(".post-content").on("transitionend webkitTransitionEnd oTransitionEnd",function(){$(".btn-menu").hide(),$("#control-wrap").show()})});var t=[".post-title h1",".post-content blockquote",".post-content blockquote h2",".post-content h1",".post-content h2",".post-content h3",".post-content h4",".post-content h5",".post-content pre",".post-content p",".post-content ul",".post-content table",".post-content"];$(".btn-font-minus").on("click",function(){if(!$(this).hasClass("disabled")){var n=parseInt($("body").css("fontSize"))-2;$("body").css("fontSize",n+"px"),t.forEach(function(n){$(n).css("fontSize",parseInt($(n).css("fontSize"))-2+"px")}),n<=12&&$(this).addClass("disabled"),$(".btn-font-plus").hasClass("disabled")&&$(".btn-font-plus").removeClass("disabled")}}),$(".btn-font-plus").on("click",function(){if(!$(this).hasClass("disabled")){var n=parseInt($("body").css("fontSize"))+2;$("body").css("fontSize",n+"px"),t.forEach(function(n){$(n).css("fontSize",parseInt($(n).css("fontSize"))+2+"px")}),36<=n&&$(this).addClass("disabled"),$(".btn-font-minus").hasClass("disabled")&&$(".btn-font-minus").removeClass("disabled")}}),$(window).on("resize",function(){$.fn.scrollNav("resetPos")})});