1var scrollPosition, refineWrapper, stickyPosition, mobileHeaderStyle, 2 mobileFilterContainer = document.querySelector('[data-zs-mobile-header-filterby]'), 3 selectedFiltersContainer = document.querySelector('[data-zs-selected-filters-conatainer]'), 4 mobileHeaderStyleIdentifier = document.querySelector('[data-zs-mobile-headerstyle]'), 5 mobilecontentWrap = document.querySelector('[data-zs-mobile-content-wrap]'); 6var headerContainer = document.querySelector('[data-headercontainer]'); 7var contentContainer = document.querySelector('[data-theme-content-container]'); 8var footerContainer = document.querySelector('.theme-footer-area'); 9var allContainers = [headerContainer, contentContainer, footerContainer]; 10 11const closeSvgCursorURI = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20data-ember-extension%3D%221%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M16%2031C24.2843%2031%2031%2024.2843%2031%2016C31%207.71573%2024.2843%201%2016%201C7.71573%201%201%207.71573%201%2016C1%2024.2843%207.71573%2031%2016%2031Z%22%20stroke%3D%22%23979797%22%20stroke-width%3D%222%22/%3E%3Cpath%20d%3D%22M9%209L24%2024%22%20stroke%3D%22%23979797%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22square%22/%3E%3Cpath%20d%3D%22M8.49512%2023.4586L24.5049%209.54144%22%20stroke%3D%22%23979797%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22square%22/%3E%3C/svg%3E"; // No I18N 12 13function handleKeyPressForClick(event, element) { 14 if (event.key === 'Enter' || event.keyCode === 13) { 15 element.click(); 16 } 17} 18 19if(mobileHeaderStyleIdentifier){ 20 mobileHeaderStyle = mobileHeaderStyleIdentifier.getAttribute("data-zs-mobile-headerstyle");// No I18N 21} 22 23if(window.zs_view == 'product'){ 24 let floatingContainer = document.querySelector('.theme-floating-add-to-cart'); 25 if(floatingContainer){ 26 isFloatingAddToCart = true; 27 window.addEventListener('scroll', updateFloatingContainerVisibility); 28 window.addEventListener('load', updateFloatingContainerVisibility); 29 } 30} 31 32function updateFloatingContainerVisibility() { 33 let mainContainer = document.querySelector('[data-zs-product-primary-details]').querySelector('.theme-product-quantity-cart-container'); 34 let floatingContainer = document.querySelector('.theme-floating-add-to-cart'); 35 let footerContainer = document.querySelector('.theme-footer-area'); 36 37 const shouldShowFloatingCTA = isOutOfViewport(mainContainer) && isOutOfViewport(footerContainer); 38 39 floatingContainer.classList.toggle('theme-show-floating-cta', shouldShowFloatingCTA);// No I18N 40 floatingContainer.classList.toggle('theme-hide-floating-cta', !shouldShowFloatingCTA);// No I18N 41} 42 43 44function isOutOfViewport(element) { 45 let rect = element.getBoundingClientRect(); 46 return ( 47 rect.bottom < 0 || 48 rect.right < 0 || 49 rect.left > window.innerWidth || 50 rect.top > window.innerHeight 51 ); 52} 53 54function closeToastMessage(element){ 55 let toastElem = element.closest('[data-toast-type]'); // No I18N 56 let toast = toastElem.getAttribute('data-toast-type'); // No I18N 57 if(toast && toast == "success"){ 58 addClass(toastElem,'theme-cart-success-remove'); 59 removeClass(toastElem,'theme-cart-success'); 60 } 61 else if(toast && toast == "failure"){ 62 addClass(toastElem,'theme-cart-failure-remove'); 63 removeClass(toastElem,'theme-cart-failure'); 64 } 65} 66 67function positionCartSuccessMsg() { 68 var header = document.querySelector('.theme-header'); 69 var mobileheader = document.querySelector('.theme-mobile-header-top'); 70 var popups = document.querySelectorAll('[data-theme-message-two], [data-theme-message-six]'); 71 var popupSeven = document.querySelectorAll('[data-theme-message-seven]'); 72 function handlePosition(popup, headerTopVal, mobileTopVal, defaultTopVal) { 73 var isHeaderVisible = header && header.getBoundingClientRect().bottom > 0; 74 var isMobileheaderVisible = mobileheader && mobileheader.getBoundingClientRect().bottom > 0; 75 if (isHeaderVisible) { 76 popup.style.top = header.getBoundingClientRect().bottom + headerTopVal + 'px'; 77 popup.classList.remove('fixed'); // No I18N 78 } else if (isMobileheaderVisible) { 79 popup.style.top = mobileheader.getBoundingClientRect().bottom + mobileTopVal + 'px'; 80 popup.classList.remove('fixed'); // No I18N 81 } else { 82 popup.style.top = defaultTopVal + '%'; 83 popup.classList.add('fixed'); // No I18N 84 } 85 } 86 87 function handleScroll() { 88 if(popups){ 89 popups.forEach(function (popup) { 90 handlePosition(popup, 16, 8, 2); 91 }); 92 } 93 else if(popupSeven){
94 popupSeven.forEach(function (popup) { 95 handlePosition(popup, 0, 0, 0); 96 }); 97 } 98 } 99 handleScroll(); 100 window.addEventListener('scroll', handleScroll); 101} 102 103if (document.querySelector('[data-theme-message-two], [data-theme-message-seven]')) { 104 window.addEventListener('load', positionCartSuccessMsg); 105} 106 107function slideRecommendedProds(elem, dir) { 108 let section = elem.closest('.zprow'); // No I18N 109 let carousel = section ? section.querySelector('[class*="theme-store-style-collection-row-"]') : null; // No I18N 110 111 if (carousel) { 112 let cards = carousel.children; 113 let scrollAmt = cards.length > 0 ? cards[0].offsetWidth : 200; 114 let containerWidth = carousel.scrollWidth - carousel.clientWidth; 115 116 if (dir === "right") { 117 if (carousel.scrollLeft >= containerWidth) { 118 carousel.scrollTo({ left: 0, behavior: "smooth" }); // No I18N 119 } else { 120 carousel.scrollBy({ left: scrollAmt, behavior: "smooth" }); // No I18N 121 } 122 } else if (dir === "left") { 123 if (carousel.scrollLeft <= 15) { 124 carousel.scrollTo({ left: containerWidth, behavior: "smooth" }); // No I18N 125 } else { 126 carousel.scrollBy({ left: -scrollAmt, behavior: "smooth" }); // No I18N 127 } 128 } 129 } 130} 131 132function customAttributeSelect(elem) { 133 let container = elem.closest('.theme-product-sizes');// No I18N 134 let selectedText = elem.getAttribute('data-value'); 135 if (container) { 136 const selectElement = container.querySelector('select[data-zs-attribute-name]'); 137 if (selectElement) { 138 const matchingOption = Array.from(selectElement.options).find( 139 option => option.textContent.trim() === selectedText 140 ); 141 if (matchingOption) { 142 selectElement.value = matchingOption.value; 143 144 const changeEvent = new Event('change', { bubbles: true }); // No I18N 145 selectElement.dispatchEvent(changeEvent); 146 } 147 } 148 149 const summaryElement = container.querySelector('.theme-custom-select-value'); 150 if (summaryElement) { 151 const clickedOption = Array.from(container.querySelectorAll('.theme-custom-select-option')).find( 152 opt => opt.getAttribute('data-value') === selectedText 153 ); 154 155 if (clickedOption) { 156 const colorLabel = clickedOption.querySelector('[data-theme-color-label]'); 157 const colorStyle = colorLabel ? colorLabel.style.background : ''; 158 159 if (colorStyle) { 160 summaryElement.innerHTML = ` 161 <label style="display:inline-block; width:20px; height:20px; background:${colorStyle}; margin-right:8px; vertical-align:middle;"></label>${selectedText}`; // No I18N 162 } else { 163 summaryElement.textContent = selectedText; 164 } 165 } 166 } 167 168 const options = container.querySelectorAll('.theme-custom-select-option'); 169 if (options.length > 0) { 170 options.forEach(opt => opt.classList.add('blur-option'));// No I18N 171 const clickedOption = Array.from(options).find( 172 opt => opt.getAttribute('data-value') === selectedText 173 ); 174 if (clickedOption) { 175 clickedOption.classList.remove('blur-option');// No I18N 176 } 177 } 178 179 // Close the dropdown 180 const detailsElement = container.querySelector('details'); // No I18N 181 if (detailsElement) { 182 detailsElement.removeAttribute('open'); // No I18N 183 } 184 } 185} 186// Close the dropdown when clicking outside 187document.addEventListener('click', function(event) { 188 const dropdowns = document.querySelectorAll('.theme-product-sizes details'); 189 dropdowns.forEach(dropdown => { 190 const container = dropdown.closest('.theme-product-sizes');// No I18N 191 if (container && !container.contains(event.target)) { 192 dropdown.removeAttribute('open'); 193 } 194 }); 195}); 196// Sync changes from the original <select> to the custom dropdown 197 198function syncCustomDropdown(selectElement) { 199 const container = selectElement.closest('.theme-product-sizes'); // No I18N 200 if (container) { 201 const selectedOption = selectElement.options[selectElement.selectedIndex]; 202 const selectedText = selectedOption ? selectedOption.textContent.trim() : ''; 203 204 const summaryElement = container.querySelector('.theme-custom-select-value'); 205 if (summaryElement) { 206 const clickedOption = Array.from(container.querySelectorAll('.theme-custom-select-option')).find( 207 opt => opt.getAttribute('data-value') === selectedText 208 ); 209 210 if (clickedOption) { 211 const colorLabel = clickedOption.querySelector('[data-theme-color-label]'); 212 const colorStyle = colorLabel ? colorLabel.style.background : ''; 213 214 if (colorStyle) { 215 summaryElement.innerHTML = ` 216 <label style="display:inline-block; width:20px; height:20px; background:${colorStyle}; margin-right:8px; vertical-align:middle;"></label>${selectedText}`; // No I18N 217 } else { 218 summaryElement.textContent = selectedText; 219 } 220 } 221 } 222 223 const options = container.querySelectorAll('.theme-custom-select-option'); 224 if (options.length > 0) { 225 options.forEach(opt => opt.classList.add('blur-option')); // No I18N 226 const clickedOption = Array.from(options).find( 227 opt => opt.getAttribute('data-value') === selectedText 228 ); 229 if (clickedOption) { 230 clickedOption.classList.remove('blur-option'); // No I18N 231 } 232 } 233 } 234} 235 236 237 238document.querySelectorAll('select[data-zs-attribute-name]').forEach(selectElement => { 239 selectElement.addEventListener('change', () => syncCustomDropdown(selectElement)); 240}); 241 242function detailtab(currTab){ 243 var allTabs = document.querySelectorAll('[data-detail-tab]'); 244 var allCont = document.querySelectorAll('[data-detail-tab-content]'); 245 for(at=0;at<allTabs.length;at++){ 246 removeClass(allTabs[at],'theme-prod-detail-tab-active'); 247 } 248 for(ac=0;ac<allCont.length;ac++){ 249 removeClass(allCont[ac],'theme-prod-detail-tab-content-active'); 250 } 251 var activetabVal = currTab.getAttribute('data-detail-tab'); 252 var activeCont = document.querySelectorAll('[data-detail-tab-content="'+activetabVal+'-content"]')[0];// No I18N 253 addClass(currTab,'theme-prod-detail-tab-active'); 254 addClass(activeCont,'theme-prod-detail-tab-content-active') 255} 256 257function openQuickViewOnKeyPress(event, element){ 258 if (event.key === 'Enter' || event.keyCode === 13) { 259 viewProductQuickLook(element.querySelector('[data-zs-product-url]')); 260 } 261} 262 263function openSlidingFilter() { 264 let filterContainer = document.querySelector('[data-zs-filter-container]'); 265 filterContainer.classList.toggle('theme-open-slider-filter'); // No I18N 266 let isFilterOpen = filterContainer.classList.contains('theme-open-slider-filter'); 267 if(isFilterOpen) { 268 let sortByContainer = document.querySelector('[data-theme-sortby-with-filter]'); 269 let isSortByDropDownOpen = sortByContainer?.querySelector('.theme-open-custom-sort'); 270 let isSortByToggleOpen = sortByContainer?.querySelector('.theme-toggle-open'); 271 let activeFilterBar = document.querySelector('.theme-category-filter-bar .zpfilter-active'); // No I18N 272 activeFilterBar?.classList.remove('zpfilter-active'); // No I18N 273 if(isSortByDropDownOpen && isSortByToggleOpen) { 274 isSortByDropDownOpen.classList.remove('theme-open-custom-sort'); // No I18N 275 isSortByToggleOpen.classList.remove('theme-toggle-open'); // No I18N 276 } 277 } 278} 279
280function activeThumbnail() { 281 var prodId; 282 var thumbNailsAtt = document.querySelectorAll("[data-thumbnail]"); 283 for (dt = 0; dt < thumbNailsAtt.length; dt++) { 284 prodId = thumbNailsAtt[dt].getAttribute("data-thumbnail"); 285 } 286 var thumbNails = document.querySelectorAll('[data-thumbnail="' + prodId + '"]'); // No I18N 287 for (tn = 0; tn < thumbNails.length; tn++) { 288 removeClass(thumbNails[tn], "theme-active-thumbnail"); 289 } 290 if (thumbNails[0]) { 291 addClass(thumbNails[0], "theme-active-thumbnail"); 292 } 293} 294 295/* PRODUCT FILTER MOBILE */ 296 297function mobileFilter() { 298 var filterIcons = document.querySelectorAll('[data-theme-product-filter-mobile-icon],[data-theme-product-filter-type-mobile-icon]');// No I18N 299 var filterContainer = document.querySelector('[data-zs-filter-container]'); 300 var filterOverlay = document.querySelector('[data-theme-product-filter-overlay]');// No I18N 301 for (let filterIcon of filterIcons) { 302 if (filterIcon) { 303 filterIcon.addEventListener('click', function() { 304 addClass(filterContainer, 'theme-mobile-filter-show'); 305 addClass(filterOverlay, 'theme-mobile-filter-overlay-show'); 306 document.getElementsByTagName("body")[0].style.overflow = 'hidden'; 307 }); 308 } 309 } 310 if (filterOverlay) { 311 filterOverlay.addEventListener('click', function() { 312 removeClass(this, 'theme-mobile-filter-overlay-show'); 313 removeClass(filterContainer, 'theme-mobile-filter-show'); 314 document.getElementsByTagName("body")[0].style.overflow = 'auto'; 315 }); 316 } 317 window.addEventListener('resize', function(event) { 318 if (document.documentElement.clientWidth > 992) { 319 document.getElementsByTagName("body")[0].style.overflow = 'auto'; 320 } 321 }); 322} 323/* PRODUCT FILTER MOBILE END */ 324 325document.addEventListener("DOMContentLoaded", function(event) { 326 activeThumbnail(); 327 mobileFilter(); 328 if(mobileHeaderStyle == '03'){ 329 mobileheaderThreeFilterSearch(); 330 } 331}); 332function productQuantity(event) { 333 var key = event.which || event.keyCode; 334 var result; 335 if (key == 8 || key == 46 || key == 37 || key == 39 || ( key > 47 && key < 58 )) { 336 result = true; 337 } 338 else { 339 result = false;
340 } 341 return result; 342} 343function getTargetContainer(element) { 344 var targetContainer = (element) ? element.closest("[data-zs-product-id]") : "";// No I18N 345 return targetContainer; 346} 347function increaseCount(e){ 348 var targetContainer = getTargetContainer(e); 349 var quantity_inputs = (targetContainer && targetContainer != "") ? targetContainer.querySelectorAll("[data-zs-quantity]") : ""; 350 351 quantity_inputs.forEach(quantity_input => { 352 var quantity = quantity_input.value; 353 if( !isNaN( quantity )){ 354 quantity_input.value++; 355 } 356 }) 357 return false; 358} 359function decreaseCount(e){ 360 var targetContainer = getTargetContainer(e); 361 var quantity_inputs = (targetContainer && targetContainer != "") ? targetContainer.querySelectorAll("[data-zs-quantity]") : ""; 362 363 quantity_inputs.forEach(quantity_input => { 364 var quantity = quantity_input.value; 365 if( !isNaN( quantity ) && quantity > 1 ) { 366 quantity_input.value--; 367 } 368 }) 369 return false; 370} 371function selectcolor(currentcolor,selectedAttribute){ 372 var targetContainer = getTargetContainer(currentcolor); 373 var currentcolorInput = currentcolor.firstElementChild; 374 var colorAttrNameContainer = targetContainer.querySelectorAll('[data-zs-attribute-name="'+selectedAttribute+'"]')[0];// No I18N 375 var colorLabel = colorAttrNameContainer.querySelectorAll("[data-theme-color-label]");// No I18N 376 for(var cc = 0; cc < colorLabel.length; cc++){ 377 removeClass(colorLabel[cc],'chekedLabel'); 378 colorLabel[cc].setAttribute('aria-checked', 'false'); 379 } 380 if (currentcolorInput.checked == true){ 381 addClass(currentcolor,'chekedLabel'); 382 updateVariantLabel(); 383 currentcolor.setAttribute('aria-checked', 'true'); 384 } 385 else{ 386 removeClass(currentcolor,'chekedLabel'); 387 currentcolor.setAttribute('aria-checked', 'false'); 388 } 389 // Sync only if floating cart exists 390 let floatingCTA = document.querySelector('.theme-floating-add-to-cart'); 391 if (floatingCTA) { 392 var selectedValue = currentcolorInput.value; 393 394 // Find all containers with same attribute 395 var allContainers = document.querySelectorAll('[data-zs-attribute-name="' + selectedAttribute + '"]'); 396 397 allContainers.forEach(container => { 398 var labels = container.querySelectorAll('[data-theme-color-label]'); 399 labels.forEach(label => { 400 var input = label.querySelector('input[type="radio"]'); 401 if (input && input.value === selectedValue) { 402 addClass(label, 'chekedLabel'); 403 } else { 404 removeClass(label, 'chekedLabel'); 405 } 406 }); 407 }); 408 } 409} 410function selectVariant(currentVariant,selectedAttribute){ 411 var targetContainer = getTargetContainer(currentVariant); 412 var currentVariantInput = currentVariant.querySelector('input[type="radio"]'); 413 var variantAttrNameContainer = targetContainer.querySelectorAll('[data-zs-attribute-name="'+selectedAttribute+'"]')[0];// No I18N 414 var variantLabel = variantAttrNameContainer.querySelectorAll("[data-theme-variant-label]");// No I18N 415 for(var cc = 0; cc < variantLabel.length; cc++){ 416 removeClass(variantLabel[cc],'chekedLabel'); 417 variantLabel[cc].setAttribute('aria-checked', 'false'); 418 } 419 if (currentVariantInput.checked == true){ 420 addClass(currentVariant,'chekedLabel'); 421 updateVariantLabel(); 422 currentVariant.setAttribute('aria-checked', 'true'); 423 } 424 else{ 425 removeClass(currentVariant,'chekedLabel'); 426 currentVariant.setAttribute('aria-checked', 'false'); 427 } 428} 429function updateVariantLabel() { 430 let attributeInputs = document.querySelectorAll("[data-zs-attribute-select] input[type='radio']"); 431 if (attributeInputs) { 432 attributeInputs.forEach((radio) => { 433 radio.addEventListener("change", function () { 434 const variantContainer = this.closest(".theme-list-variants"); // No I18N 435 if (variantContainer) { 436 const selectedVariantSummary = variantContainer.querySelector("[data-zs-selected-variant]"); 437 const variantsName = variantContainer.querySelectorAll("[data-zs-attribute-name]"); 438 if (!variantContainer.variantState) { 439 variantContainer.variantState = {}; 440 } 441 442 const attributeName = this.closest("[data-zs-attribute-select]").getAttribute("data-zs-attribute-name"); // No I18N 443 const text = this.getAttribute("data-text"); 444 445 variantContainer.variantState[attributeName] = text; 446 const variantSelectedContainer = []; 447 variantsName.forEach((variant) => { 448 const name = variant.getAttribute("data-zs-attribute-name"); 449 if (variantContainer.variantState[name]) { 450 variantSelectedContainer.push(variantContainer.variantState[name]); 451 } 452 }); 453 454 selectedVariantSummary.textContent = variantSelectedContainer.join(", "); 455 } 456 }); 457 }); 458 } 459} 460function toggleVariantDetails() { 461 let detailElements = document.querySelectorAll('.theme-list-variants'); 462 if(detailElements) {
463 detailElements.forEach(details => { 464 details.addEventListener('toggle', function () { 465 if (this.open) { 466 detailElements.forEach(element => { 467 if (element !== this) { 468 element.removeAttribute('open'); 469 } 470 }); 471 } 472 }); 473 }); 474 } 475} 476function selectColorImage(label, attribute) { 477 selectcolor(label, attribute); 478 setTimeout(() => { 479 var selectedVariant = label.querySelector('input[type="radio"]:checked'); 480 let productContainer = label.closest('[data-zs-wrapping-category-id][data-zs-product-id]'); // No I18N 481 if (selectedVariant && productContainer) { 482 let variantSelect = productContainer.querySelector('[data-zs-variants]'); // No I18N 483 var variantId = selectedVariant.value; 484 var productImage = productContainer.querySelector('.theme-product-image-area img'); // No I18N 485 var productPicture = productImage ? productImage.closest('picture') : null; // No I18N 486 var productSource = productPicture ? productPicture.querySelector('source') : null; 487 var originalSrc = productContainer.querySelector('.theme-product-image-area .theme-org-img').getAttribute('data-src'); // No I18N 488 var foundMatchingImage = false; 489 var buildResponsiveSrcSet = function (url) { 490 if (!url || url.includes('no-preview-image')) { 491 return ''; 492 } 493 var sizeTokenMatch = url.match(/\/\d+x\d+/); 494 if (!sizeTokenMatch) { 495 return ''; 496 } 497 var sizeToken = sizeTokenMatch[0]; 498 return [ 499 url.replace(sizeToken, '/200x200') + ' 200w', // No I18N 500 url.replace(sizeToken, '/400x400') + ' 400w', // No I18N 501 url.replace(sizeToken, '/600x600') + ' 600w', // No I18N 502 url.replace(sizeToken, '/800x800') + ' 800w' // No I18N 503 ].join(', '); 504 }; 505 var updateProductImageSrcSet = function (url) { 506 var nextSrcSet = buildResponsiveSrcSet(url); 507 if (!productSource) { 508 return; 509 } 510 if (nextSrcSet) { 511 productSource.setAttribute('srcset', nextSrcSet); 512 return; 513 } 514 productSource.removeAttribute('srcset'); 515 }; 516 517 for (const option of variantSelect.options) { 518 const zsAttributes = option.getAttribute('data-zs-attributes'); 519 if (zsAttributes && zsAttributes.includes(variantId) && !option.getAttribute('data-zs-images').includes('-1')) { 520 const imageUrl = option.getAttribute('data-zs-img-url'); 521 productImage.src = imageUrl; 522 productImage.setAttribute('data-src', imageUrl); 523 updateProductImageSrcSet(imageUrl); 524 foundMatchingImage = true; 525 break; 526 } 527 } 528 if (!foundMatchingImage) { 529 var fallbackImageUrl = originalSrc.includes('no-preview-image') ? originalSrc : originalSrc + '/400x400'; // No I18N 530 productImage.src = fallbackImageUrl; 531 productImage.setAttribute('data-src', originalSrc); 532 updateProductImageSrcSet(fallbackImageUrl); 533 } 534 } 535 }, 250); 536} 537function removePriceMask() { 538 if (window.zs_rendering_mode != 'live') { 539 var priceMaskContainers = document.querySelectorAll('.price-mask'); 540 priceMaskContainers.forEach(function(container) { 541 container.classList.remove('price-mask'); // No I18N 542 }); 543 } 544} 545function viewProductQuickLook (span) { 546 setInertAttribute(allContainers); 547 var productLookUpUrl = span.getAttribute("data-zs-product-url"); 548 productLookUpUrl += "?quick_look=true"; // No I18N 549 var xhttp = new XMLHttpRequest(); 550 var qvInputTargetId = document.getElementById('product_quick_look'); 551 let listStyle = span.closest('[data-zs-product-id]'); // No I18N 552 let isListStyleEleven = listStyle ? listStyle.classList.contains('theme-product-list-style-11') : null; 553 xhttp.onreadystatechange = function() { 554 if (this.readyState == 4 && this.status == 200) { 555 setInnerHTMLForId("product_quick_look", this.responseText); 556 $E.dispatch(document.body,'quickview:opened'); 557 removePriceMask(); 558 if(isListStyleEleven){ 559 repositionQuickViewContainer(listStyle, qvInputTargetId); 560 }
561 try { 562 cart.productQuickLookAddToCart(); 563 } catch(e) { 564 } 565 566 var thumbNailsAtt = document.querySelectorAll('[data-thumbnail]'); 567 var prodId; 568 for (dt = 0; dt < thumbNailsAtt.length; dt++) { 569 prodId = thumbNailsAtt[dt].getAttribute("data-thumbnail"); 570 } 571 if(prodId){ 572 var thumbNails = document.querySelectorAll('[data-thumbnail="'+prodId+'"]'); 573 for(tn=0;tn < thumbNails.length; tn++){ 574 removeClass(thumbNails[tn],'theme-active-thumbnail'); 575 } 576 if(thumbNails[0]){ 577 addClass(thumbNails[0],'theme-active-thumbnail'); 578 } 579 } 580 product_list_coupon.handleQuickViewCoupons(document.getElementById("product_quick_look")); 581 multi_currency.convertCurrencyPrice(); 582 583 deliveryLocationPinInput = qvInputTargetId.querySelector('[data-zs-delivery-location-postalcode]'); 584 deliveryLocationPinError = qvInputTargetId.querySelector('[data-zs-delivery-availability-product-details-error-message]'); 585 deliveryLocationPinValidate(deliveryLocationPinInput,deliveryLocationPinError); 586 } 587 }; 588 xhttp.open("GET", productLookUpUrl, true); 589 xhttp.send(); 590 document.getElementsByTagName("body")[0].style.overflow = 'hidden'; 591} 592 593function repositionQuickViewContainer(productCard, quickViewContainer) { 594 let quickView = quickViewContainer.querySelector(".theme-product-quick-view-inner"); 595 if (productCard && quickView) {
596 let card = productCard.getBoundingClientRect(); 597 598 let topPosition = card.top; 599 let leftPosition = card.right + 10; 600 601 const quickViewHeight = quickView.offsetHeight; 602 const quickViewWidth = quickView.offsetWidth; 603 604 const spaceRight = window.innerWidth - card.right; 605 const spaceLeft = card.left; 606 607 if (leftPosition + quickViewWidth > window.innerWidth && spaceLeft >= quickViewWidth) { 608 leftPosition = card.left - quickViewWidth - 10; 609 } 610 else if (spaceRight < quickViewWidth && spaceLeft < quickViewWidth) { 611 leftPosition = card.left + (card.width / 2) - (quickViewWidth / 2); 612 if (leftPosition < 10) leftPosition = 10; 613 if (leftPosition + quickViewWidth > window.innerWidth) leftPosition = window.innerWidth - quickViewWidth - 10; 614 } 615 if (topPosition + quickViewHeight > window.innerHeight) { 616 topPosition = window.innerHeight - quickViewHeight - 10; 617 } 618 if (topPosition < 0) { 619 topPosition = 10; 620 } 621 quickView.style.top = `${topPosition}px`; 622 quickView.style.left = `${leftPosition}px`; 623 } 624} 625 626function closeProductQuickLook(e) { 627 removeInertAttribute(allContainers); 628 var prodQuickLook = document.getElementById("product_quick_look"); 629 if (typeof wishlist != "undefined" && window.zs_wishlist_enabled) { 630 var wishlistVariantId = prodQuickLook && prodQuickLook.getElementsByClassName('wishlist-selection-container')[0] && prodQuickLook.getElementsByClassName('wishlist-selection-container')[0].getAttribute('data-zs-wishlist-variant-id'); 631 if (wishlistVariantId) { 632 wishlist.initForElement(wishlistVariantId, true); 633 } 634 } 635 if (prodQuickLook) { 636 setInnerHTMLForId("product_quick_look", ""); 637 } 638 document.getElementsByTagName("body")[0].style.overflow = "auto"; 639 $E.dispatch(document.body, "quickview:closed"); 640} 641 642document.onkeydown = function(e) { 643 e = e || window.event; 644 if (e.keyCode == 27) { 645 closeProductQuickLook(); 646 } 647}; 648 649function showDetailImage(thisel) { 650 var prodId = thisel.getAttribute("data-thumbnail"); 651 var imgId = thisel.getAttribute("data-thumbnail-active"); 652 var thisImg = thisel.getElementsByTagName("img")[0]; 653 var imgUrl = thisImg.getAttribute("data-image-resolution"); 654 var fallbackResolution = thisImg.getAttribute("data-fallback-resolution"); 655 var sizeTokenMatch = imgUrl ? imgUrl.match(/\/\d+x\d+/) : null; 656 var computedSourceSet = ""; 657 if (imgUrl && sizeTokenMatch) { 658 var sizeToken = sizeTokenMatch[0]; 659 computedSourceSet = imgUrl.replace(sizeToken, "/400x400") + " 400w, " + // No I18N 660 imgUrl.replace(sizeToken, "/600x600") + " 600w, " + // No I18N 661 imgUrl.replace(sizeToken, "/800x800") + " 800w"; // No I18N 662 } 663 var activeImageUrl = fallbackResolution && imgUrl && sizeTokenMatch 664 ? imgUrl.replace(sizeTokenMatch[0], "/800x800") 665 : imgUrl; 666 var nextSourceSet = computedSourceSet; 667 var imageLoadingOverlay = document.querySelectorAll('[data-theme-image-overlay="theme-image-overlay-' + prodId + '"]'); 668 imageLoadingOverlay.forEach(function (overlay) { 669 overlay.style.display = "block"; 670 }); 671 672 // Get all detail images for the product 673 var detailImages = document.querySelectorAll('[data-detail-image="theme-detail-image-' + prodId + '"]'); 674 var activeImage = document.querySelectorAll('[data-thumbnail-active="' + imgId + '"]')[0]; 675 var imgAlt = thisImg.getAttribute("alt"); 676 677 // Update all detail images 678 detailImages.forEach(function (detailImage) { 679 // Apply fade-out effect before changing the image 680 detailImage.style.opacity = "0"; 681 detailImage.style.transition = "opacity 0.3s ease-in-out"; // No I18N 682 setTimeout(() => { 683 detailImage.setAttribute("alt", imgAlt); 684 detailImage.setAttribute("title", imgAlt); 685 detailImage.setAttribute("src", activeImageUrl || imgUrl); 686 if (nextSourceSet) { 687 detailImage.setAttribute("srcset", nextSourceSet); 688 } 689 var detailSource = detailImage.parentElement && detailImage.parentElement.querySelector("source"); 690 if (detailSource && nextSourceSet) { 691 detailSource.setAttribute("srcset", nextSourceSet); 692 } 693 }, 150); 694 // Handle image load for each detail image 695 detailImage.onload = function () { 696 imageLoadingOverlay.forEach(function (overlay) { 697 overlay.style.display = "none"; 698 }); 699 detailImage.style.opacity = "1"; 700 }; 701 }); 702 703 // Reset active thumbnail classes 704 var thumbNails = document.querySelectorAll('[data-thumbnail="' + prodId + '"]'); 705 for (var i = 0;
705 i < thumbNails.length; i++) { 706 thumbNails[i].className = thumbNails[i].className.replace("theme-active-thumbnail", ""); 707 } 708 709 // Add active class to the clicked thumbnail 710 addClass(activeImage, "theme-active-thumbnail"); 711} 712 713 714function showPreviousImage() { 715 const activeThumbnail = document.querySelector('.theme-active-thumbnail'); 716 const thumbnails = document.querySelectorAll('.theme-product-detail-thumbnail'); 717 const activeIndex = Array.from(thumbnails).indexOf(activeThumbnail); 718 719 for (let i = 1; i < thumbnails.length; i++) { 720 const prevIndex = (activeIndex - i + thumbnails.length) % thumbnails.length; 721 const prevThumbnail = thumbnails[prevIndex]; 722 if (window.getComputedStyle(prevThumbnail).display !== 'none') { 723 showDetailImage(prevThumbnail); 724 break; 725 } 726 } 727} 728 729function showNextImage() { 730 const activeThumbnail = document.querySelector('.theme-active-thumbnail'); 731 const thumbnails = document.querySelectorAll('.theme-product-detail-thumbnail'); 732 const activeIndex = Array.from(thumbnails).indexOf(activeThumbnail); 733 734 for (let i = 1; i < thumbnails.length; i++) { 735 const nextIndex = (activeIndex + i) % thumbnails.length; 736 const nextThumbnail = thumbnails[nextIndex]; 737 if (window.getComputedStyle(nextThumbnail).display !== 'none') { 738 showDetailImage(nextThumbnail); 739 break; 740 } 741 } 742} 743 744function hideCurrency() { 745 var currencyList = document.querySelectorAll("[data-theme-currency-list]"); 746 var currencyListContainer = document.querySelector("[data-theme-currency-list-ul]"); 747 var currencyHideOverlay = document.querySelector("[data-theme-currency-hide-overlay]"); 748 var resMenu = document.querySelector('[data-non-res-menu="zptheme-menu-non-res"]'); 749 var currencyMobileOpenTop = document.querySelector("[data-theme-currency-open-top]"); 750 for (cur = 0; cur < currencyList.length; cur++) { 751 currencyList[cur].style.display = "none"; 752 currencyListContainer.firstChild.style.display = "flex"; 753 removeClass(currencyListContainer, "theme-currency-open"); 754 } 755 currencyHideOverlay.style.display = "none"; 756 currencyMobileOpenTop.style.display = "none"; 757 removeClass(resMenu, "theme-change-zindex"); 758 bindCurrencyOpenListener(); 759} 760function closeCurrencyMobile(){ 761 var currencyList = document.querySelectorAll('[data-theme-currency-list]'); 762 var currencyListContainer = document.querySelector('[data-theme-currency-list-ul]'); 763 var currencyHideMobile = document.querySelector('[data-theme-currency-hide-mobile]'); 764 var currencyMobileOpenTop = document.querySelector('[data-theme-currency-open-top]'); 765 var currencyHideOverlay = document.querySelector('[data-theme-currency-hide-overlay]'); 766 var menuId = currencyListContainer.getAttribute('data-theme-currency-list-ul'); 767 var menuClose = document.querySelector('[data-zp-burger-clickable-area="'+menuId+'"]'); 768 var resMenu = document.querySelector('[data-non-res-menu="zptheme-menu-non-res"]'); 769 for(cur=0;cur<currencyList.length;cur++){ 770 currencyList[cur].style.display = 'none'; 771 currencyListContainer.firstChild.style.display = 'flex'; 772 removeClass(currencyListContainer,'theme-currency-open'); 773 } 774 if(!['03', '04', '05'].includes(mobileHeaderStyle) && menuClose){ 775 menuClose.click(); 776 } 777 currencyHideMobile.style.display = "none"; 778 currencyMobileOpenTop.style.display = "none"; 779 if (currencyHideOverlay) { 780 currencyHideOverlay.style.display = "none"; 781 } 782 removeClass(resMenu,'theme-change-zindex'); 783 bindCurrencyOpenListener(); 784} 785function currentCurrency(currentList, evt) { 786 evt = evt || window.event; 787 var currencyListContainer = document.querySelector("[data-theme-currency-list-ul]"); 788 var currenyOpen = currencyListContainer.classList.contains("theme-currency-open"); 789 var currencyList = document.querySelectorAll("[data-theme-currency-list]"); 790 var menuId = currencyListContainer.getAttribute("data-theme-currency-list-ul"); 791 var currencyMobileOpenTop = document.querySelector("[data-theme-currency-open-top]"); 792 var currencyHideOverlay = document.querySelector("[data-theme-currency-hide-overlay]"); 793 var menuClose = document.querySelector('[data-zp-burger-clickable-area="' + menuId + '"]'); 794 var resMenu = document.querySelector('[data-non-res-menu="zptheme-menu-non-res"]'); 795 if (currentList != currencyListContainer.childNodes[0]) { 796 currencyListContainer.insertBefore(currentList,currencyListContainer.childNodes[0]); 797 var storeCurrencyMeta = localStorage.getItem("store_currency_meta"); // No I18N 798 if(storeCurrencyMeta) { 799 storeCurrencyMeta = JSON.parse(storeCurrencyMeta); 800 storeCurrencyMeta.selected_currency_set_by_customer = true; 801 localStorage.setItem("store_currency_meta", JSON.stringify(storeCurrencyMeta)); // No I18N 802 } 803 multi_currency.change(currentList.innerText); 804 } 805 if (currenyOpen == true && !["03", "04", "05"].includes(mobileHeaderStyle) && menuClose) { 806 menuClose.click(); 807 } 808 if (currencyMobileOpenTop) { 809 currencyMobileOpenTop.style.display = "none"; 810 } 811 if (window.innerWidth <= 992) { 812 if (evt && evt.stopPropagation) { 813 evt.stopPropagation(); 814 } 815 for (cur = 0; cur < currencyList.length; cur++) { 816 currencyList[cur].style.display = "none"; 817 currencyListContainer.firstChild.style.display = "flex"; 818 removeClass(currencyListContainer, "theme-currency-open"); 819 } 820 if (resMenu) { 821 removeClass(resMenu, "theme-change-zindex"); 822 } 823 if (currencyHideOverlay) { 824 currencyHideOverlay.style.display = "none"; 825 } 826 bindCurrencyOpenListener(); 827 } 828} 829 830function informMerchantAboutFailureTransaction() { 831 if (typeof cart != "undefined") { 832 cart.mailMerchantAboutFailureTransaction(); 833 } 834} 835 836 837/* ERROR MESSAGE FUNCTIONS START */ 838 839var ERROR_MESSAGE = "error_msg"; 840 841function addErrorMsg(data) { 842 /* 843 * add element error message. and scroll to error element of current postion 844 * 845 * @param data Object 846 * element is String 847 * message is String 848 * scroll is boolean (optional) 849 * scrollTopPosition is boolean (option) 850 */ 851 //Incase element is undefined, then error message cannot be shown 852 if (!data.element) { 853 return; 854 } 855 if (data.scroll) { 856 /** 857 * Browser scrollbar scroll to element view area 858 * reference ht tps://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView 859 */ 860 var target_element = data.scrollViewElem || data.element; 861 target_element.scrollIntoView && target_element.scrollIntoView(data.scrollTopPosition); 862 } 863 864 //need to check error is already added to this element 865 866 if (_hasError(data.element)) { 867 _removeErrorElement(data.element); 868 } 869 data.element.onkeydown = _removeError; 870 871 if ( 872 data.element.nodeName === "SELECT" || data.element.hasAttribute("data-onchange-event") // No i18n 873 ) { 874 data.element.onchange = _removeError; 875 } 876 877 var span_element = document.createElement("span"); 878 span_element.className = ERROR_MESSAGE; 879 $D.css(span_element, "clear", "both"); 880 $D.css(span_element, "display", "block"); 881 $D.css(span_element, "padding", "7px 0"); 882 $D.css(span_element, "width", "100%"); 883 var content = '<span style="color:#E54D42;white-space:normal;">' + data.message + "</span>"; 884 setInnerHTMLForElement(span_element, content); 885 if (data.element.parentNode) { 886 data.element.parentNode.appendChild(span_element); 887 } 888} 889 890function _hasError(element) { 891 if (element && element.parentNode) { 892 return $D.getByClass(ERROR_MESSAGE, element.parentNode).length > 0; 893 } 894 return false;
895} 896 897function _removeError() { 898 _removeErrorElement(this); 899} 900 901function _removeErrorElement(element) { 902 if (_hasError(element) && element.parentNode) { 903 var error_element = $D.getByClass(ERROR_MESSAGE, element.parentNode); 904 for (var i = 0, length = error_element.length; i < length; i++) { 905 if (error_element[i]) { 906 $D.remove(error_element[i]); 907 } 908 } 909 } 910} 911 912/* ERROR MESSAGE FUNCTIONS END */ 913 914/* PRODUCT COUPON FUNCTION START */ 915 916function showCoupons(el) { 917 var couponContainerToggle = el.parentNode.querySelector(".theme-prod-coupons-container-toggle"); 918 var couponHideBtn = el.parentNode.querySelector(".theme-prod-coupons-hide-btn"); 919 el.style.display = "none"; 920 couponContainerToggle.parentNode.style.height = couponContainerToggle.clientHeight + "px"; 921 couponHideBtn.style.display = "block"; 922} 923 924function hideCoupons(el) { 925 var couponContainerToggle = el.parentNode.querySelector('.theme-prod-coupons-container-toggle'); 926 var couponShowBtn = el.parentNode.querySelector('.theme-prod-coupons-show-btn'); 927 el.style.display = "none"; 928 couponContainerToggle.parentNode.style.height = "0px"; 929 couponShowBtn.style.display = "block"; 930} 931 932/* PRODUCT COUPON FUNCTION END */ 933 934/* START: Common Methods */ 935 936function removeClass(element, class_name) { 937 if (element) { 938 element.className = element.className.replace(class_name, ""); 939 } 940} 941function addClass(element, class_name) { 942 if (element) { 943 element.classList.add(class_name); 944 } 945} 946 947function showElementWithId(id, value) { 948 value = !value ? "" : value; 949 showElement($D.getById(id), value); 950} 951 952function showElement(element, value) { 953 if (element) { 954 element.style.display = !value ? "" : value; 955 } 956} 957 958function hideElementWithId(id) { 959 hideElement($D.getById(id)); 960} 961 962function hideElement(element) { 963 if (element) { 964 element.style.display = "none"; 965 } 966} 967 968function setInnerTextForId(id, value) { 969 setInnerTextForElement($D.getById(id), value); 970} 971 972function setInnerTextForElement(element, value) { 973 if (element) { 974 element.innerText = value; 975 } 976} 977 978function setInnerHTMLForId(id, value) { 979 setInnerHTMLForElement($D.getById(id), value); 980} 981 982function setInnerHTMLForElement(element, value) { 983 if (element) { 984 element.innerHTML = value; 985 } 986} 987 988function setContentToClass(class_id, content) { 989 var content_place_holders = $D.getByClass(class_id); 990 for (var i = 0; i < content_place_holders.length; i++) { 991 var content_place_holder = content_place_holders[i]; 992 setInnerHTMLForElement(content_place_holder, content); 993 } 994} 995 996function replaceClassInElementFromDataAttribute(data_attribute, existing_class_name, to_be_replaced_class_name) { 997 var element = $D.get("[" + data_attribute + "]"); 998 replaceClassInElement(element, existing_class_name, to_be_replaced_class_name); 999} 1000 1001function replaceClassInElement(element, existing_class_name, to_be_replaced_class_name) { 1002 if(element) { 1003 element.classList.replace(existing_class_name, to_be_replaced_class_name); 1004 } 1005} 1006 1007function currencyContainerCheck() { 1008 var currencyContainerButton = document.querySelector("[data-theme-currency-list-container]"); 1009 var currencyContainer = currencyContainerButton.querySelector("[data-theme-currency-list-ul]"); 1010 var isCurrencyContainerOpen; 1011 if (currencyContainerButton) { 1012 var observerCurrencyContainerChanged = new MutationObserver(function () { 1013 isCurrencyContainerOpen = currencyContainer.classList.contains("theme-currency-open"); 1014 if (!isCurrencyContainerOpen) { 1015 bindCurrencyOpenListener(); 1016 } 1017 }); 1018 observerCurrencyContainerChanged.observe(currencyContainer, {attributes: true,childList: true,subtree: true}); 1019 } 1020} 1021 1022function isOpenCurrency(){ 1023 bindCurrencyOpenListener(); 1024} 1025 1026function scrollPositionCheck() { 1027 var positionY = mobilecontentWrap.scrollTop; 1028 if (positionY > stickyPosition) { 1029 if (positionY > scrollPosition) { 1030 refineWrapper.classList.add("hide-refine-wrapper"); // No i18n 1031 } else { 1032 refineWrapper.classList.remove("hide-refine-wrapper"); // No i18n 1033 } 1034 scrollPosition = positionY; 1035 } 1036} 1037 1038function newFilterUpdated(){ 1039 var selectedFilters = selectedFiltersContainer.querySelectorAll('[data-zs-selected-filter]'); 1040 var selectedFiltersCount = mobileFilterContainer.querySelector('[data-zs-mobile-header-filter-selectedcount]'); 1041 if(selectedFilters.length > 0){ 1042 selectedFiltersCount.innerHTML = "("+selectedFilters.length+")"; 1043 if(!selectedFiltersCount.classList.contains('filter-selectedcount-active')){ 1044 selectedFiltersCount.classList.add('filter-selectedcount-active'); 1045} 1046 }else{ 1047 selectedFiltersCount.classList.remove('filter-selectedcount-active'); 1048 } 1049} 1050 1051function toggleFilters() { 1052 let filterIcon = document.querySelector("[data-toggle-filters]"); 1053 let collectionContainer = document.querySelector(".theme-collection-section"); 1054 let isSortByDropDownOpen = document.querySelector(".theme-open-custom-sort"); 1055 let isSortByDropDownToggleOpen = document.querySelector(".theme-toggle-open"); 1056 1057 if(isSortByDropDownOpen && isSortByDropDownToggleOpen) { 1058 isSortByDropDownOpen.classList.remove("theme-open-custom-sort"); // No I18N 1059 isSortByDropDownToggleOpen.classList.remove("theme-toggle-open"); // No I18N 1060 } 1061 1062 filterIcon.classList.toggle("theme-open-filters"); // No I18N 1063 collectionContainer.classList.toggle("theme-productfilter-hidden"); // No I18N 1064} 1065 1066// Select all search containers 1067const searchContainers = document.querySelectorAll(".theme-neobrutal-search-field-container");// No I18N 1068 1069// Add event listener to each search icon to toggle the corresponding search container
1070if(searchContainers){ 1071 searchContainers.forEach((container) => { 1072 const menu = container.closest("[data-menu-and-search]");// No I18N 1073 const searchIcon = menu.querySelector("[data-zs-search-icon]"); 1074 1075 function toggleNeoBrutalSearch(elem) { 1076 let searchContainer = elem.closest("[data-menu-and-search]"); // No I18N 1077 searchContainer.classList.toggle("theme-neobrutal-search-open");// No I18N 1078 if (searchContainer.classList.contains("theme-neobrutal-search-open")) {// No I18N 1079 searchContainer.querySelector("input").focus(); 1080 searchContainer.querySelector("input").value = ""; 1081 elem.style.display = "none"; 1082 document.body.style.cursor = `url(${closeSvgCursorURI}) 16 16, auto`; 1083 } else { 1084 elem.style.display = "block"; 1085 document.body.style.cursor = "auto"; 1086 } 1087 } 1088 1089 function closeSearchContainer() { 1090 if (searchIcon) { 1091 searchIcon.style.display = "block"; 1092 menu.classList.remove("theme-neobrutal-search-open");// No I18N 1093 document.body.style.cursor = "auto"; 1094 } 1095 let suggestionWrappers = document.querySelectorAll('.theme-search-suggestion-overlay'); 1096 if (suggestionWrappers) { 1097 let body = document.querySelector('body'); 1098 body.classList.remove('theme-body-hide-overflow'); // No I18N 1099 suggestionWrappers.forEach(wrapper => { 1100 wrapper.classList.remove('theme-show-overlay'); // No I18N 1101 }) 1102 } 1103 } 1104 1105 // Event listener to open/close search container on icon click 1106 if (searchIcon){ 1107 searchIcon.addEventListener("click", function () { 1108 toggleNeoBrutalSearch(this); 1109 }); 1110 } 1111 1112 // Event listener for clicking outside to close the search container 1113 document.addEventListener("click", function (event) { 1114 if (container && menu.classList.contains("theme-neobrutal-search-open") && !container.contains(event.target) && !searchIcon.contains(event.target)) {// No I18N 1115 closeSearchContainer(); 1116 } 1117 }); 1118 }); 1119} 1120 1121 1122function submitSearch(searchIcon){ 1123 let isFormOpen = searchIcon.closest('.theme-search-open');// No I18N 1124 let searchform = searchIcon.closest('form'); // No I18N 1125 if (searchform){ 1126 if(isFormOpen){ 1127 searchform.submit(); 1128 } 1129 else{ 1130 toggleFullSearchbox(searchIcon); 1131 } 1132 } 1133} 1134 1135/* END: Common Methods */ 1136 1137/* START: Mobile Header style three filter and search */ 1138 1139function mobileheaderThreeFilterSearch() { 1140 var headerTop = document.querySelector("[data-zs-mobile-header-three-top]"); 1141 refineWrapper = document.querySelector("[data-zs-mobile-header-refine-wrapper]"); 1142 if (headerTop && refineWrapper) { 1143 stickyPosition = headerTop.clientHeight + refineWrapper.clientHeight; 1144 refineWrapper.style.top = headerTop.clientHeight; 1145 scrollPosition = stickyPosition; 1146 if (mobilecontentWrap) { 1147 mobilecontentWrap.addEventListener("scroll", scrollPositionCheck); 1148 } 1149 } else if (refineWrapper) { 1150 scrollPosition = refineWrapper.clientHeight; 1151 } 1152 if (mobileFilterContainer && selectedFiltersContainer) { 1153 newFilterUpdated(); 1154 var observerNewFilterUpdated = new MutationObserver(newFilterUpdated); 1155 observerNewFilterUpdated.observe(selectedFiltersContainer, {attributes: true,childList: true,subtree: true}); 1156 } 1157 var currencyContainerButton = document.querySelector("[data-theme-currency-list-container]"); 1158 if (currencyContainerButton) { 1159 var observerCurrencyLoaded = new MutationObserver(currencyContainerCheck); 1160 observerCurrencyLoaded.observe(currencyContainerButton, {attributes: true, childList: true, subtree: true}); 1161 } 1162 document.addEventListener("zp-event-search-success", function (e) { 1163 document.querySelector("[data-zs-mobile-header-search] [data-zs-search-input]").value = e.detail.searchTerm; 1164 },false); 1165 document.addEventListener("zp-event-search-pending",function () { 1166 document.querySelector("[data-zs-mobile-header-search] [data-zs-search-input]").blur(); 1167 },false); 1168} 1169/* END: Mobile Header style three filter and search */ 1170 1171function closeSlidingCart() { 1172 document.getElementsByTagName('body')[0].style.overflow = 'auto';
1173 removeInertAttribute(allContainers); 1174 let slidingCart = document.querySelector('.theme-sliding-cart-container'); 1175 if(slidingCart) { 1176 slidingCart.classList.add('theme-close-sliding-cart'); // No I18N 1177 } 1178} 1179 1180function setInertAttribute(containers) { 1181 containers.forEach(container => { 1182 if (container) { 1183 container.setAttribute('inert', ''); 1184 } 1185 }); 1186} 1187function removeInertAttribute(containers) { 1188 containers.forEach(container => { 1189 if (container) { 1190 container.removeAttribute('inert'); 1191 } 1192 }); 1193} 1194function loadCartDrawer() { 1195 if(window.zs_view == 'checkout') { 1196 viewCartInCheckout(); 1197 } 1198 if (sessionStorage.getItem('cartRedirectAction') === 'true') { 1199 sessionStorage.removeItem('cartRedirectAction'); // No I18N 1200 handleMiniCart(false); 1201 } 1202 if (sessionStorage.getItem('quoteRedirectAction') === 'true') { 1203 sessionStorage.removeItem('quoteRedirectAction'); // No I18N 1204 handleMiniCart(true); 1205 } 1206 let cartIcons = document.querySelectorAll('[data-zs-view-mini-cart]'); 1207 let quoteIcons = document.querySelectorAll('[data-zs-view-mini-quote]'); 1208 cartIcons.forEach((icon) => { 1209 icon.addEventListener('click', () => handleMiniCart(false)); 1210 }); 1211 quoteIcons.forEach((icon) => { 1212 icon.addEventListener('click', () => handleMiniCart(true)); 1213 }); 1214 document.addEventListener("zp-event-add-to-cart-success", (event) => { 1215 var target = event.detail && event.detail.target; 1216 if (!target || (!target.hasAttribute('data-zs-view-mini-cart-button') && !target.hasAttribute('data-zs-view-mini-quote-button'))) { 1217 return; 1218 } 1219 var isQuote = event.detail.isQuote; 1220 if (isQuote) { 1221 handleMiniCart(true); 1222 } else { 1223 handleMiniCart(false); 1224 } 1225 }); 1226 document.addEventListener("zp-event-minicart-open-success", enableMinicartButtons); 1227} 1228 1229function enableMinicartButtons() { 1230 var minicartElements = document.querySelectorAll('[data-zs-view-mini-cart]'); 1231 for (var i = 0; i < minicartElements.length; i++) { 1232 minicartElements[i].disabled = false; 1233 } 1234} 1235 1236function loadExternalCheckoutScripts() { 1237 var checkoutScripts = [ 1238 { selector: '[data-zs-razorpay-magic-checkout-btn]', src: 'https://checkout.razorpay.com/v1/magic-checkout.js' }, // No I18N 1239 { selector: '[data-zs-gokwik-checkout-btn]', src: 'https://pdp.gokwik.co/v4/build/gokwik.js' } // No I18N 1240 ]; 1241 checkoutScripts.forEach(function (externalCheckout) { 1242 if (!document.querySelector(externalCheckout.selector) || document.querySelector('script[src="' + externalCheckout.src + '"]')) { 1243 return; 1244 } 1245 var script = document.createElement('script'); 1246 script.src = externalCheckout.src; 1247 document.head.appendChild(script); 1248 }); 1249} 1250 1251function handleMiniCart(isQuote) { 1252 var minicartPendingEvent = new CustomEvent("zp-event-minicart-pending", { // No I18N 1253 detail: { 1254 isQuote: isQuote 1255 } 1256 }); 1257 document.dispatchEvent(minicartPendingEvent); 1258 1259 var minicartElements = document.querySelectorAll('[data-zs-view-mini-cart]'); 1260 for (var i = 0; i < minicartElements.length; i++) { 1261 minicartElements[i].disabled = true; 1262 } 1263 1264 document.getElementsByTagName("body")[0].style.overflow = 'hidden'; 1265 let cartSuccessToastMessage = document.querySelector('[data-cart-add-success].theme-cart-success'); 1266 if(cartSuccessToastMessage) { 1267 cartSuccessToastMessage.classList.replace('theme-cart-success', 'theme-cart-success-remove'); // No I18N 1268 } 1269 let url = '/mini-cart'; // No I18N 1270 if (isQuote && window.zs_quote_id) { 1271 url += '?cart_id=' + window.zs_quote_id; // No I18N 1272 } 1273 var checkoutMethod = ''; 1274 var checkoutMethodData = JSON.parse(sessionStorage.getItem("checkout_method")); // No I18N 1275 if (checkoutMethodData) { 1276 if (checkoutMethodData.expiry && (Date.now() <= checkoutMethodData.expiry)) { 1277 checkoutMethod = checkoutMethodData.value; 1278 } else { 1279 sessionStorage.removeItem("checkout_method"); // No I18N 1280 checkoutMethod = ''; 1281 } 1282 } 1283 if (checkoutMethod) { 1284 url += (url.includes('?') ? '&' : '?') + 'tc=' + checkoutMethod; // No I18N 1285 } 1286 1287 $X.get({ 1288 url: url, 1289 handler: function () { 1290 let target = document.querySelector('.theme-sliding-cart-container'); 1291 var miniCartData = this.responseText; 1292 if(miniCartData){ 1293 if (checkoutMethod) { 1294 let updatedWarningBanner = document.querySelector('[data-zs-warning-banner]'); 1295 if (updatedWarningBanner) { 1296 updatedWarningBanner.style.display = 'block'; 1297 } 1298 } 1299 if(target) { 1300 target.outerHTML = miniCartData;
1301 setInertAttribute(allContainers); 1302 } 1303 else{ 1304 target = document.querySelector('.theme-cart-delete-failure-message'); 1305 let cartContainer = document.createElement('div'); 1306 target.insertAdjacentElement('afterend',cartContainer); // No I18N 1307 cartContainer.outerHTML = miniCartData; 1308 setInertAttribute(allContainers); 1309 } 1310 if (multi_currency.convertContainerOnDemand) { 1311 let currencyContainer = document.querySelector('[data-zs-currency-list]'); 1312 if (currencyContainer) { 1313 multi_currency.convertContainerOnDemand('mini-cart'); // No I18N 1314 } 1315 } 1316 } else { 1317 var minicartElements = document.querySelectorAll('[data-zs-view-mini-cart]'); 1318 for (var i = 0; i < minicartElements.length; i++) { 1319 minicartElements[i].disabled = false; 1320 } 1321 } 1322 setTimeout(() => { 1323 zsUtils.onDocumentReady(cart.init); 1324 loadExternalCheckoutScripts(); 1325 if(miniCartData) { 1326 var cartOpenSuccess = new CustomEvent("zp-event-minicart-open-success", { // No I18N 1327 detail: { 1328 cart: miniCartData, 1329 view: window.zs_view || "store_page" // No I18N 1330 } 1331 }); 1332 document.dispatchEvent(cartOpenSuccess); 1333 } 1334 else { 1335 var cartOpenFailure = new CustomEvent("zp-event-minicart-open-failure", { // No I18N 1336 detail: { 1337 view: window.zs_view || "store_page" // No I18N 1338 } 1339 }); 1340 document.dispatchEvent(cartOpenFailure); 1341 } 1342 },500); 1343 }, 1344 error: { 1345 handler: enableMinicartButtons(), 1346 condition: function() { 1347 return this.status >= 300; 1348 } 1349 } 1350 }) 1351} 1352let listLayout17 = document.querySelector('.theme-product-list-style-17'); 1353document.addEventListener('DOMContentLoaded',loadCartDrawer); 1354document.addEventListener('quickview:opened',loadCartDrawer); 1355document.addEventListener('DOMContentLoaded', () => { 1356 if (window.zs_view == 'cart') { 1357 loadExternalCheckoutScripts(); 1358 } 1359 if(listLayout17) { 1360 updateVariantLabel(); 1361 toggleVariantDetails(); 1362 } 1363}); 1364document.addEventListener('zp-event-recommended-products-loaded' ,() => { 1365 if(listLayout17) { 1366 updateVariantLabel(); 1367 toggleVariantDetails(); 1368 } 1369}) 1370 1371 1372function viewCartInCheckout() { 1373 let miniCartCheckout = document.querySelector('[data-zs-view-mini-cart]'); 1374 if(miniCartCheckout){ 1375 const viewCartElement = document.querySelector('.theme-checkout-breadcrum li:nth-child(2) a'); 1376 viewCartElement.addEventListener('click', (event) => { 1377 event.preventDefault(); 1378 history.back(); 1379 if (zs_checkout && zs_checkout.is_quote) { 1380 sessionStorage.setItem('quoteRedirectAction', 'true'); // No I18N 1381 } else { 1382 sessionStorage.setItem('cartRedirectAction', 'true'); // No I18N 1383 } 1384 }) 1385 } 1386} 1387 1388document.addEventListener('keydown', function(event) { 1389 let focusedElement = document.activeElement; 1390 if ((focusedElement.hasAttribute('data-zs-qty-dec')) && (event.key === 'ArrowDown')) { 1391 event.preventDefault(); 1392 decreaseCount(focusedElement); 1393 } 1394 if ((focusedElement.hasAttribute('data-zs-qty-inc')) && (event.key === 'ArrowUp')) { 1395 event.preventDefault(); 1396 increaseCount(focusedElement); 1397 } 1398}); 1399 1400// START: Wishlist functions 1401 1402function addToWishlistFromList(variantId, wishlistElement) { 1403 if (wishlistElement.getAttribute('data-zs-wishlisted') === 'true') { 1404 this.deleteVariantInWishList(wishlistElement, true); 1405 } else { 1406 this.addVariantToWishlistApi(variantId, wishlistElement); 1407 } 1408} 1409 1410 1411function addVariantToWishlistApi(variantId, wishlist_container) { 1412 if (window.isLoggedInUser) { 1413 wishlist_container.disabled = true; 1414 $X.post({ 1415 url: "/storefront/api/v1/wishlists/variants",//NO I18N 1416 params: { variant_ids: variantId }, 1417 headers: zsUtils.getCSRFHeader(), 1418 handler: function () { 1419 var response = JSON.parse(this.responseText); 1420 if (response.status_code == 0) { 1421 wishlist_container.setAttribute('data-zs-wishlisted', "true"); 1422 if (wishlist_container.id == "wishlist-variant") { 1423 window.zs_wishlist_variants[variantId] = true; 1424 } 1425 wishlist_container.disabled = false;
1426 } 1427 var updateWishlistActionsEvent = new CustomEvent("zp-event-wishlist-actions-alert", {detail: response}); //NO I18N 1428 document.dispatchEvent(updateWishlistActionsEvent); 1429 wishlist_container.disabled = false; 1430 } 1431 }); 1432 } else { 1433 window.location.href = "/signin"; 1434 } 1435} 1436 1437function showorHideWishListEmptyView() { 1438 var isNoResultsFound = true; 1439 var elements = document.querySelectorAll('[data-zs-variant-wishlist]'); 1440 for (var i = 0; i < elements.length; i++) { 1441 if (elements[i].style.display !== 'none') { 1442 isNoResultsFound = false; 1443 } 1444 } 1445 1446 var dataNoWishlist = document.querySelector("[data-zs-no-wishlist]"); 1447 1448 if (isNoResultsFound) { 1449 dataNoWishlist.style.display = 'block'; 1450 } else { 1451 dataNoWishlist.style.display = 'none'; 1452 } 1453} 1454 1455function deleteVariantInWishList(wishlistRemoveButton, fromIcon) { 1456 wishlistRemoveButton.disabled = true; 1457 let wishlistElement; 1458 var variantId = wishlistRemoveButton.getAttribute('data-zs-wishlist-variant-id'); 1459 if (!fromIcon) { 1460 variantId = wishlistRemoveButton.getAttribute('data-zs-product-variant-id'); 1461 wishlistElement = document.querySelector("[data-zs-variant-id='" + variantId + "']"); 1462 } 1463 $X.del({ 1464 url: "/storefront/api/v1/wishlists/variants?variant_ids=" + variantId, //NO I18N 1465 headers: zsUtils.getCSRFHeader(), 1466 handler: function () { 1467 var response = JSON.parse(this.responseText); 1468 1469 if (response.status_code == 0) { 1470 if (fromIcon && wishlistRemoveButton) { 1471 wishlistRemoveButton.setAttribute('data-zs-wishlisted', 'false'); 1472 if (wishlistRemoveButton.id == "wishlist-variant") { 1473 window.zs_wishlist_variants[variantId] = false; 1474 } 1475 wishlistRemoveButton.disabled = false; 1476 } else { 1477 if (wishlistElement) { 1478 wishlistElement.remove(); 1479 var removeLinkContainer = document.querySelector('.removed-alert-container'); 1480 var linkElement = document.querySelector('.removed-alert-container a'); 1481 if (removeLinkContainer && linkElement ) { 1482 removeLinkContainer.style.display = "flex"; 1483 linkElement.href = wishlistRemoveButton.getAttribute('data-zs-variant-url'); 1484 linkElement.innerHTML = wishlistRemoveButton.getAttribute('data-zs-variant-name'); 1485 } 1486 } 1487 showorHideWishListEmptyView.call(this); 1488 } 1489 } 1490 if (fromIcon || response.status_code != 0 ) { 1491 var updateWishlistActionsEvent = new CustomEvent("zp-event-wishlist-actions-alert", {detail: response}); //NO I18N 1492 document.dispatchEvent(updateWishlistActionsEvent); 1493 } 1494 wishlistRemoveButton.disabled = false; 1495 } 1496 }); 1497} 1498 1499function hideLinkAlert() { 1500 var removeLinkContainer = document.querySelector('.removed-alert-container'); 1501 if (removeLinkContainer) { 1502 removeLinkContainer.style.display = "none"; 1503 } 1504} 1505 1506 1507function searchWishlistByName(searchText) { 1508 var wishlist_containers = document.querySelectorAll('[data-zs-variant-wishlist][data-zs-variant-id]'); 1509 var closeIcon = document.getElementById('resetWishlistSearch'); 1510 1511 for (var i = 0; i < wishlist_containers.length; i++) { 1512 var nameElement = wishlist_containers[i].querySelector('[data-zs-variant-name]'); 1513 if (nameElement && nameElement.innerText.toLowerCase().includes(searchText.toLowerCase())) { 1514 wishlist_containers[i].style.display = 'block'; 1515 } else { 1516 wishlist_containers[i].style.display = 'none'; 1517 } 1518 } 1519 1520 if (searchText) { 1521 closeIcon.style.display = 'block'; 1522 } else { 1523 closeIcon.style.display = 'none'; 1524 } 1525 1526 this.showorHideWishListEmptyView(); 1527} 1528 1529function clearSearch() { 1530 var searchWishlistElements = document.getElementsByName('search_wishlist'); 1531 var searchWishlist = searchWishlistElements.length > 0 ? searchWishlistElements[0] : null; 1532 searchWishlist.value = ''; 1533 searchWishlistByName(''); 1534 document.getElementById('close').style.display = 'none'; 1535} 1536 1537window.addEventListener("load", function () { 1538 var searchWishlistElements = document.getElementsByName('search_wishlist'); 1539 var searchWishlist = searchWishlistElements.length > 0 ? searchWishlistElements[0] : null; 1540 if (searchWishlist) { 1541 searchWishlist.oninput = function (event) { 1542 searchWishlistByName(event.target.value); 1543 }; 1544 } 1545}); 1546 1547// END Wishlist methods 1548 1549function toggleProductsView(elem, value){ 1550 let viewBy = elem.closest('[data-view-by]'); // No I18N 1551 if(viewBy) { 1552 viewBy.setAttribute('data-view-by', value); 1553 elem.classList.add('theme-active-class'); // No I18N 1554 } 1555 productViewBy(); 1556}
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.