--- --- (function (jtd, undefined) { // Event handling jtd.addEvent = function(el, type, handler) { if (el.attachEvent) el.attachEvent('on'+type, handler); else el.addEventListener(type, handler); } jtd.removeEvent = function(el, type, handler) { if (el.detachEvent) el.detachEvent('on'+type, handler); else el.removeEventListener(type, handler); } jtd.onReady = function(ready) { // in case the document is already rendered if (document.readyState!='loading') ready(); // modern browsers else if (document.addEventListener) document.addEventListener('DOMContentLoaded', ready); // IE <= 8 else document.attachEvent('onreadystatechange', function(){ if (document.readyState=='complete') ready(); }); } // Show/hide mobile menu function initNav() { 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.ariaPressed = target.parentNode.classList.toggle('active'); } }); const siteNav = document.getElementById('site-nav'); const mainHeader = document.getElementById('main-header'); const menuButton = document.getElementById('menu-button'); disableHeadStyleSheets(); jtd.addEvent(menuButton, 'click', function(e){ e.preventDefault(); if (menuButton.classList.toggle('nav-open')) { siteNav.classList.add('nav-open'); mainHeader.classList.add('nav-open'); menuButton.ariaPressed = true; } else { siteNav.classList.remove('nav-open'); mainHeader.classList.remove('nav-open'); menuButton.ariaPressed = false; } }); {%- if site.search_enabled != false and site.search.button %} const searchInput = document.getElementById('search-input'); const searchButton = document.getElementById('search-button'); jtd.addEvent(searchButton, 'click', function(e){ e.preventDefault(); mainHeader.classList.add('nav-open'); searchInput.focus(); }); {%- endif %} } // The element is assumed to include the following stylesheets: // - a to /assets/css/just-the-docs-head-nav.css, // with id 'jtd-head-nav-stylesheet' // - a