PageSourceSearch

https://www.purdey.com/cdn/shop/t/17/assets/product-form.compiled.js?v=179946441535122296301772715376

js purdey.com collected 2026-09-24 19:52:48 UTC 10,939 bytes, 2 lines download raw bytes

1(function(){"use strict";var e="analytics.add-to-cart";function t(e2,t2){return e2??t2()}function a(e2){for(var t2=void 0,a2=e2[0],o2=1;o2<e2.length;){var s2=e2[o2],r2=e2[o2+1];if(o2+=2,(s2==="optionalAccess"||s2==="optionalCall")&&a2==null)return;s2==="access"||s2==="optionalAccess"?(t2=a2,a2=r2(a2)):s2!=="call"&&s2!=="optionalCall"||(a2=r2(function(){for(var e3=arguments.length,o3=new Array(e3),s3=0;s3<e3;s3++)o3[s3]=arguments[s3];return a2.call(t2,...o3)}),t2=void 0)}return a2}class o extends HTMLElement{constructor(){if(super(),this.cartItems=document.querySelector("cart-items"),this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cartNotification=document.querySelector("cart-notification"),this.dataset.verificationRequired){var e2=this.querySelector(".product-form__submit");a([this,"access",e3=>e3.querySelector,"call",e3=>e3(".over-18-field input"),"optionalAccess",e3=>e3.addEventListener,"call",t2=>t2("change",t3=>(t3.target.checked?e2.removeAttribute("disabled"):e2.setAttribute("disabled",""),!1))])}this.validateAdditionalInputs()}onSubmitHandler(o2){o2.preventDefault();var s2=this.querySelector('[type="submit"]');if(!a([s2,"optionalAccess",e2=>e2.classList,"access",e2=>e2.contains,"call",e2=>e2("loading")])){this.handleErrorMessage(),this.cartNotification.setActiveElement(document.activeElement),a([s2,"optionalAccess",e2=>e2.setAttribute,"call",e2=>e2("aria-disabled","true")]),a([s2,"optionalAccess",e2=>e2.classList,"access",e2=>e2.add,"call",e2=>e2("loading")]),a([this,"access",e2=>e2.querySelector,"call",e2=>e2(".loading-overlay__spinner"),"optionalAccess",e2=>e2.classList,"access",e2=>e2.remove,"call",e2=>e2("hidden")]);var r2=(function(){return{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/".concat(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"json")}}})("javascript");r2.headers["X-Requested-With"]="XMLHttpRequest",delete r2.headers["Content-Type"];var i2=new FormData(this.form);i2.append("sections",this.cartNotification.getSectionsToRender().map(e2=>e2.id)),i2.append("sections_url",window.location.pathname),r2.body=i2,fetch("".concat(window.routes.cart_add_url),r2).then(e2=>e2.json()).then(o3=>{if(o3.status)this.handleErrorMessage(o3.description);else{document.dispatchEvent(new CustomEvent(e,{detail:{productId:+this.dataset.productId,size:t(a([i2,"access",e2=>e2.get,"call",e2=>e2("Size"),"optionalAccess",e2=>e2.toString,"call",e2=>e2()]),()=>""),quantity:+t(a([i2,"access",e2=>e2.get,"call",e2=>e2("quantity"),"optionalAccess",e2=>e2.toString,"call",e2=>e2()]),()=>"1"),isEmbossed:!1,isEngraved:!1}})),a([this,"access",e2=>e2.cartItems,"optionalAccess",e2=>e2.refresh,"call",e2=>e2()]);var s3=this.closest("quick-shop-modal");s3?(document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cartNotification.renderContents(o3)})},{once:!0}),s3.hide(!0)):window.location.pathname!=="/cart"&&this.cartNotification.renderContents(o3)}}).catch(e2=>{console.error(e2)}).finally(()=>{a([s2,"optionalAccess",e2=>e2.classList,"access",e2=>e2.remove,"call",e2=>e2("loading")]),a([s2,"optionalAccess",e2=>e2.removeAttribute,"call",e2=>e2("aria-disabled")]),a([this,"access",e2=>e2.querySelector,"call",e2=>e2(".loading-overlay__spinner"),"optionalAccess",e2=>e2.classList,"access",e2=>e2.add,"call",e2=>e2("hidden")])})}}validateAdditionalInputs(){var e2=document.querySelector(".additional__field");e2&&(e2.value&&e2.value.length>0&&e2.value.trim().length>0&&e2.value.trim().length<30?this.enableButton():this.disableButton(),a([e2,"optionalAccess",e3=>e3.addEventListener,"call",t2=>t2("input",()=>{if(e2.value&&e2.value.length>0&&e2.value.trim().length>0&&e2.value.trim().length<30){this.enableButton();var t3=document.querySelector(".error");if(!t3)return;t3.classList.remove("show-error-message"),t3.classList.add("hide-error-message")}else{var f=e2.previousElementSibling?.textContent;this.disableButton();var a2=document.querySelector(".error");if(!a2)return;a2.textContent=e2.value.trim().length>=30?"".concat(f," must be 30 characters or less."):"".concat(f," cannot be empty."),a2.classList.remove("hide-error-message"),a2.classList.add("show-error-message")}})]))}enableButton(){var e2=document.querySelector(".product-form__buttons");e2&&(e2.classList.remove("disable-buy-buttons"),e2.classList.add("show-buy-buttons"))}disableButton(){var e2=document.querySelector(".product-form__buttons");e2&&(e2.classList.remove("show-buy-buttons"),e2.classList.add("disable-buy-buttons"))}handleErrorMessage(){var e2=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!e2),e2&&(this.errorMessage.textContent=e2)}}function s(e2){for(var t2=void 0,a2=e2[0],o2=1;o2<e2.length;){var s2=e2[o2],r2=e2[o2+1];if(o2+=2,(s2==="optionalAccess"||s2==="optionalCall")&&a2==null)return;s2==="access"||s2==="optionalAccess"?(t2=a2,a2=r2(a2)):s2!=="call"&&s2!=="optionalCall"||(a2=r2(function(){for(var e3=arguments.length,o3=new Array(e3),s3=0;s3<e3;s3++)o3[s3]=arguments[s3];return a2.call(t2,...o3)}),t2=void 0)}return a2}class r extends HTMLElement{constructor(){super();var e2=this.querySelector('[id^="ModalClose-"]');e2&&e2.addEventListener("click",this.hide.bind(this)),this.addEventListener("keyup",e3=>{s([e3,"access",e4=>e4.code,"optionalAccess",e4=>e4.toUpperCase,"call",e4=>e4()])==="ESCAPE"&&this.hide()}),this.classList.contains("media-modal")?this.addEventListener("pointerup",e3=>{e3.pointerType==="mouse"&&this.hide()}):this.addEventListener("click",e3=>{s([e3.target,"optionalAccess",e4=>e4.nodeName])==="MODAL-DIALOG"&&this.hide()})}show(e2){this.openedBy=e2;var t2=this.querySelector(".template-popup");document.body.classList.add("overflow-hidden"),this.setAttribute("open",""),t2&&t2.loadContent();try{window.trapFocus(this,this.querySelector('[role="dialog"]')),window.pauseAllMedia()}catch{}this.onOpened()}hide(){document.body.classList.remove("overflow-hidden"),document.body.dispatchEvent(new CustomEvent("modalClosed")),this.removeAttribute("open");try{window.removeTrapFocus(this.openedBy),window.pauseAllMedia()}catch{}}onOpened(){}}class i extends HTMLElement{constructor(){super(),this.updateProductHandle()}updateProductHandle(){(function(e2){for(var t2=void 0,a2=e2[0],o2=1;o2<e2.length;){var s2=e2[o2],r2=e2[o2+1];if(o2+=2,(s2==="optionalAccess"||s2==="optionalCall")&&a2==null)return;s2==="access"||s2==="optionalAccess"?(t2=a2,a2=r2(a2)):s2!=="call"&&s2!=="optionalCall"||(a2=r2(function(){for(var e3=arguments.length,o3=new Array(e3),s3=0;s3<e3;s3++)o3[s3]=arguments[s3];return a2.call(t2,...o3)}),t2=void 0)}})([document.querySelector(".colour-products_list"),"optionalAccess",e2=>e2.addEventListener,"call",e2=>e2("click",function(e3){if(e3.target.closest("a")){var t2=e3.target.closest("a").getAttribute("data-handle");window.history.pushState("","new product handle","products/".concat(t2))}})])}}function n(e2){for(var t2=void 0,a2=e2[0],o2=1;o2<e2.length;){var s2=e2[o2],r2=e2[o2+1];if(o2+=2,(s2==="optionalAccess"||s2==="optionalCall")&&a2==null)return;s2==="access"||s2==="optionalAccess"?(t2=a2,a2=r2(a2)):s2!=="call"&&s2!=="optionalCall"||(a2=r2(function(){for(var e3=arguments.length,o3=new Array(e3),s3=0;s3<e3;s3++)o3[s3]=arguments[s3];return a2.call(t2,...o3)}),t2=void 0)}return a2}customElements.get("product-form")||customElements.define("product-form",o),customElements.get("product-modal")||customElements.define("product-modal",class extends r{constructor(){super()}hide(){super.hide()}show(e2){super.show(e2),this.showActiveMedia()}showActiveMedia(){this.querySelectorAll('[data-media-id]:not([data-media-id="'.concat(this.openedBy.getAttribute("data-media-id"),'"])')).forEac
1h(e3=>{e3.classList.remove("active")});var e2=this.querySelector('[data-media-id="'.concat(this.openedBy.getAttribute("data-media-id"),'"]')),t2=e2.querySelector("template"),a2=t2?t2.content:null;e2.classList.add("active"),e2.scrollIntoView();var o2=this.querySelector('[role="document"]');o2.scrollLeft=(e2.width-o2.clientWidth)/2,e2.nodeName==="DEFERRED-MEDIA"&&a2&&a2.querySelector(".js-youtube")&&e2.loadContent()}}),customElements.get("related-product")||customElements.define("related-product",i),n([document,"access",e2=>e2.querySelector,"call",e2=>e2("#GiftWrappingCheckbox"),"optionalAccess",e2=>e2.addEventListener,"call",e2=>e2("change",e3=>{e3.target&&(e3.target.checked?e3.target.value="true":e3.target.value="false")})]),window.Shopify=window.Shopify||{},window.Shopify.formatMoney=function(e2,t2){typeof e2=="string"&&(e2=e2.replace(".",""));var a2="",o2=/\{\{\s*(\w+)\s*\}\}/,s2=t2||this.money_format;function r2(e3,t3){return e3===void 0?t3:e3}function i2(e3){var t3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a3=arguments.length>2&&arguments[2]!==void 0?arguments[2]:",",o3=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".";if(t3=r2(t3,2),a3=r2(a3,","),o3=r2(o3,"."),isNaN(e3)||e3===null)return"0";var s3=(e3=(e3/100).toFixed(t3)).split("."),i3=s3[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+a3),n2=s3[1]?o3+s3[1]:"";return i3+n2}switch(s2.match(o2)[1]){case"amount":a2=i2(e2,2);break;case"amount_no_decimals":a2=i2(e2,0);break;case"amount_with_comma_separator":a2=i2(e2,2,".",",");break;case"amount_no_decimals_with_comma_separator":a2=i2(e2,0,".",",")}return s2.replace(o2,a2)},document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("PriceHistoryData")){var e2=JSON.parse(document.getElementById("PriceHistoryData").innerHTML),t2=document.createElement("table"),a2=document.createElement("tbody");if(e2.prices){for(var o2 of Object.keys(e2.prices)){var s2=e2.prices[o2][window.Shopify.currency.active];if(!s2)return;var r2=document.createElement("tr"),i2=document.createElement("td");i2.className="sniffie-omnibus-price-history-popup-date",i2.style.padding="5px";var c=document.createElement("td");c.className="sniffie-omnibus-price-history-popup-title",c.style.padding="5px";var l=document.createElement("td");l.style.padding="5px";var d=new Date(o2);d.getDate()===13&&d.getMonth()===11&&d.setDate(d.getDate()-1);var u=d.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});i2.innerHTML=u,c.innerHTML="&nbsp;",l.innerHTML=window.Shopify.formatMoney(s2.price.amount,e2.money_format),r2.appendChild(i2),r2.appendChild(c),r2.appendChild(l),a2.appendChild(r2)}t2.appendChild(a2);var p=document.querySelector("#sniffie-omnibus-price-history-list");p&&n([p,"access",e3=>e3.parentNode,"optionalAccess",e3=>e3.replaceChild,"call",e3=>e3(t2,p)])}}})})();
2//# sourceMappingURL=/cdn/shop/t/17/assets/product-form.compiled.js.map?v=179946441535122296301772715376

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.