PageSourceSearch

https://onlineshop.bohnenkamp.de/assets/18f6c32a0a6db3f3d105e90467…default.packaging-unit-quantity-selector.js

js bohnenkamp.de collected 2026-10-01 14:17:23 UTC 18,220 bytes, 1 lines download raw bytes

1"use strict";(self.webpackJsonp_yves_default=self.webpackJsonp_yves_default||[]).push([[8499],{92947(t,e,i){i.r(e),i.d(e,{default:()=>m});var n=i(38827),s=i(90273),a=i(38850),r=i.n(a);function o(t,e,i,n,s,a,r){try{var o=t[a](r),u=o.value}catch(t){return void i(t)}o.done?e(u):Promise.resolve(u).then(n,s)}var u="is-hidden";class m extends n.A{constructor(){super(...arguments),this.formattedQtyInSalesUnitInput=void 0,this.formattedQtyInSalesUnitInputConfig=void 0,this.qtyInSalesUnitInput=void 0,this.qtyInBaseUnitInput=void 0,this.measurementUnitInput=void 0,this.addToCartButton=void 0,this.leadSalesUnitSelect=void 0,this.baseUnit=void 0,this.salesUnits=void 0,this.currentSalesUnit=void 0,this.productQuantityStorage=void 0,this.translations=void 0,this.leadSalesUnits=void 0,this.productPackagingUnitStorage=void 0,this.formattedAmountInSalesUnitInput=void 0,this.formattedAmountInSalesUnitInputConfig=void 0,this.amountInSalesUnitInput=void 0,this.amountDefaultInBaseUnitInput=void 0,this.itemBasePriceInput=void 0,this.itemMoneySymbolInput=void 0,this.amountInBaseUnitInput=void 0,this.currentLeadSalesUnit=void 0,this.productPackagingNewPriceBlock=void 0,this.productPackagingNewPriceValueBlock=void 0,this.quantityBetweenElement=void 0,this.quantityMinElement=void 0,this.quantityMaxElement=void 0,this.muChoiceNotificationElement=void 0,this.muChoiceListElement=void 0,this.muCurrentChoiceElement=void 0,this.puChoiceElement=void 0,this.puMinNotificationElement=void 0,this.puMaxNotificationElement=void 0,this.puIntervalNotificationElement=void 0,this.isAddToCartDisabled=void 0,this.muError=!1,this.puError=!1,this.decimals=4,this.factor=10,this.numberOfDecimalPlaces=10,this.degree=[2,3]}init(){var t,e=this;return(t=function*(){e.formattedQtyInSalesUnitInput=e.getElementsByClassName(e.jsName+"__formatted-sales-unit-quantity")[0],e.qtyInSalesUnitInput=e.getElementsByClassName(e.jsName+"__sales-unit-quantity")[0],e.qtyInSalesUnitInput&&(e.qtyInBaseUnitInput=e.getElementsByClassName(e.jsName+"__base-unit-quantity")[0],e.measurementUnitInput=e.getElementsByClassName(e.jsName+"__select-measurement-unit")[0],e.addToCartButton=e.getElementsByClassName(e.jsName+"__add-to-cart-button")[0],e.leadSalesUnitSelect=e.getElementsByClassName(e.jsName+"__select-lead-measurement-unit")[0],e.formattedAmountInSalesUnitInput=e.getElementsByClassName(e.jsName+"__formatted-user-amount")[0],e.amountInSalesUnitInput=e.getElementsByClassName(e.jsName+"__user-amount")[0],e.amountDefaultInBaseUnitInput=e.getElementsByClassName(e.jsName+"__default-amount")[0],e.amountInBaseUnitInput=document.getElementsByClassName(e.jsName+"__amount")[0],e.productPackagingNewPriceBlock=e.getElementsByClassName(e.jsName+"__product-packaging-new-price-block")[0],e.productPackagingNewPriceValueBlock=e.getElementsByClassName(e.jsName+"__product-packaging-new-price-value-block")[0],e.itemBasePriceInput=e.getElementsByClassName(e.jsName+"__item-base-price")[0],e.itemMoneySymbolInput=e.getElementsByClassName(e.jsName+"__item-money-symbol")[0],e.quantityBetweenElement=e.getElementsByClassName(e.jsName+"__quantity-between-units")[0],e.quantityMinElement=e.getElementsByClassName(e.jsName+"__minimum-quantity")[0],e.quantityMaxElement=e.getElementsByClassName(e.jsName+"__maximum-quantity")[0],e.muChoiceNotificationElement=e.getElementsByClassName(e.jsName+"__measurement-unit-choice")[0],e.muChoiceListElement=e.muChoiceNotificationElement.getElementsByClassName(e.jsName+"__list")[0],e.muCurrentChoiceElement=e.muChoiceNotificationElement.getElementsByClassName(e.jsName+"__current-choice")[0],e.puChoiceElement=e.getElementsByClassName(e.jsName+"__packaging-unit-choice")[0],e.puMinNotificationElement=e.getElementsByClassName(e.jsName+"__packaging-amount-min")[0],e.puMaxNotificationElement=e.getElementsByClassName(e.jsName+"__packaging-amount-max")[0],e.puIntervalNotificationElement=e.getElementsByClassName(e.jsName+"__packaging-amount-interval")[0],e.initJson(),e.initTranslations(),e.initCurrentSalesUnit(),e.initCurrentLeadSalesUnit(),e.mapEvents(),yield(0,s.Or)(),e.initFormDefaultValues(),e.amountInBaseUnitInput&&e.onAmountInputChange(),e.formattedQtyInSalesUnitInput&&(e.formattedQtyInSalesUnitInputConfig=e.formattedQtyInSalesUnitInput.numberFormatConfig),e.formattedAmountInSalesUnitInput&&(e.formattedAmountInSalesUnitInputConfig=e.formattedAmountInSalesUnitInput.numberFormatConfig))},function(){var e=this,i=arguments;
1return new Promise((function(n,s){var a=t.apply(e,i);function r(t){o(a,n,s,r,u,"next",t)}function u(t){o(a,n,s,r,u,"throw",t)}r(void 0)}))})()}initJson(){var t=JSON.parse(this.packagingJSONString);this.baseUnit=t.baseUnit,this.salesUnits=t.salesUnits,this.leadSalesUnits=t.leadSalesUnits,this.isAddToCartDisabled=t.isAddToCartDisabled,this.productPackagingUnitStorage=t.productPackagingUnitStorage,this.productQuantityStorage=t.productQuantityStorage}initFormDefaultValues(){this.amountInBaseUnitInput&&(this.qtyInSalesUnitInput.value=String(this.getMinQuantity()),this.leadSalesUnitSelect&&(this.leadSalesUnitSelect.value=String(this.currentLeadSalesUnit.id_product_measurement_sales_unit)),this.measurementUnitInput&&(this.measurementUnitInput.value=String(this.currentSalesUnit.id_product_measurement_sales_unit)))}initTranslations(){this.translations=JSON.parse(this.getElementsByClassName(this.jsName+"__measurement-unit-translation")[0].innerHTML)}initCurrentSalesUnit(){this.currentSalesUnit=this.salesUnits.find((t=>t.is_default))}mapEvents(){this.qtyInSalesUnitInput.addEventListener("input",(()=>this.qtyInputChange())),this.measurementUnitInput&&this.measurementUnitInput.addEventListener("change",(t=>this.onMeasurementUnitInputChange(t))),this.amountInSalesUnitInput&&this.amountInSalesUnitInput.addEventListener("input",(()=>this.onAmountInputChange())),this.leadSalesUnitSelect&&this.leadSalesUnitSelect.addEventListener("change",(t=>this.onLeadSalesUnitSelectChange(t)))}qtyInputChange(t){void 0===t&&(t=this.formattedQtyInSalesUnitInput.unformattedValue),this.muError=!1;var e=this.multiply(t,Number(this.currentSalesUnit.conversion));return e<this.getMinQuantity()?(this.muError=!0,this.hideNotifications(),this.quantityMinElement.classList.remove(u)):(e-this.getMinQuantity())%this.getQuantityInterval()!=0?(this.muError=!0,this.hideNotifications(),this.quantityBetweenElement.classList.remove(u)):this.getMaxQuantity()>0&&e>this.getMaxQuantity()&&(this.muError=!0,this.hideNotifications(),this.quantityMaxElement.classList.remove(u)),this.muError&&!isFinite(t)?(this.addToCartButton.setAttribute("disabled","disabled"),void this.qtyInSalesUnitInput.setAttribute("disabled","disabled")):this.muError||this.puError||this.isAddToCartDisabled?(this.addToCartButton.setAttribute("disabled","disabled"),void this.showCorrectInputSuggestions(t)):(this.qtyInBaseUnitInput.value=String(e),this.amountInBaseUnitInput&&this.onAmountInputChange(),this.addToCartButton.removeAttribute("disabled"),void this.hideNotifications())}hideNotifications(){this.muChoiceNotificationElement.classList.add(u),this.quantityBetweenElement.classList.add(u),this.quantityMinElement.classList.add(u),this.quantityMaxElement.classList.add(u)}showCorrectInputSuggestions(t){if(this.muError){var e=this.getMinChoice(t),i=this.getMaxChoice(t,e);this.muChoiceListElement.innerHTML="",this.muCurrentChoiceElement.innerHTML="",this.formatNumber(this.muCurrentChoiceElement,this.round(t,this.decimals),this.formattedQtyInSalesUnitInputConfig),this.muCurrentChoiceElement.innerHTML+="&nbsp"+this.getUnitName(this.currentSalesUnit.product_measurement_unit.code);var n=[];n.push(this.createChoiceElement(e)),i!==e&&n.push(this.createChoiceElement(i)),n.forEach((t=>{t&&this.muChoiceListElement.appendChild(t)})),this.muChoiceNotificationElement.classList.remove(u)}}createChoiceElement(t){if(!(t<1)){var e=document.createElement("button"),i=this.convertBaseUnitsAmountToCurrentSalesUnitsAmount(t),n=this.getUnitName(this.currentSalesUnit.product_measurement_unit.code),s=this.getUnitName(this.baseUnit.code),a=document.createElement("span"),r=document.createElement("span");return this.formatNumber(a,this.round(i,this.decimals),this.formattedQtyInSalesUnitInputConfig),this.formatNumber(r,t,this.formattedQtyInSalesUnitInputConfig),a.innerHTML+="&nbsp"+n,r.innerHTML+="&nbsp"+s,e.append("(",a,") = (",r,")"),e.type="button",e.classList.add("link","link--expand"),e.setAttribute("data-base-unit-qty",String(t)),e.setAttribute("data-sales-unit-qty",String(i)),e.onclick=t=>{var e=t.currentTarget,i=parseFloat(e.dataset.baseUnitQty),n=parseFloat(e.dataset.salesUnitQty);this.muError=!1,this.selectQty(i,n)},e}}selectQty(t,e){this.qtyInBaseUnitInput.value=String(t),this.qtyInSalesUnitInput.value=String(this.round(e,this.decimals)),this.puError||this.isAddToCartDisabled||(this.addToCartButton.removeAttribute("disabled"),this.qtyInSalesUnitInput.removeAttribute("disabled")),this.muChoiceNotificationElement.classList.add(u),this.qtyInputChange()}getMinChoice(t){var e=this.floor(this.multiply(t,this.currentSalesUnit.conversion));return e<this.getMinQuantity()?this.getMinQuantity():(e-this.getMinQuantity())%this.getQuantityInterval()!=0||this.getMaxQuantity()>0&&e>this.getMaxQuantity()?this.getMinChoice(this.convertBaseUnitsAmountToCurrentSalesUnitsAmount(e-1)):e}getMaxChoice(t,e){var i=this.ceil(this.multiply(t,this.currentSalesUnit.conversion));return this.getMaxQuantity()>0&&i>this.getMaxQuantity()?(((i=this.getMaxQuantity())-this.getMinQuantity())%this.getQuantityInterval()!=0&&(i-=(i-this.getMinQuantity())%this.getQuantityInterval()),i):(i-this.getMinQuantity())%this.getQuantityInterval()!=0?this.getMaxChoice(this.convertBaseUnitsAmountToCurrentSalesUnitsAmount((i+1)/this.currentSalesUnit.conversion),e):i}convertBaseUnitsAmountToCurrentSalesUnitsAmount(t){return Math.round(t/this.currentSalesUnit.conversion*this.currentSalesUnit.precision)/this.currentSalesUnit.precision}floor(t){return Math.floor(t)>0?Math.floor(t):Math.ceil(t)}ceil(t){return Math.ceil(t)}round(t,e){return Number(Math.round(parseFloat(t+"e"+e))+"e-"+e)}multiply(t,e){var i=t*e,n=Number(this.currentSalesUnit.precision);return Math.round(i*n)/n}getMinQuantity(){return void 0!==this.productQuantityStorage&&this.productQuantityStorage.hasOwnProperty("quantity_min")?this.productQuantityStorage.quantity_min:1}getMaxQuantity(){return void 0!==this.productQuantityStorage&&this.productQuantityStorage.hasOwnProperty("quantity_max")&&null!==this.productQuantityStorage.quantity_max?this.productQuantityStorage.quantity_max:0}getQuantityInterval(){return void 0!==this.productQuantityStorage&&this.productQuantityStorage.hasOwnProperty("quantity_interval")?this.productQuantityStorage.quantity_interval:1}onMeasurementUnitInputChange(t){var e=parseInt(t.currentTarget.value),i=this.getSalesUnitById(e),n=this.formattedQtyInSalesUnitInput.unformattedValue,s=this.multiply(n,this.currentSalesUnit.conversion);this.currentSalesUnit=i,n=this.convertBaseUnitsAmountToCurrentSalesUnitsAmount(s),isFinite(n)&&(this.qtyInSalesUnitInput.value=String(this.round(n,this.decimals))),this.qtyInputChange(n)}getSalesUnitById(t){return this.salesUnits.find((e=>t===e.id_product_measurement_sales_unit))}getUnitName(t){return this.translations.hasOwnProperty(t)?this.translations[t]:t}onAmountInputChange(t){void 0===t&&(t=this.formattedAmountInSalesUnitInput.unformattedValue);var e=Number((t*this.precision*Number(this.currentLeadSalesUnit.conversion)/this.precision).toFixed(this.numberOfDecimalPlaces));if(this.productPackagingNewPriceBlock.classList.add(u),this.puError=!1,this.amountInSalesUnitInput.disabled||(this.isAmountMultipleToInterval(e)&&(this.puError=!0,this.puIntervalNotificationElement.classList.remove(u)),e<this.getMinAmount()&&(this.puError=!0,this.puMinNotificationElement.classList.remove(u)),this.getMaxAmount()>0&&e>this.getMaxAmount()&&(this.puError=!0,this.puMaxNotificationElement.classList.remove(u))),this.puError||this.muError||this.isAddToCartDisabled)return this.askCustomerForCorrectAmountInput(t),void this.addToCartButton.setAttribute("disabled","disabled");var i=Number(this.qtyInBaseUnitInput.value),n=(e*this.precision*i/this.precision).toFixed(this.numberOfDecimalPlaces);this.amountInBaseUnitInput.value=String(parseFloat(n)),this.addToCartButton.removeAttribute("disabled"),this.hidePackagingUnitRestrictionNotifications(),this.priceCalculation(e)}priceCalculation(t){var e=Number(this.itemBasePriceInput.value),i=Number(this.amountDefaultInBaseUnitInput.value);if(i!==t){var n=t/i*e;n=n*Number(this.qtyInBaseUnitInput.value)/Math.pow(this.factor,this.degree[0]),this.productPackagingNewPriceValueBlock.innerHTML=this.itemMoneySymbolInput.value+n.toFixed(this.degree[0]),this.productPackagingNewPriceBlock.classList.remove(u)}}
1askCustomerForCorrectAmountInput(t){var e=this.puChoiceElement.getElementsByClassName(this.jsName+"__list")[0],i=this.puChoiceElement.getElementsByClassName(this.jsName+"__amount-current-choice")[0];if(this.puError){var n=this.getMinAmountChoice(t),s=this.getMaxAmountChoice(t,n);e.innerHTML="",i.innerHTML="",this.formatNumber(i,this.round(t,this.decimals),this.formattedAmountInSalesUnitInputConfig),i.innerHTML+="&nbsp"+this.getUnitName(this.currentSalesUnit.product_measurement_unit.code);var a=[];n&&a.push(this.createAmountChoiceElement(n)),s!==n&&a.push(this.createAmountChoiceElement(s)),a.forEach((t=>{t&&e.appendChild(t)})),this.puChoiceElement.classList.remove(u)}}initCurrentLeadSalesUnit(){this.leadSalesUnits&&(this.currentLeadSalesUnit=this.leadSalesUnits.find((t=>t.is_default)))}createAmountChoiceElement(t){if(!(t<1)){var e=document.createElement("button"),i=(t*this.precision/this.currentLeadSalesUnit.conversion/this.precision).toFixed(this.numberOfDecimalPlaces),n=this.getUnitName(this.currentLeadSalesUnit.product_measurement_unit.code),s=this.getUnitName(this.baseUnit.code),a=document.createElement("span"),r=document.createElement("span");return this.formatNumber(a,parseFloat(i),this.formattedAmountInSalesUnitInputConfig),this.formatNumber(r,t,this.formattedAmountInSalesUnitInputConfig),a.innerHTML+="&nbsp"+n,r.innerHTML+="&nbsp"+s,e.append("(",a,") = (",r,")"),e.type="button",e.classList.add("link","link--expand"),e.setAttribute("data-base-unit-amount",String(t)),e.setAttribute("data-sales-unit-amount",String(parseFloat(i))),e.onclick=t=>{var e=t.currentTarget,i=parseFloat(e.dataset.baseUnitAmount),n=parseFloat(e.dataset.salesUnitAmount);this.puError=!1,this.selectAmount(i,n)},e}}selectAmount(t,e){this.amountInSalesUnitInput.value=String(e),this.amountInBaseUnitInput.value=String(t),this.muError||this.isAddToCartDisabled||this.addToCartButton.removeAttribute("disabled"),this.puChoiceElement.classList.add(u),this.onAmountInputChange()}onLeadSalesUnitSelectChange(t){var e=parseInt(t.currentTarget.value),i=this.getLeadSalesUnitById(e),n=this.getAmountConversion(this.formattedAmountInSalesUnitInput.unformattedValue,i.conversion),s=this.getAmountConversion(Number(this.amountInSalesUnitInput.min),i.conversion),a=this.getAmountConversion(Number(this.amountInSalesUnitInput.max),i.conversion),r=this.getAmountConversion(Number(this.amountInSalesUnitInput.step),i.conversion);this.currentLeadSalesUnit=i,this.amountInSalesUnitInput.value=String(n),this.amountInSalesUnitInput.min&&(this.amountInSalesUnitInput.min=String(s)),this.amountInSalesUnitInput.max&&(this.amountInSalesUnitInput.max=String(a)),this.amountInSalesUnitInput.step&&(this.amountInSalesUnitInput.step=String(r)),this.onAmountInputChange(n)}hidePackagingUnitRestrictionNotifications(){this.puChoiceElement.classList.add(u),this.puMinNotificationElement.classList.add(u),this.puMaxNotificationElement.classList.add(u),this.puIntervalNotificationElement.classList.add(u)}getLeadSalesUnitById(t){return this.leadSalesUnits.find((e=>t===e.id_product_measurement_sales_unit))}getMinAmount(){return void 0!==this.productPackagingUnitStorage&&this.productPackagingUnitStorage.hasOwnProperty("amount_min")&&null!==this.productPackagingUnitStorage.amount_min?Number(this.productPackagingUnitStorage.amount_min):1}getMaxAmount(){return void 0!==this.productPackagingUnitStorage&&this.productPackagingUnitStorage.hasOwnProperty("amount_max")&&null!==this.productPackagingUnitStorage.amount_max?Number(this.productPackagingUnitStorage.amount_max):0}getAmountInterval(){return void 0!==this.productPackagingUnitStorage&&this.productPackagingUnitStorage.hasOwnProperty("amount_interval")&&null!==this.productPackagingUnitStorage.amount_interval?Number(this.productPackagingUnitStorage.amount_interval):1}getMinAmountChoice(t){var e=Number((t*this.precision*Number(this.currentLeadSalesUnit.conversion)/this.precision).toFixed(this.numberOfDecimalPlaces));return e<this.getMinAmount()?this.getMinAmount():this.isAmountGreaterThanMaxAmount(e)?0:this.isAmountMultipleToInterval(e)?this.getMinAmountChoice((e-this.getAmountPercentageOfDivision(e))/this.currentLeadSalesUnit.conversion):e}getMaxAmountChoice(t,e){var i=Number((t*this.precision*Number(this.currentLeadSalesUnit.conversion)/this.precision).toFixed(this.numberOfDecimalPlaces));return this.isAmountGreaterThanMaxAmount(i)?(i=this.getMaxAmount(),this.isAmountMultipleToInterval(i)&&(i-=this.getAmountPercentageOfDivision(i)),i):i<=e?0:this.isAmountMultipleToInterval(i)?Number(((e*this.precision+this.getAmountInterval()*this.precision)/this.precision).toFixed(this.numberOfDecimalPlaces)):i}formatNumber(t,e,i){return new(r())(t,e,i)}isAmountGreaterThanMaxAmount(t){return this.getMaxAmount()>0&&t>this.getMaxAmount()}isAmountMultipleToInterval(t){return 0!==this.getAmountPercentageOfDivision(t)}getAmountConversion(t,e){return parseFloat((t*this.precision*this.currentLeadSalesUnit.conversion/e/this.precision).toFixed(this.numberOfDecimalPlaces))}getAmountPercentageOfDivision(t){var e=Math.round(t*this.precision),i=Math.round(this.getMinAmount()*this.precision),n=this.getAmountInterval()*this.precision,s=Number(((e-i)/this.precision).toFixed(this.numberOfDecimalPlaces)),a=(Math.round(s*this.precision)%n/this.precision).toFixed(this.numberOfDecimalPlaces);return Number(a)}get precision(){return Number("1"+"0".repeat(this.numberOfDecimalPlaces))}get packagingJSONString(){return this.getAttribute("json")}}}}]);

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.