/** * File navigation.js. * * Handles toggling the navigation menu for small screens and enables TAB key * navigation support for dropdown menus. */ ( function() { var container, button, menu, links, i, len; var search_btn = document.getElementsByClassName('icon-search')[0]; search_btn.onclick = function() { var search_field = document.getElementsByClassName( 'search-field' )[0]; setTimeout( function(){ search_field.focus(); },50) } container = document.getElementById( 'site-navigation' ); if ( ! container ) { return; } button = document.getElementById( 'menu-top-mobile' ); if ( 'undefined' === typeof button ) { return; } menu = container.getElementsByTagName( 'ul' )[0]; // Hide menu toggle button if menu is empty and return early. if ( 'undefined' === typeof menu ) { button.style.display = 'none'; return; } button.onclick = function() { this.children[0].classList.toggle('active'); if (container.classList.contains( 'toggled' ) ) { container.className = container.className.replace( ' toggled', '' ); } else { container.className += ' toggled'; } }; // Get all the link elements within the menu. links = menu.getElementsByClassName('menu-item-has-children'); // Each time a menu link is focused or blurred, toggle focus. for ( i = 0, len = links.length; i < len; i++ ) { var link = links[i]; var svg = link.children[0].children[0]; link.children[0].after(svg); var knopka = link.children[1]; knopka.addEventListener('click', function() { if (window.innerWidth <= 1200) { this.nextElementSibling.classList.toggle('show'); } }) } window.addEventListener('resize', resres) function resres() { if (window.innerWidth <= 1200) { if (document.getElementById('img-ng')) { var img = document.getElementById('img-ng').getElementsByClassName('post-thumbnail')[0]; var place_to_put = document.getElementById('thumb-ng').children[0].children[1]; if (img) { place_to_put.before(img) } } } else { if (document.getElementById('img-ng')) { var place_to_put = document.getElementById('img-ng').children[0]; var img = document.getElementById('thumb-ng').getElementsByClassName('post-thumbnail')[0]; if (img) { place_to_put.before(img) } } } } resres(); } )();