PageSourceSearch

https://robertmondaviwinery.com/cdn/shop/t/261/assets/cbi_cart.js?v=158655681312418073521790108203

js robertmondaviwinery.com collected 2026-10-01 11:35:03 UTC 17,349 bytes, 2 lines download raw bytes

1let cbi_cart_toggle=null;const findCartToggle=()=>document.querySelector('a[href="/cart"]')||document.querySelector("#cart-icon-bubble-test")||document.querySelector("#cart-icon-bubble"),setupCartToggle=element=>{element&&!element.hasAttribute("data-cbi-cart-setup")&&(element.setAttribute("href","#cart"),element.setAttribute("data-cbi-cart-setup","true"))},hideCBICart=()=>{const cbi_cart_overlay=document.querySelector(".cbi-cart_overlay");if(cbi_cart_overlay){cbi_cart_overlay.style.opacity="0";const cbi_cart_shell=document.querySelector(".cbi-cart_shell");cbi_cart_shell&&(cbi_cart_shell.style.transform="translateX(100%)"),setTimeout(()=>{cbi_cart_overlay.style.display="none"},900)}},showCBICart=()=>{const cbi_cart_overlay=document.querySelector(".cbi-cart_overlay"),cbi_cart_shell=document.querySelector(".cbi-cart_shell"),trash_icons=document.querySelectorAll(".trash-icon svg");if(cbi_cart_overlay&&cbi_cart_shell){cbi_cart_shell.classList.add("animate-ready"),cbi_cart_overlay.style.opacity="1",cbi_cart_overlay.style.display="block",cbi_cart_shell.style.transform="translateX(0px)",trash_icons.forEach(svg=>{svg.style.visibility="visible"});const closeButton=document.querySelector(".cbi-cart_close-button");closeButton&&!closeButton.hasAttribute("data-event-listener-added")&&(closeButton.setAttribute("data-event-listener-added","true"),closeButton.addEventListener("click",function(_e){hideCBICart()}));const cartOverlay=document.querySelector(".cbi-cart_overlay");cartOverlay&&!cartOverlay.hasAttribute("data-event-listener-added")&&(cartOverlay.setAttribute("data-event-listener-added","true"),cartOverlay.addEventListener("click",function(_e){hideCBICart()})),setupCheckoutButtonEventListener(),setTimeout(()=>{checkMinimumBottles()},50)}};function initializeCartToggle(){const toggle=findCartToggle();return toggle?(setupCartToggle(toggle),cbi_cart_toggle=toggle,!0):!1}initializeCartToggle(),cbi_cart_toggle.addEventListener("click",function(e){e.preventDefault(),showCBICart()}),document.addEventListener("DOMContentLoaded",function(){setupCheckoutButtonEventListener()});function setupCheckoutButtonEventListener(){const checkoutButton=document.getElementById("checkout-button");checkoutButton&&!checkoutButton.hasAttribute("data-event-listener-added")&&(checkoutButton.setAttribute("data-event-listener-added","true"),checkoutButton.addEventListener("click",function(e){if(e.preventDefault(),e.stopPropagation(),this.disabled||this.classList.contains("disabled")){const messageElement=document.getElementById("minimum-bottles-message");return messageElement&&(messageElement.style.display="block",messageElement.style.animation="flashMessage 1s ease-in-out"),!1}window.location.href="/checkout"}))}const observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{mutation.type==="childList"&&mutation.addedNodes.forEach(node=>{node.nodeType===1&&(node.id==="cart-icon-bubble-test"||node.id==="cart-icon-bubble"||node.querySelector&&(node.querySelector("#cart-icon-bubble-test")||node.querySelector("#cart-icon-bubble")))&&setTimeout(()=>{initializeCartToggle()&&console.log("Successfully initialized cart toggle from mutation observer")},100)})})});observer.observe(document.body,{childList:!0,subtree:!0});let cartRetryCount=0;const cartMaxRetries=30,cartRetryInterval=setInterval(()=>{cartRetryCount++,(initializeCartToggle()||cartRetryCount>=cartMaxRetries)&&clearInterval(cartRetryInterval)},1e3);document.addEventListener("click",function(e){let cartElement=null;(e.target.id==="cart-icon-bubble-test"||e.target.id==="cart-icon-bubble")&&(cartElement=e.target),cartElement||(cartElement=e.target.closest('#cart
1-icon-bubble-test, #cart-icon-bubble, a[href="#cart"]')),cartElement&&(cartElement.hasAttribute("data-cbi-cart-setup")||setupCartToggle(cartElement),e.preventDefault(),e.stopPropagation(),showCBICart())},!0),setTimeout(()=>{observer.disconnect()},35e3),window.addEventListener("pageshow",event=>{event.persisted&&fetchSection("cbi-cart").then(()=>{document.dispatchEvent(new Event("cart:updated"))})});function findSpecificElement(item,targetId){const elem=item.parentNode.querySelector(`#${targetId}`);return elem||null}function disableButton(item){item.setAttribute("disabled",""),item.style.opacity="0.5",item.style.cursor="default"}function enableButton(item){item.removeAttribute("disabled"),item.style.opacity="1",item.style.cursor="pointer"}function showMinLimit(item){const minLimit=findSpecificElement(item,"limit-message-container-min");minLimit&&minLimit.removeAttribute("hidden")}function hideMinLimit(item){const minLimit=findSpecificElement(item,"limit-message-container-min");minLimit&&minLimit.setAttribute("hidden","")}function showMaxLimit(item){const maxLimit=findSpecificElement(item,"limit-message-container-max");maxLimit&&maxLimit.removeAttribute("hidden")}function hideMaxLimit(item){const maxLimit=findSpecificElement(item,"limit-message-container-max");maxLimit&&maxLimit.setAttribute("hidden","")}function checkMinimumBottles(){const minBottlesElement=document.querySelector("#minimum-bottles-message #cart-minimum-bottles-qty");if(minBottlesElement){const min_bottles=minBottlesElement?parseInt(minBottlesElement.textContent,10):1,nonAlcoholicItems=document.querySelectorAll("[data-category='non-alcoholic']"),productDetails=document.querySelectorAll("[data-category='alcoholic-beverage']");if(productDetails.length===0&&nonAlcoholicItems.length===0){document.getElementById("minimum-bottles-message").style.display="none";return}if(nonAlcoholicItems.length>0&&productDetails.length===0){const messageElement=document.getElementById("minimum-bottles-message");messageElement&&(messageElement.style.display="none");const checkoutButton=document.getElementById("checkout-button");checkoutButton&&(checkoutButton.disabled=!1,checkoutButton.removeAttribute("disabled"),checkoutButton.classList.remove("disabled"),checkoutButton.classList.add("checkout-button"));return}let totalBottles=0;if(productDetails.forEach(product=>{const description=product.querySelector(".description span"),currentValue=parseInt(product.querySelectorAll("input[type=text]")[0].value);let bottleCount=0;description?bottleCount=parseInt(description.textContent,10)*currentValue:bottleCount=currentValue,totalBottles+=bottleCount}),totalBottles<min_bottles){const messageElement=document.getElementById("minimum-bottles-message");messageElement&&(messageElement.style.display="block",messageElement.style.opacity="1",messageElement.style.visibility="visible");const checkoutButton=document.getElementById("checkout-button");checkoutButton&&(checkoutButton.disabled=!0,checkoutButton.setAttribute("disabled","disabled"),checkoutButton.classList.remove("checkout-button"),checkoutButton.classList.add("disabled"))}else{const messageElement=document.getElementById("minimum-bottles-message");messageElement&&(messageElement.style.display="none");const checkoutButton=document.getElementById("checkout-button");checkoutButton&&(checkoutButton.disabled=!1,checkoutButton.removeAttribute("disabled"),checkoutButton.classList.remove("disabled"),checkoutButton.classList.add("checkout-button"))}}}function debounce(func,wait){let timeout;return function(...args){const later=()=>{clearTimeout(timeout),func(...args)};clearTimeout(timeout),timeout=setTimeout(later,wait)}}const debouncedCheckMinimumBottles=debounce(checkMinimumBottles,100);function validateBoundaries(item,productKey,min=1,max=500,isMinDisplayed=!0){const currentValue=parseInt(item.parentNode.querySelectorAll("input[type=text]")[0].value);currentValue<=min?(hideMaxLimit(item.parentNode.parentNode),isMinDisplayed&&min>1&&showMinLimit(item.parentNode.parentNode),disableButton(item.parentNode.querySelectorAll("button")[0]),enableButton(item.parentNode.querySelectorAll("button")[1]),item.parentNode.querySelectorAll("input[type=text]")[0].value=min.toString(),updateItemQuantityInCart(min,productKey)):currentValue>=max?(hideMinLimit(item.parentNode.parentNode),showMaxLimit(item.parentNode.parentNode),disableButton(item.parentNode.querySelectorAll("button")[1]),enableButton(item.parentNode.querySelectorAll("button")[0]),item.parentNode.querySelectorAll("input[type=text]")[0].value=max.toString(),updateItemQuantityInCart(max,productKey)):(enableButton(item.parentNode.querySelectorAll("button")[0]),enableButton(item.parentNode.querySelectorAll("button")[1]),hideMinLimit(item.parentNode.parentNode),hideMaxLimit(item.parentNode.parentNode),updateItemQuantityInCart(currentValue,productKey))}function decrementQuantity(item,productKey,step=1,min=1){const currentValue=parseInt(item.parentNode.querySelectorAll("input[type=text]")[0].value);if(hideMaxLimit(item.parentNode.parentNode),currentValue>=min){let newValue=currentValue-step;newValue<=min?(newValue=min,disableButton(item),enableButton(item.parentNode.querySelectorAll("button")[1]),min>1&&showMinLimit(item.parentNode.parentNode),item.parentNode.querySelectorAll("input[type=text]")[0].value=min.toString()):(hideMinLimit(item.parentNode.parentNode),enableButton(item.parentNode.querySelectorAll("button")[1]),item.parentNode.querySelectorAll("input[type=text]")[0].value=newValue.toString()),updateItemQuantityInCart(newValue,productKey)}}function incrementQuantity(item,productKey,step=1,max=500){const currentValue=parseInt(item.parentNode.querySelectorAll("input[type=text]")[0].value);if(hideMinLimit(item.parentNode.parentNode),currentValue<=max){let newValue=currentValue+step;newValue>=max?(newValue=max,disableButton(item),enableButton(item.parentNode.querySelectorAll("button")[0]),showMaxLimit(item.parentNode.parentNode),item.parentNode.querySelectorAll("input[type=text]")[0].value=max.toString()):(hideMaxLimit(item.parentNode.parentNode),enableButton(item.parentNode.querySelectorAll("button")[0]),item.parentNode.querySelectorAll("input[type=text]")[0].value=newValue.toString()),updateItemQuantityInCart(newValue,productKey)}}function updateItemQuantity(quantity,productKey){const cart_product_item=document.getElementById(productKey);cart_product_item&&(cart_product_item.querySelectorAll("input[type=text]")[0].value=quantity.toString())}function fetchSection(sectionId){return fetch(window.Shopify.routes.root+"?sections="+sectionId,{method:"GET"}).then(response=>response.json()).then(data=>{const CBICartWrapper=new DOMParser().parseFromString(data["cbi-cart"],"text/html").getElementById("cbi-cart_wrapper"),currentCartWrapper=document.getElementById("cbi-cart_wrapper");if(CBICartWrapper&&currentCartWrapper){const newCartShell=CBICartWrapper.querySelector(".cbi-cart_shell");newCartShell&&newCartShell.classList.remove("animate-ready"),currentCartWrapper.remove(),document.getElementById("shopify-section-cbi-cart").appendChild(CBICartWrapper)}})}function displayErrorInCollectionPage(formData,data){if(document.querySelectorAll(".product-card-error").forEach(elem=>elem.remove()),!formData||!data||!data.message)return;let fd;try{fd=JSON.parse(formData)}catch{console.error("Invalid JSON in formData:",formData);return}const variantId=fd?.items?.[0]?.id;if(!variantId)return;const container=document.querySelector(`.prod_card[data-productvarient="${variantId}"]`);if(!container)return;const btnWrapper=container.querySelector(".product-card-btn-container");if(!btnWrapper)return;const errorDiv=document.createElement("div");errorDiv.className="product-card-error",errorDiv.textContent=data.message,errorDiv.style.fontSize="12px",errorDiv.style.color="red",btnWrapper.prepend(errorDiv)}function addToCart(formData,isJson=!0){if(window.CBI_ALLOWED_ADD_TO_CART=!0,isJson)try{const parsedData=JSON.parse(formData)}catch(e){console.error("Failed to parse formData:",e)}fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:isJson?{"Content-Type":"application/json"}:{},body:formData}).then(response=>response.json()).then(async data=>{if(data.status==422)displayError(data.message),document.getElementById("pdp-cart-error")&&(document.getElementById("pdp-cart-error").innerText=data.message),displayErrorInCollectionPage(formData,data);else{if(window.CBI_CART_PANEL_ENABLED===!1){bloomFetchCart();return}displayErrorInCollectionPage([],[]),fetchSection("cbi-cart").then(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{showCBICart(),checkMinimumBottles(),document.dispatchEvent(new Event("cart:add")),document.dispatchEvent(new Event("cart:updated")),data.status==422?displayError(data.message):document.dispatchEvent(new CustomEvent("cart:checkLimits",{detail:{itemId:data.id}}))})})})}}
1).catch(function(error){displayError(error.message)})}function handleAddToCart(quantity,key){let itemToAdd={items:[{id:key.toString(),quantity}]};addToCart(JSON.stringify(itemToAdd))}function updateItemQuantityInCart(quantity,key){let itemUpdate={id:key.toString(),quantity};fetch(window.Shopify.routes.root+"cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(itemUpdate)}).then(response=>response.json()).then(async data=>{data.status==422?(displayError(data.message),document.dispatchEvent(new CustomEvent("cart:checkItemInventory",{detail:{itemId:key}}))):(document.querySelector("#cart-error")&&document.querySelector("#cart-error").remove(),quantity===0&&removeItemFromCart(key),data.item_count===0&&hideCBICart(),checkMinimumBottles(),document.dispatchEvent(new Event("cart:updated")))}).catch(error=>{console.error("Error updating cart:",error),displayError(error.message)})}function removeItemFromCart(productKey){let totalValue=document.getElementById(productKey);totalValue&&totalValue.remove()}function displayError(errorMessage){var errorTag=document.createElement("div");errorTag.id="cart-error",errorTag.classList.add("cart-error-message"),errorTag.classList.add("mt-2"),errorTag.style.fontSize="12px",errorTag.style.fontWeight="600",errorTag.style.color="#DC1212";const closeButton=document.createElement("span");closeButton.classList.add("close-button"),closeButton.innerText="X",closeButton.addEventListener("click",()=>{errorTag.remove()}),errorTag.innerText=errorMessage,errorTag.appendChild(closeButton),document.querySelector("#cart-error")&&document.querySelector("#cart-error").remove();var eElement=document.querySelector("#product-list-container");eElement.insertBefore(errorTag,eElement.querySelector(".cart-product-item"))}document.addEventListener("cart:checkLimits",async event=>{const itemId=event.detail?.itemId?.toString();if(itemId){const min_purchase=document.getElementById("min-purchase-"+itemId),max_purchase=document.getElementById("max-purchase-"+itemId),min_purchase_value=min_purchase?parseInt(min_purchase.innerText,10):1,max_purchase_value=max_purchase?parseInt(max_purchase.innerText,10):500,inputField=document.getElementById(itemId).querySelectorAll("input[type=text]")[0],currentValue=parseInt(inputField.value);if(currentValue<=min_purchase_value||currentValue>=max_purchase_value){const isMinDisplayed=min_purchase_value>1;validateBoundaries(inputField,itemId,min_purchase_value,max_purchase_value,isMinDisplayed)}}}),document.addEventListener("cart:checkLimits",async()=>{try{const response=await fetch("/cart.js");if(!response.ok)throw new Error("Failed to fetch cart data");(await response.json()).items.forEach(item=>{const itemId=item.id.toString(),inputField=document.getElementById(itemId).querySelectorAll("input[type=text]")[0],currentValue=parseInt(inputField.value);item.quantity!==currentValue&&updateItemQuantityInCart(currentValue,itemId)})}catch(error){console.error("Error fetching cart:",error)}}),document.addEventListener("cart:checkItemInventory",async event=>{try{const itemId=event.detail?.itemId?.toString(),response=await fetch("/cart.js");if(!response.ok)throw new Error("Failed to fetch cart data");const itemChanged=(await response.json()).items.find(item=>item.id.toString()===itemId);if(itemChanged){const newQuantity=itemChanged.quantity,inputField=document.getElementById(itemId).querySelectorAll("input[type=text]")[0];enableButton(inputField.parentNode.querySelectorAll("button")[0]),enableButton(inputField.parentNode.querySelectorAll("button")[1]),hideMinLimit(inputField.parentNode.parentNode),hideMaxLimit(inputField.parentNode.parentNode),document.getElementById(itemId).querySelectorAll("input[type=text]")[0].value=newQuantity.toString()}}catch(error){console.error("Error fetching cart:",error)}});function bloomAddToCart(v_id,item){const inputElement=item.parentNode.querySelectorAll("input[type=text]")[0];let quantityValue=inputElement?.value;inputElement||(quantityValue="1"),addAndOpenCart(v_id,quantityValue),item.parentNode.querySelectorAll("input[type=text]")[0].value==""&&(item.parentNode.querySelectorAll("input[type=text]")[0].value=1)}async function addAndOpenCart(id,quantity,properties){await bloom.shoppingCart().add([{id,quantity,properties:properties||{}}]),await bloom.reloadCart(),document.dispatchEvent(new Event("cart:updated")),bloom.showCart()}async function bloomFetchCart(){try{const cart=await window.bloomCart.get();cart?(document.getElementById("cart-counter").textContent=cart.item_count,await bloom.reloadCart(),setTimeout(()=>{document.getElementById("cart-counter").click()},500)):console.error("cart not found")}catch(error){console.error("Error in bloomFetchCart:",error)}}
2//# sourceMappingURL=/cdn/shop/t/261/assets/cbi_cart.js.map?v=158655681312418073521790108203

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.