1// @codekit-prepend "external/js-cookie.min.js" quiet; 2 3 4// @prepros-prepend 'external/js-cookie.min.js'; 5 6/* _helper.js */ 7 8$(document).ready(function () { 9 // var jQuery = $; 10 11 // ================================ 12 // Setup Objects and Selectors 13 // ================================ 14 15 var INIT = INIT || {}, 16 17 // Global 18 19 SIDECAR = SIDECAR || {}, 20 STICKY_NAV = STICKY_NAV || {}; 21 22 23 24 // ================================ 25 // Initiation of all Functions 26 // ================================ 27 28 INIT = { 29 30 init: function () { 31 32 // Initialize Global Objects 33 SIDECAR.init(); 34 STICKY_NAV.init(); 35 } 36 37 }; 38 39 // ================================ 40 // Sidecar 41 // ================================ 42 43 SIDECAR = { 44 init: function () { 45 // this.localStorage(); 46 // this.localStorageBuild(); 47 this.mobileMenu(); 48 }, 49 50 localStorage: function () { 51 52 // setting up the local storage 53 if (localStorage.getItem('recentPagesVisited')) { 54 // console.log('there is something here. adding to it.') 55 var pagesArray = JSON.parse(localStorage.getItem('recentPagesVisited')); 56 if (pagesArray.length === 4) { 57 // console.log('is too many, pushing some out of recent') 58 pagesArray.shift(); 59 } 60 pagesArray.push({ 61 'title': document.title, 62 'url': window.location.href, 63 'description': document.querySelector('meta[name="description"]').content 64 }) 65 localStorage.setItem('recentPagesVisited', JSON.stringify(pagesArray)); 66 } else { 67 // console.log('there is nothing here!!'); 68 var pagesArray = [{ 69 'title': document.title, 70 'url': window.location.href, 71 'description': document.querySelector('meta[name="description"]').content 72 }]; 73 74 localStorage.setItem('recentPagesVisited', JSON.stringify(pagesArray)); 75 } 76 77 78 }, 79 localStorageBuild: function () { 80 81 // getting the local storage 82 83 var getPages = localStorage.getItem('recentPagesVisited'); 84 85 for (var i = 0; i < JSON.parse(getPages).length; i++) { 86 var page = JSON.parse(getPages)[i], 87 truncDesc = page.description.substring(0, 100) + '...', 88 truncUrl = page.url.substring(29); 89 $('#visited-sites').prepend(` 90 <li> 91 <a href="${page.url}"> 92 <div class="page-title">${page.title}</div> 93 <div class="page-url">${truncUrl}</div> 94 <div class="page-description">${truncDesc}</div> 95 </a> 96 </li> 97 `); 98 } 99 100 }, 101 megaMenuActive: function () { 102 103 if (window.matchMedia('(min-width: 768px)').matches) { 104 // tier 1 click 105 $('#fixed-header #menu > li.has-children > a').on('click', function (e) { 106 // console.log('is clicked'); 107 108 var clickedLink = $(this).attr('href').substring(1); 109 110 e.preventDefault(); 111 112 // empty anything that could be in the mega menu 113 $('#megamenu ul.no-children-list, #megamenu ul.children-list').empty(); 114 115 // add the header nav active states 116 // if no other t1s are active 117 if (!$('#fixed-header #menu > li.has-children.active').length) { 118 $(this).parent('li').addClass('active'); 119 $('#megamenu').addClass('active'); 120 } 121 // if another t1 is active 122 else if ($('#fixed-header #menu > li.has-children').length && !$(this).parent('li').hasClass('active')) { 123 $('#fixed-header #menu > li.active').removeClass('active'); 124 $(this).parent('li').addClass('active'); 125 $('#megamenu').addClass('active'); 126 127 } 128 // if this is already active 129 else if ($(this).parent('li').hasClass('active')) { 130 $(this).parent().removeClass('active'); 131 $('#megamenu').removeClass('active'); 132 } 133 134 // populate the megamenu 135 136 $('#megamenu .nav-children').find('ul.' + clickedLink + ' > li:not(.has-children)').clone().appendTo('#megamenu .active-children ul.no-children-list'); 137 $('#megamenu .nav-children').find('ul.' + clickedLink + ' > li.has-children').clone().appendTo('#megamenu .active-children ul.children-list'); 138 139 140 }); 141 } 142 143 }, 144 megaMenuClose: function () { 145 $('#close-menu').on('click', function () { 146 $('#megamenu').removeClass('active'); 147 $('ul#menu > li.active').removeClass('active'); 148 }) 149 150 }, 151 mobileMenu: function () { 152 $('#fixed-header #menu li a.expand-btn').on('click', function (e) { 153 e.preventDefault(); 154 $(this).parent('li').toggleClass('active'); 155 }) 156 } 157 }; 158 159 // ================================ 160 // Sticky Nav 161 // ================================ 162 163 STICKY_NAV = { 164 init: function () { 165 this.headerSearch(); 166 }, 167 headerSearch: function () { 168 $('.icon-search').on('click', function () { 169 $('#fixed-header').toggleClass('search-active'); 170 if ($('#fixed-header.search-active').length) { 171 $('#headerSearch').focus(); 172 } else { 173 $('#headerSearch').blur(); 174 } 175 }) 176 $(function () { 177 $('#searchBtn').click(function () { 178 window.location.href = '/search-results?q=' + $('#headerSearch').val(); 179 }) 180 }); 181 $('#headerSearch').on('keydown', function (e) { 182 if (e.which == 13) { 183 e.preventDefault(); 184 window.location.href = '/search-results?q=' + $('#headerSearch').val(); 185 } 186 }); 187 } 188 189 190 }; 191 192 193 // ================================ 194 // Smooth scrolling anchors 195 // ================================ 196 197 // Initialize 198 INIT.init(); 199 200 201}); // end doc ready 202const customDownload = document.querySelector('a[href*="DownloadReport"]'); 203if (customDownload) { 204 customDownload.setAttribute('id', 'formPopupToggle') 205} 206// popup form 207const toggle = document.querySelectorAll('#formPopupToggle'); 208let toggleAll = ['#formPopup', '#formPopupOverlay']; 209toggle.forEach((btn) => { 210 btn.addEventListener('click', (e) => { 211 e.preventDefault(); 212 toggleAll.forEach((el) => { 213 document.querySelector(el).classList.toggle('active') 214 }) 215 }) 216})
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.