1/** 2 * File navigation.js. 3 * 4 * Handles toggling the navigation menu for small screens and enables TAB key 5 * navigation support for dropdown menus. 6 */ 7( function() { 8 var container, button, menu, links, subMenus, i, len; 9 10 container = document.getElementById( 'site-navigation' ); 11 if ( ! container ) { 12 return; 13 } 14 15 button = container.getElementsByTagName( 'button' )[0]; 16 if ( 'undefined' === typeof button ) { 17 return; 18 } 19 20 menu = container.getElementsByTagName( 'ul' )[0]; 21 22 // Hide menu toggle button if menu is empty and return early. 23 if ( 'undefined' === typeof menu ) { 24 button.style.display = 'none'; 25 return; 26 } 27 28 menu.setAttribute( 'aria-expanded', 'false' ); 29 if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { 30 menu.className += ' nav-menu'; 31 } 32 33 button.onclick = function() { 34 if ( -1 !== container.className.indexOf( 'toggled' ) ) { 35 container.className = container.className.replace( ' toggled', '' ); 36 button.setAttribute( 'aria-expanded', 'false' ); 37 menu.setAttribute( 'aria-expanded', 'false' ); 38 } else { 39 container.className += ' toggled'; 40 button.setAttribute( 'aria-expanded', 'true' ); 41 menu.setAttribute( 'aria-expanded', 'true' ); 42 } 43 }; 44 45 // Get all the link elements within the menu. 46 links = menu.getElementsByTagName( 'a' ); 47 subMenus = menu.getElementsByTagName( 'ul' ); 48 49 // Set menu items with submenus to aria-haspopup="true". 50 for ( i = 0, len = subMenus.length; i < len; i++ ) { 51 subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' ); 52 } 53 54 // Each time a menu link is focused or blurred, toggle focus. 55 for ( i = 0, len = links.length; i < len; i++ ) { 56 links[i].addEventListener( 'focus', toggleFocus, true ); 57 links[i].addEventListener( 'blur', toggleFocus, true ); 58 } 59 60 /** 61 * Sets or removes .focus class on an element. 62 */ 63 function toggleFocus() { 64 var self = this; 65 66 // Move up through the ancestors of the current link until we hit .nav-menu. 67 while ( -1 === self.className.indexOf( 'nav-menu' ) ) { 68 69 // On li elements toggle the class .focus. 70 if ( 'li' === self.tagName.toLowerCase() ) { 71 if ( -1 !== self.className.indexOf( 'focus' ) ) { 72 self.className = self.className.replace( ' focus', '' ); 73 } else { 74 self.className += ' focus'; 75 } 76 } 77 78 self = self.parentElement; 79 } 80 } 81 82// Fix child menus for touch devices. 83 function fixMenuTouchTaps( container ) { 84 var touchStartFn, 85 parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ); 86 87 if ( 'ontouchstart' in window ) { 88 touchStartFn = function( e ) { 89 var menuItem = this.parentNode; 90 91 if ( ! menuItem.classList.contains( 'focus' ) ) { 92 e.preventDefault(); 93 for( var i = 0; i < menuItem.parentNode.children.length; ++i ) { 94 if ( menuItem === menuItem.parentNode.children[i] ) { 95 continue; 96 } 97 menuItem.parentNode.children[i].classList.remove( 'focus' ); 98 } 99 menuItem.classList.add( 'focus' ); 100 } else { 101 menuItem.classList.remove( 'focus' ); 102 } 103 }; 104 105 for ( var i = 0; i < parentLink.length; ++i ) { 106 parentLink[i].addEventListener( 'touchstart', touchStartFn, false ) 107 } 108 } 109 } 110 111 fixMenuTouchTaps( container ); 112} )(); 113; 114(function ($) { 115 var $header = $('.header-top:first'), 116 $headerHeight = $('.header-top').innerHeight(), 117 $headerOffset = $('.custom-header').innerHeight(), 118 $headerHiddenClass = 'site-header-hidden', 119 $headerFixedClass = 'site-header-fixed', 120 $navigation = $('.main-navigation'), 121 $navMenuItem = $navigation.find('.menu-item'), 122 navigationHeight, 123 navigationOuterHeight, 124 navPadding, 125 navMenuItemHeight, 126 idealNavHeight, 127 navIsNotTooTall; 128 129 // adjust header margin based on height of menu 130 function adjustHeaderMargin() { 131 // check to see if on mobile by checking menu-toggle display 132 if ('none' === $('.menu-toggle').css('display')) { 133 // Don't define this 'til we're using it, it may change 134 $headerHeight = $('.header-top').innerHeight(); 135 136 // if yes, we want to bump the custom header down a bit, so the menu doesn't cut it off 137 $('.custom-header-image').css('margin-top', $headerHeight); 138 } 139 } 140 141 // Make sure the nav isn't taller than two rows 142 navigationHeight = $navigation.height();
143 navMenuItemHeight = $navMenuItem.outerHeight() * 3; 144 idealNavHeight = navMenuItemHeight; 145 navIsNotTooTall = navigationHeight <= idealNavHeight; 146 147 //we add the scroll class to the navs 148 function adjustScrollClass() { 149 // Make sure we're not on a mobile screen 150 if ('none' === $('.menu-toggle').css('display')) { 151 if ( 152 $(window).scrollTop() <= $headerOffset && 153 $header.hasClass($headerFixedClass) 154 ) { 155 // accounts for empty or removed custom header image 156 if (0 !== $headerOffset) { 157 $header.removeClass($headerFixedClass); 158 $header.addClass($headerHiddenClass); 159 } 160 } else if ($(window).scrollTop() >= $headerOffset) { 161 //If the scroll is more than the custom header 162 163 // Make sure the menu is not too tall 164 if (navIsNotTooTall || navMenuItemHeight == 0) { 165 // Don't define this 'til we're using it, it may change 166 $headerHeight = $('.header-top').innerHeight(true); 167 168 // If not, fix that header! 169 $header.addClass($headerFixedClass); 170 $header.removeClass($headerHiddenClass); 171 $('.custom-header').css('margin-top', $headerHeight); 172 } 173 } else { 174 //If not we remove it 175 $header.removeClass($headerFixedClass); 176 $header.removeClass($headerHiddenClass); 177 $('.custom-header').css('margin-top', 'auto'); 178 } 179 } 180 } 181 182 // Check to see if iOS device 183 // iOS devices make a mess of background-attachment: fixed and background-size: cover 184 185 function checkiOS() { 186 return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 187 } 188 189 /* 190 * Test if background-attachment: fixed is supported. 191 * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed 192 */ 193 function supportsFixedBackground() { 194 var el = document.createElement('div'), 195 isSupported; 196 197 try { 198 if (!('backgroundAttachment' in el.style) || checkiOS()) { 199 return false; 200 } 201 el.style.backgroundAttachment = 'fixed'; 202 isSupported = 'fixed' === el.style.backgroundAttachment; 203 return isSupported; 204 } catch (e) { 205 return false; 206 } 207 } 208 209 // Let's fire some JavaScript! 210 $(document).ready(function () { 211 // On load, we want to adjust the header margin 212 adjustHeaderMargin(); 213 adjustScrollClass(); 214 215 // We also want to check the device, and add a class if not iOS: 216 if (false === supportsFixedBackground()) { 217 document.documentElement.className += ' no-background-fixed'; 218 } 219 }); 220 221 // On scroll, we want to stick/unstick the header 222 $(window).on('scroll', function () { 223 adjustScrollClass(); 224 }); 225 226 // we also want to do the same on window rezize 227 $(window).on('resize', function () { 228 setTimeout(adjustHeaderMargin, 500); 229 }); 230 231 // Use mutant observer to check when .wf-active is added to theme for Custom Fonts. 232 // That way we can make sure the header is the correct height when it happens. 233 var MutationObserver = 234 window.MutationObserver || 235 window.WebKitMutationObserver || 236 window.MozMutationObserver; 237 238 $.fn.attrchange = function (callback) { 239 if (MutationObserver) { 240 var options = { 241 subtree: false, 242 attributes: true, 243 }; 244 245 var observer = new MutationObserver(function (mutations) { 246 mutations.forEach(function (e) { 247 callback.call(e.target, e.attributeName); 248 }); 249 }); 250 251 return this.each(function () { 252 observer.observe(this, options); 253 }); 254 } 255 }; 256 257 $('html').attrchange(function (attrName) { 258 if (attrName == 'class' && $('html').hasClass('wf-active')) { 259 adjustHeaderMargin(); 260 } 261 }); 262})(jQuery); 263; 264/** 265 * File skip-link-focus-fix.js. 266 * 267 * Helps with accessibility for keyboard only users. 268 * 269 * Learn more: https://git.io/vWdr2 270 */ 271( function() { 272 var isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, 273 isOpera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, 274 isIe = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; 275 276 if ( ( isWebkit || isOpera || isIe ) && document.getElementById && window.addEventListener ) { 277 window.addEventListener( 'hashchange', function() { 278 var id = location.hash.substring( 1 ), 279 element; 280 281 if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { 282 return; 283 } 284 285 element = document.getElementById( id ); 286 287 if ( element ) { 288 if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { 289 element.tabIndex = -1; 290 } 291 292 element.focus(); 293 } 294 }, false ); 295 } 296})(); 297;
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.