1 line
28 KiB
JavaScript
Raw Normal View History

!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/bundles/bundle.js")}({"./client/src/bundles/UserForms.js":function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return"none"!==e.style.display&&"hidden"!==e.style.visibility&&!e.classList.contains("hide")}var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r("./node_modules/async-validator/dist-web/index.js"),o=function(e){return e&&e.__esModule?e:{default:e}}(u),a=function(){function e(t,r){n(this,e),this.dom=t,this.userForm=r,this.progressTitle=this.userForm.dom.querySelector(".progress-title"),this.buttons=this.dom.querySelectorAll(".step-button-jump"),this.currentStepNumber=this.dom.querySelector(".current-step-number"),this.init()}return s(e,[{key:"init",value:function(){var e=this;this.dom.style.display="initial",this.buttons.forEach(function(t){t.addEventListener("click",function(r){r.preventDefault();var n=parseInt(t.getAttribute("data-step"),10);return e.userForm.jumpToStep(n-1),!1})}),this.userForm.dom.addEventListener("userform.form.changestep",function(t){e.update(t.detail.stepId)}),this.update(0)}},{key:"update",value:function(e){var t=this.userForm.getCurrentStepID()+1,r=this.userForm.getStep(e),n=r.step,s=e/(this.buttons.length-1)*100;this.currentStepNumber.innerText=t,this.dom.querySelectorAll("[aria-valuenow]").forEach(function(e){e.setAttribute("aria-valuenow",t)}),this.buttons.forEach(function(e){var r=e,n=r.parentNode;parseInt(r.getAttribute("data-step"),10)===t&&i(r)&&(n.classList.add("current"),n.classList.add("viewed"),r.disabled=!1),n.classList.remove("current")}),this.progressTitle.innerText=n.getAttribute("data-title"),s=s?s+"%":"",this.dom.querySelector(".progress-bar").style.width=s}}]),e}(),l=function(){function e(t,r){n(this,e),this.step=t,this.userForm=r,this.viewed=!1,this.buttonHolder=null,this.id=0,this.init()}return s(e,[{key:"init",value:function(){var e=this,t=this.getHTMLId();this.buttonHolder=document.querySelector(".step-button-wrapper[data-for='"+t+"']"),["userform.field.hide","userform.field.show"].forEach(function(t){e.buttonHolder.addEventListener(t,function(){e.userForm.dom.trigger("userform.form.conditionalstep")})})}},{key:"setId",value:function(e){this.id=e}},{key:"getHTMLId",value:function(){return this.step.getAttribute("id")}},{key:"show",value:function(){this.step.setAttribute("aria-hidden",!1),this.step.classList.remove("hide"),this.step.classList.add("viewed"),this.viewed=!0}},{key:"hide",value:function(){this.step.setAttribute("aria-hidden",!0),this.step.classList.add("hide")}},{key:"conditionallyHidden",value:function(){var e=this.buttonHolder.querySelector("button");return!("none"!==e.style.display&&"hidden"!==e.visibility&&!e.classList.contains("hide"))}},{key:"getValidatorType",value:function(e){return"email"===e.getAttribute("type")?"email":"date"===e.getAttribute("type")?"date":e.classList.contains("numeric")||"numeric"===e.getAttribute("type")?"number":"string"}},{key:"getValidatorMessage",value:function(e){return e.getAttribute("data-msg-required")?e.getAttribute("data-msg-required"):this.getFieldLabel(e)+" is required"}},{key:"getHolderForField",value:function(e){return window.closest(e,".field")}},{key:"getFieldLabel",value:function(e){var t=this.getHolderForField(e);if(t){var r=t.querySelector("label.left, legend.left");if(r)return r.innerText}return e.getAttribute("name")}},{key:"getValidati