1(function($){ 2 $(function(){ 3 $('.dropdown .arrow').each(function(){ 4 if ($(this).next().hasClass('sub-menu') == false) { 5 $(this).remove(); 6 } 7 }); 8 }); 9 $(document).on('keydown', function(event){ 10 var el = $(':focus'); 11 // console.log(el.text()); 12 var larr = 37, 13 uarr = 38, 14 rarr = 39, 15 darr = 40; 16 switch (event.keyCode) { 17 case larr: 18 arrow_left(el); 19 break; 20 case uarr: 21 arrow_up(el); 22 break; 23 case rarr: 24 arrow_right(el); 25 break; 26 case darr: 27 arrow_down(el); 28 break; 29 default: 30 console.log('you pressed key nr', event.keyCode); 31 } 32 }); 33 function arrow_up(el) { 34 if (el.parent().hasClass('dropdown')) { 35 el.parent().removeClass('open'); 36 } 37 else if (el.parent().is('li:first-child') && el.parent().parentsUntil('.menu-item-has-children').hasClass('dropdown')){ 38 console.log('parent is first'); 39 el.closest('.dropdown').removeClass('open').find('> a').focus(); 40 } 41 else { 42 el.parent().prev('.menu-item').find('a:first').focus(); 43 } 44 } 45 function arrow_left(el) { 46 console.log(el.parent()); 47 if (el.closest('.sub-menu').length > 0) { 48 el.closest('.sub-menu').removeClass('active').parent().find('a:first').focus(); 49 } 50 else if (el.parent().is(':first-child')) { 51 el.parent().parent().find('> a').focus(); 52 } 53 else { 54 el.parent().find('a:first').focus(); 55 } 56 } 57 function arrow_right(el) { 58 if (el.parent().has('.menu-item')) { 59 el.siblings('.sub-menu').first().addClass('active').find('li:first-child > a').focus(); 60 } 61 else { 62 el.next('.menu-item').find('a:first').focus(); 63 } 64 } 65 function arrow_down(el) { 66 if (el.parent().hasClass('dropdown')) { 67 el.parent().addClass('open').find('.sub-menu li:first-child > a').focus(); 68 el.parent().siblings().removeClass('open'); 69 } 70 else { 71 el.parent().next('.menu-item').find('a:first').focus(); 72 } 73 } 74})(jQuery);
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.