1/** 2 * Theme functions file 3 * 4 * Contains handlers for navigation, accessibility, header sizing 5 * footer widgets and Featured Content slider 6 * 7 */ 8( function( $ ) { 9 $('#mobile-button, #mobile_menu .fa-times').click(function(e) { 10 e.preventDefault(); 11 $('body').toggleClass('mm-open'); 12 }); 13 $('#mobile_menu .menu > .menu-item-has-children > a').click(function(e) { 14 e.preventDefault(); 15 16 $(this).toggleClass('open'); 17 }); 18 19 var body = $( 'body' ), 20 _window = $( window ); 21 22 // Enable menu toggle for small screens. 23 ( function() { 24 var nav = $( '#primary-navigation' ), button, menu; 25 if ( ! nav ) { 26 return; 27 } 28 button = nav.find( '.menu-toggle' ); 29 if ( ! button ) { 30 return; 31 } 32 33 // Hide button if menu is missing or empty. 34 menu = nav.find( '.nav-menu' ); 35 if ( ! menu || ! menu.children().length ) { 36 button.hide(); 37 return; 38 } 39 $( '.menu-toggle' ).on( 'click.twentyfourteen', function() { 40 nav.toggleClass( 'toggled-on' ); 41 } ); 42 } )(); 43 44 /* 45 * Makes "skip to content" link work correctly in IE9 and Chrome for better 46 * accessibility. 47 * 48 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ 49 */ 50 _window.on( 'hashchange.twentyfourteen', function() { 51 var element = document.getElementById( location.hash.substring( 1 ) ); 52 53 if ( element ) { 54 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) { 55 element.tabIndex = -1; 56 } 57 element.focus(); 58 59 // Repositions the window on jump-to-anchor to account for header height. 60 window.scrollBy( 0, -80 ); 61 } 62 } ); 63 64 $( function() { 65 // Search toggle. 66 $( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) { 67 var that = $( this ), 68 wrapper = $( '.search-box-wrapper' ); 69 70 that.toggleClass( 'active' ); 71 wrapper.toggleClass( 'hide' ); 72 if ( that.is( '.active' ) || $( '.search-toggle .screen-reader-text' )[0] === event.target ) { 73 wrapper.find( '.search-field' ).focus(); 74 } 75 } ); 76 77 /* 78 * Fixed header for large screen. 79 * If the header becomes more than 48px tall, unfix the header. 80 * 81 * The callback on the scroll event is only added if there is a header 82 * image and we are not on mobile. 83 */ 84 if ( _window.width() > 781 ) { 85 var mastheadHeight = $( '#masthead' ).height(), 86 toolbarOffset, mastheadOffset; 87 88 if ( mastheadHeight > 48 ) { 89 body.removeClass( 'masthead-fixed' ); 90 } 91 if ( body.is( '.header-image' ) ) { 92 toolbarOffset = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0; 93 mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset; 94 95 _window.on( 'scroll.twentyfourteen', function() { 96 if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) { 97 body.addClass( 'masthead-fixed' ); 98 } else { 99 body.removeClass( 'masthead-fixed' ); 100 } 101 } ); 102 } 103 } 104 105 // Focus styles for menus. 106 $( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', 107 function() { 108 $( this ).parents().toggleClass( 'focus' ); 109 } ); 110 } ); 111 112 _window.load( function() { 113 // Arrange footer widgets vertically. 114 if ( $.isFunction( $.fn.masonry ) ) { 115 $( '#footer-sidebar' ).masonry( { 116 itemSelector: '.widget', 117 columnWidth: function( containerWidth ) { 118 return containerWidth / 4; 119 }, 120 gutterWidth: 0, 121 isResizable: true, 122 isRTL: $( 'body' ).is( '.rtl' ) 123 } ); 124 } 125 126 // Initialize Featured Content slider. 127 if ( body.is( '.slider' ) ) { 128 $( '.featured-content' ).featuredslider( { 129 selector: '.featured-content-inner > article', 130 controlsContainer: '.featured-content' 131 } ); 132 } 133 } ); 134} )( 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.