mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: avoid javascript errors if toc isn't present #268
This commit is contained in:
parent
c7b2eee5a6
commit
b1444965f4
1 changed files with 10 additions and 6 deletions
|
@ -306,6 +306,10 @@ function initMenuScrollbar(){
|
|||
return;
|
||||
}
|
||||
|
||||
var elc = document.querySelector('#body-inner');
|
||||
var elm = document.querySelector('#content-wrapper');
|
||||
var elt = document.querySelector('#TableOfContents');
|
||||
|
||||
var autofocus = false;
|
||||
document.addEventListener('keydown', function(event){
|
||||
// for initial keyboard scrolling support, no element
|
||||
|
@ -315,9 +319,9 @@ function initMenuScrollbar(){
|
|||
// it and give focus to the scrollbar - only
|
||||
// to just remove the focus right after scrolling
|
||||
// happend
|
||||
var c = document.querySelector('#body-inner').matches(':hover');
|
||||
var m = document.querySelector('#content-wrapper').matches(':hover');
|
||||
var t = document.querySelector('#TableOfContents').matches(':hover');
|
||||
var c = elc && elc.matches(':hover');
|
||||
var m = elm && elm.matches(':hover');
|
||||
var t = elt && elt.matches(':hover');
|
||||
var f = event.target.matches( formelements );
|
||||
if( !c && !m && !t && !f ){
|
||||
// only do this hack if none of our scrollbars
|
||||
|
@ -343,9 +347,9 @@ function initMenuScrollbar(){
|
|||
// scrollbars will install their own keyboard handlers
|
||||
// that need to be executed inbetween our own handlers
|
||||
// PSC removed for #242 #243 #244
|
||||
// psc = new PerfectScrollbar('#body-inner');
|
||||
psm = new PerfectScrollbar('#content-wrapper');
|
||||
pst = document.querySelector('#TableOfContents') ? new PerfectScrollbar('#TableOfContents') : null;
|
||||
// psc = elc && new PerfectScrollbar('#body-inner');
|
||||
psm = elm && new PerfectScrollbar('#content-wrapper');
|
||||
pst = elt && new PerfectScrollbar('#TableOfContents');
|
||||
document.addEventListener('keydown', function(){
|
||||
// if we facked initial scrolling, we want to
|
||||
// remove the focus to not leave visual markers on
|
||||
|
|
Loading…
Reference in a new issue