1/*! 2 * Validator v0.8.1 for Bootstrap 3, by @1000hz 3 * Copyright 2015 Cina Saffary 4 * Licensed under http://opensource.org/licenses/MIT 5 * 6 * https://github.com/1000hz/bootstrap-validator 7 */ 8 9+(function (a) { 10 "use strict"; 11 function b(b) { 12 return this.each(function () { 13 var c = a(this), 14 e = a.extend({}, d.DEFAULTS, c.data(), "object" == typeof b && b), 15 f = c.data("bs.validator"); 16 (f || "destroy" != b) && 17 (f || c.data("bs.validator", (f = new d(this, e))), 18 "string" == typeof b && f[b]()); 19 }); 20 } 21 var c = ':input:not([type="submit"], button):enabled:visible', 22 d = function (b, c) { 23 (this.$element = a(b)), 24 (this.options = c), 25 (c.errors = a.extend({}, d.DEFAULTS.errors, c.errors)); 26 for (var e in c.custom) 27 if (!c.errors[e]) 28 throw new Error( 29 "Missing default error message for custom validator: " + e 30 ); 31 a.extend(d.VALIDATORS, c.custom), 32 this.$element.attr("novalidate", !0), 33 this.toggleSubmit(), 34 this.$element.on( 35 "input.bs.validator change.bs.validator focusout.bs.validator", 36 a.proxy(this.validateInput, this) 37 ), 38 this.$element.on("submit.bs.validator", a.proxy(this.onSubmit, this)), 39 this.$element.find("[data-match]").each(function () { 40 var b = a(this), 41 c = b.data("match"); 42 a(c).on("input.bs.validator", function () { 43 b.val() && b.trigger("input.bs.validator"); 44 }); 45 }); 46 }; 47 (d.DEFAULTS = { 48 delay: 500, 49 html: !1, 50 disable: !0, 51 custom: {}, 52 errors: { match: "Does not match", minlength: "Not long enough" }, 53 feedback: { success: "glyphicon-ok", error: "glyphicon-warning-sign" }, 54 }), 55 (d.VALIDATORS = { 56 native: function (a) { 57 var b = a[0]; 58 return b.checkValidity ? b.checkValidity() : !0; 59 }, 60 match: function (b) { 61 var c = b.data("match"); 62 return !b.val() || b.val() === a(c).val(); 63 }, 64 minlength: function (a) { 65 var b = a.data("minlength"); 66 return !a.val() || a.val().length >= b; 67 }, 68 }), 69 (d.prototype.validateInput = function (b) { 70 var c = a(b.target), 71 d = c.data("bs.validator.errors"); 72 if ( 73 (c.is('[type="radio"]') && 74 (c = this.$element.find('input[name="' + c.attr("name") + '"]')), 75 this.$element.trigger( 76 (b = a.Event("validate.bs.validator", { relatedTarget: c[0] })) 77 ), 78 !b.isDefaultPrevented()) 79 ) { 80 var e = this; 81 this.runValidators(c).done(function (f) { 82 c.data("bs.validator.errors", f), 83 f.length ? e.showErrors(c) : e.clearErrors(c), 84 (d && f.toString() === d.toString()) || 85 ((b = f.length 86 ? a.Event("invalid.bs.validator", { 87 relatedTarget: c[0], 88 detail: f, 89 }) 90 : a.Event("valid.bs.validator", { 91 relatedTarget: c[0], 92 detail: d, 93 })), 94 e.$element.trigger(b)), 95 e.toggleSubmit(), 96 e.$element.trigger( 97 a.Event("validated.bs.validator", { relatedTarget: c[0] }) 98 ); 99 }); 100 } 101 }), 102 (d.prototype.runValidators = function (b) { 103 function c(a) { 104 return ( 105 b.data(a + "-error") || 106 b.data("error") || 107 ("native" == a && b[0].validationMessage) || 108 g.errors[a] 109 ); 110 } 111 var e = [], 112 f = a.Deferred(), 113 g = this.options; 114 return ( 115 b.data("bs.validator.deferred") && 116 b.data("bs.validator.deferred").reject(), 117 b.data("bs.validator.deferred", f), 118 a.each( 119 d.VALIDATORS, 120 a.proxy(function (a, d) { 121 if ((b.data(a) || "native" == a) && !d.call(this, b)) { 122 var f = c(a); 123 !~e.indexOf(f) && e.push(f); 124 } 125 }, this) 126 ), 127 !e.length && b.val() && b.data("remote") 128 ? this.defer(b, function () { 129 var d = {}; 130 (d[b.attr("name")] = b.val()), 131 a 132 .get(b.data("remote"), d) 133 .fail(function (a, b, d) { 134 e.push(c("remote") || d); 135 }) 136 .always(function () { 137 f.resolve(e); 138 }); 139 }) 140 : f.resolve(e), 141 f.promise() 142 ); 143 }), 144 (d.prototype.validate = function () { 145 var a = this.options.delay; 146 return ( 147 (this.options.delay = 0), 148 this.$element.find(c).trigger("input.bs.validator"), 149 (this.options.delay = a), 150 this 151 ); 152 }), 153 (d.prototype.showErrors = function (b) { 154 var c = this.options.html ? "html" : "text"; 155 this.defer(b, function () { 156 var d = b.closest(".form-group"), 157 e = d.find(".help-block.with-errors"), 158 f = d.find(".form-control-feedback"),
159 g = b.data("bs.validator.errors"); 160 g.length && 161 ((g = a("<div/>").append( 162 a.map(g, function (b) { 163 return a("<span/>").css({ 164 display: "block", 165 "font-size": "12px", 166 color: "#f0f0f0" 167 })[c](b); 168 }) 169 )), 170 void 0 === e.data("bs.validator.originalContent") && 171 e.data("bs.validator.originalContent", e.html()), 172 e.empty().append(g), 173 d.addClass("has-error"), 174 f.length && 175 f.removeClass(this.options.feedback.success) && 176 f.addClass(this.options.feedback.error) && 177 d.removeClass("has-success")); 178 }); 179 }), 180 (d.prototype.clearErrors = function (a) { 181 var b = a.closest(".form-group"), 182 c = b.find(".help-block.with-errors"), 183 d = b.find(".form-control-feedback"); 184 c.html(c.data("bs.validator.originalContent")), 185 b.removeClass("has-error"), 186 d.length && 187 d.removeClass(this.options.feedback.error) && 188 d.addClass(this.options.feedback.success) && 189 b.addClass("has-success"); 190 }), 191 (d.prototype.hasErrors = function () { 192 function b() { 193 return !!(a(this).data("bs.validator.errors") || []).length; 194 } 195 return !!this.$element.find(c).filter(b).length; 196 }), 197 (d.prototype.isIncomplete = function () { 198 function b() { 199 return "checkbox" === this.type 200 ? !this.checked 201 : "radio" === this.type 202 ? !a('[name="' + this.name + '"]:checked').length 203 : "" === a.trim(this.value); 204 } 205 return !!this.$element.find(c).filter("[required]").filter(b).length; 206 }), 207 (d.prototype.onSubmit = function (a) { 208 this.validate(), 209 (this.isIncomplete() || this.hasErrors()) && a.preventDefault(); 210 }), 211 (d.prototype.toggleSubmit = function () { 212 if (this.options.disable) { 213 var b = a('button[type="submit"], input[type="submit"]') 214 .filter('[form="' + this.$element.attr("id") + '"]') 215 .add( 216 this.$element.find('input[type="submit"], button[type="submit"]') 217 ); 218 b.toggleClass("disabled", this.isIncomplete() || this.hasErrors()).css({ 219 "pointer-events": "all", 220 cursor: "pointer", 221 }); 222 } 223 }), 224 (d.prototype.defer = function (b, c) { 225 return ( 226 (c = a.proxy(c, this)), 227 this.options.delay 228 ? (window.clearTimeout(b.data("bs.validator.timeout")), 229 void b.data( 230 "bs.validator.timeout", 231 window.setTimeout(c, this.options.delay) 232 )) 233 : c() 234 ); 235 }), 236 (d.prototype.destroy = function () { 237 return ( 238 this.$element 239 .removeAttr("novalidate") 240 .removeData("bs.validator") 241 .off(".bs.validator"), 242 this.$element 243 .find(c) 244 .off(".bs.validator") 245 .removeData(["bs.validator.errors", "bs.validator.deferred"]) 246 .each(function () { 247 var b = a(this), 248 c = b.data("bs.validator.timeout"); 249 window.clearTimeout(c) && b.removeData("bs.validator.timeout"); 250 }), 251 this.$element.find(".help-block.with-errors").each(function () { 252 var b = a(this), 253 c = b.data("bs.validator.originalContent"); 254 b.removeData("bs.validator.originalContent").html(c); 255 }), 256 this.$element 257 .find('input[type="submit"], button[type="submit"]') 258 .removeClass("disabled"), 259 this.$element.find(".has-error").removeClass("has-error"), 260 this 261 ); 262 }); 263 var e = a.fn.validator; 264 (a.fn.validator = b), 265 (a.fn.validator.Constructor = d), 266 (a.fn.validator.noConflict = function () { 267 return (a.fn.validator = e), this; 268 }), 269 a(window).on("load", function () { 270 a('form[data-bs-toggle="validator"]').each(function () { 271 var c = a(this); 272 b.call(c, c.data()); 273 }); 274 }); 275})(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.