16 lines
2.5 KiB
JavaScript
16 lines
2.5 KiB
JavaScript
/*
|
|
* Copyright (c) 2010-2017, 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 Finding={init:function(){Util.killIE(),this._initToc(),$(".scroll-down").click(function(t){t.preventDefault();var o=$(this),n=$("html, body"),a=!!o.attr("data-offset")&&o.attr("data-offset"),i=parseInt(a);n.stop(!0,!1).animate({scrollTop:$(this.hash).offset().top+i},500)}),$("body").click(function(t){0===$(t.target).closest(".nav").length&&$("body").hasClass("nav-opened")&&!$(t.target).hasClass("icon-gotop")&&$("body").removeClass("nav-opened").addClass("nav-closed")}),$(".menu-button").click(function(t){t.stopPropagation(),$("body").toggleClass("nav-opened nav-closed")}),$("body").append('<a class="icon-gotop fn-none" href="javascript:Util.goTop()"></a>'),$(window).scroll(function(){$(window).scrollTop()>$(window).height()?$(".icon-gotop").show():$(".icon-gotop").hide()})},_initToc:function(){return 0===$(".b3-solo-list").length?($(".nav .icon-sitemap, .nav .icon-list").show(),!1):($(".nav .icon-sitemap, .nav .icon-list").show(),$(".nav ul:first").hide(),$(".nav ul:first").after($(".b3-solo-list")),void $("body").toggleClass("nav-opened nav-closed"))},tabNav:function(t){$(".nav .current").removeClass("current"),"toc"===t?($(".nav ul:first").hide(),$(".nav ul:last").show(),$(".icon-list").addClass("current")):($(".nav ul:first").show(),$(".nav ul:last").hide(),$(".icon-sitemap").addClass("current"))},share:function(){$(".share span").click(function(){var t=$(this).data("type"),o=encodeURIComponent($("title").text()),n=$(".post-title a").attr("href")?$(".post-title a").attr("href"):location,a=$(".post-content img:eq(0)").attr("src"),i={};i.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+o+"&url="+n+"&pic="+a,i.weibo="http://v.t.sina.com.cn/share/share.php?title="+o+"&url="+n+"&pic="+a,i.google="https://plus.google.com/share?url="+n,i.twitter="https://twitter.com/intent/tweet?status="+o+" "+n,window.open(i[t],"_blank","top=100,left=200,width=648,height=618")})}};Finding.init(); |