From 028fe602f0dd017bc44d9802ed88a0a9a2b6b3be Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 12 Sep 2017 18:04:27 +0300 Subject: [PATCH 01/55] MOD: move `getContentHeight` to variable. --- source/js/src/utils.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/js/src/utils.js b/source/js/src/utils.js index 8f2f89e40..ea054add1 100644 --- a/source/js/src/utils.js +++ b/source/js/src/utils.js @@ -102,10 +102,8 @@ NexT.utils = NexT.$u = { $top.toggleClass('back-to-top-on', window.pageYOffset > THRESHOLD); var scrollTop = $(window).scrollTop(); - var docHeight = $('#content').height(); - var winHeight = $(window).height(); - var contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight); - var scrollPercent = (scrollTop) / (contentMath); + var contentHeight = NexT.utils.getContentHeight(); + var scrollPercent = (scrollTop) / (contentHeight); var scrollPercentRounded = Math.round(scrollPercent*100); var scrollPercentMaxed = (scrollPercentRounded > 100) ? 100 : scrollPercentRounded; $('#scrollpercent>span').html(scrollPercentMaxed); @@ -265,6 +263,14 @@ NexT.utils = NexT.$u = { return scrollbarWidth; }, + getContentHeight: function () { + var docHeight = $('#content').height(), + winHeight = $(window).height(), + contentHeight = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight); + + return contentHeight; + }, + /** * Affix behaviour for Sidebar. * From 43dd4b4b809f0342fe199f1db780afde3e6f3e45 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 12 Sep 2017 19:33:13 +0300 Subject: [PATCH 02/55] FIX: jumping affix if sidebar taller then content. --- source/js/src/post-details.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/js/src/post-details.js b/source/js/src/post-details.js index 1197a574f..2311ee3ee 100644 --- a/source/js/src/post-details.js +++ b/source/js/src/post-details.js @@ -30,8 +30,10 @@ $(document).ready(function () { // Sidebar float function initAffix () { - var headerHeight = $('.header-inner').height(); - var footerOffset = parseInt($('.main').css('padding-bottom'), 10); + var headerHeight = $('.header-inner').height(), + sidebarHeight = $('.sidebar-inner').outerHeight(), + contentHeight = $('#content').height(), + footerOffset = $('.footer').height(); /*jshint camelcase: false */ var sidebarTop = (CONFIG.sidebar.offset_float === 0) ? @@ -39,12 +41,14 @@ $(document).ready(function () { headerHeight; /*jshint camelcase: true */ + if (sidebarTop + sidebarHeight < contentHeight) { $('.sidebar-inner').affix({ offset: { top: sidebarTop, bottom: footerOffset } }); + } $(document) .on('affixed.bs.affix', function () { From 61086aa23ed8fa2e94580421cbc696852978fc06 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 12 Sep 2017 19:43:44 +0300 Subject: [PATCH 03/55] MOD: rename `getContentHeight` function. --- source/js/src/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/js/src/utils.js b/source/js/src/utils.js index ea054add1..6d23cecb1 100644 --- a/source/js/src/utils.js +++ b/source/js/src/utils.js @@ -102,8 +102,8 @@ NexT.utils = NexT.$u = { $top.toggleClass('back-to-top-on', window.pageYOffset > THRESHOLD); var scrollTop = $(window).scrollTop(); - var contentHeight = NexT.utils.getContentHeight(); - var scrollPercent = (scrollTop) / (contentHeight); + var contentVisibilityHeight = NexT.utils.getContentVisibilityHeight(); + var scrollPercent = (scrollTop) / (contentVisibilityHeight); var scrollPercentRounded = Math.round(scrollPercent*100); var scrollPercentMaxed = (scrollPercentRounded > 100) ? 100 : scrollPercentRounded; $('#scrollpercent>span').html(scrollPercentMaxed); @@ -263,12 +263,12 @@ NexT.utils = NexT.$u = { return scrollbarWidth; }, - getContentHeight: function () { + getContentVisibilityHeight: function () { var docHeight = $('#content').height(), winHeight = $(window).height(), - contentHeight = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight); + contentVisibilityHeight = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight); - return contentHeight; + return contentVisibilityHeight; }, /** From 619c49e7200b171772c12da3b554757fcb5e8b24 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 04:07:49 +0300 Subject: [PATCH 04/55] ADD: scrolling to active TOC if TOC > viewport. Scrolling to center active TOC element if TOC content is taller then viewport. --- source/js/src/post-details.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/js/src/post-details.js b/source/js/src/post-details.js index 2311ee3ee..ecf65a05b 100644 --- a/source/js/src/post-details.js +++ b/source/js/src/post-details.js @@ -17,6 +17,9 @@ $(document).ready(function () { removeCurrentActiveClass(); $currentActiveElement.addClass('active-current'); + + // Scrolling to center active TOC element if TOC content is taller then viewport. + $tocElement.scrollTop($currentActiveElement.offset().top - $tocElement.offset().top + $tocElement.scrollTop() - ($tocElement.height() / 2)); }) .on('clear.bs.scrollspy', removeCurrentActiveClass); From 9ce276ff1f61e32da0875e4478a69fd8ed3cfdd4 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 04:13:39 +0300 Subject: [PATCH 05/55] FIX: sidebar with `motion` on Mist & Muse schemes. --- source/js/src/post-details.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/js/src/post-details.js b/source/js/src/post-details.js index ecf65a05b..e5fc3feaa 100644 --- a/source/js/src/post-details.js +++ b/source/js/src/post-details.js @@ -147,7 +147,7 @@ $(document).ready(function () { CONFIG.sidebar.display === 'always'; var hasTOC = $tocContent.length > 0 && $tocContent.html().trim().length > 0; if (isSidebarCouldDisplay && hasTOC) { - CONFIG.motion ? + CONFIG.motion.enable ? (NexT.motion.middleWares.sidebar = function () { NexT.utils.displaySidebar(); }) : NexT.utils.displaySidebar(); From e75a2a1192dabf886b5108360ac247bb9de91b68 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 08:24:34 +0300 Subject: [PATCH 06/55] ADD: sidebar scrollable in all schemes [1]. --- source/js/src/utils.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/source/js/src/utils.js b/source/js/src/utils.js index 6d23cecb1..e8b80f840 100644 --- a/source/js/src/utils.js +++ b/source/js/src/utils.js @@ -267,16 +267,26 @@ NexT.utils = NexT.$u = { var docHeight = $('#content').height(), winHeight = $(window).height(), contentVisibilityHeight = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight); - return contentVisibilityHeight; }, - + + getSidebarSchemePadding: function () { + var sidebarb2tHeight = ($('.back-to-top').css('display') == 'block') ? 0 : $('.back-to-top').height(), + sidebarNavHeight = ($('.sidebar-nav').css('display') == 'block') ? $('.sidebar-nav').outerHeight(true) : 0, + sidebarInner = $('.sidebar-inner'), + sidebarPadding = sidebarInner.innerWidth() - sidebarInner.width(), + sidebarSchemePadding = this.isPisces() || this.isGemini() ? + ((sidebarPadding * 2) + sidebarNavHeight + (CONFIG.sidebar.offset * 2) + sidebarb2tHeight) : + ((sidebarPadding * 2) + (sidebarNavHeight / 2)); + return sidebarSchemePadding; + }, + /** * Affix behaviour for Sidebar. * * @returns {Boolean} */ - needAffix: function () { - return this.isPisces() || this.isGemini(); - } +// needAffix: function () { +// return this.isPisces() || this.isGemini(); +// } }; From 334e50e992e48299fa64dfeb9b2c089e4815d4d8 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 08:30:56 +0300 Subject: [PATCH 07/55] ADD: sidebar scrollable in all schemes [2]. --- source/js/src/post-details.js | 39 +++++++---------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/source/js/src/post-details.js b/source/js/src/post-details.js index e5fc3feaa..bdb359c8b 100644 --- a/source/js/src/post-details.js +++ b/source/js/src/post-details.js @@ -3,7 +3,7 @@ $(document).ready(function () { initScrollSpy(); - NexT.utils.needAffix() && initAffix(); +// NexT.utils.needAffix() && initAffix(); initTOCDimension(); function initScrollSpy () { @@ -31,58 +31,33 @@ $(document).ready(function () { } } - // Sidebar float - function initAffix () { - var headerHeight = $('.header-inner').height(), - sidebarHeight = $('.sidebar-inner').outerHeight(), - contentHeight = $('#content').height(), - footerOffset = $('.footer').height(); - - /*jshint camelcase: false */ - var sidebarTop = (CONFIG.sidebar.offset_float === 0) ? - headerHeight + CONFIG.sidebar.offset : - headerHeight; - /*jshint camelcase: true */ - - if (sidebarTop + sidebarHeight < contentHeight) { - $('.sidebar-inner').affix({ - offset: { - top: sidebarTop, - bottom: footerOffset - } - }); - } - - $(document) - .on('affixed.bs.affix', function () { - updateTOCHeight(document.body.clientHeight - 100); - }); - } - function initTOCDimension () { - var updateTOCHeightTimer; + var updateTOCHeightTimer, + sidebarSchemePadding = NexT.utils.getSidebarSchemePadding(); $(window).on('resize', function () { updateTOCHeightTimer && clearTimeout(updateTOCHeightTimer); updateTOCHeightTimer = setTimeout(function () { - var tocWrapperHeight = document.body.clientHeight - 100; + var tocWrapperHeight = document.body.clientHeight - sidebarSchemePadding; updateTOCHeight(tocWrapperHeight); }, 0); }); // Initialize TOC Height. - updateTOCHeight(document.body.clientHeight - 100); + updateTOCHeight(document.body.clientHeight - sidebarSchemePadding); // Initialize TOC Width. var scrollbarWidth = NexT.utils.getScrollbarWidth(); $('.post-toc').css('width', 'calc(100% + ' + scrollbarWidth + 'px)'); + $('.site-overview').css('width', 'calc(100% + ' + scrollbarWidth + 'px)'); } function updateTOCHeight (height) { height = height || 'auto'; $('.post-toc').css('max-height', height); + $('.site-overview').css('max-height', height); } }); From 59209cf56fcdd9f70cb9cb166fc02e16ef96e801 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 08:32:14 +0300 Subject: [PATCH 08/55] ADD: sidebar scrollable in all schemes [3]. --- source/js/src/schemes/pisces.js | 35 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/source/js/src/schemes/pisces.js b/source/js/src/schemes/pisces.js index d4125b6bd..d62d9a399 100644 --- a/source/js/src/schemes/pisces.js +++ b/source/js/src/schemes/pisces.js @@ -1,17 +1,22 @@ $(document).ready(function () { - var $headerInner = $('.header-inner'); - var $sidebar = $('#sidebar'); - var getSidebarTop = function(){ - return $headerInner.height() + CONFIG.sidebar.offset; - }; - var setSidebarMarginTop = function(sidebarTop){ - return $sidebar.css({ 'margin-top': sidebarTop }); - }; - var mql = window.matchMedia('(min-width: 991px)'); - setSidebarMarginTop(getSidebarTop()).show(); - mql.addListener(function(e){ - if(e.matches){ - setSidebarMarginTop(getSidebarTop()); - } - }); + + initAffix(); + + function initAffix () { + var headerHeight = $('.header-inner').height(), + headerOffset = (headerHeight + CONFIG.sidebar.offset) + + footerInner = $('.footer-inner'), + footerMargin = footerInner.outerHeight(true) - footerInner.outerHeight(), + footerOffset = footerInner.outerHeight(true) + footerMargin; + + $('.sidebar-inner').affix({ + offset: { + top: headerOffset - CONFIG.sidebar.offset, + bottom: footerOffset + } + }); + + $('#sidebar').css({ 'margin-top': headerOffset + 'px' }).show(); + } }); From a8344d824badc8dc4e2f4b5ac616d092f110b06a Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 08:45:22 +0300 Subject: [PATCH 09/55] FIX: sidebar scrollable in all schemes [4]. --- source/js/src/schemes/pisces.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/js/src/schemes/pisces.js b/source/js/src/schemes/pisces.js index d62d9a399..ca05b7fdc 100644 --- a/source/js/src/schemes/pisces.js +++ b/source/js/src/schemes/pisces.js @@ -3,9 +3,7 @@ $(document).ready(function () { initAffix(); function initAffix () { - var headerHeight = $('.header-inner').height(), - headerOffset = (headerHeight + CONFIG.sidebar.offset) - + var headerOffset = $('.header-inner').height() + CONFIG.sidebar.offset, footerInner = $('.footer-inner'), footerMargin = footerInner.outerHeight(true) - footerInner.outerHeight(), footerOffset = footerInner.outerHeight(true) + footerMargin; From af067cdff92b270b96134934c661934a09a25a1c Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 09:06:44 +0300 Subject: [PATCH 10/55] ADD: sidebar scrollable in all schemes [5]. --- source/css/_schemes/Pisces/_sidebar.styl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/css/_schemes/Pisces/_sidebar.styl b/source/css/_schemes/Pisces/_sidebar.styl index 0892744ea..3d4f93b15 100644 --- a/source/css/_schemes/Pisces/_sidebar.styl +++ b/source/css/_schemes/Pisces/_sidebar.styl @@ -12,6 +12,7 @@ .sidebar-inner { +//padding: 20px 10px 0; box-sizing: border-box; width: 240px; color: $text-color; @@ -21,8 +22,13 @@ &.affix { position: fixed; - top: $sidebar-offset-float; + top: $sidebar-offset; } + + &.affix-bottom { + position: absolute; + } + } .site-overview { From 65cb1622326471b660a769cca21a951ab804496d Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 09:09:02 +0300 Subject: [PATCH 11/55] ADD: sidebar scrollable in all schemes [6]. --- source/css/_common/components/back-to-top-sidebar.styl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/css/_common/components/back-to-top-sidebar.styl b/source/css/_common/components/back-to-top-sidebar.styl index ab797f3e7..d23d35d57 100644 --- a/source/css/_common/components/back-to-top-sidebar.styl +++ b/source/css/_common/components/back-to-top-sidebar.styl @@ -1,6 +1,6 @@ .back-to-top { display: none; - margin: 15px -10px -20px; + margin: 20px -10px -20px; background: $body-bg-color; font-size: $b2t-font-size; opacity: $b2t-opacity; From d23c0e076e871799010a24d67be10e95da1c624d Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 09:10:44 +0300 Subject: [PATCH 12/55] ADD: sidebar scrollable in all schemes [7]. --- source/css/_common/components/sidebar/sidebar.styl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/css/_common/components/sidebar/sidebar.styl b/source/css/_common/components/sidebar/sidebar.styl index 39b11fdbf..635cc94fd 100644 --- a/source/css/_common/components/sidebar/sidebar.styl +++ b/source/css/_common/components/sidebar/sidebar.styl @@ -32,6 +32,15 @@ text-align: center; } +.site-overview-wrap { + overflow: hidden; +} + +.site-overview { + overflow-y: auto; + overflow-x: hidden; +} + @import "sidebar-toggle"; @import "sidebar-author"; @import "site-state"; From 0f27b0c300bae1e7344c92ecaeb569b8c953d693 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sat, 23 Sep 2017 09:20:16 +0300 Subject: [PATCH 13/55] ADD: sidebar scrollable in all schemes [8]. --- layout/_macro/sidebar.swig | 197 +++++++++++++++++++------------------ 1 file changed, 99 insertions(+), 98 deletions(-) diff --git a/layout/_macro/sidebar.swig b/layout/_macro/sidebar.swig index 5392bbaaa..6b755da11 100644 --- a/layout/_macro/sidebar.swig +++ b/layout/_macro/sidebar.swig @@ -17,125 +17,126 @@ {% if display_toc and toc(page.content).length > 1 %} {% endif %} -