This commit is contained in:
@@ -76,7 +76,7 @@ var NexT = {
|
||||
'top': '0'
|
||||
}, function () {
|
||||
// 当有文章页面有目录时,回调不放这里,侧边栏就会一片空白
|
||||
if ($('.b3-solo-list li').length > 0 && $(window).width() > 1000) {
|
||||
if ($('.article__toc li').length > 0 && $(window).width() > 1000) {
|
||||
$('.sidebar-toggle').click();
|
||||
}
|
||||
});
|
||||
@@ -92,54 +92,18 @@ var NexT = {
|
||||
});
|
||||
},
|
||||
initArticle: function () {
|
||||
if ($('.b3-solo-list li').length > 0 && $(window).width() > 1000) {
|
||||
if ($('.article__toc li').length > 0 && $(window).width() > 1000) {
|
||||
// add color to sidebar menu
|
||||
$('.sidebar-toggle').addClass('has-toc');
|
||||
|
||||
// append toc to sidebar menu
|
||||
var articleTocHTML = '<ul><li class="current" data-tab="toc">' + Label.tocLabel + '</li><li data-tab="site">' + Label.siteViewLabel + '</li></ul><section></section>';
|
||||
$('.sidebar').prepend(articleTocHTML);
|
||||
var $sectionF = $('.sidebar section:first').html($('.b3-solo-list')),
|
||||
$sectionL = $('.sidebar section:last');
|
||||
$sectionF.height($(window).height() - 90);
|
||||
// 切换 tab
|
||||
$('.sidebar > ul > li').click(function () {
|
||||
if ($(this).data('tab') === 'toc') {
|
||||
$sectionL.animate({
|
||||
"opacity": '0',
|
||||
"top": '-50px'
|
||||
}, 300, function () {
|
||||
$sectionF.show().css('top', '-50px');
|
||||
$sectionF.animate({
|
||||
"opacity": '1',
|
||||
"top": '0'
|
||||
}, 300);
|
||||
});
|
||||
} else {
|
||||
$sectionF.animate({
|
||||
"opacity": '0',
|
||||
"top": '-50px'
|
||||
}, 300, function () {
|
||||
$sectionF.hide().css('top', '-50px');
|
||||
$sectionL.animate({
|
||||
"opacity": '1',
|
||||
"top": '0'
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
$('.sidebar > ul > li').removeClass('current');
|
||||
$(this).addClass('current');
|
||||
});
|
||||
|
||||
this.initToc();
|
||||
}
|
||||
},
|
||||
initToc: function () {
|
||||
var $articleTocs = $('.vditor-reset [id^=b3_solo_h]'),
|
||||
$articleToc = $('.b3-solo-list');
|
||||
$articleToc = $('.article__toc');
|
||||
|
||||
$(window).scroll(function (event) {
|
||||
if ($('.b3-solo-list li').length === 0) {
|
||||
if ($('.article__toc li').length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
2
next/js/next.min.js
vendored
2
next/js/next.min.js
vendored
@@ -1 +1 @@
|
||||
var NexT={init:function(){$(".sidebar-toggle").click(function(){var i=$(".sidebar");$(this).hasClass("sidebar-active")?($(this).removeClass("sidebar-active"),$("body").animate({"padding-right":0}),i.animate({right:-320}),i.find("section").css("opacity",0)):($(this).addClass("sidebar-active"),$("body").animate({"padding-right":320}),i.animate({right:0},function(){i.find("section:first").animate({opacity:1})}))}),$(".site-nav-toggle").click(function(){$(".site-nav").slideToggle()}),$(document).ready(function(){setTimeout(function(){$(".logo-wrap").css("opacity",1),$(".logo-line-before i").animate({left:"0"},function(){$(".site-title").css("opacity",1).animate({top:0},function(){$(".menu").css("opacity",1).animate({"margin-top":"15px"}),$(".main").css("opacity",1).animate({top:"0"},function(){0<$(".b3-solo-list li").length&&1e3<$(window).width()&&$(".sidebar-toggle").click()})})}),$(".logo-line-after i").animate({right:"0"})},500)})},initArticle:function(){if(0<$(".b3-solo-list li").length&&1e3<$(window).width()){$(".sidebar-toggle").addClass("has-toc");var i='<ul><li class="current" data-tab="toc">'+Label.tocLabel+'</li><li data-tab="site">'+Label.siteViewLabel+"</li></ul><section></section>";$(".sidebar").prepend(i);var t=$(".sidebar section:first").html($(".b3-solo-list")),a=$(".sidebar section:last");t.height($(window).height()-90),$(".sidebar > ul > li").click(function(){"toc"===$(this).data("tab")?a.animate({opacity:"0",top:"-50px"},300,function(){t.show().css("top","-50px"),t.animate({opacity:"1",top:"0"},300)}):t.animate({opacity:"0",top:"-50px"},300,function(){t.hide().css("top","-50px"),a.animate({opacity:"1",top:"0"},300)}),$(".sidebar > ul > li").removeClass("current"),$(this).addClass("current")}),this.initToc()}},initToc:function(){var n=$(".vditor-reset [id^=b3_solo_h]"),l=$(".b3-solo-list");$(window).scroll(function(i){if(0===$(".b3-solo-list li").length)return!1;var t=[];n.each(function(i){t.push({id:this.id,offsetTop:this.offsetTop})});for(var a=$(window).scrollTop(),e=0,o=t.length;e<o;e++)if(a<t[e].offsetTop+200){l.find("li").removeClass("current");var s=0<e?e-1:0;l.find('a[href="#'+t[s].id+'"]').parent().addClass("current");break}a>=t[t.length-1].offsetTop+200&&(l.find("li").removeClass("current"),l.find("li:last").addClass("current"))}),$(window).scroll()}};NexT.init();
|
||||
var NexT={init:function(){$(".sidebar-toggle").click(function(){var i=$(".sidebar");$(this).hasClass("sidebar-active")?($(this).removeClass("sidebar-active"),$("body").animate({"padding-right":0}),i.animate({right:-320}),i.find("section").css("opacity",0)):($(this).addClass("sidebar-active"),$("body").animate({"padding-right":320}),i.animate({right:0},function(){i.find("section:first").animate({opacity:1})}))}),$(".site-nav-toggle").click(function(){$(".site-nav").slideToggle()}),$(document).ready(function(){setTimeout(function(){$(".logo-wrap").css("opacity",1),$(".logo-line-before i").animate({left:"0"},function(){$(".site-title").css("opacity",1).animate({top:0},function(){$(".menu").css("opacity",1).animate({"margin-top":"15px"}),$(".main").css("opacity",1).animate({top:"0"},function(){0<$(".article__toc li").length&&1e3<$(window).width()&&$(".sidebar-toggle").click()})})}),$(".logo-line-after i").animate({right:"0"})},500)})},initArticle:function(){if(0<$(".article__toc li").length&&1e3<$(window).width()){$(".sidebar-toggle").addClass("has-toc");var i='<ul><li class="current" data-tab="toc">'+Label.tocLabel+'</li><li data-tab="site">'+Label.siteViewLabel+"</li></ul><section></section>";$(".sidebar").prepend(i);var t=$(".sidebar section:first").html($(".article__toc")),a=$(".sidebar section:last");t.height($(window).height()-90),$(".sidebar > ul > li").click(function(){"toc"===$(this).data("tab")?a.animate({opacity:"0",top:"-50px"},300,function(){t.show().css("top","-50px"),t.animate({opacity:"1",top:"0"},300)}):t.animate({opacity:"0",top:"-50px"},300,function(){t.hide().css("top","-50px"),a.animate({opacity:"1",top:"0"},300)}),$(".sidebar > ul > li").removeClass("current"),$(this).addClass("current")}),this.initToc()}},initToc:function(){var n=$(".vditor-reset [id^=b3_solo_h]"),l=$(".article__toc");$(window).scroll(function(i){if(0===$(".article__toc li").length)return!1;var t=[];n.each(function(i){t.push({id:this.id,offsetTop:this.offsetTop})});for(var a=$(window).scrollTop(),e=0,o=t.length;e<o;e++)if(a<t[e].offsetTop+200){l.find("li").removeClass("current");var s=0<e?e-1:0;l.find('a[href="#'+t[s].id+'"]').parent().addClass("current");break}a>=t[t.length-1].offsetTop+200&&(l.find("li").removeClass("current"),l.find("li:last").addClass("current"))}),$(window).scroll()}};NexT.init();
|
Reference in New Issue
Block a user