1/** 2 * navigation.js 3 * 4 * Handles toggling the navigation menu for small screens. 5 */ 6( function() { 7 var container, button, menu; 8 9 container = document.getElementById( 'site-navigation' ); 10 if ( ! container ) 11 return; 12 13 button = container.getElementsByTagName( 'button' )[0]; 14 if ( 'undefined' === typeof button ) 15 return; 16 17 menu = container.getElementsByTagName( 'ul' )[0]; 18 19 // Hide menu toggle button if menu is empty and return early. 20 if ( 'undefined' === typeof menu ) { 21 button.style.display = 'none'; 22 return; 23 } 24 25 if ( -1 === menu.className.indexOf( 'nav-menu' ) ) 26 menu.className += ' nav-menu'; 27 28 button.onclick = function() { 29 if ( -1 !== container.className.indexOf( 'toggled' ) ) 30 container.className = container.className.replace( ' toggled', '' ); 31 else 32 container.className += ' toggled'; 33 }; 34 35 // Fix child menus for touch devices. 36 function fixMenuTouchTaps( container ) { 37 var touchStartFn, 38 parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ); 39 40 if ( 'ontouchstart' in window ) { 41 touchStartFn = function( e ) { 42 var menuItem = this.parentNode; 43 44 if ( ! menuItem.classList.contains( 'focus' ) ) { 45 e.preventDefault(); 46 for( var i = 0; i < menuItem.parentNode.children.length; ++i ) { 47 if ( menuItem === menuItem.parentNode.children[i] ) { 48 continue; 49 } 50 menuItem.parentNode.children[i].classList.remove( 'focus' ); 51 } 52 menuItem.classList.add( 'focus' ); 53 } else { 54 menuItem.classList.remove( 'focus' ); 55 } 56 }; 57 58 for ( var i = 0; i < parentLink.length; ++i ) { 59 parentLink[i].addEventListener( 'touchstart', touchStartFn, false ) 60 } 61 } 62 } 63 64 fixMenuTouchTaps( container ); 65} )(); 66; 67( function() { 68 var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, 69 is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, 70 is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; 71 72 if ( ( is_webkit || is_opera || is_ie ) && 'undefined' !== typeof( document.getElementById ) ) { 73 var eventMethod = ( window.addEventListener ) ? 'addEventListener' : 'attachEvent'; 74 window[ eventMethod ]( 'hashchange', function() { 75 var element = document.getElementById( location.hash.substring( 1 ) ); 76 77 if ( element ) { 78 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) 79 element.tabIndex = -1; 80 81 element.focus(); 82 } 83 }, false ); 84 } 85})(); 86; 87( function( $ ) { 88 89 // Focus styles for menus. 90 $( '.main-navigation' ).find( 'a' ).on( 'focus.sela blur.sela', function() { 91 $( this ).parents().toggleClass( 'focus' ); 92 } ); 93 94 // Additional class for posts with thumbnails 95 function addHentryClass() { 96 $( '.hentry + .has-post-thumbnail' ).prev().addClass( 'has-post-thumbnail-prev' ); 97 } 98 99 $( document.body ).on( 'post-load', addHentryClass ); 100 101 addHentryClass(); 102 103} )( jQuery ); 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.