1/* 2* Validation wrapper 3* @version: 2.0.0 (Mon, 25 Nov 2019) 4* @requires: jQuery v3.0 or later, jQuery Validation v1.19.1 5* @author: HtmlStream 6* @event-namespace: .HSCore.components.HSValidation 7* @license: Htmlstream Libraries (https://htmlstream.com/licenses) 8* Copyright 2020 Htmlstream 9*/ 10 11;(function ($) { 12 'use strict'; 13 14 $.HSCore.components.HSValidation = { 15 defaults: { 16 errorElement: 'div', 17 errorClass: 'invalid-feedback' 18 }, 19 20 init: function (el, options) { 21 if (!el.length) return; 22 23 var context = this, 24 defaults = Object.assign({}, context.defaults), 25 dataSettings = el.attr('data-hs-validation-options') ? JSON.parse(el.attr('data-hs-validation-options')) : {}, 26 settings = { 27 errorPlacement: context.errorPlacement, 28 highlight: context.highlight, 29 unhighlight: context.unHighlight, 30 submitHandler: context.submitHandler, 31 onkeyup: function (element) { 32 $(element).valid(); 33 } 34 }; 35 settings = $.extend(true, defaults, settings, dataSettings, options); 36 37 /* Start : object preparation */ 38 39 if (el.hasClass('js-step-form')) { 40 $.validator.setDefaults({ 41 ignore: ':hidden:not(.active select)' 42 }); 43 } else { 44 $.validator.setDefaults({ 45 ignore: ':hidden:not(select)' 46 }); 47 } 48 49 /* End : object preparation */ 50 51 /* Start : Init */ 52 53 var newValidate = el.validate(settings); 54 55 /* End : Init */ 56 57 /* Start : custom functionality implementation */ 58 59 if (el.find('select').length) { 60 el.find('select').change(function () { 61 $(this).valid(); 62 }); 63 } 64 65 /* End : custom functionality implementation */ 66 67 return newValidate; 68 }, 69 70 rules: function (el) { 71 var args = Array.prototype.slice.call(arguments, 1); 72 73 $.fn.rules.apply(el, args); 74 }, 75 76 errorPlacement: function (error, element) { 77 var $this = $(element), 78 errorMsgClasses = $this.data('error-msg-classes'); 79 80 error.addClass(errorMsgClasses); 81 error.appendTo(element.parents('.js-form-message')); 82 }, 83 84 highlight: function (element) { 85 var $this = $(element), 86 errorClass = $this.data('error-class') ? $this.data('error-class') : 'is-invalid', 87 successClass = $this.data('success-class') ? $this.data('error-class') : 'is-valid'; 88 89 $this.removeClass(successClass).addClass(errorClass) 90 .parents('label').removeClass(successClass).addClass(errorClass); 91 }, 92 93 unHighlight: function (element) { 94 var $this = $(element), 95 errorClass = $this.data('error-class') ? $this.data('error-class') : 'is-invalid', 96 successClass = $this.data('success-class') ? $this.data('error-class') : 'is-valid'; 97 98 $this.removeClass(errorClass).addClass(successClass) 99 .parents('label').removeClass(errorClass).addClass(successClass); 100 }, 101 102 submitHandler: function (form) { 103 form.submit(); 104 } 105 }; 106 107})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.