(function ($) { 'use strict'; document.addEventListener('DOMContentLoaded', function () { // Wait for DOM to be ready. var container = document.getElementById('site-navigation'); if (!container) { return; } var menu = container.querySelector('ul'); // Hide menu toggle button if menu is empty and return early. if (!menu) { button.style.display = 'none'; return; } menu.classList.add('nav-menu'); themeToggle('handheld'); var handheldNavigation = $('.handheld-navigation'); if (handheldNavigation.length > 0) { handheldNavigation.find('.menu-item-has-children > a, .page_item_has_children > a').each(function(index, element) { var dropdown = $(''); dropdown.insertAfter(element); dropdown.on('click', function (e) { e.preventDefault(); dropdown.toggleClass('toggled-on'); dropdown.siblings('ul').stop().slideToggle(400); }); }); } }); function themeToggle($nameToggle) { var toggleObject = document.getElementById($nameToggle + '-toggle'); var toggleOverlay = document.getElementById($nameToggle + '-overlay'); var toggleClose = document.getElementById($nameToggle + '-close'); var toggleWrap = document.getElementById($nameToggle + '-wrap'); if ( null === toggleObject || null === toggleOverlay || null === toggleClose ) { return; } document.body.classList.add('has-' + $nameToggle + '-toggle'); toggleObject.addEventListener('click', function (event) { event.preventDefault(); handheldNavigationVisibility(); }); toggleOverlay.addEventListener('click', function (event) { handheldNavigationVisibility(); }); toggleClose.addEventListener('click', function (event) { handheldNavigationVisibility(); }); var handheldNavigationVisibility = function () { toggleWrap.classList.toggle('active'); toggleOverlay.classList.toggle('active'); document.body.classList.toggle($nameToggle + '-toggle-active'); $('html').toggleClass('overflow-hidden'); }; } })(jQuery);