1/** 2 * Theme functions file. 3 * 4 * Contains handlers for navigation. 5 */ 6 7jQuery(function($){ 8 "use strict"; 9 jQuery('.main-menu-navigation > ul').superfish({ 10 delay: 500, 11 animation: {opacity:'show',height:'show'}, 12 speed: 'fast' 13 }); 14 15 $( window ).scroll( function() { 16 if ( $( this ).scrollTop() > 200 ) { 17 $( '.back-to-top' ).addClass( 'show-back-to-top' ); 18 } else { 19 $( '.back-to-top' ).removeClass( 'show-back-to-top' ); 20 } 21 }); 22 23 // Click event to scroll to top. 24 $( '.back-to-top' ).click( function() { 25 $( 'html, body' ).animate( { scrollTop : 0 }, 500 ); 26 return false; 27 }); 28}); 29 30function disco_night_club_open() { 31 jQuery(".sidenav").addClass('show'); 32} 33function disco_night_club_close() { 34 jQuery(".sidenav").removeClass('show'); 35 jQuery( '.mobile-menu' ).focus(); 36} 37 38function disco_night_club_menuAccessibility() { 39 var links, i, len, 40 disco_night_club_menu = document.querySelector( '.nav-menu' ), 41 disco_night_club_iconToggle = document.querySelector( '.nav-menu ul li:first-child a' ); 42 43 let disco_night_club_focusableElements = 'button, a, input'; 44 let disco_night_club_firstFocusableElement = disco_night_club_iconToggle; // get first element to be focused inside menu 45 let disco_night_club_focusableContent = disco_night_club_menu.querySelectorAll(disco_night_club_focusableElements); 46 let disco_night_club_lastFocusableElement = disco_night_club_focusableContent[disco_night_club_focusableContent.length - 1]; // get last element to be focused inside menu 47 48 if ( ! disco_night_club_menu ) { 49 return false; 50 } 51 52 links = disco_night_club_menu.getElementsByTagName( 'a' ); 53 54 // Each time a menu link is focused or blurred, toggle focus. 55 for ( i = 0, len = links.length; i < len; i++ ) { 56 links[i].addEventListener( 'focus', toggleFocus, true ); 57 links[i].addEventListener( 'blur', toggleFocus, true ); 58 } 59 60 // Sets or removes the .focus class on an element. 61 function toggleFocus() { 62 var self = this; 63 64 // Move up through the ancestors of the current link until we hit .mobile-menu. 65 while (-1 === self.className.indexOf( 'nav-menu' ) ) { 66 // On li elements toggle the class .focus. 67 if ( 'li' === self.tagName.toLowerCase() ) { 68 if ( -1 !== self.className.indexOf( 'focus' ) ) { 69 self.className = self.className.replace( ' focus', '' ); 70 } else { 71 self.className += ' focus'; 72 } 73 } 74 self = self.parentElement; 75 } 76 } 77 78 // Trap focus inside modal to make it ADA compliant 79 document.addEventListener('keydown', function (e) { 80 let isTabPressed = e.key === 'Tab' || e.keyCode === 9; 81 82 if ( ! isTabPressed ) { 83 return; 84 } 85 86 if ( e.shiftKey ) { // if shift key pressed for shift + tab combination 87 if (document.activeElement === disco_night_club_firstFocusableElement) { 88 disco_night_club_lastFocusableElement.focus();
88 // add focus for the last focusable element 89 e.preventDefault(); 90 } 91 } else { // if tab key is pressed 92 if (document.activeElement === disco_night_club_lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab 93 disco_night_club_firstFocusableElement.focus(); // add focus for the first focusable element 94 e.preventDefault(); 95 } 96 } 97 }); 98} 99 100jQuery(function($){ 101 $('.mobile-menu').click(function () { 102 disco_night_club_menuAccessibility(); 103 }); 104});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.