fixed 12325
This commit is contained in:
240
next/js/next.js
240
next/js/next.js
@@ -17,7 +17,7 @@
|
||||
* @fileoverview util and every page should be used.
|
||||
*
|
||||
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
|
||||
* @version 0.3.1.0, Feb 17, 2017
|
||||
* @version 0.4.0.0, Jul 26, 2017
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -25,114 +25,152 @@
|
||||
* @static
|
||||
*/
|
||||
var NexT = {
|
||||
init: function () {
|
||||
$('.sidebar-toggle').click(function () {
|
||||
var $sidebar = $('.sidebar');
|
||||
if ($(this).hasClass('sidebar-active')) {
|
||||
$(this).removeClass('sidebar-active');
|
||||
init: function () {
|
||||
$('.sidebar-toggle').click(function () {
|
||||
var $sidebar = $('.sidebar');
|
||||
if ($(this).hasClass('sidebar-active')) {
|
||||
$(this).removeClass('sidebar-active');
|
||||
|
||||
$('body').animate({
|
||||
'padding-right': 0
|
||||
});
|
||||
$sidebar.animate({
|
||||
right: -320
|
||||
});
|
||||
$sidebar.find('section').css('opacity', 0);
|
||||
} else {
|
||||
$(this).addClass('sidebar-active');
|
||||
$('body').animate({
|
||||
'padding-right': 320
|
||||
});
|
||||
$sidebar.animate({
|
||||
right: 0
|
||||
}, function () {
|
||||
$sidebar.find('section:first').animate({
|
||||
'opacity': 1
|
||||
});
|
||||
});
|
||||
}
|
||||
$('body').animate({
|
||||
'padding-right': 0
|
||||
});
|
||||
|
||||
$('.site-nav-toggle').click(function () {
|
||||
$('.site-nav').slideToggle();
|
||||
$sidebar.animate({
|
||||
right: -320
|
||||
});
|
||||
$sidebar.find('section').css('opacity', 0);
|
||||
} else {
|
||||
$(this).addClass('sidebar-active');
|
||||
$('body').animate({
|
||||
'padding-right': 320
|
||||
});
|
||||
$sidebar.animate({
|
||||
right: 0
|
||||
}, function () {
|
||||
$sidebar.find('section:first').animate({
|
||||
'opacity': 1
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(function () {
|
||||
// logo animate
|
||||
$('.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 () {
|
||||
// 当有文章页面有目录时,回调不放这里,侧边栏就会一片空白
|
||||
if ($('.b3-solo-list li').length > 0 && $(window).width() > 1000) {
|
||||
$('.sidebar-toggle').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.site-nav-toggle').click(function () {
|
||||
$('.site-nav').slideToggle();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('.logo-line-after i').animate({
|
||||
'right': '0'
|
||||
});
|
||||
}, 500);
|
||||
|
||||
$('body').on('click', '.article-body img', function () {
|
||||
window.open(this.src);
|
||||
$(document).ready(function () {
|
||||
setTimeout(function () {
|
||||
// logo animate
|
||||
$('.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'
|
||||
});
|
||||
});
|
||||
},
|
||||
initArticle: function () {
|
||||
if ($('.b3-solo-list 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');
|
||||
$('.main').css('opacity', 1).animate({
|
||||
'top': '0'
|
||||
}, function () {
|
||||
// 当有文章页面有目录时,回调不放这里,侧边栏就会一片空白
|
||||
if ($('.b3-solo-list li').length > 0 && $(window).width() > 1000) {
|
||||
$('.sidebar-toggle').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('.logo-line-after i').animate({
|
||||
'right': '0'
|
||||
});
|
||||
}, 500);
|
||||
|
||||
$('body').on('click', '.article-body img', function () {
|
||||
window.open(this.src);
|
||||
});
|
||||
});
|
||||
},
|
||||
initArticle: function () {
|
||||
if ($('.b3-solo-list 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 = $('.article-body [id^=b3_solo_h]'),
|
||||
$articleToc = $('.b3-solo-list');
|
||||
|
||||
$(window).scroll(function (event) {
|
||||
if ($('.b3-solo-list li').length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 界面各种图片加载会导致帖子目录定位
|
||||
var toc = [];
|
||||
$articleTocs.each(function (i) {
|
||||
toc.push({
|
||||
id: this.id,
|
||||
offsetTop: this.offsetTop
|
||||
});
|
||||
});
|
||||
|
||||
// 当前目录样式
|
||||
var scrollTop = $(window).scrollTop();
|
||||
for (var i = 0, iMax = toc.length; i < iMax; i++) {
|
||||
if (scrollTop < toc[i].offsetTop + 200) {
|
||||
$articleToc.find('li').removeClass('current');
|
||||
var index = i > 0 ? i - 1 : 0;
|
||||
$articleToc.find('a[href="#' + toc[index].id + '"]').parent().addClass('current');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scrollTop >= toc[toc.length - 1].offsetTop + 200) {
|
||||
$articleToc.find('li').removeClass('current');
|
||||
$articleToc.find('li:last').addClass('current');
|
||||
}
|
||||
});
|
||||
|
||||
$(window).scroll();
|
||||
}
|
||||
};
|
||||
NexT.init();
|
2
next/js/next.min.js
vendored
2
next/js/next.min.js
vendored
@@ -13,4 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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(){$(".b3-solo-list li").length>0&&$(window).width()>1e3&&$(".sidebar-toggle").click()})})}),$(".logo-line-after i").animate({right:"0"})},500),$("body").on("click",".article-body img",function(){window.open(this.src)})})},initArticle:function(){if($(".b3-solo-list li").length>0&&$(window).width()>1e3){$(".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")})}}};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(){$(".b3-solo-list li").length>0&&$(window).width()>1e3&&$(".sidebar-toggle").click()})})}),$(".logo-line-after i").animate({right:"0"})},500),$("body").on("click",".article-body img",function(){window.open(this.src)})})},initArticle:function(){if($(".b3-solo-list li").length>0&&$(window).width()>1e3){$(".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 i=$(".article-body [id^=b3_solo_h]"),t=$(".b3-solo-list");$(window).scroll(function(a){if(0===$(".b3-solo-list li").length)return!1;var o=[];i.each(function(i){o.push({id:this.id,offsetTop:this.offsetTop})});for(var e=$(window).scrollTop(),n=0,s=o.length;n<s;n++)if(e<o[n].offsetTop+200){t.find("li").removeClass("current");var l=n>0?n-1:0;t.find('a[href="#'+o[l].id+'"]').parent().addClass("current");break}e>=o[o.length-1].offsetTop+200&&(t.find("li").removeClass("current"),t.find("li:last").addClass("current"))}),$(window).scroll()}};NexT.init();
|
Reference in New Issue
Block a user