1( function() { 2 var container, menu, links, i, len; 3 4 container = document.getElementById( 'site-navigation' ); 5 if ( ! container ) { 6 return; 7 } 8 9 menu = container.getElementsByTagName( 'ul' )[0]; 10 11 // Get all the link elements within the menu. 12 links = menu.getElementsByTagName( 'a' ); 13 14 // Each time a menu link is focused or blurred, toggle focus. 15 for ( i = 0, len = links.length; i < len; i++ ) { 16 links[i].addEventListener( 'focus', toggleFocus, true ); 17 links[i].addEventListener( 'blur', toggleFocus, true ); 18 } 19 20 /** 21 * Sets or removes .focus class on an element. 22 */ 23 function toggleFocus() { 24 var self = this; 25 26 // Move up through the ancestors of the current link until we hit .menu. 27 while ( -1 === self.className.indexOf( 'nav-menu' ) ) { 28 // On li elements toggle the class .focus. 29 if ( 'li' === self.tagName.toLowerCase() ) { 30 if ( -1 !== self.className.indexOf( 'focus' ) ) { 31 self.className = self.className.replace( ' focus', '' ); 32 } else { 33 self.className += ' focus'; 34 } 35 } 36 37 self = self.parentElement; 38 } 39 } 40} )();
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.