Skip to content

Commit e2dccfc

Browse files
committed
Update build files
1 parent a66f69d commit e2dccfc

File tree

2 files changed

+105
-196
lines changed

2 files changed

+105
-196
lines changed

dist/index.js

Lines changed: 104 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,214 +1,123 @@
1-
(function webpackUniversalModuleDefinition(root, factory) {
2-
if(typeof exports === 'object' && typeof module === 'object')
3-
module.exports = factory();
4-
else if(typeof define === 'function' && define.amd)
5-
define([], factory);
6-
else if(typeof exports === 'object')
7-
exports["html5formValidation"] = factory();
8-
else
9-
root["html5formValidation"] = factory();
10-
})(window, function() {
11-
return /******/ (function(modules) { // webpackBootstrap
12-
/******/ // The module cache
13-
/******/ var installedModules = {};
14-
/******/
15-
/******/ // The require function
16-
/******/ function __webpack_require__(moduleId) {
17-
/******/
18-
/******/ // Check if module is in cache
19-
/******/ if(installedModules[moduleId]) {
20-
/******/ return installedModules[moduleId].exports;
21-
/******/ }
22-
/******/ // Create a new module (and put it into the cache)
23-
/******/ var module = installedModules[moduleId] = {
24-
/******/ i: moduleId,
25-
/******/ l: false,
26-
/******/ exports: {}
27-
/******/ };
28-
/******/
29-
/******/ // Execute the module function
30-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31-
/******/
32-
/******/ // Flag the module as loaded
33-
/******/ module.l = true;
34-
/******/
35-
/******/ // Return the exports of the module
36-
/******/ return module.exports;
37-
/******/ }
38-
/******/
39-
/******/
40-
/******/ // expose the modules object (__webpack_modules__)
41-
/******/ __webpack_require__.m = modules;
42-
/******/
43-
/******/ // expose the module cache
44-
/******/ __webpack_require__.c = installedModules;
45-
/******/
46-
/******/ // define getter function for harmony exports
47-
/******/ __webpack_require__.d = function(exports, name, getter) {
48-
/******/ if(!__webpack_require__.o(exports, name)) {
49-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50-
/******/ }
51-
/******/ };
52-
/******/
53-
/******/ // define __esModule on exports
54-
/******/ __webpack_require__.r = function(exports) {
55-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57-
/******/ }
58-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
59-
/******/ };
60-
/******/
61-
/******/ // create a fake namespace object
62-
/******/ // mode & 1: value is a module id, require it
63-
/******/ // mode & 2: merge all properties of value into the ns
64-
/******/ // mode & 4: return value when already ns object
65-
/******/ // mode & 8|1: behave like require
66-
/******/ __webpack_require__.t = function(value, mode) {
67-
/******/ if(mode & 1) value = __webpack_require__(value);
68-
/******/ if(mode & 8) return value;
69-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70-
/******/ var ns = Object.create(null);
71-
/******/ __webpack_require__.r(ns);
72-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74-
/******/ return ns;
75-
/******/ };
76-
/******/
77-
/******/ // getDefaultExport function for compatibility with non-harmony modules
78-
/******/ __webpack_require__.n = function(module) {
79-
/******/ var getter = module && module.__esModule ?
80-
/******/ function getDefault() { return module['default']; } :
81-
/******/ function getModuleExports() { return module; };
82-
/******/ __webpack_require__.d(getter, 'a', getter);
83-
/******/ return getter;
84-
/******/ };
85-
/******/
86-
/******/ // Object.prototype.hasOwnProperty.call
87-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88-
/******/
89-
/******/ // __webpack_public_path__
90-
/******/ __webpack_require__.p = "";
91-
/******/
92-
/******/
93-
/******/ // Load entry module and return exports
94-
/******/ return __webpack_require__(__webpack_require__.s = 0);
95-
/******/ })
96-
/************************************************************************/
97-
/******/ ([
98-
/* 0 */
99-
/***/ (function(module, exports, __webpack_require__) {
100-
101-
"use strict";
102-
103-
104-
Object.defineProperty(exports, "__esModule", {
105-
value: true
106-
});
107-
exports.default = void 0;
108-
109-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
110-
111-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
112-
113-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
114-
115-
var html5formValidation =
116-
/*#__PURE__*/
117-
function () {
118-
function html5formValidation() {
119-
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.querySelector('form');
120-
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
121-
122-
_classCallCheck(this, html5formValidation);
123-
124-
this.settings = Object.assign({}, {
125-
errorElement: 'error',
126-
invalidClass: 'invalid',
127-
submitHandler: null,
128-
validateOnInput: true
129-
}, settings);
130-
this.form = element;
131-
this.errorDiv = "<div class=\"".concat(this.settings.errorElement, "\"></div>");
132-
this.init();
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define(["exports"], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory(exports);
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory(mod.exports);
11+
global.index = mod.exports;
13312
}
13+
})(this, function (_exports) {
14+
"use strict";
15+
16+
Object.defineProperty(_exports, "__esModule", {
17+
value: true
18+
});
19+
_exports.default = void 0;
20+
21+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22+
23+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24+
25+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26+
27+
var html5formValidation =
28+
/*#__PURE__*/
29+
function () {
30+
function html5formValidation() {
31+
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.querySelector('form');
32+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
33+
34+
_classCallCheck(this, html5formValidation);
35+
36+
this.settings = Object.assign({}, {
37+
errorElement: 'error',
38+
invalidClass: 'invalid',
39+
submitHandler: null,
40+
validateOnInput: true
41+
}, settings);
42+
this.form = element;
43+
this.errorDiv = "<div class=\"".concat(this.settings.errorElement, "\"></div>");
44+
this.init();
45+
}
13446

135-
_createClass(html5formValidation, [{
136-
key: "init",
137-
value: function init() {
138-
var _this = this;
47+
_createClass(html5formValidation, [{
48+
key: "init",
49+
value: function init() {
50+
var _this = this;
13951

140-
this.form.noValidate = true;
141-
this.settings.validateOnInput && this.validateAll(this.form);
52+
this.form.noValidate = true;
53+
this.settings.validateOnInput && this.validateAll(this.form);
14254

143-
this.form.onsubmit = function (event) {
144-
_this.validateAll(_this.form);
55+
this.form.onsubmit = function (event) {
56+
_this.validateAll(_this.form);
14557

146-
if (!_this.form.checkValidity()) {
147-
event.preventDefault();
148-
} else {
149-
if (typeof _this.settings.submitHandler === 'function') {
58+
if (!_this.form.checkValidity()) {
15059
event.preventDefault();
60+
} else {
61+
if (typeof _this.settings.submitHandler === 'function') {
62+
event.preventDefault();
15163

152-
_this.settings.submitHandler(_this);
64+
_this.settings.submitHandler(_this);
65+
}
15366
}
154-
}
155-
};
156-
}
157-
}, {
158-
key: "validateAll",
159-
value: function validateAll(form) {
160-
var requiredFields = form.querySelectorAll('[required]');
161-
var _iteratorNormalCompletion = true;
162-
var _didIteratorError = false;
163-
var _iteratorError = undefined;
164-
165-
try {
166-
for (var _iterator = requiredFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
167-
var field = _step.value;
168-
this.validateField(field);
169-
}
170-
} catch (err) {
171-
_didIteratorError = true;
172-
_iteratorError = err;
173-
} finally {
67+
};
68+
}
69+
}, {
70+
key: "validateAll",
71+
value: function validateAll(form) {
72+
var requiredFields = form.querySelectorAll('[required]');
73+
var _iteratorNormalCompletion = true;
74+
var _didIteratorError = false;
75+
var _iteratorError = undefined;
76+
17477
try {
175-
if (!_iteratorNormalCompletion && _iterator.return != null) {
176-
_iterator.return();
78+
for (var _iterator = requiredFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
79+
var field = _step.value;
80+
this.validateField(field);
17781
}
82+
} catch (err) {
83+
_didIteratorError = true;
84+
_iteratorError = err;
17885
} finally {
179-
if (_didIteratorError) {
180-
throw _iteratorError;
86+
try {
87+
if (!_iteratorNormalCompletion && _iterator.return != null) {
88+
_iterator.return();
89+
}
90+
} finally {
91+
if (_didIteratorError) {
92+
throw _iteratorError;
93+
}
18194
}
18295
}
18396
}
184-
}
185-
}, {
186-
key: "validateField",
187-
value: function validateField(field) {
188-
var _this2 = this;
189-
190-
if (!(field.nextSibling.classList && field.nextSibling.classList.contains(this.settings.errorElement))) {
191-
field.insertAdjacentHTML('afterend', this.errorDiv);
192-
}
97+
}, {
98+
key: "validateField",
99+
value: function validateField(field) {
100+
var _this2 = this;
193101

194-
field.oninvalid = function () {
195-
field.classList.add(_this2.settings.invalidClass);
196-
field.nextSibling.textContent = field.validationMessage;
197-
};
102+
if (!(field.nextSibling.classList && field.nextSibling.classList.contains(this.settings.errorElement))) {
103+
field.insertAdjacentHTML('afterend', this.errorDiv);
104+
}
198105

199-
field.oninput = function () {
200-
field.nextSibling.textContent = '';
201-
field.classList.remove(_this2.settings.invalidClass);
202-
field.checkValidity();
203-
};
204-
}
205-
}]);
106+
field.oninvalid = function () {
107+
field.classList.add(_this2.settings.invalidClass);
108+
field.nextSibling.textContent = field.validationMessage;
109+
};
206110

207-
return html5formValidation;
208-
}();
111+
field.oninput = function () {
112+
field.nextSibling.textContent = '';
113+
field.classList.remove(_this2.settings.invalidClass);
114+
field.checkValidity();
115+
};
116+
}
117+
}]);
209118

210-
exports.default = html5formValidation;
119+
return html5formValidation;
120+
}();
211121

212-
/***/ })
213-
/******/ ])["default"];
214-
});
122+
_exports.default = html5formValidation;
123+
});

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)