PageSourceSearch

https://www.druckluft-fachhandel.de/theme/ab446cc6d7d87ba72f54525c….form-country-state-select.plugin.00e836.js

js druckluft-fachhandel.de collected 2026-09-24 22:52:57 UTC 6,577 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[25132],{5132(e,t,i){i.r(t),i.d(t,{default:()=>s});var n=i(4335),o=i(9068);class s extends n.A{static #e=this.options={countrySelectSelector:".country-select",initialCountryAttribute:"data-initial-country-id",countryStateSelectSelector:".country-state-select",initialCountryStateAttribute:"data-initial-country-state-id",countryStatePlaceholderSelector:'[data-placeholder-option="true"]',vatIdFieldInput:"#vatIds",zipcodeFieldInput:'[data-input-name="zipcodeInput"]',vatIdRequired:"data-vat-id-required",stateRequired:"data-state-required",zipcodeRequired:"data-zipcode-required",scopeElementSelector:null,prefix:null};init(){this.initClient(),this.initSelects(),this._getFormFieldToggleInstance(),this._formFieldToggleInstance&&this._formFieldToggleInstance.$emitter.subscribe("onChange",this._onFormFieldToggleChange.bind(this))}initClient(){this._client=new o.A}initSelects(){this.scopeElement=this.el,this.options.scopeElementSelector&&(this.scopeElement=document.querySelector(this.options.scopeElementSelector));let{countrySelectSelector:e,countryStateSelectSelector:t,initialCountryAttribute:i,initialCountryStateAttribute:n}=s.options,o=this.scopeElement.querySelector(e),r=this.scopeElement.querySelector(t),d=o.getAttribute(i),l=r.getAttribute(n),a=o.options[o.selectedIndex],u=!!a.getAttribute(this.options.vatIdRequired),c=document.querySelector(this.options.vatIdFieldInput),p=!!a.getAttribute(this.options.stateRequired),h=this.scopeElement.querySelectorAll(this.options.zipcodeFieldInput),g=!!a.getAttribute(this.options.zipcodeRequired);o.addEventListener("change",this.onChangeCountry.bind(this)),d&&(this.requestStateData(d,l,p),g&&this._updateZipcodeFields(h,g),c&&this._updateVatIdField(c,u))}onChangeCountry(e){let t=e.target.value,i=e.target.options[e.target.selectedIndex],n=!!i.getAttribute(this.options.stateRequired);this.requestStateData(t,null,n);let o=!!i.getAttribute(this.options.vatIdRequired),s=document.querySelector(this.options.vatIdFieldInput),r=this.scopeElement.querySelectorAll(this.options.zipcodeFieldInput),d=!!i.getAttribute(this.options.zipcodeRequired);this._updateZipcodeFields(r,d),s&&this._updateVatIdField(s,o)}requestStateData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];fetch(`${window.router["frontend.country.country-data"]}?countryId=${encodeURIComponent(e)}`,{headers:{"X-Requested-With":"XMLHttpRequest","Content-Type":"application/json"}}).then(e=>e.json()).then(e=>this._updateStateSelect(e.states,i,t))}_updateVatIdField(e,t){this._differentShippingCheckbox&&"billingAddress"===this.options.prefix||(t?window.formValidation.setFieldRequired(e):window.formValidation.setFieldNotRequired(e))}_updateZipcodeFields(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e&&e.forEach(e=>{!0===t?window.formValidation.setFieldRequired(e):window.formValidation.setFieldNotRequired(e)})}_updateStateSelect(e,t,i){let n=this.scopeElement.querySelector(this.options.countryStateSelectSelector),o=n.querySelector(this.options.countryStatePlaceholderSelector);this._removeStateOptions(n),this._addStateOptions(e,i,n),t?(window.formValidation.setFieldRequired(n),o.setAttribute("disabled","disabled")):(window.formValidation.setFieldNotRequired(n),o.removeAttribute("disabled"))}_removeStateOptions(e){let t=`option:not(${this.options.countryStatePlaceholderSelector})`,i=e;e||(i=this.scopeElement.querySelector(this.options.countryStateSelectSelector)),i.querySelectorAll(t).forEach(e=>e.remove())}_addStateOptions(e,t,i){let n=i;if(i||(n=this.scopeElement.querySelector(this.options.countryStateSelectSelector)),0===e.length){n.parentNode.classList.add("d-none"),n.setAttribute("disabled","disabled");return}e.map(e=>this._createStateOptionEl(e,t)).forEach(e=>{n.append(e)}),n.parentNode.classList.remove("d-none"),n.removeAttribute("disabled")}_createStateOptionEl(e,t){let i=document.createElement("option");return i.setAttribute("value",e.id),i.innerText=e.translated.name,e.id===t&&i.setAttribute("selected","selected"),i}_getFormFieldToggleInstance(){let e=document.querySelector('[data-form-field-toggle-target=".js-form-field-toggle-shipping-address"]');e&&(this._formFieldToggleInstance=window.PluginManager.getPluginInstanceFromElement(e,"FormFieldToggle"))}_onFormFieldToggleChange(e){this._differentShippingCheckbox=e.target.checked;let t=this._differentShippingCheckbox?".register-shipping":".register-billing",i=document.querySelector(t).querySelector(this.options.countrySelectSelector),n=!!i.options[i.selectedIndex].getAttribute(this.options.vatIdRequired),o=document.querySelector(this.options.vatIdFieldInput);
1o&&this._updateVatIdField(o,n)}}},9068(e,t,i){i.d(t,{A:()=>n});class n{constructor(){this._request=null,this._errorHandlingInternal=!1}get(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=this._createPreparedRequest("GET",e,i);return this._sendRequest(n,null,t)}post(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("POST",e,n);return this._sendRequest(o,t,i)}delete(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("DELETE",e,n);return this._sendRequest(o,t,i)}patch(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("PATCH",e,n);return this._sendRequest(o,t,i)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn(`the request to ${e.responseURL} was aborted`)}),e.addEventListener("error",()=>{console.warn(`the request to ${e.responseURL} failed with status ${e.status}`)}),e.addEventListener("timeout",()=>{console.warn(`the request to ${e.responseURL} timed out`)})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,i){return this._registerOnLoaded(e,i),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,i){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),i&&this._request.setRequestHeader("Content-type",i),this._request}}}}]);

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.