Files
Last update 4 months 1 week
by
Arnaud-Apu-Fanovard
ProductPricing.js.téléchargementfunction CheckValidQuanityPdpBuyButton(){var e,t=$("#BuyQty").val(),n=/^(?!0+$)\d+$/;t==""||n.test(t)&&t.indexOf(".")>-1==!1&&!isNaN(t)?($("#btnBuy").prop("disabled",!1),e=document.getElementById("BuyQty-error-span"),e&&(e.style.display="none"),document.getElementById("BuyQty").classList.remove("input-validation-error")):($("#btnBuy").prop("disabled",!0),e=document.getElementById("BuyQty-error-span"),e&&(e.classList.remove("field-validation-valid"),e.classList.add("field-validation-error"),e.style.display="block",e.textContent=document.getElementById("BuyQty").getAttribute("data-val-regex")),document.getElementById("BuyQty").classList.add("input-validation-error"))}function FormatBuyPackRads(e,t){t===void 0&&(t="");var o,i,n=Number($('input:hidden[name="FullReelQtyForPriceAvail'+t+'"]').val()),s=Number($('input:hidden[name="MinQtyForPriceAvail'+t+'"]').val());IsObjectValid(e)&&IsPositiveInt(e)&&IsObjectValid(n)&&IsPositiveInt(n)&&n>1&&IsObjectValid(s)&&IsPositiveInt(s)&&s>0?($("div#pdp-product-pack-options"+t).show(),s>1&&s===n?($("div#pdp-buy-pack-full-qty"+t).show(),$("div#pdp-buy-pack-rads"+t).hide()):e%n===0?($("div#pdp-buy-pack-full-qty"+t).show(),$("div#pdp-buy-pack-rads"+t).hide()):($("div#pdp-buy-pack-full-qty"+t).hide(),$("div#pdp-buy-pack-rads"+t).show(),o=$('input:hidden[name="CutTapeRadioTextForPriceAvail'+t+'"]').val(),i=$('input:hidden[name="MouseReelRadioTextForPriceAvail'+t+'"]').val(),e>n&&(o=$('input:hidden[name="FullReelOrAmmoAndCutTapeTextForPriceAvail'+t+'"]').val(),i=$('input:hidden[name="FullReelOrAmmoAndMouseReelTextForPriceAvail'+t+'"]').val()),$("span#spanBuyPackCutTapeForPriceAvail"+t).text(o),$("span#spanBuyPackMouseReelForPriceAvail"+t).text(i))):$("div#pdp-product-pack-options"+t).hide()}function PopulateExtPrice(e,t){t===void 0&&(t="");var n,s;t?(n=JSON.parse($("#hdnProductUnitPricing"+t).val()),s=JSON.parse($("#hdnProductFullReelOrAmmoPricing"+t).val())):(n=productUnitPricing,s=productFullReelOrAmmoPricing),$.ajax({url:"/Product/Product/GetFormattedExtendedPriceWithVat",type:"POST",data:{quantity:e,unitPricing:n,fullReelOrAmmoPricing:s},success:function(e){IsPriceInformationValid(e)?($(".pdp-product-unit-price"+t).text(e.unit),$(".pdp-product-extend-price"+t).text(e.extended),$(".pdp-product-unit-extend-price"+t).show()):$(".pdp-product-unit-extend-price"+t).hide()}})}function IsPriceInformationValid(e){var t=/\d/;return IsObjectValid(e)&&IsObjectValid(e.unit)&&IsObjectValid(e.extended)&&t.test(e.unit)&&t.test(e.extended)}function BuyQtyChange(e,t){t===void 0&&(t="");var o=-1,n=-1,i=$('input:hidden[name="RequestQuoteQty'+t+'"]').val(),s=e.val();IsPositiveInt(s)?(IsObjectValid(i)&&i.length!==0&&Number(i)>0&&(o=Number(i)),IsObjectValid(s)&&s.length!==0&&Number(s)>0&&Math.floor(s)===Number(s)&&(n=Number(s)),n>0&&FormatBuyPackRads(n,t),n>0&&(o===-1||o>0&&n<o)?($("#pdp-product-pack-options"+t).show(),PopulateExtPrice(e.val(),t),FormatBuyPackRads(n,t)):($(".pdp-product-unit-extend-price"+t).hide(),(o===-1||n<=0)&&$("#pdp-product-pack-options"+t).hide())):($(".pdp-product-unit-extend-price"+t).hide(),$("#pdp-product-pack-options"+t).hide())}function GaPdpRequestDeliveryQuoteOnClick(){window.isGA4PDPEnabled&&window.dataLayer.push({event:"pdp_quote_delivery_link_clicked"})}function IsObjectValid(e){return typeof e!="undefined"&&e}function IsPositiveInt(e){return/^(?!0+$)\d+$/.test(e)}function SelectQuantity(e,t){t===void 0&&(t="");var n=$("#BuyQty"+t);n.val(e),BuyQtyChange(n,t),t?$(".compare-product-modal-qty").trigger("qtylink"):($(".compare-product-modal-qty").trigger("qtylink"),CheckValidQuanityPdpBuyButton())}function BindBuyQtyKeyupAction(){$('input[id="BuyQty"]').on("keyup",function(){BuyQtyChange($('input[id="BuyQty"]'))})}function CompareProductBindBuyQtyKeyupAction(){$("input[data-partnumber]").on("keyup",function(){BuyQtyChange($(this),$(this).attr("data-partnumber"))})}function BindFactoryLeadTimePopover(){$("#factoryLeadTimeMsg").popover(),$(document).on("click",function(e){$('[data-toggle="popover"],[data-original-title]').each(function(){!$(this).is(e.target)&&$(this).has(e.target).length===0&&$(".popover").has(e.target).length===0&&((($(this).popover("hide").data("bs.popover")||{}).inState||{}).click=!1)})}),$(document).on("keyup",function(e){e.which===27&&$("#factoryLeadTimeMsg").popover("hide")})}function BindProductPricingAvailability(){$(".DigitalDeliverLink").on("click",function(e){return e.preventDefault(),DdPopup(),!1}),$("#lnkRestCenCebEufPopUp").on("click",function(e){return e.preventDefault(),RestCenCebEufPopUp(e.target.href),!1}),$("#lnkRestZeroPricePopUp").on("click",function(e){return e.preventDefault(),RestZeroPricePopUp(e.target.href),!1}),$("#lnkRestItarPopUp, #lnkSpecShipRestItarPopUp").on("click",function(e){return e.preventDefault(),RestItarPopUp(e.target.href),!1}),$("#lnkRestLthormPopUp").on("click",function(e){return e.preventDefault(),RestLthormPopUp(e.target.href),!1}),$("#lnkRestEeePopUp").on("click",function(e){return e.preventDefault(),RestEeePopUp(e.target.href),!1}),$("#lnkRestHzfPopUp").on("click",function(e){return e.preventDefault(),RestHzfPopUp(e.target.href),!1}),$("#lnkRestBigRmbPopUp").on("click",function(e){return e.preventDefault(),RestBigRmbPopUp(e.target.href),!1}),$("#lnkCategoryRestrictionPopUp").on("click",function(e){return e.preventDefault(),RestPunchoutCategoryPopUp(e.target.href),!1}),$("#lnkRestPartLevelRestrictionPopUp").on("click",function(e){return e.preventDefault(),$("#restrictedPartModal").modal({show:!0}),!1}),$(".pdp-product-availability").on("click","#collapseOnOrder, #expandOnOrder",function(){$(".onOrderLine").toggleClass("showOnOrder hideOnOrder")}),BindFactoryLeadTimePopover(),BindBuyQtyKeyupAction(),CompareProductBindBuyQtyKeyupAction()}function OpenCompareProductPackagingModal(e,t){var n=$("#compareProductPackagingModal");n&&($.ajax({type:"GET",url:"/Product/Product/PackagingChoiceDialog?mouseReelFeeFormatted="+e+"&fullReelQty="+t,success:function(e){if(e!==null){var t=n.find("div.modal-content");t&&(t.html(e),n.show())}}}),n.modal("show"))}$(document).ready(function(){try{BindProductPricingAvailability()}catch{}})