PageSourceSearch

https://www.bodylab.dk/theme/b15f317276263b8cf3120f98b282bbbe/js/s…n_forms_form-validation_plugin_js.134229.js

js bodylab.dk collected 2026-09-24 17:49:41 UTC 4,130 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["plugin_forms_form-validation_plugin_js"],{3634:(t,e,i)=>{i.r(e),i.d(e,{default:()=>o});var s=i(9568),a=i(4049),l=i(9610),n=i(3266);class o extends s.Z{init(){if(!1===this._isFormElement())throw Error("Element is not of type <form>");this.options.stylingEnabled&&this._setNoValidate(),this._registerEvents()}_isFormElement(){return"form"===this.el.tagName.toLowerCase()}_setNoValidate(){this.el.setAttribute("novalidate","")}_registerEvents(){this.options.stylingEnabled&&this.el.addEventListener("submit",this._onFormSubmit.bind(this)),this._registerValidationListener(this.options.equalAttr,this._onValidateEqualTrigger.bind(this),["change"]),this._registerValidationListener(this.options.equalAttr,l.Z.debounce(this._onValidateEqual.bind(this),this.options.debounceTime),[this.options.eventName]),this._registerValidationListener(this.options.lengthAttr,this._onValidateLength.bind(this),["change"]),this._registerValidationListener(this.options.requiredAttr,this._onValidateRequired.bind(this),["change"])}_registerValidationListener(t,e,i){let s=a.Z.querySelectorAll(this.el,"[".concat(t,"]"),!1);s&&n.Z.iterate(s,t=>{n.Z.iterate(i,i=>{t.removeEventListener(i,e),t.addEventListener(i,e)})})}_onFormSubmit(t){let e=this.el.checkValidity();!1===e&&(t.preventDefault(),t.stopPropagation()),this.el.classList.add(this.options.styleCls),this.$emitter.publish("beforeSubmit",{validity:e})}_onValidateEqualTrigger(t){let e=a.Z.getDataAttribute(t.target,this.options.equalAttr),i=a.Z.querySelectorAll(this.el,"[".concat(this.options.equalAttr,"='").concat(e,"']"));i[1].value.trim().length>0&&n.Z.iterate(i,e=>{e.dispatchEvent(new CustomEvent(this.options.eventName,{target:t.target}))}),this.$emitter.publish("onValidateEqualTrigger")}_onValidateEqual(t){let e=a.Z.getDataAttribute(t.target,this.options.equalAttr),i=a.Z.querySelectorAll(this.el,"[".concat(this.options.equalAttr,"='").concat(e,"']")),s=!0;[...i].reduce((t,e)=>{t.value.trim()!==e.value.trim()&&(s=!1)}),n.Z.iterate(i,t=>{s?this._setFieldToValid(t,this.options.equalAttr):this._setFieldToInvalid(t,this.options.equalAttr)}),this.$emitter.publish("onValidateEqual")}_onValidateLength(t){let e=t.target,i=e.value.trim(),s=a.Z.getDataAttribute(t.target,this.options.lengthAttr),l=e.nextElementSibling;i.length<s?(this._setFieldToInvalid(e,this.options.lengthAttr),l&&l.hasAttribute(this.options.lengthTextAttr)&&l.classList.add(this.options.hintCls)):(this._setFieldToValid(e,this.options.lengthAttr),l&&l.hasAttribute(this.options.lengthTextAttr)&&l.classList.remove(this.options.hintCls)),this.$emitter.publish("onValidateLength")}_onValidateRequired(t){let e=t.target;""===e.value.trim()?this._setFieldToInvalid(e,this.options.requiredAttr):this._setFieldToValid(e,this.options.requiredAttr),this.$emitter.publish("onValidateRequired")}_setFieldToInvalid(t,e){this._showInvalidMessage(t,e),t.setAttribute("invalid",!0),this.$emitter.publish("setFieldToInvalid")}_showInvalidMessage(t,e){let i=t.parentElement;i&&this.options.stylingEnabled&&i.classList.add(this.options.styleCls);let s=a.Z.getDataAttribute(t,"".concat(e,"-message"),!1);s&&(i.querySelector(".js-validation-message")||t.insertAdjacentHTML("afterEnd",'<div class="invalid-feedback js-validation-message" data-type="'.concat(e,'">').concat(s,"</div>")),t.setCustomValidity(s)),this.$emitter.publish("showInvalidMessage")}_setFieldToValid(t,e){this._hideInvalidMessage(t,e),t.removeAttribute("invalid"),t.setCustomValidity(""),this.$emitter.publish("setFieldToValid")}_hideInvalidMessage(t,e){let i=t.parentElement;if(i&&this.options.stylingEnabled&&i.classList.remove(this.options.styleCls),i){let t=a.Z.querySelector(i,".js-validation-message[data-type=".concat(e,"]"),!1);t&&t.remove()}this.$emitter.publish("hideInvalidMessage")}}o.options={stylingEnabled:!0,styleCls:"was-validated",hintCls:"invalid-feedback",debounceTime:"150",eventName:"ValidateEqual",equalAttr:"data-form-validation-equal",lengthAttr:"data-form-validation-length",lengthTextAttr:"data-form-validation-length-text",requiredAttr:"data-form-validation-required"}}}]);

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.