1function docReady(fn) { 2 // see if DOM is already available 3 if (document.readyState === "complete" || document.readyState === "interactive") { 4 // call on next available tick 5 setTimeout(fn, 1); 6 } else { 7 document.addEventListener("DOMContentLoaded", fn); 8 } 9} 10 11 12// on dom ready 13docReady(function(){ 14 15 const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) 16 17 18 // move parent link to end of children list 19 20 const parentMenuItems = document.querySelectorAll('.sn_header_nav_full_wr .sn_header_nav_full_i.menu-item-has-children'); 21 22 if (parentMenuItems.length){ 23 24 parentMenuItems.forEach(function(parentMenuItem){ 25 26 const linkEl = parentMenuItem.querySelector('a'); 27 28 const childMenu = parentMenuItem.querySelector('.sn_header_nav_full_sub_in div.align-items-stretch'); 29 30 const subMenuContainer = parentMenuItem.querySelector('.sn_header_nav_full_sub_in'); 31 32 if (linkEl){ 33 34 // make sure it's not empty 35 const linkHref = linkEl.getAttribute('href'); 36 37 if (linkHref !== "#"){ 38 39 let newMenuItem = document.createElement("div"); 40 41 // get classes from parent 42 newMenuItem.classList = parentMenuItem.classList; 43 44 // remove unnecessary classes 45 newMenuItem.classList.remove('menu-item-has-children','open', 'current-menu-item', 'current_page_item'); 46 47 // add sub classes 48 newMenuItem.classList.add('_sub', '_text_c1', 'menu-item-link-to-parent'); 49 50 let newMenuItemA = document.createElement("a"); 51 let newMenuItemSpan = document.createElement("span"); 52 53 newMenuItemSpan.innerHTML = parentMenuItem.querySelector('span').innerHTML; 54 55 newMenuItemA.setAttribute("href", linkHref); 56 57 newMenuItemA.appendChild(newMenuItemSpan); 58 // newMenuItemA.appendChild(newMenuItemArrow); 59 newMenuItem.appendChild(newMenuItemA); 60 subMenuContainer.insertBefore(newMenuItem,subMenuContainer.firstChild ); 61 62 } 63 } 64 }); 65 } 66 67 68 69 if (vw < 1023){ 70 71 const hasProductsSlider = document.querySelector('.ar-products-slider'); 72 73 if (hasProductsSlider){ 74 // get product slider items 75 const psItems = hasProductsSlider.querySelectorAll('.swiper-slide'); 76 77 // console.log(psItems); 78 79 if (psItems.length){ 80 psItems.forEach(function(psItem){ 81 // find image 82 const psImage = psItem.querySelector('.sn_slider_full_sl_image'); 83 const psContent = psItem.querySelector('.sn_slider_full_sl_content'); 84 const parentDiv = psContent.parentNode; 85 parentDiv.insertBefore(psImage,psContent); 86 }); 87 } 88 } 89 90 // move the pretitle inside the title on certain mobile sliders 91 const hasProductTasteArr = document.querySelectorAll('.ar-product-taste'); 92 93 if (hasProductTasteArr.length){ 94 hasProductTasteArr.forEach(function(hasProductTaste){ 95 96 const preTitle = hasProductTaste.querySelector('.sn_block_teaser_skyscraper_sl .sn_block_teaser_skyscraper_sl_pretitle > span'); 97 const theTitle = hasProductTaste.querySelector('.sn_block_teaser_skyscraper_sl .sn_block_teaser_skyscraper_sl_title'); 98 const spacer = document.createTextNode(" "); 99 100 console.log(preTitle, theTitle); 101 102 if (preTitle && theTitle){ 103 theTitle.insertBefore(spacer, theTitle.firstChild); 104 theTitle.insertBefore(preTitle, theTitle.firstChild); 105 } 106 }); 107 } 108 109 } 110 111 // manage menu items onclick events 112 113 let menuOpenTimer; 114 115 function closeSubmenus(){ 116 const allMenuItems = document.querySelectorAll('.sn_header_nav._full .menu-item-has-children'); 117 allMenuItems.forEach(function(otherMenuItem){ 118 otherMenuItem.classList.remove('open'); 119 }); 120 // clearTimeout(menuOpenTimer); 121 122 } 123 124 document.addEventListener("click",function(el){ 125 const clickedItem = el.target; 126 127 if (!clickedItem.classList.contains('menu-item-has-children')){ 128 129 closeSubmenus(); 130 } 131 132 }); 133 134 135 document.querySelectorAll('.sn_header_nav._full .menu-item-has-children').forEach(function(el){ 136 137 el.addEventListener("click",function(subEl){ 138 139 const menuItem = subEl.target.closest('.menu-item'); 140 141 if (menuItem) { 142 143 if (menuItem.classList.contains('_sub')){ 144 // console.log('has _sub'); 145 return true; 146 } 147 148 subEl.preventDefault(); 149 150 clearTimeout(menuOpenTimer); 151 152 if (!menuItem.classList.contains('open')) { 153 154 closeSubmenus(); // close other menus 155 menuOpenTimer = setTimeout(function(){ 156 menuItem.classList.add('open'); 157 }, 350); 158 159 } else { 160 161 closeSubmenus(); // close other menus 162 163 } 164 } 165 166 }, false) 167 }); 168 169 170 // move CTA on teaser skyscraper sliders 171 172 const sliderCtas = document.querySelectorAll('.sn_block_teaser_skyscraper .swiper-slide .sn_btn'); 173 174 if (sliderCtas.length){ 175 sliderCtas.forEach(function(cta){ 176 const pagination = cta.closest('.sn_block_teaser_skyscraper_sl_wr').querySelector('.sn_swiper_pagination'); 177 const trgtContainer = pagination.parentNode; 178 if (trgtContainer){ 179 trgtContainer.insertBefore(cta,pagination); 180 } 181 }); 182 } 183 184 // move breadcrumbs out of product taste skyscraper sliders 185 186 const ssBreadcrumbs = document.querySelectorAll('.ar-product-taste .sn_block_teaser_skyscraper_full .wpseo_breadcrumb'); 187 188 if (ssBreadcrumbs.length){
189 ssBreadcrumbs.forEach(function(ssBreadcrumb){ 190 const trgtContainer = ssBreadcrumb.closest('.ar-product-taste'); 191 if (trgtContainer){ 192 trgtContainer.insertBefore(ssBreadcrumb,trgtContainer.firstChild); 193 } 194 195 }); 196 } 197 198 // move age gate logo outside of modal main content 199 const ageGateCardLogo = document.querySelector('.sn_age_gate_card_logo'); 200 201 if (ageGateCardLogo){ 202 console.log(ageGateCardLogo); 203 204 const ageGateCardContainer = document.querySelector('.sn_age_gate_card').parentNode; 205 206 if (ageGateCardContainer){ 207 // ageGateCardContainer.insertBefore(ageGateCardLogo,ageGateCardContainer.firstChild); 208 } 209 210 } 211 212 213 // detect scroll down buttons 214 215 const scrollDownBtns = document.querySelectorAll('.vlmk-scrolldown'); 216 217 if (scrollDownBtns.length){ 218 scrollDownBtns.forEach(function(scrollDownBtn){ 219 220 scrollDownBtn.addEventListener("click",function(e){ 221 222 e.preventDefault(); 223 224 const trgt = scrollDownBtn.closest('.sn_block').nextElementSibling; 225 226 scroll({ 227 top: trgt.offsetTop, 228 behavior: "smooth" 229 }); 230 231 console.log(trgt); 232 233 }); 234 }); 235 } 236 237 238 // detect scroll direction 239 240 var prevScroll = 0; 241 242 window.addEventListener("scroll", function(){ 243 var curScroll = window.pageYOffset || document.documentElement.scrollTop; 244 245 /* 246 if (curScroll > 40){ 247 document.body.classList.add('compact-header'); 248 } else { 249 document.body.classList.remove('compact-header'); 250 } 251 */ 252 253 var disableSnap = false; 254 //disableSnap = true; 255 256 // disable scroll snap for specific pages 257 if ( document.body.classList.contains('page-template-tpl-disclaimer') || 258 document.body.classList.contains('ar-parent-cocktails') ){ 259 disableSnap = true; 260 } 261 262 263 // disable scroll snap after specific blocks 264 const mlProdProcess = document.querySelector('.ar-cocktails-intro, .ar-cocktail-meta'); 265 266 if (mlProdProcess){ 267 268 //console.log(mlProdProcess.getBoundingClientRect().top - 40); 269 270 if (mlProdProcess.getBoundingClientRect().top - 40 < 0) { 271 disableSnap = true; 272 } 273 } 274 275 /* 276 const mlCocktailDesc = document.querySelector('.ar-cocktail-description'); 277 278 if (mlCocktailDesc){ 279 if (curScroll > mlCocktailDesc.getBoundingClientRect().top - 40) { 280 disableSnap = true; 281 } 282 } 283 */ 284 285 286 287 288 if (!disableSnap){ 289 290 document.documentElement.classList.add('scroll-snap'); // add class to HTML tag 291 document.body.classList.add('scroll-snap'); 292 293 } else { 294 document.documentElement.classList.remove('scroll-snap'); // remove class from HTML tag 295 document.body.classList.remove('scroll-snap'); 296 } 297 298 prevScroll = curScroll <= 0 ? 0 : curScroll; 299 300 }, false); 301 302 303 304 305 306 307 308});
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.