!function(e){if("undefined"!=typeof epi&&void 0!==epi.EPiServer&&void 0!==epi.EPiServer.Forms)if(void 0!==e){var t=function(e,t){this.workingFormInfo=t.workingFormInfo,this.dependantInfo=e,this.$domElement=i.getFormElementBlock(e.fieldName,this.workingFormInfo.$workingForm),this.onDependencyStateChanged=t.onDependencyStateChanged,this.dependency=new epi.EPiServer.Forms.Dependency.Dependant(e,t.workingFormInfo),this._registerEventListener(this.dependency),this.isSatisfied=this.dependency.isSatisfied,"function"==typeof this.onDependencyStateChanged&&this.onDependencyStateChanged(this.$domElement,this.dependantInfo,this.isSatisfied),this.check()};t.prototype={_registerEventListener:function(t){var n=this;e(t).on("change",function(e,t){n.onDependencyChangeHandler.call(n,t)})},onDependencyChangeHandler:function(t){this.isSatisfied!==t.isSatisfied&&(this.isSatisfied=t.isSatisfied,this._executeAction(),"function"==typeof this.onDependencyStateChanged&&this.onDependencyStateChanged(this.$domElement,this.dependantInfo,this.isSatisfied),e(this.$domElement).trigger("formsDependencyStateChanged"))},check:function(){this.dependency.runCheck()},_executeAction:function(){if(this.dependantInfo.action){var e=epi.EPiServer.Forms.Dependency.Actions,t=this.dependantInfo.action.clientsideAction;e[t]&&"function"==typeof e[t]&&e[t](this)}}};var n=function(e,t){this.workingFormInfo=t,this.conditions=e.conditions,this.conditionCombination=e.conditionCombination,this.isSatisfied=null,this._registerEventListener()};n.prototype={_registerEventListener:function(){if(this.conditions&&!(this.conditions.length<=0))for(var t=this,n=[],r=0;r
0&&e.each(m,function(e,n){"change"!==n?s[n](i.debounce(function(e){e.stopPropagation(),t._handleValueChange()},epi.EPiServer.Forms.ThrottleTimeout,t)):s[n](function(){t._handleValueChange.apply(t)})}),e(o).on("formsDependencyStateChanged",function(e,n){t._handleValueChange.apply(t)}),n.push(a.fieldName)}}},runCheck:function(){this._handleValueChange()},_handleValueChange:function(){var t=this.isSatisfied;this.isSatisfied=this._checkSatisfaction(),this.isSatisfied!==t&&e(this).trigger("change",{isSatisfied:this.isSatisfied})},_checkSatisfaction:function(){if(!this.conditions||this.conditions.length<=0)return!0;for(var e=0;e
=0||((l=document.createElement("script")).type="text/javascript",l.async=n||!1,l.defer=n||!1,l.src=s,r.appendChild(l),i.LoadedScripts.push(s));l?i._setupCallback(l,t):t()},loadExternalCssOnDemand:function(e,t){for(var n=document.getElementsByTagName("head")[0],r=0,a=e.length,o=null;r
").text(t).html()},htmlDecodeEntities:function(e){var t=document.createElement("textarea");return t.innerHTML=e,t.value},isMatchedReg:function(e,t){try{var n=new RegExp(t).exec(e);return null!=n&&n.length>0}catch(e){return console.debug(e.message),!1}},raiseFormsEvent:function(t,n){var i=e.extend(!0,{type:"forms",workingFormInfo:t},n);if(t)t.$workingForm.triggerHandler(i);else{var r=e('.EPiServerForms:eq(0), [data-f-type="form"]:first');(!r||r.length<1)&&(r=e("body")),r.triggerHandler(i)}},injectVisitorData:function(t){var n=e(".FormHidden[data-epiforms-visitordatasources], [data-f-visitordatasources]",t.$workingForm);if(n&&0!==n.length){var i=null;n.each(function(){if((i=e(this))&&i.length>0){var t=null,n=i.data("epiforms-visitordatasources")||i.data("f-visitordatasources");e(n.split(",")).each(function(e,n){"function"==typeof(t=epi.EPiServer.Forms.VisitorData[n])&&t(i)})}})}},isElementType:function(e,t){return e.data("f-type")===t},getElementName:function(e){return e.attr("name")||e.data("epiforms-element-name")||e.data("f-element-name")},getElementValue:function(t){return t.hasClass("FormFileUpload")||i.isElementType(t,"fileupload")?i.getPreviousPostedFiles(t):t.hasClass("FormChoice")||i.isElementType(t,"choice")?t.find(".FormChoice__Input:checked, [data-f-datainput]:checked").map(function(t,n){return e(n).val()}).get():t.hasClass("FormSelection")||i.isElementType(t,"selection")?[].concat(t.find("select").val()):t.hasClass("FormCaptcha")||t.hasClass("FormTextbox")||t.hasClass("FormTextbox--Textarea")||i.isElementType(t,"captcha")||i.isElementType(t,"textbox")?e(".FormTextbox__Input, [data-f-datainput]",t).val().trim():t.hasClass("FormRange")||i.isElementType(t,"range")?e(".FormRange__Input, [data-f-datainput]",t).val().trim():t.hasClass("Form__CustomElement")||i.isElementType(t,"custom")?epi.EPiServer.Forms.Extension.getCustomElementValue(t):i.getNonSpecificElementValue(t)},getFormStepBlock:function(e,t){return console.warn("This is obsolete.Use getFormElementBlock() instead."),i.getFormElementBlock(e,t)},getFormElementBlock:function(t,n){if(!t)return[];var i=e(".Form__Element [data-epiforms-element-name='"+t+"']",n);return i&&0!==i.length||(i=e("[data-f-element-name='"+t+"']",n)),i},getWorkingFormFromInnerElement:function(t){return e(t).parents(".EPiServerForms:first, [data-f-type='form']:first")},getFormIdentifier:function(e){return e.prop("id")},getPreviousPostedFiles:function(t){var n=t.find(".FormFileUpload__Input, [data-f-datainput]"),r=i.getElementName(n),a=i.getWorkingFormFromInnerElement(n),o=epi.EPiServer.Forms.Utils.getFormIdentifier(a),s=epi.EPiServer.Forms.Data.loadFormDataFromStorage(o),l=n[0].files;return e.each(s,function(e,t){if(e.indexOf("__TempData")>-1&&e.replace("__TempData","")==r&&0===l.length)return l=t,!1}),l},getNonSpecificElementValue:function(t){if(!t.attr("data-f-element-name"))return t.val().trim();var n=t.find(":input");if(0===n.length)return t.val().trim();if("input"!=n[0].tagName.toLowerCase())return e(n[0]).val().trim();var i=n[0].type.toLowerCase();return"checkbox"==i||"radio"==i?n.filter(":checked").map(function(t,n){return e(n).val()}).get():e(n[0]).val().trim()},getCurrentStepIndex:function(t){var n=e("input[name=__FormCurrentStepIndex]",t.$workingForm).val();return void 0===n||""===n.trim()||isNaN(+n)||+n>t.StepsInfo.Steps.length-1?t.StepsInfo.AllStepsAreNotLinked?n=0:e.each(t.StepsInfo.Steps,function(e,i){if(i.attachedContentLink==epi.EPiServer.CurrentPageLink&&a.isStepSatisfyDependentCondition(i,t))return n=e,!1}):n=+n,n},setCurrentStepIndex:function(t,n){return e("input[name=__FormCurrentStepIndex]",t.$workingForm).val(n),n},validateRegularExpressionValidator:function(e,t,n){return n&&n.model&&n.model.jsPattern&&""!==t?i.isMatchedReg(t,n.model.jsPattern)?{isValid:!0}:{isValid:!1,message:i.stringFormat(n.model.message,[n.model.jsPattern,n.description])}:{isValid:!0}},showNextStepOnEnterKeyDown:function(t){var n=i.getWorkingFormFromInnerElement(t.target),r=t.keyCode,a=e(".Form__NavigationBar .Form__NavigationBar__Action.btnNext, [data-f-type='navigationbar'] [data-f-navigation-next]",n),o=e(".Form__Element.FormSubmitButton, [data-f-type='submitbutton']",n).parent(".FormStep, [data-f-type='step']").filter(function(t){return!e(this).hasClass("hide")});return 13!==r||0!==o.length||null==a||!a.length||(t.preventDefault(),t.stopPropagation(),a.trigger("click"),!0)},scrollToTheTopOfForm:function(t){null!=t&&"fixed"!==t.css("position").toLowerCase()&&e(document).scrollTop()>0&&window.scrollTo(0,t.offset().top)}},Extension:{getSummarizedText:function(t,n,r){var a=r?"
":"\n",o=r?t.ConfirmMessage:i.htmlDecodeEntities(t.ConfirmMessage),s=t.ElementsInfo,l=[],m=[],d=["__FormGuid","__FormLanguage","__FormCurrentStepIndex","__FormSubmissionId"],p=t.ConfirmMessage?o+a+a:"",f=null,u=null;for(var c in n)if(!(l.indexOf(c.replace("__TempData",""))>-1||i.isInactiveField(t,c))){var g=c.indexOf("__TempData")>-1?s[c.replace("__TempData","")]:s[c];f=g&&g.friendlyName?g.friendlyName:"",(null==(u=g&&1==g.customBinding?epi.EPiServer.Forms.CustomBindingElements[g.type](g,n[c]):n[c])||u instanceof Array&&0===u.length||e.isEmptyObject(u))&&(u=""),u instanceof Array?u=e.map(u,function(e,t){return e?"string"==typeof e?e:"object"==typeof e?e.name:void 0:null}).join(", "):u instanceof FileList&&0===u.length?u="":(u=u.toString().substr(0,46).trim()).length>=45&&(u+=" ..."),e("[name="+c+"]",t.$workingForm).hasClass("FormHideInSummarized")&&m.push(c),""==f||null==f||""==u||null==u||d.indexOf(c)>=0||m.indexOf(c)>=0||(l.push(c),p+=r?i.stringFormat("{0}: {1}"+a,[i.htmlEncodeEntities(f),i.htmlEncodeEntities(u)]):i.stringFormat("{0}: {1}"+a,[i.htmlDecodeEntities(f),u]))}return p},onBeforeSubmit:function(){var t=e.Deferred();return t.resolve(),t.promise()},showSummarizedText:function(t,n,i,r){var a=e.Deferred(),o=this.getSummarizedText(n,t,!1);return o&&""!==o.trim()?(setTimeout(function(){var e=confirm(o);a.resolve(e)},100),a.promise()):(a.resolve(!0),a.promise())},getCustomElementValue:function(e){return e.val()||e.find("[data-f-datainput]").val()},bindCustomElementValue:function(e,t){e.find(".Form__CustomInput, [data-f-datainput]").val(t)},resetCustomElementValue:function(e){e.find(".Form__CustomInput, [data-f-datainput]").val("")},getAllDataElements:function(t){return e(".Form__Element, .Form__CustomElement, [data-f-type]",t).not(".FormStep,.FormSubmitButton,.Form__Element--NonData,[data-f-type='step'],[data-f-type='form'],[data-f-type='resetbutton'],[data-f-type='submitbutton'],[data-f-element-nondata]")},isStepSatisfyDependentCondition:function(e,t){if(!e)return!1;var n=e.dependField,i=r.loadFormDataFromStorage(t.Id),a=epi.EPiServer.Forms.DependConditions[e.dependCondition];return!(n&&a&&i)||(l._isInactiveElement(n,t)?a(null,e.dependValue):a(i[n],e.dependValue))},getAntiForgeryToken:function(t){return{antiForgeryToken:e('input[name="__RequestVerificationToken"]',t.$workingForm).val()}},buildSubmitRequestHeader:function(t){var n={},i=this.getAntiForgeryToken(t);return e.extend(n,i),n}},Data:{loadCurrentFormDataFromStorage:function(e){var t=epi.EPiServer.Forms.Utils.getFormIdentifier(e);return this.loadFormDataFromStorage(t)},loadFormDataFromStorage:function(e){var t=this.getStorage()[e];return t&&(t=JSON.parse(t))||{}},saveCurrentFormDataToStorage:function(e,t){var n=epi.EPiServer.Forms.Utils.getFormIdentifier(e);return this.saveFormDataToStorage(n,t)},saveFormDataToStorage:function(e,t){var n=this.getStorage();try{n.setItem(e,JSON.stringify(t))}catch(e){console.log("Local Storage not supported: "+e.message)}return t},clearFormDataInStorage:function(e){removeFormDataInStorage(epi.EPiServer.Forms.Utils.getFormIdentifier(e))},removeFormDataInStorage:function(e){this.getStorage().removeItem(e)},getStorage:function(){return sessionStorage}},Validation:{getValidatorByValidatorType:function(e,t){if(e instanceof Array&&0!==e.length&&t)for(var n=0,i=null,r=e.length;n
=0&&e.workingFormInfo.DependencyInactiveElements.splice(t,1)}else this._hideElement(e),e.workingFormInfo.DependencyInactiveElements.push(e.dependantInfo.fieldName)},hide:function(e){if(e.isSatisfied)this._hideElement(e),e.workingFormInfo.DependencyInactiveElements.push(e.dependantInfo.fieldName);else{this._showElement(e);var t=e.workingFormInfo.DependencyInactiveElements&&e.workingFormInfo.DependencyInactiveElements.indexOf(e.dependantInfo.fieldName);t>=0&&e.workingFormInfo.DependencyInactiveElements.splice(t,1)}},_hideElement:function(e){e.$domElement.hide(this.Config.HideDuration),e.$domElement.addClass("hide")},_showElement:function(e){e.$domElement.show(this.Config.ShowDuration),e.$domElement.removeClass("hide")}},DependantController:t,Dependant:n,_initDependencyInfos:function(e){var t=e.DependenciesInfo;if(t&&!(t.length<=0)){e.DependantControllers=[];for(var n=0;n
=0)){var a=i.getCurrentStepIndex(n),o=e(n.$steps[a]);return e(t,o).length>0?i.getElementValue(t):epi.EPiServer.Forms.Data.loadCurrentFormDataFromStorage(n.$workingForm)[r]}}},_getTriggerEventForDependeeElement:function(e){return i.isElementType(e,"textbox")?"keyup":"change"},_getTriggerEventsForDependeeElement:function(e){return i.isElementType(e,"textbox")?"number"===e.attr("data-f-modifier")?["keyup","change"]:["keyup"]:["change"]},_isElementOfInactiveSteps:function(t,n){var i=n.StepsInfo.Steps.filter(function(e){return!1===e.isActive});if(0===i.length)return!1;for(var r=0;r
-1)return!0}}return!1},_isInactiveElement:function(e,t){return t.DependencyInactiveElements.indexOf(e)>-1||this._isElementOfInactiveSteps(e,t)}},Navigation:{findNextStep:function(e,t){var n=null,i=e+1,r=t.StepsInfo.Steps[i];if(r){var a=epi.EPiServer.Forms.Extension.isStepSatisfyDependentCondition(r,t);r.isActive=a,n=a?r:this.findNextStep(i,t)}return n},findPreviousStep:function(e,t){var n=null,i=e-1,r=t.StepsInfo.Steps[i];return r&&(n=epi.EPiServer.Forms.Extension.isStepSatisfyDependentCondition(r,t)?r:this.findPreviousStep(i,t)),n}}});var m={VisitorData:{"EPiServer.Forms.Implementation.VisitorData.GeoVisitorDataSource":function(t){var n=i.getWorkingFormFromInnerElement(t),r=epi.EPiServer.Forms[i.getFormIdentifier(n)].DataSubmitController;e.get(r+"/GetGeoData").done(function(e){if(!t.val()){var n=t.data("epiforms-visitordataproperty")||t.data("f-visitordataproperty");null!=e&&e[n]&&t.val(e[n])}})}}},d={Validators:{"EPiServer.Forms.Implementation.Validation.RequiredValidator":function(e,t,n){return n&&(""==t||t&&!t.length)?{isValid:!1,message:n.model.message}:{isValid:!0}},"EPiServer.Forms.Implementation.Validation.RegularExpressionValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.EmailValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.UrlValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateDDMMYYYYValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateMMDDYYYYValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateYYYYMMDDValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.IntegerValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.PositiveIntegerValidator":i.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.AllowedExtensionsValidator":function(e,t,n){if(!t||t instanceof Array&&0===t.length)return{isValid:!0};var i,r,a,o,s=t,l=n.model.accept,m=epi.EPiServer.Forms.UploadExtensionBlackList.split(","),d=void 0==l||l.length<1?[]:l.split(","),p=0,f=0,u=d.length,c=s.length;if(u>0)for(;p
>>0))}(i)).length<1||(o=o.toLowerCase(),r.indexOf(o)>=0||!(a.length<1||a.indexOf(o)>-1)))return{isValid:!1,message:epi.EPiServer.Forms.Utils.stringFormat(n.model.message,[l])};return{isValid:!0}},"EPiServer.Forms.Implementation.Validation.MaxFileSizeValidator":function(e,t,n){for(var i=t,r=0,a=i.length,o=n.model.sizeInBytes;r
o)return{isValid:!1,message:epi.EPiServer.Forms.Utils.stringFormat(n.model.message,[o/1048576])};return{isValid:!0}},"EPiServer.Forms.Implementation.Validation.NumericValidator":function(e,t,n){var i;return t&&(i=t,isNaN(parseFloat(i))||!isFinite(i))?{isValid:!1,message:n.model.message}:{isValid:!0}},"EPiServer.Forms.Implementation.Validation.CaptchaValidator":{initialize:function(t){var n=this;t.parents(".FormCaptcha, [data-f-type='captcha']").find(".FormCaptcha__Refresh, [data-f-captcha-refresh]").on("click",function(t){n._refreshCaptcha(e(this)),t.preventDefault()})},validate:function(e,t,n){var i=t.trim();return{isValid:null!=i&&""!==i,message:n.model.message}},onServerValidateFailed:function(e,t){this._refreshCaptcha(e),e.focus()},_refreshCaptcha:function(e){var t=e.hasClass("FormCaptcha")||i.isElementType(e,"captcha")?e:e.parents(".FormCaptcha, [data-f-type='captcha']"),n=t.find(".FormCaptcha__Image, [data-f-captcha-image]"),r=t.find(".FormTextbox__Input, [data-f-datainput]");n.attr("src",n.attr("src")+"&d="+Math.random()),r.val("")}}}},p={DependConditions:{Equals:function(e,t){return(e=e?epi.EPiServer.Forms.Utils.getConcatString(e,",").toUpperCase():"")===(t=t?t.toUpperCase():"")},NotEquals:function(e,t){return(e=e?epi.EPiServer.Forms.Utils.getConcatString(e,",").toUpperCase():"")!==(t=t?t.toUpperCase():"")},Contains:function(e,t){return e=e?epi.EPiServer.Forms.Utils.getConcatString(e,",").toUpperCase():"",t=t?t.toUpperCase():"",e.indexOf(t)>=0},NotContains:function(e,t){return!(e=e?epi.EPiServer.Forms.Utils.getConcatString(e,","):"")&&t||e&&!t||e&&t&&e.toUpperCase().indexOf(t.toUpperCase())<0},MatchRegularExpression:function(e,t){var n=new RegExp(t,"igm");return n.ignoreCase=n.global=n.multiline=!0,!t||t&&n.test(e)}}};e.extend(!0,epi.EPiServer.Forms,m),e.extend(!0,epi.EPiServer.Forms,d),e.extend(!0,epi.EPiServer.Forms,p),e.extend(!0,epi.EPiServer.Forms,{CustomBindingElements:{}}),epi.EPiServer.Forms.init=function(){epi.EPiServer.Forms.__Initialized||(epi.EPiServer.Forms.__Initialized=!0,e(document).ready(function(){function t(t){t.preventDefault(),t.stopPropagation();var n=i.getWorkingFormFromInnerElement(t.target),s=c(n);if(!1===s.SubmittableStatus.submittable)return p(s,s.SubmittableStatus.message),!1;e.when(a.onBeforeSubmit(n)).then(function(){var m=y(s);if(!v(m,s))return S(m),E(m),!1;var f=function(t){var n=c(t),i=g(t),a=r.loadFormDataFromStorage(n.Id);return e.extend(a,i)}(n);e.when(function(t,n){var i=e.Deferred();if(!t.ShowSummarizedData)return i.resolve(!0),i.promise();return a.showSummarizedText(n,t,["__FormGuid","__FormLanguage","__FormCurrentStepIndex","__FormSubmissionId"],[])}(s,f)).then(function(r){if(!r)return!1;var a=[];for(var m in f)if(!(m.indexOf("__TempData")>-1||l._isInactiveElement(m,s)||i.getFormElementBlock(m,n).parents(".FormStep:first, [data-f-type='step']:first").hasClass("hide"))){var u=o.getElementValidators(s.ValidationInfo,m);a=a.concat(o.validateFormValue(m,f[m],u))}var c=e.grep(a,function(e){return 0==e.isValid});if(c.length>0){var g=e.map(c,function(e){return e.message});return p(s,g.join(" ")),!1}d(t)})})}function n(e){e.preventDefault(),e.stopPropagation();var t=i.getWorkingFormFromInnerElement(e.target),n=c(t);i.raiseFormsEvent(n,{type:"formsReset",sourceEvent:e}),m(t,n),h(n.StepsInfo.Steps[0],n)}function m(t,n){if(t.get(0).reset(),n.SubmittableStatus&&!1===n.SubmittableStatus.submittable?p(n,n.SubmittableStatus.message):p(n,""),r.removeFormDataInStorage(n.Id),e("[aria-invalid=true]",t).attr("aria-invalid","false"),a.getAllDataElements(t).each(function(t,n){var r=e(n);F(r).text(""),r.removeClass("ValidationFail ValidationSuccess"),r.hasClass("FormChoice")||i.isElementType(r,"choice")?r.find("input[type=checkbox], input[type=radio]").each(function(t,n){var i=e(n);i.prop("checked",!(!i.data("epiforms-default-value")&&!i.data("f-default-value")))}):r.hasClass("FormSelection")||i.isElementType(r,"selection")?(r.find("option[disabled]:eq(0)").prop("selected",!0),r.find("option").each(function(t,n){var i=e(n);!1===i.prop("disabled")&&i.prop("selected",!(!i.data("epiforms-default-value")&&!i.data("f-default-value")))})):r.hasClass("FormFileUpload")||i.isElementType(r,"fileupload")?(f(r).text(""),C(r.find(".FormFileUpload__Input, [data-f-datainput]"))):(r.hasClass("Form__CustomElement")||i.isElementType(r,"custom"))&&a.resetCustomElementValue(r)}),n.DependantControllers&&n.DependantControllers.length)for(var o=0;o
0&&null!==x[0]&&"object"==typeof x[0]){for(var A,$=x,U="",O=0;O<$.length;O++)x[0].file&&Object.getPrototypeOf(x[0].file)===File.prototype&&(A=$[O].file,b.append(N+"_file_"+O,A)),U+=$[O].name+"|";b.append(N,U)}else b.append(N,x);i.raiseFormsEvent(d,{type:"formsStartSubmitting",formData:b}),g.prop("disabled",!0),p(d,"");var B=e.ajax({url:d.DataSubmitController+"/Submit",headers:a.buildSubmitRequestHeader(d),data:b,cache:!1,type:n.prop("method"),processData:!1,contentType:!1,async:epi.EPiServer.Forms.AsyncSubmit||n.data("epiforms-async-submit")||n.data("f-async-submit")||!1}),R="";B.done(function(a){if(t.preventDefault(),e(".Form__Element__ValidationError, [data-f-validationerror]").text(""),!0===a.IsSuccess){var s=y(d);if(e(".FormFileUpload .FormFileUpload__Input, [data-f-type='fileupload'] [data-f-datainput]",s).each(function(t,n){e(this).val(""),C(e(this))}),0==T&&0==v){i.raiseFormsEvent(d,{type:"formsNavigationNextStep",targetStep:P});var l=r.loadFormDataFromStorage(d.Id),f=e.extend(l,{__FormSubmissionId:a.Data.SubmissionId});return r.saveFormDataToStorage(d.Id,f),i.raiseFormsEvent(d,{type:"formsSubmitted",formData:b,isFinalizedSubmission:!1,isSuccess:a.IsSuccess,returnedResult:a}),h(P,d),!1}1==T&&m(n,d),i.raiseFormsEvent(d,{type:"formsSubmitted",formData:b,isFinalizedSubmission:T,isSuccess:a.IsSuccess,returnedResult:a});var u=d.StepsInfo.Steps.length;if(a.RedirectUrl)return R=a.RedirectUrl,window.location.href=a.RedirectUrl,!1;0==v&&!P&&V
0&&function(t,n){for(var i=null,r=0;r
0){var f=o.validateFormValue(s,p,m),u=e.grep(f,function(e){return!1===e.isValid}),c=e.grep(n.ValidationInfo,function(e){return e.targetElementId===l||e.targetElementName===l})[0],g=e("#"+c.targetElementId);if(u&&u.length>0){var v=e.map(u,function(e){return e.message});g.attr("aria-invalid","true"),r.addClass("ValidationFail"),a.text(v.join(" ")).show(),d=!1}else r.addClass("ValidationSuccess"),g.attr("aria-invalid","false"),d=!0}return i.raiseFormsEvent(n,{type:"elementValidated",isValid:d,elementName:s,elementValue:p,elementIdentifier:l,element:t,$messageContainer:a}),d}(a,n)&&r}),i.raiseFormsEvent(n,{type:"formsStepValidating",isValid:r}),n.$workingForm.toggleClass("ValidationSuccess",r),n.$workingForm.toggleClass("ValidationFail",!r),r}function F(t){var n=i.getElementName(t),r=i.stringFormat("{0}[data-epiforms-linked-name='{1}'], {0}[data-epiforms-linked-name='{2}']",[".Form__Element__ValidationError",n,t.attr("id")]),a=i.stringFormat("{0}[data-f-linked-name='{1}'], {0}[data-f-linked-name='{2}']",["[data-f-validationerror]",n,t.attr("id")]);return e(r).add(a)}function h(t,n){if(t)if(i.raiseFormsEvent(n,{type:"formsNavigateToStep",targetStep:t}),function(t,n){e.each(t,function(t,r){var o=-1!==t.indexOf("__TempData")?t.replace("__TempData",""):t,s=e('[data-epiforms-element-name="'+o+'"], [data-f-element-name="'+o+'"]',n);if(0!==s.length&&!s.hasClass("FormExcludeDataRebind")&&!s.data("f-excludedatarebind")){var l=s.find(".FormChoice__Input--Checkbox, [data-f-datainput]:checkbox");if(l.length>0)e.each(l,function(){var t=e(this).val();e(this).attr("checked",r.indexOf(t)>-1)});else if((l=s.find(".FormChoice__Input--Radio, [data-f-datainput]:radio")).length>0){var m=Array.isArray(r)?r[0]:r;e.each(l,function(){var t=e(this).val();e(this).attr("checked",m==t)})}else if(s.hasClass("FormSelection")||i.isElementType(s,"selection"))e("option:enabled",s).each(function(t,n){e(n).attr("selected",r.indexOf(e(n).val())>-1)});else if(!s.hasClass("FormCaptcha")&&!i.isElementType(s,"captcha"))if((l=s.find(".FormFileUpload__Input, [data-f-datainput]:file")).length>0){var d="";if(r instanceof Array&&r.length>0){var p=r.map(function(e){return e.name}).join(", ");d=d.concat(p)}if(""!==d){var u=i.stringFormat(epi.EPiServer.Forms.Messages.fileUpload.postedFile,[d]);f(s).text(u).show()}}else s.hasClass("Form__CustomElement")||i.isElementType(s,"custom")?a.bindCustomElementValue(s,r):s.find("[data-f-datainput]:first").val(r)}})}(r.loadFormDataFromStorage(n.Id),n.$workingForm),n.StepsInfo.AllStepsAreNotLinked||t.attachedContentLink==epi.EPiServer.CurrentPageLink)n.$steps.addClass("hide"),n.$steps.each(function(r,a){if(r===t.index)return e(a).removeClass("hide"),i.setCurrentStepIndex(n,t.index),!1}),i.scrollToTheTopOfForm(n.$workingForm);else{if(t.attachedUrl&&t.attachedUrl.length)return void window.location.replace(t.attachedUrl);n.StepsInfo.AllStepsAreNotLinked||p(n,epi.EPiServer.Forms.Messages.viewMode.malformStepConfiguration)}else n.$steps.hide();_(n)}function S(t){epi.EPiServer.Forms.Validators["EPiServer.Forms.Implementation.Validation.CaptchaValidator"]._refreshCaptcha(e(".Form__Element.FormCaptcha, [data-f-type='captcha']",t))}function E(t){if(t){var n=e(".Form__Element.ValidationFail",t)[0];if(n){n.scrollIntoView();var i=e("[data-f-datainput]",n);i&&i.length>0&&i[0].focus()}}}function _(t){var n=i.getCurrentStepIndex(t),r=e(".Form__NavigationBar, [data-f-type='navigationbar']",t.$workingForm);if(n<0)r.hide();else{var a=e(".Form__NavigationBar__Action.btnPrev, [data-f-navigation-previous]",r).prop("disabled",!1),o=e(".Form__NavigationBar__Action.btnNext, [data-f-navigation-next]",r).prop("disabled",!1);0!==n&&!1!==t.SubmittableStatus.submittable||a.prop("disabled",!0),n!==t.StepsInfo.Steps.length-1&&!1!==t.SubmittableStatus.submittable||o.prop("disabled",!0);var s=n+1,l=t.StepsInfo.Steps.length;e(".Form__NavigationBar, [data-f-type='navigationbar']",t.$workingForm).toggle(t.ShowNavigationBar),e(".Form__NavigationBar__ProgressBar__CurrentStep, [data-f-navigation-currentStep]",r).text(s),e(".Form__NavigationBar__ProgressBar__StepsCount, [data-f-navigation-stepcount]",r).text(l),e(".Form__NavigationBar__ProgressBar--Progress, [data-f-navigation-progress]",r).css({width:100*s/l+"%"})}}function y(t){var n=i.getCurrentStepIndex(t);return e(t.$steps[n])}function C(e){/MSIE/.test(navigator.userAgent)&&e.replaceWith(e=e.clone(!0))}r.getStorage()?(e('.EPiServerForms, [data-f-type="form"]').each(function(o,l){var m=e(l),f=c(m);f.SubmittableStatus&&!1===f.SubmittableStatus.submittable&&p(f,f.SubmittableStatus.message),function(t){if(!t||!t.StepsInfo||!t.StepsInfo.Steps)return;if(t.$steps=e(".FormStep, [data-f-type='step']",t.$workingForm),t.StepsInfo.Steps.length<2)return;h(t.StepsInfo.Steps[i.getCurrentStepIndex(t)],t),e(".Form__NavigationBar__Action.btnNext, [data-f-navigation-next]",t.$workingForm).on("click",function(n){n.preventDefault(),e.when(a.onBeforeSubmit(t.$workingForm)).then(function(){var e=y(t);if(!v(e,t))return S(e),E(e),!1;d(n)})}),e(".Form__NavigationBar__Action.btnPrev, [data-f-navigation-previous]",t.$workingForm).on("click",function(n){n.preventDefault();var a=u(t.$workingForm,function(e){return e.hasClass("FormFileUpload")||i.isElementType(e,"fileupload")});r.saveFormDataToStorage(t.Id,a);var o=s.findPreviousStep(i.getCurrentStepIndex(t),t);h(o,t);var l=e("section[data-epiforms-stepindex="+o.index+"], section[data-f-stepindex="+o.index+"]",t.$workingForm);S(l),i.raiseFormsEvent(t,{type:"formsNavigationPrevStep",targetStep:o})})}(f);for(var g=1;g
=65&&t<=90||32===t)return!1;if(!e.shiftKey&&!e.altKey&&!e.ctrlKey&&t>=48&&t<=57||t>=96&&t<=105||65===e.keyCode&&!0===e.ctrlKey||67===t&&!0===e.ctrlKey||88===t&&!0===e.ctrlKey||t>=35&&t<=39||8===t||9===t||13===t||46===t||45===t)return!0;var n=this.value;return(109!==t&&189!==t||"-"!==n[0])&&(!((!(e.shiftKey||e.altKey||e.ctrlKey||190!==t)||188===t||110===t)&&/[\.,]/.test(n))&&void 0)}).on("keyup",function(e){var t=this.value;isNaN(t)&&t&&(t=(t=("-"===t[0]?"-":"")+t.replace(/[^0-9\.]/g,"")).replace(/\.(?=(.*)\.)+/g,""),this.value=t)}),e('.EPiServerForms input.FormTextbox__Input,.FormChoice__Input.FormChoice__Input--Checkbox,.FormRange__Input,.FormTextbox__Input.FormUrl__Input,.FormChoice__Input.FormChoice__Input--Radio,.FormTextbox__Input.FormCaptcha__Input.FormHideInSummarized,[data-f-type="form"] [data-f-datainput]:not(textarea)').on("keydown",function(e){return i.showNextStepOnEnterKeyDown(e)})):e('.EPiServerForms .Form__Status__Message, [data-f-type="form"] [data-f-form-statusmessage]').text(epi.EPiServer.Forms.ErrorMessages.cantnotworkwithoutstorage)}))},epi.EPiServer.Forms.ExternalScriptSources.length<=0&&epi.EPiServer.Forms.ExternalCssSources.length<=0?epi.EPiServer.Forms.init():(i.loadExternalScriptOnDemand(epi.EPiServer.Forms.ExternalScriptSources,function(){i.raiseFormsEvent(null,{type:"formsLoadExternalScripts",scripts:epi.EPiServer.Forms.ExternalScriptSources}),epi.EPiServer.Forms.init()}),i.loadExternalCssOnDemand(epi.EPiServer.Forms.ExternalCssSources,function(){i.raiseFormsEvent(null,{type:"formsLoadExternalCss",Css:epi.EPiServer.Forms.ExternalCssSources})}))}else console.error("Forms cannot work without jQuery.");else console.error("Forms is not initialized correctly.")}($$epiforms||$);