solo-skins/skins/Medium/js/common.min.js
2018-01-30 18:07:19 +08:00

16 lines
2.8 KiB
JavaScript

/*
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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()},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()&&o<a-$(window).height()&&$(".article__toolbar").css({bottom:0,opacity:1})):i-o<0&&($(".header").css({top:"-64px"}).removeClass("header--fixed"),$(".main").css("padding-top","0"),$(".article__toolbar").css({bottom:"-44px",opacity:0}))):($(window).height()<=$(".post").height()&&t.css("opacity",0),$(".header").removeClass("header--fixed").css("top","-64px"),$(".main").css("padding-top","0")),o>a-$(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"),s=encodeURIComponent(i.data("title")+" - "+i.data("blogtitle")),n=encodeURIComponent(o),c={};c.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+s+"&url="+n+"&pic="+a,c.weibo="http://v.t.sina.com.cn/share/share.php?title="+s+"&url="+n+"&pic="+a,c.google="https://plus.google.com/share?url="+n,c.twitter="https://twitter.com/intent/tweet?status="+s+" "+n,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(c[t],"_blank","top=100,left=200,width=648,height=618")})}};Skin.init();