2 lines
1.8 KiB
JavaScript
2 lines
1.8 KiB
JavaScript
/* Copyright (c) 2010-2016, b3log.org & hacpai.com Licensed under the Apache License, Version 2.0 (the "License");
|
|
*/var Yilia={init:function(){Util.killIE(),this._initToc(),this.resetTags(),$(window).scroll(function(){$("article").length>0&&0===$("article.post").length&&$("article:not(.show)").each(function(){$(this).offset().top<=$(window).scrollTop()+$(window).height()-$(this).height()/13&&$(this).addClass("show")}),$(window).scrollTop()>$(window).height()?$(".icon-goup").show():$(".icon-goup").hide(), (($(document).height() - $("body").height() - 300) < $(window).scrollTop()) ? $("#backBtm").hide() : $("#backBtm").show(), 1===$("article.post").length&&$("article.post").addClass("show")}),$(window).scroll()},_initToc:function(){return 0!==$(".b3-solo-list li").length&&($(".side footer").after('<div class="toc"><a href="javascript:hideToc();" class="close iconfont icon-close2"></a></div>'),$(".side .toc a").after($(".b3-solo-list")),void $(".side .toc-btn").show())},resetTags:function(){$("a.tag").each(function(t){$(this).addClass("color"+Math.ceil(3*Math.random()))})},share:function(){$(".share span").click(function(){var t=$(this).data("type"),i=encodeURIComponent($("title").text()+" "+$("meta[name=description]").attr("content")),o=$(".post-title a").attr("href")?$(".post-title a").attr("href"):location,img=($("article.post img:eq(1)").length==0?$("article.post img:eq(0)"):$("article.post img:eq(1)")),e=$(img).attr("src"),s={};s.qq = "http://connect.qq.com/widget/shareqq/index.html?title="+i+"&url="+o;s.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+i+"&url="+o+"&pic="+e,s.weibo="http://v.t.sina.com.cn/share/share.php?title="+i+"&url="+o+"&pic="+e,s.google="https://plus.google.com/share?url="+o,s.twitter="https://twitter.com/intent/tweet?status="+i+" "+o,window.open(s[t],"_blank","top=100,left=200,width=720,height=618")})}};Yilia.init(); |