https://www.wewashlaundryco.com/umbraco/api/MyAssetDependency/Bund…&mimeType=text/javascript&v=1.0.0
vendor: 14,673 bytes, lines 1-4
1/*! jQuery Validation Plugin - v1.19.3 - 1/9/2021 2 * https://jqueryvalidation.org/ 3 * Copyright (c) 2021 Jörn Zaefferer; Licensed MIT */ 4!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.on("click.validate",":submit",function(b){c.submitButton=b.currentTarget,a(this).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(this).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.on("submit.validate",function(b){function d(){var d,e;return c.submitButton&&(c.settings.submitHandler||c.formSubmitted)&&(d=a("<input type='hidden'/>").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),!(c.settings.submitHandler&&!c.settings.debug)||(e=c.settings.submitHandler.call(c,c.currentForm,b),d&&d.remove(),void 0!==e&&e)}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,b||(d=d.concat(c.errorList))}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0],k="undefined"!=typeof this.attr("contenteditable")&&"false"!==this.attr("contenteditable");if(null!=j&&(!j.form&&k&&(j.form=this.closest("form")[0],j.name=this.attr("name")),null!=j.form)){if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(a,b){i[b]=f[b],delete f[b]}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g)),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}});var b=function(a){return a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};a.extend(a.expr.pseudos||a.expr[":"],{blank:function(c){return!b(""+a(c).val())},filled:function(c){var d=a(c).val();return null!==d&&!!b(""+d)},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:void 0===c?b:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||a.inArray(c.keyCode,d)!==-1||(b.name in this.submitted||b.name in this.invalid)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}."),step:a.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){var c="undefined"!=typeof a(this).attr("contenteditable")&&"false"!==a(this).attr("contenteditable");if(!this.form&&c&&(this.form=a(this).closest("form")[0],this.name=a(this).attr("name")),d===this.form){var e=a.data(this.form,"validator"),f="on"+b.type.replace(/^validate/,""),g=e.settings;g[f]&&!a(this).is(g.ignore)&&g[f].call(e,this,b)}}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.currentForm,e=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){e[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c,d,e=this.clean(b),f=this.validationTargetFor(e),g=this,h=!0;return void 0===f?delete this.invalid[e.name]:(this.prepareElement(f),this.currentElements=a(f),d=this.groups[f.name],d&&a.each(this.groups,function(a,b){b===d&&a!==f.name&&(e=g.validationTargetFor(g.clean(g.findByName(a))),e&&e.name in g.invalid&&(g.currentElements.push(e),h=g.check(e)&&h))}),c=this.check(f)!==!1,h=h&&c,c?this.invalid[f.name]=!1:this.invalid[f.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),a(b).attr("aria-invalid",!c)),h},showErrors:function(b){if(b){var c=this;a.extend(this.errorMap,b),this.errorList=a.map(this.errorMap,function(a,b){return{message:a,element:c.findByName(b)[0]}}),this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var b=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(b)},resetElements:function(a){var b;if(this.settings.unhighlight)for(b=0;a[b];b++)this.settings.unhighlight.call(this,a[b],this.settings.errorClass,""),this.findByName(a[b].name).removeClass(this.settings.validClass);else a.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)void 0!==a[b]&&null!==a[b]&&a[b]!==!1&&c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").trigger("focus").trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var d=this.name||a(this).attr("name"),e="undefined"!=typeof a(this).attr("contenteditable")&&"false"!==a(this).attr("contenteditable");return!d&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),e&&(this.form=a(this).closest("form")[0],this.name=d),this.form===b.currentForm&&(!(d in c||!b.objectLength(a(this).rules()))&&(c[d]=!0,!0))})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([])},reset:function(){this.resetInternals(),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d,e=a(b),f=b.type,g="undefined"!=typeof e.attr("contenteditable")&&"false"!==e.attr("contenteditable");return"radio"===f||"checkbox"===f?this.findByName(b.name).filter(":checked").val():"number"===f&&"undefined"!=typeof b.validity?b.validity.badInput?"NaN":e.val():(c=g?e.text():e.val(),"file"===f?"C:\\fakepath\\"===c.substr(0,12)?c.substr(12):(d=c.lastIndexOf("/"),d>=0?c.substr(d+1):(d=c.lastIndexOf("\\"),d>=0?c.substr(d+1):c)):"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f,g=a(b).rules(),h=a.map(g,function(a,b){return b}).length,i=!1,j=this.elementValue(b);"function"==typeof g.normalizer?f=g.normalizer:"function"==typeof this.settings.normalizer&&(f=this.settings.normalizer),f&&(j=f.call(b,j),delete g.normalizer);for(d in g){e={method:d,parameters:g[d]};try{if(c=a.validator.methods[d].call(this,j,b,e.parameters),"dependency-mismatch"===c&&1===h){i=!0;continue}if(i=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(k){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",k),k instanceof TypeError&&(k.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),k}}if(!i)return this.objectLength(g)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(void 0!==arguments[a])return arguments[a]},defaultMessage:function(b,c){"string"==typeof c&&(c={method:c});var d=this.findDefined(this.customMessage(b.name,c.method),this.customDataMessage(b,c.method),!this.settings.ignoreTitle&&b.title||void 0,a.validator.messages[c.method],"<strong>Warning: No message defined for "+b.name+"</strong>"),e=/\$?\{(\d+)\}/g;return"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),d},formatAndAdd:function(a,b){var c=this.defaultMessage(a,b);this.errorList.push({message:c,element:a,method:b.method}),this.errorMap[a.name]=c,this.submitted[a.name]=c},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g,h=this.errorsFor(b),i=this.idOrName(b),j=a(b).attr("aria-describedby");h.length?(h.removeClass(this.settings.validClass).addClass(this.settings.errorClass),h.html(c)):(h=a("<"+this.settings.errorElement+">").attr("id",i+"-error").addClass(this.settings.errorClass).html(c||""),d=h,this.settings.wrapper&&(d=h.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement.call(this,d,a(b)):d.insertAfter(b),h.is("label")?h.attr("for",i):0===h.parents("label[for='"+this.escapeCssMeta(i)+"']").length&&(f=h.attr("id"),j?j.match(new RegExp("\\b"+this.escapeCssMeta(f)+"\\b"))||(j+=" "+f):j=f,a(b).attr("aria-describedby",j),e=this.groups[b.n
4ame],e&&(g=this,a.each(g.groups,function(b,c){c===e&&a("[name='"+g.escapeCssMeta(b)+"']",g.currentForm).attr("aria-describedby",h.attr("id"))})))),!c&&this.settings.success&&(h.text(""),"string"==typeof this.settings.success?h.addClass(this.settings.success):this.settings.success(h,b)),this.toShow=this.toShow.add(h)},errorsFor:function(b){var c=this.escapeCssMeta(this.idOrName(b)),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+this.escapeCssMeta(d).replace(/\s+/g,", #")),this.errors().filter(e)},escapeCssMeta:function(a){return a.replace(/([\\!"#$%&'()*+,.\/:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+this.escapeCssMeta(b)+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return!this.dependTypes[typeof a]||this.dependTypes[typeof a](a,b)},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);
vendor: 4,563 bytes, line 4
4return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(b){this.pending[b.name]||(this.pendingRequest++,a(b).addClass(this.settings.pendingClass),this.pending[b.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],a(b).removeClass(this.settings.pendingClass),c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.submitButton&&a("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b,c){return c="string"==typeof c&&c||"remote",a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,{method:c})})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur").find(".validate-lessThan-blur").off(".validate-lessThan").removeClass("validate-lessThan-blur").find(".validate-lessThanEqual-blur").off(".validate-lessThanEqual").removeClass("validate-lessThanEqual-blur").find(".validate-greaterThanEqual-blur").off(".validate-greaterThanEqual").removeClass("validate-greaterThanEqual-blur").find(".validate-greaterThan-blur").off(".validate-greaterThan").removeClass("validate-greaterThan-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max|step/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a[c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),""===d&&(d=!0),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0===e.param||e.param:(a.data(c.form,"validator").resetElements(a(c)),delete b[d])}}),a.each(b,function(a,d){b[a]="function"==typeof d&&"normalizer"!==a?d(c):d}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var a;b[this]&&(Array.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(a=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(a[0]),Number(a[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:void 0!==b&&null!==b&&b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)}
4,url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[\/?#]\S*)?$/i.test(a)},date:function(){var a=!1;return function(b,c){return a||(a=!0,this.settings.debug&&window.console&&console.warn("The `date` method is deprecated and will be removed in version '2.0.0'.\nPlease don't use it, since it relies on the Date constructor, which\nbehaves very differently across browsers and locales. Use `dateISO`\ninstead or one of the locale specific methods in `localizations/`\nand `additional-methods.js`.")),this.optional(c)||!/Invalid|NaN/.test(new Date(b).toString())}}(),dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},minlength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d>=c},maxlength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d<=c},rangelength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d>=c[0]&&d<=c[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||a<=c},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},step:function(b,c,d){var e,f=a(c).attr("type"),g="Step attribute on input type "+f+" is not supported.",h=["text","number","range"],i=new RegExp("\\b"+f+"\\b"),j=f&&!i.test(h.join()),k=function(a){var b=(""+a).match(/(?:\.(\d+))?$/);return b&&b[1]?b[1].length:0},l=function(a){return Math.round(a*Math.pow(10,e))},m=!0;if(j)throw new Error(g);return e=k(d),(k(b)>e||l(b)%l(d)!==0)&&(m=!1),this.optional(c)||m},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.not(".validate-equalTo-blur").length&&e.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d,e){if(this.optional(c))return"dependency-mismatch";e="string"==typeof e&&e||"remote";var f,g,h,i=this.previousValue(c,e);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),i.originalMessage=i.originalMessage||this.settings.messages[c.name][e],this.settings.messages[c.name][e]=i.message,d="string"==typeof d&&{url:d}||d,h=a.param(a.extend({data:b},d.data)),i.old===h?i.valid:(i.old=h,f=this,this.startRequest(c),g={},g[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:g,context:f.currentForm,success:function(a){var d,g,h,j=a===!0||"true"===a;f.settings.messages[c.name][e]=i.originalMessage,j?(h=f.formSubmitted,f.resetInternals(),f.toHide=f.errorsFor(c),f.formSubmitted=h,f.successList.push(c),f.invalid[c.name]=!1,f.showErrors()):(d={},g=a||f.defaultMessage(c,{method:e,parameters:b}),d[c.name]=i.message=g,f.invalid[c.name]=!0,f.showErrors(d)),i.valid=j,f.stopRequest(c,j)}},d)),"pending")}}});var c,d={};return a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,c){var e=a.port;"abort"===a.mode&&(d[e]&&d[e].abort(),d[e]=c)}):(c=a.ajax,a.ajax=function(b){var e=("mode"in b?b:a.ajaxSettings).mode,f=("port"in b?b:a.ajaxSettings).port;return"abort"===e?(d[f]&&d[f].abort(),d[f]=c.apply(this,arguments),d[f]):c.apply(this,arguments)}),a});// Unobtrusive validation support library for jQuery and jQuery Validate 5// Copyright (c) .NET Foundation. All rights reserved. 6// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 7// @version v3.2.12 8!function(a){"function"==typeof define&&define.amd?define("jquery.validate.unobtrusive",["jquery-validation"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery-validation")):jQuery.validator.unobtrusive=a(jQuery)}(function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");
8r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("<li />").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function u(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=f.unobtrusive.options||{},u=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),u("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),u("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),u("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)}
8,validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var m,f=a.validator,v="unobtrusiveValidation";return f.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=u(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){f.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=u(this);a&&a.attachValidation()})}},m=f.unobtrusive.adapters,m.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},m.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},m.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},m.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},f.addMethod("__dummy__",function(a,e,n){return!0}),f.addMethod("regex",function(a,e,n){var t;return!!this.optional(e)||(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),f.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),f.methods.extension?(m.addSingleVal("accept","mimtype"),m.addSingleVal("extension","extension")):m.addSingleVal("extension","extension","accept"),m.addSingleVal("regex","pattern"),m.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),m.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),m.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),m.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),m.add("required",function(a){"INPUT"===a.element.tagName.toUpperCase()&&"CHECKBOX"===a.element.type.toUpperCase()||e(a,"required",!0)}),m.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),m.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),m.add("fileextensions",["extensions"],function(a){e(a,"extension",a.params.extensions)}),a(function(){f.unobtrusive.parse(document)}),f.unobtrusive});(function () { 9 10 11 // polyfill for matches and closest 12 if (!Element.prototype.matches) Element.prototype.matches = Element.prototype.msMatchesSelector; 13 if (!Element.prototype.closest) Element.prototype.closest = function (selector) { 14 var el = this; 15 while (el) { 16 if (el.matches(selector)) { 17 return el; 18 } 19 el = el.parentElement; 20 } 21 }; 22 23 24 25 //execute init() on document ready 26 if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { 27 listen(); 28 } else { 29 document.addEventListener("DOMContentLoaded", listen); 30 } 31 32 function listen() { 33 34 // Inline script setting umbracoFormsCollection was removed in 8.11/9.3, and replaced by config elements. 35 // So if we have them, use it, otherwise fall-back to legacy method. 36 var configElements = document.getElementsByClassName("umbraco-forms-form-config"); 37 if (configElements.length > 0) { 38 var umbracoFormsCollectionFromConfig = []; 39 for (var i = 0; i < configElements.length; i++) { 40 var configElement = configElements[i]; 41 var form = { 42 formId: configElement.dataset.id, 43 pageButtonConditions: JSON.parse(configElement.dataset.serializedPageButtonConditions), 44 fieldSetConditions: JSON.parse(configElement.dataset.serializedFieldsetConditions), 45 fieldConditions: JSON.parse(configElement.dataset.serializedFieldConditions), 46 triggerConditionsCheckOn: configElement.dataset.triggerConditionsCheckOn, 47 recordValues: JSON.parse(configElement.dataset.serializedFieldsNotDisplayed) 48 }; 49 umbracoFormsCollectionFromConfig.push(form); 50 } 51 initCollection(umbracoFormsCollectionFromConfig, true); // Set the 'jsonParsed' flag, indicating that we already have a JSON structure, which we don't have with the legacy, inline script method. 52 } else { 53 if (typeof umbracoFormsCollection === "undefined") { 54 //this will occur if this js file is loaded before the inline scripts, in which case 55 //we'll listen for the inline scripts to execute a custom event. 56 document.addEventListener("umbracoFormLoaded", init); 57 } 58 else { 59 initCollection(umbracoFormsCollection); 60 } 61 } 62 63 // Scrolling to the submitted form was also moved from an inline script in 8.11/9.3. 64 var submittedFormElement = document.getElementById("umbraco-forms-form-submitted"); 65 if (submittedFormElement) { 66 scrollToSubmittedForm(); 67 } 68 } 69 70 function initCollection(formsCollection, jsonParsed) { 71 configureUmbracoFormsValidation(); 72 73 for (var i = 0; i < formsCollection.length; i++) { 74 init({ form: formsCollection[i] }, jsonParsed); 75 } 76 } 77 78 function init(e, jsonParsed) { 79 80 var formItem = jsonParsed ? e.form : JSON.parse(decodeURI(e.form)); 81 82 var forms = document.querySelectorAll('.umbraco-forms-form'); 83 84 for (var i = 0; i < forms.length; i++) { 85 var form = forms[i]; 86 87 dependencyCheck(form); 88 89 var page = form.querySelector('.umbraco-forms-page'); 90 var conditions = new UmbracoFormsConditions(page, 91 formItem.pageButtonConditions, 92 formItem.fieldSetConditions, 93 formItem.fieldConditions, 94 formItem.triggerConditionsCheckOn && formItem.triggerConditionsCheckOn.length > 0 ? formItem.triggerConditionsCheckOn : "change", 95 formItem.recordValues); 96 conditions.watch(); 97 98 applyFormAccessibility(form); 99 100 } 101 } 102 103 function scrollToSubmittedForm() { 104 document.onreadystatechange = function () { 105 106 if (document.readyState == "complete") {
107 var validationsDivs = document.querySelectorAll(".field-validation-error, .umbraco-forms-submitmessage"); 108 var scrollY = 0; 109 for (var i = 0; i < validationsDivs.length; i++) { 110 var node = getNode(validationsDivs[i]); 111 var offset = node.getBoundingClientRect().top; 112 if (0 < offset && (offset < scrollY || scrollY === 0)) { 113 scrollY = offset; 114 } 115 } 116 117 if (scrollY > 0) { 118 window.scrollTo(0, scrollY); 119 } 120 } 121 } 122 123 function getNode(node) { 124 var runner = node; 125 while (runner.tagName !== "BODY") { 126 if (runner.classList.contains("umbraco-forms-field")) { 127 return runner; 128 } 129 130 runner = runner.parentNode; 131 } 132 133 return node; 134 } 135 } 136 137 /** Configures the jquery validation for Umbraco forms */ 138 function configureUmbracoFormsValidation() { 139 140 if (window.aspnetValidation !== undefined) { 141 // Asp-net validation setup: 142 143 var validationService = new aspnetValidation.ValidationService(); 144 145 // TODO: equivilant to this: 146 /* 147 $.validator.setDefaults({ 148 ignore: ":hidden" 149 }); 150 */ 151 152 var required = function (value, element) { 153 // Handle single and multiple checkboxes: 154 if (element.type.toLowerCase() === "checkbox" || element.type.toLowerCase() === "radio") { 155 var allCheckboxesOfThisName = element.form.querySelectorAll("input[name='" + element.name + "']"); 156 for (var i = 0; i < allCheckboxesOfThisName.length; i++) { 157 if (allCheckboxesOfThisName[i].checked === true) { 158 return true; 159 } 160 } 161 return false; 162 } 163 return Boolean(value); 164 } 165 validationService.addProvider("requiredcb", required); 166 validationService.addProvider("required", required);// this will go instead of the build-in required. 167 168 169 var umbracoforms_regex = function (value, element, params) { 170 if (!value || !params.pattern) { 171 return true; 172 } 173 174 var r = new RegExp(params.pattern); 175 return r.test(value); 176 } 177 validationService.addProvider("umbracoforms_regex", umbracoforms_regex); 178 179 var wrapProviderWithIgnorerBehaviour = function (provider) { 180 return function (value, element, params) { 181 182 // If field is hidden we ignorer the validation. 183 if (element.offsetParent === null) { 184 return true; 185 } 186 187 return provider(value, element, params); 188 } 189 } 190 191 // we can only incept with default validator if we do it after bootstrapping but before window load event triggers validationservice. 192 window.addEventListener('load', function () { 193 194 // Wrap all providers with ignorer hidden fields logic: 195 for (var key in validationService.providers) { 196 validationService.providers[key] = wrapProviderWithIgnorerBehaviour(validationService.providers[key]); 197 } 198 }); 199 200 // bootstrap validation service. 201 validationService.bootstrap(); 202
203 // Without jquery validation, the previous page submit button click isn't sent with it's name, 204 // so can't be used server-side to determine whether to go forward or back. 205 // Hence we'll use an alternate method, setting a hidden field that's also used in the check. 206 var handlePreviousClicked = function () { 207 this.form.elements["PreviousClicked"].value = "clicked"; 208 }; 209 210 // - previous buttons are indicated by a data attribute of data-umb="prev-forms-form", introduced in 8.12/9.4. 211 var previousButtonElements = document.querySelectorAll("[data-umb='prev-forms-form']"); 212 213 // - prior to that classes were used to identify them, so for compatibility with custom themes, we'll check for those too 214 // if we haven't found any via the data attribute. 215 if (previousButtonElements.length === 0) { 216 previousButtonElements = document.getElementsByClassName("prev cancel"); 217 } 218 219 for (var i = 0; i < previousButtonElements.length; i++) { 220 previousButtonElements[i].form.elements["PreviousClicked"].value = ""; 221 previousButtonElements[i].addEventListener('click', handlePreviousClicked, false); 222 } 223 224 } else if (typeof jQuery === "function" && $.validator && $.validator.unobtrusive) { 225 //Jquery validation setup 226 227 $.validator.setDefaults({ 228 ignore: ":hidden" 229 }); 230 231 $.validator.unobtrusive.adapters.addBool("requiredcb", "required"); 232 233 234 $.validator.addMethod("umbracoforms_regex", function (value, element) { 235 236 var regex = $(element).attr("data-regex"); 237 var val = $(element).val(); 238 if (val.length === 0) { 239 return true; 240 } 241 return val.match(regex); 242 }); 243 244 $.validator.unobtrusive.adapters.addBool("regex", "umbracoforms_regex"); 245 246 var submitInputs = document.querySelectorAll(".umbraco-forms-form input[type=submit]:not(.cancel)"); 247 for (let i = 0; i < submitInputs.length; i++) { 248 var input = submitInputs[i]; 249 input.addEventListener("click", function (evt) { 250 evt.preventDefault(); 251 var frm = $(this).closest("form"); 252 resetValidationMessages(frm[0]); 253 frm.validate(); 254 if (frm.valid()) { 255 frm.submit(); 256 this.setAttribute("disabled", "disabled"); 257 258 } 259 }.bind(input)); 260 } 261 } 262 263 } 264 265 /** 266 * method to determine if Umbraco Forms can run and has the required dependencies loaded 267 * @param {Form Element} formEl the element of the form 268 */ 269 function dependencyCheck(formEl) { 270 // Only perform check if the global 'Umbraco.Sys' is null/undefined. 271 // If present means we are in backoffice & that this is being rendered as a macro preview and We do not need to perform this check here. 272 // Similarly we need a check for if running in a rich text editor. 273 var isBackOffice = function () { 274 return typeof Umbraco !== "undefined" && typeof Umbraco.Sys !== "undefined"; 275 }; 276 var isBackOfficeRte = function () { 277 return document.body.id === "tinymce"; 278 }; 279 if (isBackOffice() || isBackOfficeRte()) { 280 return; 281 } 282 283 var errorElement = document.createElement("div"); 284 errorElement.className = "umbraco-forms missing-library"; 285 errorElement.style.color = "#fff"; 286 errorElement.style.backgroundColor = "#9d261d"; 287 errorElement.style.padding = "15px"; 288 errorElement.style.margin = "10px 0"; 289 var errorMessage = ""; 290 291 //Ensure umbracoForm is not null 292 if (formEl) { 293 294 //Check to see if the message for the form has been inserted already 295 var checkForExistinhgErr = formEl.getElementsByClassName('umbraco-forms missing-library'); 296 if (checkForExistinhgErr.length > 0) { 297 return; 298 } 299 300 var hasValidationFramework = false; 301 302 if (window.jQuery && $ && $.validator !== undefined) { 303 hasValidationFramework = true; 304 } else if (window.aspnetValidation !== undefined) { 305 hasValidationFramework = true; 306 } 307 308 if (hasValidationFramework === false) { 309 errorMessage = errorMessage + "Umbraco Forms requires a validation framework to run, please read documentation for posible options."; 310 } 311 312 if (errorMessage !== "") { 313 errorElement.innerHTML = errorMessage + '<br/> <a href="https://our.umbraco.org/documentation/products/umbracoforms/developer/Prepping-Frontend/" target="_blank" style="text-decoration:underline;
313 color:#fff;">See Umbraco Forms Documentation</a>'; 314 315 formEl.insertBefore(errorElement, formEl.childNodes[0]); 316 } 317 } 318 } 319 320 /** 321 * Applies form accessibility improvements. 322 * @param {Element} formEl the element of the form. 323 */ 324 function applyFormAccessibility(formEl) { 325 setFocusToFirstElementOnValidationError(formEl); 326 } 327 328 /** 329 * Monitors for validation errors and when found sets the focus to the first field with an error. 330 * @param {Element} formEl the element of the form. 331 */ 332 function setFocusToFirstElementOnValidationError(formEl) { 333 if ("MutationObserver" in window === false) { 334 return; 335 } 336 337 // To implement this, we are relying on on monitoring for validation message elements, which only fires when there are changes. 338 // So if you have two errors, and fix the first one, it wouldn't then highlight the second one on re-submitting the form. 339 // Unless we reset the validation messages on submit, so they get changed back on errors. 340 if (window.aspnetValidation !== undefined) { 341 var form = formEl.getElementsByTagName('form')[0]; 342 var handleResetValidationMessages = function (event) { 343 resetValidationMessages(form); 344 }; 345 form.addEventListener('submit', handleResetValidationMessages, false); 346 } else { 347 // For jquery.validate, we need to hook this in as part of the submit handler coded in configureUmbracoFormsValidation(); 348 } 349 350 // Watch for changes to the validation error messages in the DOM tree using a MutationObserver. 351 // See: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver 352 var observer = new MutationObserver(function (mutationRecords) { 353 for (var i = 0; i < mutationRecords.length; i++) { 354 var mutationRecord = mutationRecords[i]; 355 if (mutationRecord.target.className === 'field-validation-error') { 356 setFocusOnFormField(mutationRecord.target); 357 break; 358 } 359 } 360 }); 361 362 observer.observe(formEl, { 363 attributes: true, 364 attributeFilter: ['class'], 365 childList: false, 366 characterData: false, 367 subtree: true 368 }); 369 } 370 371 /** 372 * Resets the validation messages for a form. 373 * @param {Element} formEl the element of the form. 374 */ 375 function resetValidationMessages(formEl) { 376 var validationErrorMessageElements = formEl.getElementsByClassName('field-validation-error'); 377 for (var i = 0; i < validationErrorMessageElements.length; i++) { 378 validationErrorMessageElements[i].className = 'field-validation-valid'; 379 } 380 } 381 382 /** 383 * Sets the focus to the form field input element associated with the provided validation message element. 384 * @param {Element} validationErrorEl the element of the validation error. 385 */ 386 function setFocusOnFormField(validationErrorEl) { 387 var formFieldElement = validationErrorEl.previousElementSibling; 388 while (formFieldElement) { 389 if (formFieldElement.tagName.toLowerCase() === 'input' || 390 formFieldElement.tagName.toLowerCase() === 'textarea' || 391 formFieldElement.tagName.toLowerCase() === 'select') { 392 formFieldElement.focus(); 393 break; 394 } 395 396 if (formFieldElement.classList.contains("radiobuttonlist") || 397 formFieldElement.classList.contains("checkboxlist")) { 398 for (var i = 0; i < formFieldElement.children.length; i++) { 399 var formFieldChildElement = formFieldElement.children[i]; 400 if (formFieldChildElement.tagName.toLowerCase() === 'input') { 401 formFieldChildElement.focus(); 402 break; 403 } 404 } 405 406 break; 407 } 408 409 formFieldElement = formFieldElement.previousElementSibling; 410 } 411 } 412 413 /** 414 * Class to handle Umbraco Forms conditional statements 415 * @param {any} form a reference to the form 416 * @param {any} pageButtonConditions a reference to the page button conditions 417 * @param {any} fieldsetConditions a reference to the fieldset conditions 418 * @param {any} fieldConditions a reference to the field conditions 419 * @param {any} triggerConditionsCheckOn the client-side event on which condition checks should be triggered 420 * @param {any} values the form values 421 * @return {Object} reference to the created class 422 */ 423 function UmbracoFormsConditions(form, pageButtonConditions, fieldsetConditions, fieldConditions, triggerConditionsCheckOn, values) { 424
425 //our conditions "class" - must always be newed to work as it uses a form instance to operate on 426 //load all the information from the dom and serverside info and then the class will take care of the rest 427 428 var self = {}; 429 self.form = form; 430 self.pageButtonConditions = pageButtonConditions; 431 self.fieldsetConditions = fieldsetConditions; 432 self.fieldConditions = fieldConditions; 433 self.triggerConditionsCheckOn = triggerConditionsCheckOn; 434 self.values = values; 435 self.dataTypes = {}; 436 437 //Iterates through all the form elements found on the page to update the registered value 438 function populateFieldValues(page, formValues, dataTypes) { 439 440 var selectFields = page.querySelectorAll("select"); 441 for (let i = 0; i < selectFields.length; i++) { 442 const field = selectFields[i]; 443 formValues[field.getAttribute("id")] = field.value; 444 dataTypes[field.getAttribute("id")] = "select"; 445 } 446 447 var textareaFields = page.querySelectorAll("textarea"); 448 for (let i = 0; i < textareaFields.length; i++) { 449 const field = textareaFields[i]; 450 formValues[field.getAttribute("id")] = field.value; 451 dataTypes[field.getAttribute("id")] = "textarea"; 452 } 453 454 // clear out all saved checkbox values to we can safely append 455 var checkboxFields = page.querySelectorAll("input[type=checkbox]"); 456 for (let i = 0; i < checkboxFields.length; i++) { 457 const field = checkboxFields[i]; 458 formValues[field.getAttribute("name")] = null; 459 dataTypes[field.getAttribute("id")] = "checkbox"; 460 } 461 462 //$page.find("input").each(function () { 463 var inputFields = page.querySelectorAll("input"); 464 for (let i = 0; i < inputFields.length; i++) { 465 const field = inputFields[i]; 466 467 if (field.getAttribute('type') === "text" || 468 field.getAttribute('type') === "number" || 469 field.getAttribute('type') === "email" || 470 field.getAttribute('type') === "url" || 471 field.getAttribute('type') === "tel" || 472 field.getAttribute('type') === "date" || 473 field.getAttribute('type') === "datetime-local" || 474 field.getAttribute("type") === "hidden") { 475 formValues[field.getAttribute("id")] = field.value; 476 dataTypes[field.getAttribute("id")] = "text"; 477 } 478 479 if (field.getAttribute('type') === "radio") { 480 if (field.matches(':checked')) { 481 formValues[field.getAttribute("name")] = field.value; 482 dataTypes[field.getAttribute("id")] = "radio"; 483 } 484 } 485 486 if (field.getAttribute("type") === "checkbox") { 487 if (field.getAttribute("id") !== field.getAttribute("name")) { 488 if (field.matches(":checked")) { 489 if (formValues[field.getAttribute("name")] === null) { 490 formValues[field.getAttribute("name")] = field.value; 491 } 492 else { 493 formValues[field.getAttribute("name")] += ";;" + field.value; 494 } 495 } 496 } 497 else { 498 formValues[field.getAttribute("name")] = (field.matches(":checked") ? "true" : "false"); 499 } 500 } 501 } 502 } 503 504 /* Public api */ 505 506 self.operators = { 507 Is: function (value, expected, dataType) { 508 if ((value || "") === expected) { 509 return true; 510 } 511 if (value == null) { 512 return (expected == value); 513 } 514 515 if (dataType === "checkbox") { 516 if (expected.toUpperCase() === "TRUE" || expected.toUpperCase() === "ON") { 517 expected = "true" 518 } else if (expected.toUpperCase() === "FALSE" || expected.toUpperCase() === "OFF") { 519 expected = "false" 520 } 521 } 522 523 var values = value.split(';;'); 524 var matchingExpected = values.filter( 525 function (o) { 526 return o === expected; 527 }); 528 return matchingExpected.length > 0;
529 }, 530 IsNot: function (value, unexpected, dataType) { 531 if (value == null) { 532 return (unexpected != value); 533 } 534 var values = value.split(';;'); 535 var matchingUnexpected = values.filter( 536 function (o) { 537 return o === unexpected; 538 }); 539 540 if (dataType === "checkbox") { 541 if (unexpected.toUpperCase() === "TRUE" || unexpected.toUpperCase() === "ON") { 542 unexpected = "true" 543 } else if (unexpected.toUpperCase() === "FALSE" || unexpected.toUpperCase() === "OFF") { 544 unexpected = "false" 545 } 546 } 547 return (value || "") !== unexpected && matchingUnexpected.length === 0; 548 }, 549 GreaterThen: function (value, limit) { 550 if (isNaN(value) || isNaN(limit)) { 551 return value > limit; 552 } 553 554 return parseInt(value) > parseInt(limit); 555 }, 556 LessThen: function (value, limit) { 557 if (isNaN(value) || isNaN(limit)) { 558 return value < limit; 559 } 560 561 return parseInt(value) < parseInt(limit); 562 }, 563 StartsWith: function (value, criteria) { 564 return value && value.indexOf(criteria) === 0; 565 }, 566 EndsWith: function (value, criteria) { 567 return value && value.indexOf(criteria) === value.length - criteria.length; 568 }, 569 Contains: function (value, criteria) { 570 return value && value.indexOf(criteria) > -1; 571 } 572 }; 573 574 self.watch = function () { 575 // This is a special case for pikaday 576 // The only way around to pickup the value, for now, is to 577 // subscribe to blur events 578 var datepickerfields = self.form.querySelectorAll('.datepickerfield'); 579 for (let i = 0; i < datepickerfields.length; i++) { 580 const field = datepickerfields[i]; 581 field.addEventListener('blur', function () { 582 if (this.value === "") { 583 // Here comes the hack 584 // Force the hidden datepicker field the datepicker field 585 var id = this.getAttribute("id"); 586 var hiddenDatePickerField = id.substr(0, id.length - 2); 587 self.values[hiddenDatePickerField] = ""; 588 document.getElementById(hiddenDatePickerField).value = "";// sadly we cant use querySelector with current mark-up (would need to prefix IDs) 589 } 590 591 populateFieldValues(self.form, self.values, self.dataTypes); 592 //process the conditions 593 self.run(); 594 }.bind(field)); 595 } 596 //subscribe to change or input event as per configuration 597 var changeablefields = self.form.querySelectorAll("input, textarea, select"); 598 for (let i = 0; i < changeablefields.length; i++) { 599 const field = changeablefields[i]; 600 field.addEventListener(self.triggerConditionsCheckOn, function () { 601 populateFieldValues(self.form, self.values, self.dataTypes); 602 //process the conditions 603 self.run(); 604 }.bind(field)); 605 } 606 607 //register all values from the current fields on the page 608 populateFieldValues(self.form, self.values, self.dataTypes); 609 610 //the initial run-through of all the conditions 611 self.run(); 612 }; 613 614 self.run = function () { 615 var fsId, 616 fieldId, 617 618 /* 619 fsConditions = params.fsConditions || {}, 620 fieldConditions = params.fieldConditions || {}, 621 values = params.values || {},*/ 622 623 cachedResults = {}; 624 625 function evaluateRuleInstance(rule) { 626 var value = self.values[rule.field], 627 dataType = self.dataTypes[rule.field], 628 func = self.operators[rule.operator], 629 result = value !== null && func(value, rule.value, dataType); 630 return result; 631 } 632 633 function evaluateRule(rule) { 634 var dependencyIsVisible = true; 635 636 if (self.fieldConditions[rule.field]) { 637 dependencyIsVisible = isVisible(rule.field, self.fieldConditions[rule.field]); 638 } 639 640 if (dependencyIsVisible) { 641 return evaluateRuleInstance(rule); 642 } 643 else { 644 return false; 645 } 646 } 647 648 function evaluateCondition(id, condition) { 649 // This was once pretty. Now it needs refactoring again. :) 650 651 var any = condition.logicType === "Any", 652 all = condition.logicType === "All", 653 fieldsetVisibilities = {}, 654 hasHiddenFieldset = false, 655 success = true, 656 rule, 657 i; 658 659 // If we don't have any rules defined, we must return false (as neither 'any' nor 'all' of the conditions 660 // can be considered passing). 661 if (condition.rules.length === 0) { 662 return false; 663 } 664 665 for (i = 0; i < condition.rules.length; i++) { 666 rule = condition.rules[i]; 667 668 if (id === rule.field || id === rule.fieldsetId) { 669 throw new Error("Field or fieldset " + id + " has a condition on itself."); 670 } 671 672 if (fieldsetVisibilities[rule.fieldsetId] !== undefined) { 673 continue; 674 } 675 676 if (self.fieldsetConditions[rule.fieldsetId]) { 677 678 fieldsetVisibilities[rule.fieldsetId] = 679 isVisible(rule.fieldsetId, self.fieldsetConditions[rule.fieldsetId]); 680 681 if (!fieldsetVisibilities[rule.fieldsetId]) { 682 hasHiddenFieldset = true; 683 } 684 } 685 else { 686 fieldsetVisibilities[rule.fieldsetId] = true; 687 } 688 } 689 690 if (all && hasHiddenFieldset) { 691 return false; 692 } 693 694 for (i = 0; i < condition.rules.length; i++) { 695 rule = condition.rules[i]; 696 697 if (fieldsetVisibilities[rule.fieldsetId]) { 698 success = evaluateRule(condition.rules[i]); 699 } 700 else { 701 success = false; 702 } 703 704 if (any && success) { 705 break; 706 } 707 if (all && !success) { 708 break; 709 } 710 } 711 return success; 712 } 713 714 function evaluateConditionVisibility(id, condition) { 715 var show = condition.actionType === "Show", 716 cachedResult = cachedResults[id]; 717 718 var success; 719 if (cachedResult === undefined) { 720 cachedResults[id] = show; // set default value to avoid circular issues 721 success = (cachedResults[id] = evaluateCondition(id, condition)); 722 } else { 723 success = cachedResult; 724 } 725 726 var visible = !(success ^ show); 727 return visible; 728 } 729 730 function isVisible(id, condition) { 731 if (condition) { 732 return evaluateConditionVisibility(id, condition); 733 } 734 return true; 735 } 736 737 function handleCondition(element, id, condition) { 738 var shouldShow = isVisible(id, condition); 739 if (element) { 740 if (shouldShow) { 741 element.style.display = ""; 742 } 743 else { 744 element.style.display = "none"; 745 } 746 } 747 } 748 749 for (pageId in self.pageButtonConditions) { 750 if (Object.prototype.hasOwnProperty.call(self.pageButtonConditions, pageId)) { 751 var pageElem = document.getElementById(pageId); 752 if (pageElem) { 753 handleCondition(pageElem.querySelector("input[name='__next'], button[name='__next']"), fsId, self.pageButtonConditions[pageId], "Page"); 754 } 755 } 756 } 757 758 for (fsId in self.fieldsetConditions) { 759 if (Object.prototype.hasOwnProperty.call(self.fieldsetConditions, fsId)) { 760 handleCondition(document.getElementById(fsId), fsId, self.fieldsetConditions[fsId], "Fieldset");// sadly we cant use querySelector with current mark-up (would need to prefix IDs) 761 } 762 } 763 764 for (fieldId in self.fieldConditions) { 765 if (Object.prototype.hasOwnProperty.call(self.fieldConditions, fieldId)) { 766 if (document.getElementById(fieldId)) { 767 handleCondition(document.getElementById(fieldId).closest(".umbraco-forms-field"),// sadly we cant use querySelector with current mark-up (would need to prefix IDs) 768 fieldId, 769 self.fieldConditions[fieldId], 770 "Field"); 771 } 772 } 773 } 774 }; 775 776 return self; 777 } 778})();
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.