mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
nav: remove jQuery #452
This commit is contained in:
parent
1491e66580
commit
f322e58ddd
1 changed files with 22 additions and 14 deletions
|
@ -365,14 +365,10 @@ function initArrowNav(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// button navigation
|
// button navigation
|
||||||
jQuery(function() {
|
var e = document.querySelector( 'a.nav-prev' );
|
||||||
jQuery('a.nav-prev').click(function(){
|
e && e.addEventListener( 'click', navPrev );
|
||||||
location.href = jQuery(this).attr('href');
|
e = document.querySelector( 'a.nav-next' );
|
||||||
});
|
e && e.addEventListener( 'click', navNext );
|
||||||
jQuery('a.nav-next').click(function() {
|
|
||||||
location.href = jQuery(this).attr('href');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// keyboard navigation
|
// keyboard navigation
|
||||||
// avoid prev/next navigation if we are not at the start/end of the
|
// avoid prev/next navigation if we are not at the start/end of the
|
||||||
|
@ -384,7 +380,7 @@ function initArrowNav(){
|
||||||
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
|
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
|
||||||
if( event.which == '37' ){
|
if( event.which == '37' ){
|
||||||
if( !scrollLeft && el.scrollLeft <= 0 ){
|
if( !scrollLeft && el.scrollLeft <= 0 ){
|
||||||
jQuery('a.nav-prev').click();
|
navPrev();
|
||||||
}
|
}
|
||||||
else if( scrollLeft != -1 ){
|
else if( scrollLeft != -1 ){
|
||||||
clearTimeout( scrollLeft );
|
clearTimeout( scrollLeft );
|
||||||
|
@ -393,7 +389,7 @@ function initArrowNav(){
|
||||||
}
|
}
|
||||||
if( event.which == '39' ){
|
if( event.which == '39' ){
|
||||||
if( !scrollRight && el.scrollLeft + el.clientWidth >= el.scrollWidth ){
|
if( !scrollRight && el.scrollLeft + el.clientWidth >= el.scrollWidth ){
|
||||||
jQuery('a.nav-next').click();
|
navNext();
|
||||||
}
|
}
|
||||||
else if( scrollRight != -1 ){
|
else if( scrollRight != -1 ){
|
||||||
clearTimeout( scrollRight );
|
clearTimeout( scrollRight );
|
||||||
|
@ -419,11 +415,13 @@ function initArrowNav(){
|
||||||
});
|
});
|
||||||
|
|
||||||
// avoid keyboard navigation for input fields
|
// avoid keyboard navigation for input fields
|
||||||
jQuery(formelements).keydown(function (e) {
|
document.querySelectorAll( formelements ).forEach( function( e ){
|
||||||
if (e.which == '37' || e.which == '39') {
|
e.addEventListener( 'keydown', function( event ){
|
||||||
e.stopPropagation();
|
if( event.which == 37 || event.which == 39 ){
|
||||||
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initMenuScrollbar(){
|
function initMenuScrollbar(){
|
||||||
|
@ -630,6 +628,16 @@ function showPrint(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function navPrev(){
|
||||||
|
var e = document.querySelector( 'a.nav-prev' );
|
||||||
|
location.href = e && e.getAttribute( 'href' );
|
||||||
|
};
|
||||||
|
|
||||||
|
function navNext(){
|
||||||
|
var e = document.querySelector( 'a.nav-next' );
|
||||||
|
location.href = e && e.getAttribute( 'href' );
|
||||||
|
};
|
||||||
|
|
||||||
function initToc(){
|
function initToc(){
|
||||||
if( isPrint ){
|
if( isPrint ){
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue