1(function() { 2 3 /** 4 * hasClass utility 5 */ 6 function hasClass(el, cls) { 7 if ( el.classList.contains( cls ) ){ 8 return true; 9 } 10 return false; 11 } 12 13 /** 14 * Throttle function 15 * Underscore.js 1.10.2 https://underscorejs.org 16 * (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 17 * Underscore may be freely distributed under the MIT license. 18 */ 19 function throttle(func, wait, options) { 20 var now = Date.now || function() { 21 return new Date().getTime(); 22 }; 23 var timeout, context, args, result; 24 var previous = 0; 25 if (!options) options = {}; 26 var later = function() { 27 previous = options.leading === false ? 0 : now(); 28 timeout = null; 29 result = func.apply(context, args); 30 if (!timeout) context = args = null; 31 }; 32 var throttled = function() { 33 var _now = now(); 34 if (!previous && options.leading === false) previous = _now; 35 var remaining = wait - (_now - previous); 36 context = this; 37 args = arguments; 38 if (remaining <= 0 || remaining > wait) { 39 if (timeout) { 40 clearTimeout(timeout); 41 timeout = null; 42 } 43 previous = _now; 44 result = func.apply(context, args); 45 if (!timeout) context = args = null; 46 } else if (!timeout && options.trailing !== false) { 47 timeout = setTimeout(later, remaining); 48 } 49 return result; 50 }; 51 return throttled; 52 } 53 54 /** 55 * Runs the burger menu and sticky header functions as soon as the document is `ready` 56 */ 57 document.addEventListener( 'DOMContentLoaded', function() { 58 var header = document.querySelector( '#masthead' ); 59 if ( header != null && hasClass( document.body, 'tw-header-sticky' ) ) { 60 if ( hasClass( document.body, 'tw-header-light' ) || hasClass( document.body, 'page-template-tw-header-transparent' ) ) { 61 var scrollTop = window.pageYOffset; 62 if ( scrollTop > 30 ) { 63 document.body.classList.add( 'tw-header-opaque' ); 64 } 65 window.addEventListener( 'scroll', throttle( function() { 66 var scrollTop = window.pageYOffset; 67 if ( scrollTop > 30 ) { 68 document.body.classList.add( 'tw-header-opaque' ); 69 } else { 70 document.body.classList.remove( 'tw-header-opaque' ); 71 } 72 }, 100 ) ); 73 } 74 } 75 }); 76})();
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.