1jQuery( function ( $ ) { 2 3 // Focus styles for menus when using keyboard navigation 4 5 // Properly update the ARIA states on focus (keyboard) and mouse over events 6 $( 'nav > ul' ).on( 'focus.wparia mouseenter.wparia', '[aria-haspopup="true"]', function ( ev ) { 7 $( ev.currentTarget ).attr( 'aria-expanded', true ); 8 // $(ev.currentTarget).addClass('selected'); 9 $(ev.currentTarget).find('> ul').css('display', 'block'); 10 // console.log( 'AAA', $( ev.currentTarget ).parents('.menu-item').attr('aria-expanded') ); 11 12 } ); 13 14 // Properly update the ARIA states on blur (keyboard) and mouse out events 15 $( 'nav > ul' ).on( 'blur.wparia mouseleave.wparia', '[aria-haspopup="true"]', function ( ev ) { 16 $( ev.currentTarget ).attr( 'aria-expanded', false ); 17 // console.log( 'BBB', $( ev.currentTarget ).parents('.menu-item').attr('aria-expanded') ); 18 } ); 19 20 21 22 $(window).keyup(function (e) { 23 24 // console.log('keyup'); 25 26 var $focusedItem = $("nav > ul li:focus"); 27 var $focusParent = $focusedItem.parents('[aria-expanded="true"]'); 28 var code = (e.keyCode ? e.keyCode : e.which); 29 if (code == 9 && $focusedItem.length) { 30 // console.log('I was tabbed!', $focusParent); 31 // $("nav > ul li").not($focusedItem).css('background', 'red'); 32 // $focusParent.siblings().css('background', 'green'); 33 // $focusedItem.css('background', 'blue'); 34 35 $focusedItem.siblings().find('ul').css('display', 'none');; 36 $focusParent.siblings().find('ul').css('display', 'none');; 37 38 } 39 40 if(code == 13){ 41 var href = $focusedItem.find('a').attr('href'); 42 if(typeof href != 'undefined'){ 43 // console.log('enter pressed > go to ', href); 44 window.location = href; 45 } 46 // console.log($focusedItem.find('a').attr('href')); 47 } 48 49 }); 50 51 $('.mobile-nav .menu-item-has-children .sub-menu li:last-child a').on('blur', function() { 52 if (!$(this).parent().hasClass('menu-item-has-children')) { 53 $(this).parent().parent().hide(); 54 } 55 }); 56 $('.mobile-nav li a').on('focus', function() { 57 if ($(this).parent().parent().parent().hasClass('mobile-nav')) { 58 $(this).parent().prev().find('.sub-menu').hide(); 59 } 60 }); 61 //Close menu if focus logo; 62 $('.logo-link, .school-logo-link, .logo-text').on('focus', function() { 63 $('.sitewide-menu').hide(); 64 $('.menu-button').attr("aria-expanded", false); 65 $('.flaticon-menu').text('Menu collapsed'); 66 }); 67 // $("nav ul li").each(function (i) { $(this).attr('tabindex', i + 1); }); 68 69} );
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.