/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
var Skin={init:function(){$("body").on("click",".content-reset img",function(){window.open(this.src)}),$(window).scroll(function(){0!==$("#headerNav").length&&($(window).scrollTop()>64?($("#headerNav").addClass("header__nav--fixed"),$(".main").css("margin-top","100px")):($("#headerNav").removeClass("header__nav--fixed"),$(".main").css("margin-top","50px")))}),$(window).scroll(),Util.initPjax(function(){Util.parseMarkdown("content-reset"),location.href===latkeConfig.servePath+"/tags.html"&&Skin.initTags()},function(){Util.parseMarkdown("content-reset"),Skin.initArticle(),Skin.initComment($(".post__tags").data("oid"),$(".post__tags").data("tag"))})},initTags:function(){for(var t=$("#tags"),e=t.find(".tag"),i=parseInt(e.first().data("count")),o=Math.ceil(i/5),a=0;as*o&&n<=(s+1)*o){e[a].className="tag tag__level"+s;break}t.html(e.get().sort(function(t,e){var i=$(t).text().toLowerCase(),o=$(e).text().toLowerCase();return i.localeCompare(o)}))},initArticle:function(){Skin._share("#articleShare"),Skin._share("#articleSideShare"),Skin._share("#articleBottomShare");var t=$(".post__side");$(window).height()>=$(".post").height()&&t.css("opacity",1),t.css("left",($(".post").offset().left-20)/2-27+"px");var e=($(window).height()-249)/2+125,i=$(window).scrollTop();$(window).scroll(function(){var o=$(window).scrollTop(),a=$(".article__bottom").offset().top;o>65?(t.css("opacity",1),i-o>0?($(".header").addClass("header--fixed").css({top:"0"}),$(".main").css("padding-top","64px"),$(window).height()<=$(".post").height()&&oa-$(window).height()?a<$(window).height()?t.css({position:"absolute",top:a-125+"px"}):t.css({position:"absolute",top:a-e+"px"}):t.css({position:"fixed",top:"50%"}),i=o}),$(window).scroll()},_share:function(t){var e=$(t),i=e.find(".article__code"),o=i.data("url"),a=i.data("avatar"),n=encodeURIComponent(i.data("title")+" - "+i.data("blogtitle")),s=encodeURIComponent(o),r={};r.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+n+"&url="+s+"&pic="+a,r.weibo="http://v.t.sina.com.cn/share/share.php?title="+n+"&url="+s+"&pic="+a,r.google="https://plus.google.com/share?url="+s,r.twitter="https://twitter.com/intent/tweet?status="+n+" "+s,e.find("span").click(function(){var t=$(this).data("type");if(t)return"wechat"===t?(0===i.find("canvas").length?i.qrcode({width:128,height:128,text:o}):i.slideToggle(),!1):void window.open(r[t],"_blank","top=100,left=200,width=648,height=618")})}};Skin.init();