提交 52b062c3 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

refactor: Not show toc when the post not heading

上级 28e188f1
......@@ -92,7 +92,7 @@ $(document).ready(function () {
.on('click', function () {
scrollHeadingToTop('#' + $(this).attr('id'));
});
// Click the post toc.
$('.toc-link').on('click', function (e) {
e.preventDefault();
......
......@@ -149,21 +149,21 @@ $(document).ready(function () {
$('.sidebar-nav-toc').on('click', function () {
$('.sidebar-nav-toc').toggleClass('current');
$('.sidebar-nav-overview').toggleClass('current');
$tocWrapper.css('display', 'block');
$tocWrapper.velocity('fadeIn');
$view.css('display', 'none');
$view.velocity('fadeOut');
});
$('.sidebar-nav-overview').on('click', function () {
$('.sidebar-nav-toc').toggleClass('current');
$('.sidebar-nav-overview').toggleClass('current');
$tocWrapper.css('display', 'none');
$tocWrapper.velocity('fadeOut');
$view.css('display', 'block');
$view.velocity('fadeIn');
});
......
$(document).ready(function () {
CONFIG.shortcuts.switch_post && Stun.utils.registerSwitchPost();
CONFIG.shortcuts.switch_post && Stun.utils.registerHotkeyToSwitchPost();
// Not reload this, because it's changeless.
if (CONFIG.external_link) {
......@@ -7,11 +7,12 @@ $(document).ready(function () {
}
Stun.utils.pjaxReloadBoot = function () {
this.initTocDisplay();
this.addCopyButtonToCopyright();
this.registerCopyEvent();
CONFIG.reward && this.registerShowReward();
CONFIG.gallery_waterfall && this.galleryWaterFall();
CONFIG.lazyload && this.lazyLoadImages();
CONFIG.gallery_waterfall && this.showImageToWaterfall();
CONFIG.lazyload && this.lazyLoadImage();
if (CONFIG.external_link) {
var WRAPPER = '.archive-inner, .post-title';
......
......@@ -174,6 +174,13 @@ Stun.utils = Stun.$u = {
return false;
}
},
initTocDisplay: function () {
if ($('.post-body').find('h1,h2,h3,h4,h5,h6')[0]) return;
$('.sidebar-nav').addClass('hide');
$('.sidebar-toc').addClass('hide');
$('.sidebar-overview').removeClass('hide');
},
// Wrap images with fancybox support.
wrapImageWithFancyBox: function () {
$('.content img').not(':hidden').each(function () {
......@@ -223,7 +230,7 @@ Stun.utils = Stun.$u = {
});
},
// Display the image in the gallery as a waterfall.
galleryWaterFall: function () {
showImageToWaterfall: function () {
var gConfig = CONFIG.gallery_waterfall;
var colWidth = parseInt(gConfig.col_width);
var colGapX = parseInt(gConfig.gap_x);
......@@ -239,7 +246,7 @@ Stun.utils = Stun.$u = {
});
},
// Lazy load the images of post.
lazyLoadImages: function () {
lazyLoadImage: function () {
$('img.lazyload').lazyload();
},
// Add a mark icon to the link with `target="_blank"` attribute.
......@@ -260,7 +267,7 @@ Stun.utils = Stun.$u = {
.append($icon);
},
// Switch to the prev / next post by shortcuts.
registerSwitchPost: function () {
registerHotkeyToSwitchPost: function () {
var _this = this;
$(document).on('keydown', function (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册