1/*! 2 * Immediately Invoked Function Expression Boilerplate 3 * (c) 2019 Chris Ferdinandi, MIT License, https://gomakethings.com 4 */ 5;(function () { 6 7 'use strict'; 8 9 /** 10 * Analytics 11 */ 12 13 const initializeAnalytics = function() { 14 gtag('js', new Date()); 15 gtag('config', 'G-VT2NCZ3G4Z'); // or gtag('config', 'G-XXXXXXXXXX'); 16 }; 17 18 const setCookie = function(name,value,days) { 19 var expires = ""; 20 if (days) { 21 var date = new Date(); 22 date.setTime(date.getTime() + (days*24*60*60*1000)); 23 expires = "; expires=" + date.toUTCString(); 24 } 25 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 26 }; 27 28 const getCookie = function(name) { 29 var nameEQ = name + "="; 30 var ca = document.cookie.split(';'); 31 for(var i=0;i < ca.length;i++) { 32 var c = ca[i]; 33 while (c.charAt(0)==' ') c = c.substring(1,c.length); 34 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 35 } 36 return null; 37 }; 38 39 const eraseCookie = function(name) { 40 document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 41 }; 42 43 const toggler = document.querySelector('.nav__toggle'); 44 if (toggler) { 45 toggler.addEventListener('click', function () { 46 const nav = document.querySelector('.nav') 47 nav.classList.toggle('nav--is-open'); 48 document.body.classList.toggle('navigation-is-open'); 49 }); 50 51 const closeBtn = document.querySelector('.nav__close-full'); 52 closeBtn.addEventListener('click', function () { 53 const nav = document.querySelector('.nav') 54 nav.classList.toggle('nav--is-open'); 55 document.body.classList.toggle('navigation-is-open'); 56 }); 57 } 58 59 60 /** 61 * Tables 62 */ 63 const createTableWrapper = function() { 64 const wpTables = document.querySelectorAll('.is-style-timetable-accordion'); 65 wpTables.forEach(function(table) { 66 const wrapper = document.createElement('div'); 67 wrapper.classList.add('wp-block-table-outer-container'); 68 table.parentNode.insertBefore(wrapper, table); 69 wrapper.appendChild(table); 70 }); 71 } 72 createTableWrapper(); 73 74 75 const tables = document.querySelectorAll('.is-style-timetable-accordion'); 76 tables.forEach(function(table, index) { 77 table.setAttribute('id', `table-accordion-${index}`); 78 const thead = table.querySelector('thead'); 79 thead.addEventListener('click', function () { 80 table.classList.toggle('is-style-timetable-accordion--open'); 81 82 if (table.classList.contains('is-style-timetable-accordion--open')) { 83 button.setAttribute('aria-expanded', 'true'); 84 button.classList.add('wp-block-table__th-button--open'); 85 } else { 86 button.setAttribute('aria-expanded', 'false'); 87 button.classList.remove('wp-block-table__th-button--open'); 88 } 89 }); 90 91 92 const button = document.createElement('button'); 93 button.setAttribute('type', 'button'); 94 button.classList.add('wp-block-table__th-button'); 95 button.setAttribute('aria-label', 'Toggle table'); 96 button.setAttribute('aria-expanded', 'false'); 97 button.setAttribute('aria-controls', `table-accordion-${index}`); 98 99 button.addEventListener('click', function (e) { 100 e.stopPropagation(); 101 table.classList.toggle('is-style-timetable-accordion--open'); 102 103 if (table.classList.contains('is-style-timetable-accordion--open')) { 104 button.setAttribute('aria-expanded', 'true'); 105 button.classList.add('wp-block-table__th-button--open'); 106 } else { 107 button.setAttribute('aria-expanded', 'false'); 108 button.classList.remove('wp-block-table__th-button--open'); 109 } 110 }); 111 table.parentNode.insertBefore(button, table.parentNode.firstChild); 112 //table.insertBefore(button, table.parentNode); 113 }); 114 115 116 /** 117 * Table scroll detection 118 */ 119 120 const checkTableScroll = function() { 121 const wpTables = document.querySelectorAll('.wp-block-table'); 122 123 wpTables.forEach(function(table) { 124 125 // Check if the table has horizontal scroll 126 const hasScroll = table.scrollWidth > table.clientWidth; 127 128 if (hasScroll) { 129 table.classList.add('wp-block-table--is-scroller'); 130 } else { 131 table.classList.remove('wp-block-table--is-scroller'); 132 } 133 }); 134 }; 135 136 // Check on page load 137 checkTableScroll(); 138 139 // Check on window resize 140 window.addEventListener('resize', checkTableScroll); 141 142 // Check when new content is loaded (for dynamic content) 143 const observer = new MutationObserver(function(mutations) { 144 let shouldCheck = false;
145 146 mutations.forEach(function(mutation) { 147 if (mutation.type === 'childList') { 148 // Check if any added nodes contain wp-block-table elements 149 mutation.addedNodes.forEach(function(node) { 150 if (node.nodeType === Node.ELEMENT_NODE) { 151 if (node.classList && node.classList.contains('wp-block-table')) { 152 shouldCheck = true; 153 } else if (node.querySelector && node.querySelector('.wp-block-table')) { 154 shouldCheck = true; 155 } 156 } 157 }); 158 } 159 }); 160 161 if (shouldCheck) { 162 // Use setTimeout to ensure DOM is fully updated 163 setTimeout(checkTableScroll, 100); 164 } 165 }); 166 167 // Start observing 168 observer.observe(document.body, { 169 childList: true, 170 subtree: true 171 }); 172 173 174 /** 175 * Cookie consent 176 */ 177 const cookieConsent = document.querySelector('.cookie-consent'); 178 if (cookieConsent) { 179 if(!getCookie('cookieConsent')) { 180 cookieConsent.classList.add('cookie-consent--visible'); 181 } 182 183 document.getElementById('cookie-consent-all').addEventListener('click', function(e) { 184 e.stopPropagation(); 185 setCookie('cookieConsent', 'all', 365); 186 cookieConsent.classList.remove('cookie-consent--visible'); 187 }); 188 189 document.getElementById('cookie-consent-essential').addEventListener('click', function(e) { 190 e.stopPropagation(); 191 const settings = document.querySelector('.cookie-consent__settings'); 192 settings.classList.toggle('cookie-consent__settings--visible'); 193 //setCookie('cookieConsent', 'essential', 365); 194 //cookieConsent.classList.remove('cookie-consent--visible'); 195 }); 196 197 document.getElementById('save-cookie-settings').addEventListener('click', function(e) { 198 e.stopPropagation(); 199 if (document.getElementById('cookie-consent-analytics').checked === true) { 200 setCookie('cookieConsent', 'all', 365); 201 cookieConsent.classList.remove('cookie-consent--visible'); 202 } else { 203 setCookie('cookieConsent', 'essential', 365); 204 cookieConsent.classList.remove('cookie-consent--visible'); 205 } 206 }); 207 208 if (document.getElementById('cookie-consent-analytics') && getCookie('cookieConsent') === 'all') { 209 document.getElementById('cookie-consent-analytics').checked = true; 210 } 211 } 212 213 /** 214 * Open cookie consent 215 */ 216 if (document.querySelector('a[href="#cookie-consent"]')) { 217 document.querySelector('a[href="#cookie-consent"]').addEventListener('click', function(e) { 218 e.preventDefault(); 219 if (cookieConsent) { 220 cookieConsent.classList.add('cookie-consent--visible'); 221 } 222 }); 223 } 224 225 /** 226 * Cookie consent all 227 */ 228 229 if (cookieConsent && getCookie('cookieConsent') === 'all') { 230 initializeAnalytics(); 231 } 232 233 /** 234 * Important message 235 */ 236 /*const importantMessages = document.querySelectorAll('button[data-message-id]'); 237 importantMessages.forEach(function(message) { 238 message.addEventListener('click', function(e) { 239 e.preventDefault(); 240 setCookie(`important-message-${message.getAttribute('data-message-id')}`, 'hidden', 30); 241 242 const messageElement = document.querySelector(`[data-message-id="${message.getAttribute('data-message-id')}"]`); 243 /*messageElement.style.display = 'none'; 244 console.log(messageElement); 245 }); 246 });*/ 247 248})();
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.