mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
1 line
93 KiB
JavaScript
1 line
93 KiB
JavaScript
|
!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,n){(function(e){e(function(t){function n(n){var i=this;return this.$el=n instanceof e?n:t(n),this.steps=[],this.errorContainer=new r(this.$el.children(".error-container")),this.$el.on("userform.action.prev",function(e){i.prevStep()}),this.$el.on("userform.action.next",function(e){i.nextStep()}),t("#userform-progress").on("userform.progress.changestep",function(e,t){i.jumpToStep(t-1)}),this.$el.on("userform.form.valid",function(e,t){i.errorContainer.removeStepLink(t)}),this.$el.validate(this.validationOptions),t(".optionset.requiredField input").each(function(){t(this).rules("add",{required:!0})}),this}function r(n){return this.$el=n instanceof e?n:t(n),this.$el.find("h4").text(ss.i18n._t("UserForms.ERROR_CONTAINER_HEADER","Please correct the following errors and try again:")),this}function i(n){var i=this;return this.$el=n instanceof e?n:t(n),this.$elButton=t(".step-button-wrapper[data-for='"+this.$el.prop("id")+"']"),this.viewed=!1,this.valid=!1,this.id=null,this.hide(),u.DISPLAY_ERROR_MESSAGES_AT_TOP&&(this.errorContainer=new r(this.$el.find(".error-container")),a.$el.on("userform.form.error",function(e,n){i.$el.is(":visible")&&t.each(n.errorList,function(e,n){i.errorContainer.updateErrorMessage(t(n.element),n.message)})}),a.$el.on("userform.form.valid",function(e,t){i.errorContainer.removeErrorMessage(t)})),this.$elButton.on("userform.field.hide userform.field.show",function(){a.$el.trigger("userform.form.conditionalstep")}),this}function o(n){var r=this;return this.$el=n instanceof e?n:t(n),this.$buttons=this.$el.find(".step-button-jump"),this.$jsAlign=this.$el.find(".js-align"),this.$buttons.each(function(e,n){t(n).on("click",function(e){e.preventDefault(),r.$el.trigger("userform.progress.changestep",[parseInt(t(this).data("step"),10)])})}),a.$el.on("userform.form.changestep",function(e,t){r.update(t)}),a.$el.on("userform.form.conditionalstep",function(){var e=r.$buttons.filter(":visible");e.each(function(e,n){t(n).text(e+1)}),r.$el.find(".progress-bar").attr("aria-valuemax",e.length),r.$el.find(".total-step-number").text(e.length)}),this.$jsAlign.each(function(e,n){var i=t(n),o=100/(r.$jsAlign.length-1)*e+"%",s=i.innerWidth()/2*-1;i.css({left:o,marginLeft:s}),e===r.$jsAlign.length-1?i.css({marginLeft:2*s}):0===e&&i.css({marginLeft:0})}),this.update(0),this}function s(n){var r=this;return this.$el=n instanceof e?n:t(n),this.$prevButton=this.$el.find(".step-button-prev"),this.$nextButton=this.$el.find(".step-button-next"),this.$prevButton.parent().attr("aria-hidden",!1).show(),this.$nextButton.parent().attr("aria-hidden",!1).show(),this.$prevButton.on("click",function(e){e.preventDefault(),r.$el.trigger("userform.action.prev")}),this.$nextButton.on("click",function(e){e.preventDefault(),r.$el.trigger("userform.action.next")}),a.$el.on("userform.form.changestep userform.form.conditionalstep",function(){r.update()}),this.update(),this}var a=null,u={},l={show:function(){this.$el.attr("aria-hidden",!1).show()},hide:function(){this.$el.attr("aria-hidden",!0).hide()}};n.prototype.validationOptions={ignore:":hidden,ul",errorClass:"error",errorElement:"span",errorPlacement:function(e,t){e.addClass("message"),t.is(":radio")||t.parents(".checkboxset").length>0?e.insertAfter(t.closest("ul")):t.parents(".checkbox").length>0?e.insertAfter(t.next("label")):e.insertAfter(t)},invalidHandler:function(e,t){setTimeout(function(){t.currentElements.filter(".error").first().focus()},0)},submitHandler:function(e,n){var r=!0;a.currentStep&&(a.currentStep.valid=t(e).valid()),t.each(a.steps,function(e,t){t.valid||t.conditionallyHidden()||(r=!1,a.error
|