agenda-libre-ruby/public/webshims/1.15.10/shims/form-shim-extend.js

1 line
12 KiB
JavaScript
Raw Normal View History

webshims.register("form-shim-extend",function(a,b,c,d,e,f){"use strict";b.inputTypes=b.inputTypes||{};var g=b.cfg.forms,h=b.bugs,i=/\s*,\s*/g,j=b.inputTypes,k={radio:1,checkbox:1},l=function(){var a=this,c=(a.getAttribute("type")||"").toLowerCase();return b.inputTypes[c]?c:a.type},m=function(a,b){"type"in a||(a.type=l.call(b))};!function(){if("querySelector"in d){try{h.findRequired=!a('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /></form>')[0].querySelector("select:required")}catch(b){h.findRequired=!1}(h.bustedValidity||h.findRequired)&&!function(){var b=a.find,c=a.find.matchesSelector,d=/(\:valid|\:invalid|\:optional|\:required)(?=[\s\[\~\.\+\>\:\#*]|$)/gi,e=function(a){return a+"-element"};a.find=function(){var a=Array.prototype.slice,c=function(c){var f=arguments;return f=a.call(f,1,f.length),f.unshift(c.replace(d,e)),b.apply(this,f)};for(var f in b)b.hasOwnProperty(f)&&(c[f]=b[f]);return c}(),a.find.matchesSelector=function(a,b){return b=b.replace(d,e),c.call(this,a,b)}}()}}(),b.addInputType=function(a,b){j[a]=b};var n={customError:!1,typeMismatch:!1,badInput:!1,rangeUnderflow:!1,rangeOverflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,patternMismatch:!1,valueMissing:!1,valid:!0},o=function(b){if("select-one"==b.type&&b.size<2){var c=a("> option:first-child",b);return!!c.prop("selected")}return!1},p=a([]),q=function(b){b=a(b);var c,e,f=p;return"radio"==b[0].type&&(c=b[0].name,c?(e=b.prop("form"),f=a(d.getElementsByName(c)).filter(function(){return"radio"==this.type&&a.prop(this,"form")==e&&this.name==c})):f=b),f},r={url:1,email:1,text:1,search:1,tel:1,password:1},s=a.extend({textarea:1},r),t={valueMissing:function(a,b,c){if(!a.prop("required"))return!1;var d=!1;return m(c,a[0]),d="select"==c.nodeName?!b&&(a[0].selectedIndex<0||o(a[0])):k[c.type]?"checkbox"==c.type?!a.is(":checked"):!q(a).filter(":checked")[0]:!b},patternMismatch:function(a,c,d){var e,f=!1;if(""===c||"select"==d.nodeName)return f;if(m(d,a[0]),!r[d.type])return f;var g=a.attr("pattern");if(!g)return f;try{g=new RegExp("^(?:"+g+")$")}catch(h){b.error('invalid pattern value: "'+g+'" | '+h),g=f}if(!g)return f;for(c="email"==d.type&&a.prop("multiple")?c.split(i):[c],e=0;e<c.length;e++)if(!g.test(c[e])){f=!0;break}return f}};a.each({tooShort:["minLength",-1],tooLong:["maxLength",1]},function(a,b){t[a]=function(a,c,d){if(!c||"select"==d.nodeName||a.prop("defaultValue")==c)return!1;if(m(d,a[0]),!s[d.type])return!1;var e=a.prop(b[0]);return e>0&&e*b[1]<c.length*b[1]}}),a.each({typeMismatch:"mismatch",badInput:"bad"},function(a,b){t[a]=function(c,d,e){if(""===d||"select"==e.nodeName)return!1;var f=!1;return m(e,c[0]),j[e.type]&&j[e.type][b]?f=j[e.type][b](d,c):"validity"in c[0]&&"name"in c[0].validity&&(f=c[0].validity[a]||!1),f}}),b.modules["form-core"].getGroupElements=q,b.addValidityRule=function(a,b){t[a]=b},a.event.special.invalid={add:function(){a.event.special.invalid.setup.call(this.form||this)},setup:function(){var c=this.form||this;return a.data(c,"invalidEventShim")?void(c=null):(a(c).data("invalidEventShim",!0).on("submit",a.event.special.invalid.handler),b.moveToFirstEvent(c,"submit"),b.bugs.bustedValidity&&a.nodeName(c,"form")&&!function(){var a=c.getAttribute("novalidate");c.setAttribute("novalidate","novalidate"),b.data(c,"bustedNoValidate",null==a?null:a)}(),void(c=null))},teardown:a.noop,handler:function(b){if("submit"==b.type&&!b.testedValidity&&b.originalEvent&&a.nodeName(b.target,"form")&&!a.prop(b.target,"noValidate")){b.testedValidity=!0;var c=!a(b.target).callProp("reportValidity");return c?(b.stopImmediatePropagation(),f.noFormInvalid||a(b.target).trigger("invalid"),!1):void 0}}},a.event.special.submit=a.event.special.submit||{setup:function(){return!1}};var u=a.event.special.submit.setup;a.extend(a.event.special.submit,{setup:function(){return a.nodeName(this,"form")?a(this).on("invalid",a.noop):a("form",this).on("invalid",a.noop),u.apply(this,arguments)}}),b.ready("form-shim-extend2 WINDOWLOAD",function(){a(c).on("invalid",a.noop)}),b.addInputType("email",{mismatch:function(){var a