PageSourceSearch

https://www.hannoush.com/cdn/shop/t/40/assets/product-add-to-cart.js?v=129323858590248101631788874359

js hannoush.com collected 2026-09-24 12:06:44 UTC 8,896 bytes, 2 lines download raw bytes

1(function(){"use strict";function parseCarePlanTable(raw){try{const table=JSON.parse(raw||"[]");return Array.isArray(table)?table.sort(function(a,b){return a.max-b.max}):[]}catch{return[]}}function getCarePlanInfo(table,price){return table.find(function(row){return price<=row.max})}function getVariantId(container){const variantSelects=(container.closest(".thb-product-detail")||container.closest("#Product-Drawer")||document).querySelector("variant-selects");return variantSelects&&variantSelects.currentVariant&&variantSelects.currentVariant.id?variantSelects.currentVariant.id:container.dataset.mainVariantId}function getRingSizeProperty(container){const root=container.closest(".thb-product-detail")||container.closest("#Product-Drawer")||document,ringSelect=root.querySelector('select[name="properties[Ring Size]"]');if(ringSelect)return ringSelect.value;const ringRadio=root.querySelector('input[name="properties[Ring Size]"]:checked');return ringRadio?ringRadio.value:null}function openCartUi(){var productDrawer=document.getElementById("Product-Drawer");productDrawer&&(productDrawer.classList.remove("active"),productDrawer.querySelector(".product-quick-images--container")?.classList.remove("active"),document.body.classList.remove("open-quick-view"));var cartDrawer=document.getElementById("Cart-Drawer");return cartDrawer?(document.body.classList.add("open-cc"),document.body.classList.add("open-cart"),cartDrawer.classList.add("active"),cartDrawer.querySelector(".product-recommendations--full")?.classList.add("active"),typeof dispatchCustomEvent=="function"&&dispatchCustomEvent("cart-drawer:open"),!0):!1}function refreshCartSections(){var root=window.theme&&window.theme.routes&&window.theme.routes.root||"/";return fetch(root+"?sections=cart-drawer,cart-bubble").then(function(res){return res.json()}).then(function(sections){if(sections["cart-drawer"]&&document.getElementById("Cart-Drawer")){var drawerInner=document.getElementById("Cart-Drawer").querySelector(".cart-drawer")||document.getElementById("Cart-Drawer"),parsed=new DOMParser().parseFromString(sections["cart-drawer"],"text/html"),source=parsed.querySelector(".cart-drawer")||parsed.querySelector(".shopify-section");source&&drawerInner&&(drawerInner.innerHTML=source.innerHTML)}if(sections["cart-bubble"]){var bubble=document.getElementById("cart-drawer-toggle");if(bubble){var bubbleParsed=new DOMParser().parseFromString(sections["cart-bubble"],"text/html"),countEl=bubbleParsed.querySelector(".thb-item-count"),target=bubble.querySelector(".thb-item-count");countEl&&target&&(target.innerHTML=countEl.innerHTML)}}}).catch(function(){})}function initContainer(container){if(!container||container.dataset.hjAtcInit==="true")return;container.dataset.hjAtcInit="true";var addBtn=container.querySelector(".product-add-to-cart-container__submit"),btnText=container.querySelector(".product-add-to-cart-container__text"),spinner=container.querySelector(".product-add-to-cart-container__spinner"),careLinkContainer=container.querySelector(".product-add-to-cart-container__care-plan"),qtyInput=container.querySelector(".product-add-to-cart-container__qty"),qtySelector=container.querySelector("quantity-selector");if(!addBtn||!btnText||!qtyInput)return;var mainPrice=parseFloat(container.dataset.mainPrice||"0"),isWatch=container.dataset.isWatch==="true",jewelryTable=parseCarePlanTable(container.dataset.jewelryCarePlanTable||container.dataset.carePlanTable||"[]"),watchTable=parseCarePlanTable(container.dataset.watchCarePlanTable||"[]"),carePlanTable=isWatch?watchTable:jewelryTable,planLabel=isWatch?"Watch Care Plan":"Custom Care Plan",addCarePlan=!1,selectedPlanId=null,selectedPlanPrice=null;function carePlanButtonLabel(added,price){var amount="$"+price.toFixed(2);return added?"\u2713 "+planLabel+" - "+amount:"+ "+planLabel+" - "+amount}if(careLinkContainer&&(careLinkContainer.innerHTML=""),mainPrice>0&&careLinkContainer){var matchedPlan=getCarePlanInfo(carePlanTable,mainPrice);if(matchedPlan){selectedPlanId=matchedPlan.id,selectedPlanPrice=matchedPlan.price;var actions=document.createElement("div");actions.className="product-add-to-cart-container__care-actions";var careBtn=document.createElement("button");careBtn.type="button",careBtn.className="button outline product-add-to-cart-container__care-btn",careBtn.setAttribute("aria-pressed","fal
1se");var careBtnLabel=document.createElement("span");careBtnLabel.textContent=carePlanButtonLabel(!1,selectedPlanPrice),careBtn.appendChild(careBtnLabel),actions.appendChild(careBtn),careBtn.addEventListener("click",function(e){e.preventDefault(),addCarePlan=!addCarePlan,careBtn.setAttribute("aria-pressed",addCarePlan?"true":"false"),careBtn.classList.toggle("is-selected",addCarePlan),careBtnLabel.textContent=carePlanButtonLabel(addCarePlan,selectedPlanPrice)}),careLinkContainer.appendChild(actions);var descSource=container.querySelector(".product-add-to-cart-container__care-desc"),descHtml=descSource?descSource.innerHTML.trim():"";if(descHtml){var detailsBtn=document.createElement("button");detailsBtn.type="button",detailsBtn.className="product-add-to-cart-container__care-details-btn",detailsBtn.setAttribute("aria-expanded","false"),detailsBtn.textContent="What's covered?";var panel=document.createElement("div");panel.className="product-add-to-cart-container__care-details-panel",panel.hidden=!0,panel.innerHTML=descHtml,detailsBtn.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();var open=panel.hidden;panel.hidden=!open,detailsBtn.setAttribute("aria-expanded",open?"true":"false"),detailsBtn.textContent=open?"Hide coverage details":"What's covered?"}),careLinkContainer.appendChild(detailsBtn),careLinkContainer.appendChild(panel)}}}if(qtySelector){var minusBtn=qtySelector.querySelector(".minus"),plusBtn=qtySelector.querySelector(".plus");minusBtn&&minusBtn.addEventListener("click",function(){var currentQty=parseInt(qtyInput.value,10)||1;currentQty>1&&(qtyInput.value=currentQty-1)}),plusBtn&&plusBtn.addEventListener("click",function(){var currentQty=parseInt(qtyInput.value,10)||1;qtyInput.value=currentQty+1})}qtyInput.addEventListener("change",function(){var value=parseInt(this.value,10)||1;value<1&&(this.value=1)}),addBtn.addEventListener("click",function(){var currentVariantId=getVariantId(container);if(currentVariantId){btnText.style.display="none",spinner&&(spinner.style.display="inline-block"),addBtn.setAttribute("aria-disabled","true");var ringValue=getRingSizeProperty(container),selectedQuantity=parseInt(qtyInput.value,10)||1,mainItem={id:parseInt(currentVariantId,10),quantity:selectedQuantity};ringValue&&(mainItem.properties={"Ring Size":ringValue});var items=[mainItem];addCarePlan&&selectedPlanId&&items.push({id:parseInt(selectedPlanId,10),quantity:selectedQuantity,properties:{"Care Plan Variant ID":parseInt(currentVariantId,10)}}),fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items})}).then(function(res){return res.ok?res.json():res.json().then(function(err){throw err})}).then(function(){return typeof dispatchCustomEvent=="function"&&dispatchCustomEvent("cart:item-added",{product:mainItem}),refreshCartSections().then(function(){openCartUi()||(window.location.href="/cart")})}).catch(function(err){console.error("Add to cart error:",err),alert(err&&err.description||"Error adding to cart.")}).finally(function(){btnText.style.display="inline",spinner&&(spinner.style.display="none"),addBtn.removeAttribute("aria-disabled")})}})}function initProductAddToCartContainers(root){var scope=root&&root.querySelectorAll?root:document;scope.querySelectorAll('.product-add-to-cart-container:not([data-hj-atc-init="true"])').forEach(initContainer)}window.HjCarePlanCart={getLinkedParentVariantId:function(item){if(!item||!item.properties)return null;var value=item.properties["Care Plan Variant ID"];return value==null||value===""?null:value},buildUpdates:function(cart,line,quantity){var idx=parseInt(line,10)-1,qty=parseInt(quantity,10);if(!cart||!Array.isArray(cart.items)||isNaN(idx)||idx<0||idx>=cart.items.length)return null;(isNaN(qty)||qty<0)&&(qty=0);var item=cart.items[idx],updates={};if(updates[item.key]=qty,this.getLinkedParentVariantId(item)==null){var parentVariantId=String(item.variant_id);cart.items.forEach(function(ci){var linked=window.HjCarePlanCart.getLinkedParentVariantId(ci);linked!=null&&String(linked)===parentVariantId&&(updates[ci.key]=qty)})}return updates}},window.initProductAddToCartContainers=initProductAddToCartContainers,document.addEventListener("DOMContentLoaded",function(){initProductAddToCartContainers(document)}),document.addEventListener("quick-view:open",function(){var drawer=document.getElementById("Product-Drawer-Content");drawer&&initProductAddToCartContainers(drawer)})})();
2//# sourceMappingURL=/cdn/shop/t/40/assets/product-add-to-cart.js.map?v=129323858590248101631788874359

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.