|
1 | 1 | /*! |
2 | | - * Validator v0.11.3 for Bootstrap 3, by @1000hz |
| 2 | + * Validator v0.11.5 for Bootstrap 3, by @1000hz |
3 | 3 | * Copyright 2016 Cina Saffary |
4 | 4 | * Licensed under http://opensource.org/licenses/MIT |
5 | 5 | * |
|
30 | 30 |
|
31 | 31 | this.$element.on('input.bs.validator change.bs.validator focusout.bs.validator', $.proxy(this.onInput, this)) |
32 | 32 | this.$element.on('submit.bs.validator', $.proxy(this.onSubmit, this)) |
33 | | - this.$element.on('reset.bs.validator', $.proxy(this.onReset, this)) |
| 33 | + this.$element.on('reset.bs.validator', $.proxy(this.reset, this)) |
34 | 34 |
|
35 | 35 | this.$element.find('[data-match]').each(function () { |
36 | 36 | var $this = $(this) |
|
47 | 47 | this.toggleSubmit() |
48 | 48 | } |
49 | 49 |
|
50 | | - Validator.VERSION = '0.11.3' |
| 50 | + Validator.VERSION = '0.11.5' |
51 | 51 |
|
52 | 52 | Validator.INPUT_SELECTOR = ':input:not([type="hidden"], [type="submit"], [type="reset"], button)' |
53 | 53 |
|
|
285 | 285 | this.$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors()) |
286 | 286 | } |
287 | 287 |
|
288 | | - Validator.prototype.onReset = function (e) { |
289 | | - var self = this |
290 | | - var options = this.options |
291 | | - |
292 | | - window.setTimeout(function () { |
293 | | - self.destroy() |
294 | | - Plugin.call(self.$element, options) |
295 | | - }, 0) |
296 | | - } |
297 | | - |
298 | 288 | Validator.prototype.defer = function ($el, callback) { |
299 | 289 | callback = $.proxy(callback, this, $el) |
300 | 290 | if (!this.options.delay) return callback() |
301 | 291 | window.clearTimeout($el.data('bs.validator.timeout')) |
302 | 292 | $el.data('bs.validator.timeout', window.setTimeout(callback, this.options.delay)) |
303 | 293 | } |
304 | 294 |
|
305 | | - Validator.prototype.destroy = function () { |
306 | | - this.$element |
307 | | - .removeAttr('novalidate') |
308 | | - .removeData('bs.validator') |
309 | | - .off('.bs.validator') |
310 | | - .find('.form-control-feedback') |
311 | | - .removeClass([this.options.feedback.error, this.options.feedback.success].join(' ')) |
| 295 | + Validator.prototype.reset = function () { |
| 296 | + this.$element.find('.form-control-feedback') |
| 297 | + .removeClass(this.options.feedback.error) |
| 298 | + .removeClass(this.options.feedback.success) |
312 | 299 |
|
313 | 300 | this.$inputs |
314 | | - .off('.bs.validator') |
315 | 301 | .removeData(['bs.validator.errors', 'bs.validator.deferred']) |
316 | 302 | .each(function () { |
317 | 303 | var $this = $(this) |
318 | 304 | var timeout = $this.data('bs.validator.timeout') |
319 | 305 | window.clearTimeout(timeout) && $this.removeData('bs.validator.timeout') |
320 | 306 | }) |
321 | 307 |
|
322 | | - this.$element.find('.help-block.with-errors').each(function () { |
323 | | - var $this = $(this) |
324 | | - var originalContent = $this.data('bs.validator.originalContent') |
| 308 | + this.$element.find('.help-block.with-errors') |
| 309 | + .each(function () { |
| 310 | + var $this = $(this) |
| 311 | + var originalContent = $this.data('bs.validator.originalContent') |
325 | 312 |
|
326 | | - $this |
327 | | - .removeData('bs.validator.originalContent') |
328 | | - .html(originalContent) |
329 | | - }) |
| 313 | + $this |
| 314 | + .removeData('bs.validator.originalContent') |
| 315 | + .html(originalContent) |
| 316 | + }) |
330 | 317 |
|
331 | | - this.$element.find('input[type="submit"], button[type="submit"]').removeClass('disabled') |
| 318 | + this.$btn.removeClass('disabled') |
332 | 319 |
|
333 | 320 | this.$element.find('.has-error, .has-danger, .has-success').removeClass('has-error has-danger has-success') |
334 | 321 |
|
335 | 322 | return this |
336 | 323 | } |
337 | 324 |
|
| 325 | + Validator.prototype.destroy = function () { |
| 326 | + this.reset() |
| 327 | + |
| 328 | + this.$element |
| 329 | + .removeAttr('novalidate') |
| 330 | + .removeData('bs.validator') |
| 331 | + .off('.bs.validator') |
| 332 | + |
| 333 | + this.$inputs |
| 334 | + .off('.bs.validator') |
| 335 | + |
| 336 | + this.options = null |
| 337 | + this.validators = null |
| 338 | + this.$element = null |
| 339 | + this.$btn = null |
| 340 | + |
| 341 | + return this |
| 342 | + } |
| 343 | + |
338 | 344 | // VALIDATOR PLUGIN DEFINITION |
339 | 345 | // =========================== |
340 | 346 |
|
|
0 commit comments