This commit is contained in:
parent
99aedd8406
commit
5008cd8006
@ -19,7 +19,7 @@
|
||||
* @fileoverview util and every page should be used.
|
||||
*
|
||||
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
|
||||
* @version 1.1.0.0, Oct 13, 2016
|
||||
* @version 1.1.1.0, Sep 21, 2018
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -116,11 +116,11 @@ var Finding = {
|
||||
tabNav: function (type) {
|
||||
$('.nav .current').removeClass('current');
|
||||
if (type === 'toc') {
|
||||
$('.nav ul:first').hide();
|
||||
$('.nav ul:first, .nav .count').hide();
|
||||
$('.nav ul:last').show();
|
||||
$('.icon-list').addClass('current');
|
||||
} else {
|
||||
$('.nav ul:first').show();
|
||||
$('.nav ul:first, .nav .count').show();
|
||||
$('.nav ul:last').hide();
|
||||
$('.icon-sitemap').addClass('current');
|
||||
}
|
||||
|
2
Finding/js/Finding.min.js
vendored
2
Finding/js/Finding.min.js
vendored
@ -15,4 +15,4 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
var Finding={init:function(){Util.killIE(),this._initToc(),$(".scroll-down").click(function(t){t.preventDefault();var o=$(this),n=$("html, body"),i=!!o.attr("data-offset")&&o.attr("data-offset"),e=parseInt(i);n.stop(!0,!1).animate({scrollTop:$(this.hash).offset().top+e},500)}),$("body").append('<a class="icon-gotop fn-none" href="javascript:Util.goTop()"></a><span class="menu-button icon-menu"><span class="word">Menu</span></span>'),$(".menu-button").click(function(t){t.stopPropagation(),$("body").toggleClass("nav-opened nav-closed")}),$(window).scroll(function(){$(window).scrollTop()>$(".main-header").height()?$(".icon-gotop").show():$(".icon-gotop").hide()})},_initToc:function(){if(0===$(".b3-solo-list li").length)return $(".nav .icon-list").hide(),void $(".nav .icon-sitemap").click();$(".nav ul:first").after($(".b3-solo-list")),$("body").toggleClass("nav-opened nav-closed"),$(".nav .icon-list").show(),Finding.tabNav("toc");var t=$(".article-body [id^=b3_solo_h]"),o=$(".b3-solo-list");$(window).scroll(function(n){if(0===$(".b3-solo-list li").length)return!1;var i=[];t.each(function(t){i.push({id:this.id,offsetTop:this.offsetTop})});for(var e=$(window).scrollTop(),s=0,a=i.length;s<a;s++)if(e<i[s].offsetTop+280){o.find("li").removeClass("current");var l=s>0?s-1:0;o.find('a[href="#'+i[l].id+'"]').parent().addClass("current");break}e>=i[i.length-1].offsetTop+280&&(o.find("li").removeClass("current"),o.find("li:last").addClass("current"))}),$(window).scroll()},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,i=$(".post-content img:eq(0)").attr("src"),e={};e.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+o+"&url="+n+"&pic="+i,e.weibo="http://v.t.sina.com.cn/share/share.php?title="+o+"&url="+n+"&pic="+i,e.google="https://plus.google.com/share?url="+n,e.twitter="https://twitter.com/intent/tweet?status="+o+" "+n,window.open(e[t],"_blank","top=100,left=200,width=648,height=618")})}};Finding.init();
|
||||
var Finding={init:function(){Util.killIE(),this._initToc(),$(".scroll-down").click(function(t){t.preventDefault();var n=$(this),o=$("html, body"),i=!!n.attr("data-offset")&&n.attr("data-offset"),e=parseInt(i);o.stop(!0,!1).animate({scrollTop:$(this.hash).offset().top+e},500)}),$("body").append('<a class="icon-gotop fn-none" href="javascript:Util.goTop()"></a><span class="menu-button icon-menu"><span class="word">Menu</span></span>'),$(".menu-button").click(function(t){t.stopPropagation(),$("body").toggleClass("nav-opened nav-closed")}),$(window).scroll(function(){$(window).scrollTop()>$(".main-header").height()?$(".icon-gotop").show():$(".icon-gotop").hide()})},_initToc:function(){if(0===$(".b3-solo-list li").length)return $(".nav .icon-list").hide(),void $(".nav .icon-sitemap").click();$(".nav ul:first").after($(".b3-solo-list")),$("body").toggleClass("nav-opened nav-closed"),$(".nav .icon-list").show(),Finding.tabNav("toc");var t=$(".article-body [id^=b3_solo_h]"),n=$(".b3-solo-list");$(window).scroll(function(o){if(0===$(".b3-solo-list li").length)return!1;var i=[];t.each(function(t){i.push({id:this.id,offsetTop:this.offsetTop})});for(var e=$(window).scrollTop(),s=0,a=i.length;s<a;s++)if(e<i[s].offsetTop+280){n.find("li").removeClass("current");var l=s>0?s-1:0;n.find('a[href="#'+i[l].id+'"]').parent().addClass("current");break}e>=i[i.length-1].offsetTop+280&&(n.find("li").removeClass("current"),n.find("li:last").addClass("current"))}),$(window).scroll()},tabNav:function(t){$(".nav .current").removeClass("current"),"toc"===t?($(".nav ul:first, .nav .count").hide(),$(".nav ul:last").show(),$(".icon-list").addClass("current")):($(".nav ul:first, .nav .count").show(),$(".nav ul:last").hide(),$(".icon-sitemap").addClass("current"))},share:function(){$(".share span").click(function(){var t=$(this).data("type"),n=encodeURIComponent($("title").text()),o=$(".post-title a").attr("href")?$(".post-title a").attr("href"):location,i=$(".post-content img:eq(0)").attr("src"),e={};e.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+n+"&url="+o+"&pic="+i,e.weibo="http://v.t.sina.com.cn/share/share.php?title="+n+"&url="+o+"&pic="+i,e.google="https://plus.google.com/share?url="+o,e.twitter="https://twitter.com/intent/tweet?status="+n+" "+o,window.open(e[t],"_blank","top=100,left=200,width=648,height=618")})}};Finding.init();
|
Loading…
x
Reference in New Issue
Block a user