agenda-libre-ruby/public/webshims/1.15.8/shims/form-validators.js

1 line
8.1 KiB
JavaScript
Raw Normal View History

webshims.register("form-validators",function(a,b,c,d,e,f){"use strict";var g;b.ready("form-validation",function(){g="."+f.iVal.errorClass+", ."+f.iVal.successClass}),function(){var c,e,f={},h=!1,i="input, select, textarea, fieldset[data-dependent-validation]",j=function(a){"refreshCustomValidityRules"==a.type&&b.error("refreshCustomValidityRules event was renamed to updatecustomvalidity"),b.refreshCustomValidityRules(a.target)},k=function(){function b(b){var c,d,e={},f=function(){var b,d;for(var f in e)b=e[f].elem,b!=c&&e[f].val!=(d=b.value)&&(e[f].val=d,g&&a.find.matchesSelector(b,g)?a(b).trigger("updatevalidation.webshims"):m(b))};return a(b).on("autocomplete change",function(a){clearTimeout(d),c=a.target,d=setTimeout(f,9)}),e}function c(c,d,e){var f=a.data(c,"autocompleteElements")||a.data(c,"autocompleteElements",b(c));f[e]={elem:d,val:d.value}}function d(b,c){var d=a.data(b,"autocompleteElements");d&&d[c]&&delete d[c]}return{add:function(b){var d,e;(d=b.id)&&("password"==b.type||(e=b.autocomplete)&&"off"!=e)&&setTimeout(function(){var e=a.prop(b,"form");e&&c(e,b,d)},9)},remove:function(b){var c;(c=b.id)&&setTimeout(function(){var e=a.prop(b,"form");e&&d(e,c)},9)}}}(),l=function(){return!l.types[this.type]};l.types={hidden:1,image:1,button:1,reset:1,submit:1},b.customErrorMessages={},b.addCustomValidityRule=function(){var c,e=function(){a(d.querySelectorAll(i)).filter(l).each(function(){m(this)})};return function(a,d,g){f[a]=d,b.customErrorMessages[a]||(b.customErrorMessages[a]=[],b.customErrorMessages[a][""]=g||a),h&&(clearTimeout(c),c=setTimeout(e))}}(),b.refreshCustomValidityRules=function(d){if(e){var g,h,i=a(d).data(),j="",l=i&&i.customMismatchedRule,m=i&&a.prop(d,"validity")||{valid:1};return i&&(l||m.valid)&&(g=a(d).val(),h=function(e,f){c=!0,e?(i.customMismatchedRule=f,"string"!=typeof e&&(e=b.getContentValidationMessage(d,!1,f),e&&"object"==typeof e&&(e=e[f]),e&&"string"==typeof e||(e=b.customErrorMessages[f][b.activeLang()]||b.customErrorMessages[f][""]||e.customError||e.defaultMessage||"")),b.replaceValidationplaceholder&&(e=b.replaceValidationplaceholder(d,e,f)),k.add(d)):(e="",i.customMismatchedRule="",k.remove(d)),a(d).setCustomValidity(e),c=!1},a.each(f,function(a,b){return j=b(d,g,i,h)||"",l=a,j?!1:void 0}),i&&i.dependentValidation&&!i.dependentValidation._init&&!i.dependentValidation.masterElement&&f.dependent(d,g,i,a.noop),"async"==j||!j&&m.valid||h(j,l)),j}};var m=b.refreshCustomValidityRules;a("body").on("click",function(b){if("submit"==b.target.type&&!b.isDefaultPrevented()){var c,e,f,g;try{c=d.activeElement}catch(h){}if(!c||c==b.target)return;g=a(b.target).jProp("form").prop("elements")||[],c&&"form"in c&&a.prop(c,"willValidate")&&a(c).trigger("updatevalidation.webshims");for(e=0,f=g.length;f>e;e++)a.data(g[e],"customMismatchedRule")&&m(g[e])}}),b.ready("forms form-validation",function(){a.propHooks.setCustomValidity={get:function(b){return c||a.data(b,"customMismatchedRule",""),null}},setTimeout(function(){b.addReady(function(b,c){e=!0,a(b.querySelectorAll(i)).add(c.filter(i)).filter(l).each(function(){m(this)}),h=!0}),a(d).on("refreshCustomValidityRules updatecustomvalidity",j)},29)})}(),function(){var c=b.cfg.forms,h=b.addCustomValidityRule,i=function(a,b){return d.getElementById(b)||d.getElementsByName(b)[0]};h("partialPattern",function(a,b,c){return c=c.partialPattern,b&&c?!new RegExp("("+c+")","i").test(b):void 0},"This format is not allowed here."),a("<input />").prop("minLength")!==e&&"tooShort"in(a("<input />").prop("validity")||{})||h("tooShort",function(a,c){var d;if(c&&c!=a.defaultValue&&(d=a.getAttribute("minlength")))return d=parseInt(d,10),d>0&&d>c.length?(b.validityMessages.__active||{}).tooShort||!0:""},"Entered value is too short."),h("grouprequired",function(b,c,e){var f,g;if("grouprequired"in e&&"checkbox"===b.type&&(g=b.name))return e.grouprequired.checkboxes||(e.grouprequired={},e.grouprequired.checkboxes=a((f=a.prop(b,"form"))&&f[g]||d.getElementsByName(g)).filter('[type="checkbox"]'),e.grouprequired.checkboxes.off("click.groupRequired").on("click.groupRequired",function(