biofriction-wp-theme/node_modules/foundation-sites/dist/js/plugins/foundation.abide.min.js

3 lines
12 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.core.plugin","./foundation.core.utils","jquery"],e):"object"==typeof exports?exports["foundation.abide"]=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("jquery")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.abide"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery))}(window,function(r,i,n,a){return function(r){var i={};function n(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,n),e.l=!0,e.exports}return n.m=r,n.c=i,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}({"./foundation.core":function(t,e){t.exports=r},"./foundation.core.plugin":function(t,e){t.exports=i},"./foundation.core.utils":function(t,e){t.exports=n},"./js/entries/plugins/foundation.abide.js":function(t,e,r){"use strict";r.r(e);var i=r("./foundation.core");r.d(e,"Foundation",function(){return i.Foundation});var n=r("./js/foundation.abide.js");r.d(e,"Abide",function(){return n.Abide}),i.Foundation.plugin(n.Abide,"Abide")},"./js/foundation.abide.js":function(t,e,r){"use strict";r.r(e),r.d(e,"Abide",function(){return c});var i=r("jquery"),d=r.n(i),a=r("./foundation.core.plugin"),o=r("./foundation.core.utils");function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){function r(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),l(this,u(r).apply(this,arguments))}var e,i,n;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(r,a["Plugin"]),e=r,(i=[{key:"_setup",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this.$element=t,this.options=d.a.extend(!0,{},r.defaults,this.$element.data(),e),this.className="Abide",this._init()}},{key:"_init",value:function(){var r=this;this.$inputs=d.a.merge(this.$element.find("input").not("[type=submit]"),this.$element.find("textarea, select"));var t=this.$element.find("[data-abide-error]");this.options.a11yAttributes&&(this.$inputs.each(function(t,e){return r.addA11yAttributes(d()(e))}),t.each(function(t,e){return r.addGlobalErrorA11yAttributes(d()(e))})),this._events()}},{key:"_events",value:function(){var e=this;this.$element.off(".abide").on("reset.zf.abide",function(){e.resetForm()}).on("submit.zf.abide",function(){return e.validateForm()}),"fieldChange"===this.options.validateOn&&this.$inputs.off("change.zf.abide").on("change.zf.abide",function(t){e.validateInput(d()(t.target))}),this.options.liveValidate&&this.$inputs.off("input.zf.abide").on("input.zf.abide",function(t){e.validateInput(d()(t.target))}),this.options.validateOnBlur&&this.$inputs.off("blur.zf.abide").on("blur.zf.abide",function(t){e.validateInput(d()(t.target))})}},{key:"_reflow",value:function(){this._init()}},{key:"requiredCheck",value:function(t){if(!t.attr("required"))return!0;var e=!0;switch(t[0].type){case"checkbox":e=t[0].checked;break;case"select":case"select-one":case"select-multiple":var r=t.find("option:selected");r.length&&r.val()||(e=!1);break;default:t.val()&&t.val().length||(e=!1)}return e}},{key:"findFormError",value:function(t){var e=t[0].id,r=t.siblings(this.options.formErrorSelector);return r.length||(r=t.parent().find(this.options.formErrorSelector)),e&&(r=r.add(this.$element.find('[data-form-error-for="'.concat(e,'"]')))),r}},{key:"findLabel",value:function(t){var e=t[0].id,r=this.$element.find('label[for="'.concat(e,'"]'));return r.length?r:t.closest("label")}},{key:"findRadioLabels",value:function(t){var n=this,e=t.map(function(t,e){var r=e.id,i=n.$element.find('label[for="'.concat(r,'"]'));return i.length||(i=d()(e).closest("label")),i[0]});return d()(e)}},{key:"addErrorClasses",value:function(t){var e=this.findLabel(t),r=this.findFormError(t);e.length&&e.addClass(this.options.labelErrorClass),r.length&&r.addClass(this.options.formErrorClass),t.addClass(this.options.inputErrorClass).attr({"data-invalid":"","aria-invalid":!0})}},{key:"addA11yAttributes",value:function(t){var e=this.findFormError(t),r=e.filter("label"),i=e.first();if(e.length){if(void 0===t.attr("aria-describedby")){var n=i.attr("id");void 0===n&&(n=Object(o.GetYoDigits)(6,"abide-error"),i.attr("id",n)),t.attr("aria-describedby",n)}if(r.filter("[for]").length<r.length){var a=t.attr("id");void 0===a&&(a=Object(o.GetYoDigits)(6,"abide-input"),t.attr("id",a)),r.each(function(t,e){var r=d()(e);void 0===r.attr("for")&&r.attr("for",a)})}e.each(function(t,e){var r=d()(e);void 0===r.attr("role")&&r.attr("role","alert")}).end()}}},{key:"addGlobalErrorA11yAttributes",value:function(t){void 0===t.attr("aria-live")&&t.attr("aria-live",this.options.a11yErrorLevel)}},{key:"removeRadioErrorClasses",value:function(t){var e=this.$element.find(':radio[name="'.concat(t,'"]')),r=this.findRadioLabels(e),i=this.findFormError(e);r.length&&r.removeClass(this.options.labelErrorClass),i.length&&i.removeClass(this.options.formErrorClass),e.removeClass(this.options.inputErrorClass).attr({"data-invalid":null,"aria-invalid":null})}},{key:"removeErrorClasses",value:function(t){if("radio"==t[0].type)return this.removeRadioErrorClasses(t.attr("name"));var e=this.findLabel(t),r=this.findFormError(t);e.length&&e.removeClass(this.options.labelErrorClass),r.length&&r.removeClass(this.options.formErrorClass),t.removeClass(this.options.inputErrorClass).attr({"data-invalid":null,"aria-invalid":null})}},{key:"validateInput",value:function(t){var e=this.requiredCheck(t),r=!1,i=!0,n=t.attr("data-validator"),a=!0;if(t.is("[data-abide-ignore]")||t.is('[type="hidden"]')||t.is("[disabled]"))return!0;switch(t[0].type){case"radio":r=this.validateRadio(t.attr("name"));break;case"checkbox":r=e;break;case"select":case"select-one":case"select-multiple":r=e;break;default:r=this.validateText(t)}n&&(i=this.matchValidation(t,n,t.attr("required"))),t.attr("data-equalto")&&(a=this.options.validators.equalTo(t));var o=-1===[e,r,i,a].indexOf(!1),s=(o?"valid":"invalid")+".zf.abide";if(o){var l=this.$element.find('[data-equalto="'.concat(t.attr("id"),'"]'));if(l.length){var u=this;l.each(function(){d()(this).val()&&u.validateInput(d()(this))})}}return this[o?"removeErrorClasses":"addErrorClasses"](t),t.trigger(s,[t]),o}},{key:"validateForm",value:function(){var i=this,t=[],e=this;this.$inputs.each(function(){t.push(e.validateInput(d()(this)))});var n=-1===t.indexOf(!1);return this.$element.find("[data-abide-error]").each(function(t,e){var r=d()(e);i.options.a11yAttributes&&i.addGlobalErrorA11yAttributes(r),r.css("display",n?"none":"block")}),this.$element.trigger((n?"formvalid":"forminvalid")+".zf.abide",[this.$element]),n}},{key:"validateText",value:function(t,e){e=e||t.attr("pattern")||t.attr("type");var r=t.val(),i=!1;return r.length?i=this.options.patterns.hasOwnProperty(e)?this.options.patterns[e].test(r):e===t.attr("type")||new RegExp(e).test(r):t.prop("required")||(i=!0),i}},{key:"validateRadio",value:function(t){var e=this.$element.find(':radio[name="'.concat(t,'"]')),r=!1,i=!1;return e.each(function(t,e){d()(e).attr("required")&&(i=!0)}),i||(r=!0),r||e.each(function(t,e){d()(e).prop("checked")&&(r=!0)}),r}},{key:"matchValidation",value:function(e,t,r){var i=this;return r=!!r,-1===t.split(" ").map(function(t){return i.options.validators[t](e,r,e.parent())}).indexOf(!1)}},{key:"resetForm",value:function(){var t=this.$element,e=this.options;d()(".".concat(e.labelErrorClass),t).not("small").removeClass(e.labelErrorClass),d()(".".concat(e.inputErrorClass),t).not("small").removeClass(e.inputErrorClass),d()("".concat(e.formErrorSelector,".").concat(e.formErrorClass)).removeClass(e.formErrorClass),t.find("[data-abide-error]").css("display","none"),d()(":input",t).not(":button, :submit, :reset, :hidden, :radio, :checkbox, [data-abide-ignore]").val("").attr({"data-invalid":null,"aria-invalid":null}),d()(":input:radio",t).not("[data-abide-ignore]").prop("checked",!1).attr({"data-invalid":null,"aria-invalid":null}),d()(":input:checkbox",t).not("[data-abide-ignore]").prop("checked",!1).attr({"data-invalid":null,"aria-invalid":null}),t.trigger("formreset.zf.abide",[t])}},{key:"_destroy",value:function(){var t=this;this.$element.off(".abide").find("[data-abide-error]").css("display","none"),this.$inputs.off(".abide").each(function(){t.removeErrorClasses(d()(this))})}}])&&s(e.prototype,i),n&&s(e,n),r}();c.defaults={validateOn:"fieldChange",labelErrorClass:"is-invalid-label",inputErrorClass:"is-invalid-input",formErrorSelector:".form-error",formErrorClass:"is-visible",a11yAttributes:!0,a11yErrorLevel:"assertive",liveValidate:!1,validateOnBlur:!1,patterns:{alpha:/^[a-zA-Z]+$/,alpha_numeric:/^[a-zA-Z0-9]+$/,integer:/^[-+]?\d+$/,number:/^[-+]?\d*(?:[\.\,]\d+)?$/,card:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(?:222[1-9]|2[3-6][0-9]{2}|27[0-1][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,cvv:/^([0-9]){3,4}$/,email:/^[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])?)+$/,url:/^((?:(https?|ftps?|file|ssh|sftp):\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))$/,domain:/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,datetime:/^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,date:/(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,time:/^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,dateISO:/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,month_day_year:/^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,day_month_year:/^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,color:/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,website:{test:function(t){return c.defaults.patterns.domain.test(t)||c.defaults.patterns.url.test(t)}}},validators:{equalTo:function(t,e,r){return d()("#".concat(t.attr("data-equalto"))).val()===t.val()}}}},0:function(t,e,r){t.exports=r("./js/entries/plugins/foundation.abide.js")},jquery:function(t,e){t.exports=a}})});
//# sourceMappingURL=foundation.abide.min.js.map