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, i, len; 9 10 container = document.getElementById( 'site-navigation' ); 11 if ( ! container ) { 12 return; 13 } 14 15 button = document.getElementById( 'primary-menu-button' ); 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 48 // Each time a menu link is focused or blurred, toggle focus. 49 for ( i = 0, len = links.length; i < len; i++ ) { 50 links[i].addEventListener( 'focus', toggleFocus, true ); 51 links[i].addEventListener( 'blur', toggleFocus, true ); 52 } 53 54 /** 55 * Sets or removes .focus class on an element. 56 */ 57 function toggleFocus() { 58 var self = this; 59 60 // Move up through the ancestors of the current link until we hit .nav-menu. 61 while ( -1 === self.className.indexOf( 'nav-menu' ) ) { 62 63 // On li elements toggle the class .focus. 64 if ( 'li' === self.tagName.toLowerCase() ) { 65 if ( -1 !== self.className.indexOf( 'focus' ) ) { 66 self.className = self.className.replace( ' focus', '' ); 67 } else { 68 self.className += ' focus'; 69 } 70 } 71 72 self = self.parentElement; 73 } 74 } 75 76 /** 77 * Toggles `focus` class to allow submenu access on tablets. 78 */ 79 ( function( container ) { 80 var touchStartFn, i, 81 parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ); 82 83 if ( 'ontouchstart' in window ) { 84 touchStartFn = function( e ) { 85 var menuItem = this.parentNode, i; 86 87 if ( ! menuItem.classList.contains( 'focus' ) ) { 88 e.preventDefault(); 89 for ( i = 0; i < menuItem.parentNode.children.length; ++i ) { 90 if ( menuItem === menuItem.parentNode.children[i] ) { 91 continue; 92 } 93 menuItem.parentNode.children[i].classList.remove( 'focus' ); 94 } 95 menuItem.classList.add( 'focus' ); 96 } else { 97 menuItem.classList.remove( 'focus' ); 98 } 99 }; 100 101 for ( i = 0; i < parentLink.length; ++i ) { 102 parentLink[i].addEventListener( 'touchstart', touchStartFn, false ); 103 } 104 } 105 }( container ) ); 106} )(); 107; 108( function () { 109 // Helper matches function (not a polyfill), compatible with IE 11.
110 function matches( el, sel ) { 111 if ( Element.prototype.matches ) { 112 return el.matches( sel ); 113 } 114 115 if ( Element.prototype.msMatchesSelector ) { 116 return el.msMatchesSelector( sel ); 117 } 118 } 119 120 // Helper closest parent node function (not a polyfill) based on 121 // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill 122 function closest( el, sel ) { 123 if ( el.closest ) { 124 return el.closest( sel ); 125 } 126 127 var current = el; 128 129 do { 130 if ( matches( el, sel ) ) { 131 return current; 132 } 133 current = current.parentElement || current.parentNode; 134 } while ( current !== null && current.nodeType === 1 ); 135 136 return null; 137 } 138 139 function emitResizeEvent() { 140 if ( typeof( Event ) === 'function' ) { 141 window.dispatchEvent( new Event( 'resize' ) ); 142 } else { 143 var event = window.document.createEvent( 'UIEvents' ); 144 event.initUIEvent( 'resize', true, false, window, 0 ); 145 window.dispatchEvent( event ); 146 } 147 } 148 149 function updatePage() { 150 galleryWrapper(); 151 outdentMedia(); 152 } 153 154 // Wrap tiled galleries so we can outdent them 155 function galleryWrapper() { 156 var galleries = document.querySelectorAll( '.entry-content .tiled-gallery' ); 157 var shouldOutdent = false; 158 159 for( var i = 0; i < galleries.length; i++ ) { 160 var gallery = galleries[ i ]; 161 var parent = gallery.parentNode; 162 163 // If this tiled gallery has not yet been wrapped, add a wrapper. 164 if ( parent && ! parent.classList.contains( 'tiled-gallery-wrapper' ) ) { 165 var div = document.createElement( 'div' ); 166 parent.insertBefore( div, gallery ); 167 parent.removeChild( gallery ); 168 div.appendChild( gallery ); 169 div.classList.add( 'tiled-gallery-wrapper' ); 170 171 // Outdent in the next event loop. 172 shouldOutdent = true; 173 } 174 } 175 176 if ( shouldOutdent ) { 177 emitResizeEvent(); 178 } 179 } 180 181 // Add an extra class to large images and videos to outdent them. 182 function outdentMedia() { 183 var images = document.querySelectorAll( '.entry-content img, .post-image-link img' ); 184 185 for ( var i = 0; i < images.length; i++ ) { 186 outdentImage( images[ i ] ); 187 } 188 189 var wrappers = document.querySelectorAll( '.entry-content .jetpack-video-wrapper' ); 190 191 for ( var j = 0; j < wrappers.length; j++ ) { 192 var wrapper = wrappers[ j ]; 193 var firstChild = wrapper.querySelector( ':first-child' ); 194 195 if ( firstChild && firstChild.offsetWidth >= 1100 ) { 196 wrapper.classList.add( 'caption-big' ); 197 } 198 } 199 } 200 201 // Process an individual image for resizing. 202 function outdentImage( img ) { 203 // Is the original size in the DOM? 204 var widthStr = img.getAttribute( 'width' ) || img.dataset.measuredWidth; 205 if ( widthStr ) { 206 var width = Number.parseInt( widthStr, 10 ); 207 if ( width > 0 ) { 208 resizeImage( img, width ); 209 } 210 return; 211 } 212 213 // If not, we'll need to wait until the image loads, 214 // to measure and resize it. 215 if ( img.complete ) { 216 // Image is already loaded. 217 measureAndResizeImage( img ); 218 } else { 219 // Wait for the image to load before resizing it. 220 img.addEventListener( 221 'load', 222 function () { 223 measureAndResizeImage( img ); 224 } 225 ); 226 } 227 } 228 229 // Measure an image and resize it. 230 function measureAndResizeImage( img ) { 231 // Prefer the current source; in most cases, that should give us 232 // the image from cache, and we shouldn't have to double fetch. 233 var src = img.currentSrc || img.src; 234 if ( ! src ) { 235 return; 236 } 237 238 var newImg = new Image(); 239 240 newImg.addEventListener( 241 'load', 242 function () { 243 // Store the measured width in the DOM, so we don't need to do 244 // it again for this image. 245 img.dataset.measuredWidth = newImg.width; 246 resizeImage( img, newImg.width ); 247 } 248 ); 249 250 newImg.src = src; 251 } 252 253 function resizeImage( img, imgWidth ) { 254 var caption = closest( img, 'figure' ); 255 256 if ( imgWidth >= 1100 && 257 ! closest( img, '.tiled-gallery-item-large' ) && 258 ! closest( img, '[class^="wp-block-"]' ) ) { 259 img.classList.add( 'size-big' ); 260 } 261 262 if ( caption && caption.classList.contains( 'wp-caption' ) && imgWidth >= 1100 ) { 263 caption.classList.add( 'size-big' ); 264 } 265 } 266 267 // After DOM is ready. 268 if ( document.readyState !== 'loading' ) { 269 updatePage(); 270 } else { 271 document.addEventListener( 'DOMContentLoaded', updatePage ); 272 } 273 274 // After window is resized or infinite scroll loads new posts 275 window.addEventListener( 'resize', updatePage ); 276 document.body.addEventListener( 'is.post-load', updatePage ); 277 278} )(); 279; 280/** 281 * File skip-link-focus-fix.js. 282 * 283 * Helps with accessibility for keyboard only users. 284 * 285 * Learn more: https://git.io/vWdr2 286 */ 287(function() { 288 var isIe = /(trident|msie)/i.test( navigator.userAgent ); 289 290 if ( isIe && document.getElementById && window.addEventListener ) { 291 window.addEventListener( 'hashchange', function() { 292 var id = location.hash.substring( 1 ), 293 element; 294 295 if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { 296 return; 297 } 298 299 element = document.getElementById( id ); 300 301 if ( element ) { 302 if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { 303 element.tabIndex = -1; 304 } 305 306 element.focus(); 307 } 308 }, false ); 309 } 310})(); 311; 312/** 313 * script-wpcom.js 314 * 315 * Handles toggling of body class name to help WordPress.com custom colors target color changes at different window sizes. 316 * The Custom Colors plugin does not support media queries. 317 */ 318( function() { 319 function checkWidth( init ) { 320 // If browser is resized, check width again 321 if ( window.innerWidth > 992 ) { 322 document.body.classList.add( 'tablet-desktop' ); 323 } 324 else { 325 if ( ! init ) { 326 document.body.classList.remove( 'tablet-desktop' ); 327 } 328 } 329 } 330
331 function init() { 332 checkWidth( true ); 333 window.addEventListener( 'resize', function() { 334 checkWidth( false); 335 } ); 336 } 337 338 // After DOM is ready. 339 if ( document.readyState !== 'loading' ) { 340 init(); 341 } else { 342 document.addEventListener( 'DOMContentLoaded', init ); 343 } 344} )(); 345;
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.