mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Merge branch 'improvement/navigation' into improvement/navigation-new
# Conflicts: # _includes/nav.html # _layouts/default.html
This commit is contained in:
@@ -24,17 +24,28 @@ jtd.onReady = function(ready) {
|
||||
// Show/hide mobile menu
|
||||
|
||||
function initNav() {
|
||||
const mainNav = document.querySelector('.js-main-nav');
|
||||
const pageHeader = document.querySelector('.js-page-header');
|
||||
const navTrigger = document.querySelector('.js-main-nav-trigger');
|
||||
jtd.addEvent(document, 'click', function(e){
|
||||
var target = e.target;
|
||||
while (target && !(target.classList && target.classList.contains('nav-list-expander'))) {
|
||||
target = target.parentNode;
|
||||
}
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
target.parentNode.classList.toggle('active');
|
||||
}
|
||||
});
|
||||
|
||||
const siteNav = document.getElementById('site-nav');
|
||||
const mainHeader = document.getElementById('main-header');
|
||||
const navTrigger = document.getElementById('site-nav-trigger');
|
||||
|
||||
jtd.addEvent(navTrigger, 'click', function(e){
|
||||
e.preventDefault();
|
||||
var text = navTrigger.innerText;
|
||||
var textToggle = navTrigger.getAttribute('data-text-toggle');
|
||||
|
||||
mainNav.classList.toggle('nav-open');
|
||||
pageHeader.classList.toggle('nav-open');
|
||||
siteNav.classList.toggle('nav-open');
|
||||
mainHeader.classList.toggle('nav-open');
|
||||
navTrigger.classList.toggle('nav-open');
|
||||
navTrigger.innerText = textToggle;
|
||||
navTrigger.setAttribute('data-text-toggle', text);
|
||||
@@ -93,8 +104,8 @@ function initSearch() {
|
||||
function searchResults(index, data) {
|
||||
var index = index;
|
||||
var docs = data;
|
||||
var searchInput = document.querySelector('.js-search-input');
|
||||
var searchResults = document.querySelector('.js-search-results');
|
||||
var searchInput = document.getElementById('search-input');
|
||||
var searchResults = document.getElementById('search-results');
|
||||
|
||||
function hideResults() {
|
||||
searchResults.innerHTML = '';
|
||||
@@ -282,8 +293,8 @@ function initSearch() {
|
||||
// Focus
|
||||
|
||||
function pageFocus() {
|
||||
var mainContent = document.querySelector('.js-main-content');
|
||||
mainContent.focus();
|
||||
var mainWrap = document.getElementById('main-wrap');
|
||||
mainWrap.focus();
|
||||
}
|
||||
|
||||
// Switch theme
|
||||
|
Reference in New Issue
Block a user