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

1 line
17 KiB
JavaScript
Raw Normal View History

webshims.register("form-validation",function(a,b,c,d,e,f){"use strict";function g(a){return a.name}function h(){if(!a.data(this,"wsCustomFile")){var b=Array.prototype.map,c=a(this),d=a('input[type="file"]',c),e=a(".ws-file-value",c),f=a.trim(e.html())||"&#160;",h=function(){var a=d.prop("files")||[],c=b.call(a,g).join(", ")||d.val();c?e.text(c):e.html(f)};a.data(this,"wsCustomFile",{showSelected:h}),a("button:not(.ws-capture-button)",c).attr("tabindex","-1"),d.on("change.webshim",h).each(h).jProp("form").on("reset",function(){setTimeout(h)}),n&&a('<div class="ws-coverfile" />').insertAfter(d).on("click.webshim",function(a){a.stopImmediatePropagation(),d.trigger("click")})}}var i="webkitURL"in c,j=b.support,k=j.formvalidation&&!b.bugs.bustedValidity,l=i&&k,m=navigator.userAgent,n=-1!=m.indexOf("MSIE"),o=l&&parseFloat((m.match(/Safari\/([\d\.]+)/)||["","999999"])[1],10),p=f.iVal,q=p.errorClass||(p.errorClass="user-error"),r=p.successClass||(p.successClass="user-success"),s="."+r+", ."+q,t=p.errorWrapperClass||(p.errorWrapperClass="ws-invalid"),u=p.successWrapperClass||(p.successWrapperClass="ws-success"),v=p.errorBoxClass||(p.errorBoxClass="ws-errorbox"),w=p.errorMessageClass||(p.errorMessageClass="ws-errormessage"),x=p.errorBoxWrapper||(p.errorBoxWrapper="div"),y=p.errorMessageWrapper||(p.errorMessageWrapper="p"),z={checkbox:1,radio:1},A=b.loader,B=A.addModule,C=a([]),D=function(){return!a.prop(this,"form")},E=b.modules,F=E["form-core"].getGroupElements||function(b){b=a(b);var c,e,f=C;return"radio"==b[0].type&&(e=b.prop("form"),c=b[0].name,f=c?e?a(e).jProp(c):a(d.getElementsByName(c)).filter(D):b,f=f.filter('[type="radio"]')),f},G=function(b,c){var d;return a.each(b,function(b,e){return e?(d=b+a.prop(c,"validationMessage"),!1):void 0}),d},H=function(a){var b;try{b=d.activeElement.name===a}catch(c){}return b},I={radio:1,checkbox:1,"select-one":1,"select-multiple":1,file:1,date:1,month:1,week:1,text:1,password:1,search:1,email:1,tel:1,url:1},J={time:1,date:1,month:1,datetime:1,week:1,"datetime-local":1},K={refreshvalidityui:1,updatevalidation:1},L="."+p.errorClass+", ."+p.successClass,M=function(c){if(p.sel){var d,e,f,g;if(c.target&&(d=a(c.target).getNativeElement()[0],f=a(d).getShadowElement(),"submit"!=d.type&&a.prop(d,"willValidate")&&("change"!=c.type||!(g=f.prop("type"))||I[g]))){e=a.data(d,"webshimsswitchvalidityclass");var h=function(){if(g||(g=f.prop("type")),!(l&&("change"==c.type||537.36>o)&&J[g]&&a.find.matchesSelector(c.target,":focus")||"focusout"==c.type&&"radio"==d.type&&H(d.name))){if("async"==b.refreshCustomValidityRules(d))return void a(d).one("updatevalidation.webshims",M);var e,h,i,j,k,m=a.prop(d,"validity");m.valid?f.hasClass(r)||(e=r,h=q,j="changedvaliditystate",i="changedvalid",z[d.type]&&d.checked&&F(d).not(d).removeClass(h).addClass(e).removeAttr("aria-invalid"),f.removeAttr("aria-invalid"),a.removeData(d,"webshimsinvalidcause")):(k=G(m,d),a.data(d,"webshimsinvalidcause")!=k&&(a.data(d,"webshimsinvalidcause",k),j="changedvaliditystate"),f.hasClass(q)||(e=q,h=r,z[d.type]&&!d.checked&&F(d).not(d).removeClass(h).addClass(e).attr("aria-invalid","true"),f.attr("aria-invalid","true"),i="changedinvalid")),e&&(f.addClass(e).removeClass(h),setTimeout(function(){a(d).trigger(i)})),j&&setTimeout(function(){a(d).trigger(j)}),a.removeData(d,"webshimsswitchvalidityclass")}};f.triggerHandler("wsallowinstantvalidation",[c])!==!1&&(e&&clearTimeout(e),K[c.type]?("refreshvalidityui"==c.type&&b.error("refreshvalidityui was renamed to updatevalidation"),h()):a.data(d,"webshimsswitchvalidityclass",setTimeout(h)))}}},N=function(){b.errorbox.reset(this)};"validityUIEvents"in f&&(b.error("validityUIEvents was renamed to iVal.events"),p.events=f.validityUIEvents),p.events="events"in p?p.events||"":"focusout change",p.events&&(p.events+=" "),p.fieldWrapper||(p.fieldWrapper=":not(span):not(label):not(em):not(strong):not(p):not(.ws-custom-file)"),E["form-core"].getGroupElements||(E["form-core"].getGroupElements=F),a(d.body||"html").on(p.events+"refreshvalidityui updatevalidation.webshims invalid",M).on("refreshvalidationui.web