diff --git a/source/js/scroll.js b/source/js/scroll.js index e14bc8dcb2c0b8f092e4baf6f166ce96e23c90c3..67a241f94445275330f34fb1845de90e569f9412 100644 --- a/source/js/scroll.js +++ b/source/js/scroll.js @@ -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(); diff --git a/source/js/sidebar.js b/source/js/sidebar.js index 877f2c15e901b10900e342931529c76f193a69b3..c997fb6d5c28fa75f77d86b4dd1a2468efd47a08 100644 --- a/source/js/sidebar.js +++ b/source/js/sidebar.js @@ -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'); }); diff --git a/source/js/stun-boot.js b/source/js/stun-boot.js index d25a72daa97664c2ad58992fab01d729402e4d14..7345503bd6509a599e78cb6fa49c628f1d9350b0 100644 --- a/source/js/stun-boot.js +++ b/source/js/stun-boot.js @@ -1,5 +1,5 @@ $(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'; diff --git a/source/js/utils.js b/source/js/utils.js index 3c4c82f1cdec073a9623723fc40f1e4cb6d711ab..5e61d33996c7534d54747782fdfd088d0ad45c96 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -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) {