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

refactor: Not show toc when the post not heading

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