(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("jquery")); else if(typeof define === 'function' && define.amd) define(["jquery"], factory); else { var a = typeof exports === 'object' ? factory(require("jquery")) : factory(root["jQuery"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(self, function(__WEBPACK_EXTERNAL_MODULE_jquery__) { return /******/ (function() { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./js/foundation.abide.js": /*!********************************!*\ !*** ./js/foundation.abide.js ***! \********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Abide: function() { return /* binding */ Abide; } /* harmony export */ }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.plugin */ "./js/foundation.core.plugin.js"); /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.utils */ "./js/foundation.core.utils.js"); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(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 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /** * Abide module. * @module foundation.abide */ var Abide = /*#__PURE__*/function (_Plugin) { function Abide() { _classCallCheck(this, Abide); return _callSuper(this, Abide, arguments); } _inherits(Abide, _Plugin); return _createClass(Abide, [{ key: "_setup", value: /** * Creates a new instance of Abide. * @class * @name Abide * @fires Abide#init * @param {Object} element - jQuery object to add the trigger to. * @param {Object} options - Overrides to the default plugin settings. */ function _setup(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; this.$element = element; this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default().extend(true, {}, Abide.defaults, this.$element.data(), options); this.isEnabled = true; this.formnovalidate = null; this.className = 'Abide'; // ie9 back compat this._init(); } /** * Initializes the Abide plugin and calls functions to get Abide functioning on load. * @private */ }, { key: "_init", value: function _init() { var _this2 = this; this.$inputs = jquery__WEBPACK_IMPORTED_MODULE_0___default().merge( // Consider as input to validate: this.$element.find('input').not('[type="submit"]'), // * all input fields expect submit this.$element.find('textarea, select') // * all textareas and select fields ); this.$submits = this.$element.find('[type="submit"]'); var $globalErrors = this.$element.find('[data-abide-error]'); // Add a11y attributes to all fields if (this.options.a11yAttributes) { this.$inputs.each(function (i, input) { return _this2.addA11yAttributes(jquery__WEBPACK_IMPORTED_MODULE_0___default()(input)); }); $globalErrors.each(function (i, error) { return _this2.addGlobalErrorA11yAttributes(jquery__WEBPACK_IMPORTED_MODULE_0___default()(error)); }); } this._events(); } /** * Initializes events for Abide. * @private */ }, { key: "_events", value: function _events() { var _this3 = this; this.$element.off('.abide').on('reset.zf.abide', function () { _this3.resetForm(); }).on('submit.zf.abide', function () { return _this3.validateForm(); }); this.$submits.off('click.zf.abide keydown.zf.abide').on('click.zf.abide keydown.zf.abide', function (e) { if (!e.key || e.key === ' ' || e.key === 'Enter') { e.preventDefault(); _this3.formnovalidate = e.target.getAttribute('formnovalidate') !== null; _this3.$element.submit(); } }); if (this.options.validateOn === 'fieldChange') { this.$inputs.off('change.zf.abide').on('change.zf.abide', function (e) { _this3.validateInput(jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target)); }); } if (this.options.liveValidate) { this.$inputs.off('input.zf.abide').on('input.zf.abide', function (e) { _this3.validateInput(jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target)); }); } if (this.options.validateOnBlur) { this.$inputs.off('blur.zf.abide').on('blur.zf.abide', function (e) { _this3.validateInput(jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target)); }); } } /** * Calls necessary functions to update Abide upon DOM change * @private */ }, { key: "_reflow", value: function _reflow() { this._init(); } /** * Checks whether the submitted form should be validated or not, consodering formnovalidate and isEnabled * @returns {Boolean} * @private */ }, { key: "_validationIsDisabled", value: function _validationIsDisabled() { if (this.isEnabled === false) { // whole validation disabled return true; } else if (typeof this.formnovalidate === 'boolean') { // triggered by $submit return this.formnovalidate; } // triggered by Enter in non-submit input return this.$submits.length ? this.$submits[0].getAttribute('formnovalidate') !== null : false; } /** * Enables the whole validation */ }, { key: "enableValidation", value: function enableValidation() { this.isEnabled = true; } /** * Disables the whole validation */ }, { key: "disableValidation", value: function disableValidation() { this.isEnabled = false; } /** * Checks whether or not a form element has the required attribute and if it's checked or not * @param {Object} element - jQuery object to check for required attribute * @returns {Boolean} Boolean value depends on whether or not attribute is checked or empty */ }, { key: "requiredCheck", value: function requiredCheck($el) { if (!$el.attr('required')) return true; var isGood = true; switch ($el[0].type) { case 'checkbox': isGood = $el[0].checked; break; case 'select': case 'select-one': case 'select-multiple': var opt = $el.find('option:selected'); if (!opt.length || !opt.val()) isGood = false; break; default: if (!$el.val() || !$el.val().length) isGood = false; } return isGood; } /** * Get: * - Based on $el, the first element(s) corresponding to `formErrorSelector` in this order: * 1. The element's direct sibling('s). * 2. The element's parent's children. * - Element(s) with the attribute `[data-form-error-for]` set with the element's id. * * This allows for multiple form errors per input, though if none are found, no form errors will be shown. * * @param {Object} $el - jQuery object to use as reference to find the form error selector. * @param {String[]} [failedValidators] - List of failed validators. * @returns {Object} jQuery object with the selector. */ }, { key: "findFormError", value: function findFormError($el, failedValidators) { var _this4 = this; var id = $el.length ? $el[0].id : ''; var $error = $el.siblings(this.options.formErrorSelector); if (!$error.length) { $error = $el.parent().find(this.options.formErrorSelector); } if (id) { $error = $error.add(this.$element.find("[data-form-error-for=\"".concat(id, "\"]"))); } if (!!failedValidators) { $error = $error.not('[data-form-error-on]'); failedValidators.forEach(function (v) { $error = $error.add($el.siblings("[data-form-error-on=\"".concat(v, "\"]"))); $error = $error.add(_this4.$element.find("[data-form-error-for=\"".concat(id, "\"][data-form-error-on=\"").concat(v, "\"]"))); }); } return $error; } /** * Get the first element in this order: * 2. The