Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
v0.11.5 🌹
Browse files Browse the repository at this point in the history
  • Loading branch information
1000hz committed Jul 16, 2016
1 parent fda991c commit d22b879
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 65 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
Changelog
=========
### 0.11.5
* Fixed an event binding order issue when the form is reset. ([#375](https://github.com/1000hz/bootstrap-validator/pull/375))

### 0.11.3
* Fixed `.has-success` not being cleared if a field `.has-feedback` and has it's value cleared. Shoutout to [@net](https://github.com/1000hz/bootstrap-validator/pull/375) for bringing the bugs fixed in 0.11.1 - 0.11.3 to my attention.

Expand Down
64 changes: 35 additions & 29 deletions dist/validator.js
@@ -1,5 +1,5 @@
/*!
* Validator v0.11.3 for Bootstrap 3, by @1000hz
* Validator v0.11.5 for Bootstrap 3, by @1000hz
* Copyright 2016 Cina Saffary
* Licensed under http://opensource.org/licenses/MIT
*
Expand Down Expand Up @@ -30,7 +30,7 @@

this.$element.on('input.bs.validator change.bs.validator focusout.bs.validator', $.proxy(this.onInput, this))
this.$element.on('submit.bs.validator', $.proxy(this.onSubmit, this))
this.$element.on('reset.bs.validator', $.proxy(this.onReset, this))
this.$element.on('reset.bs.validator', $.proxy(this.reset, this))

this.$element.find('[data-match]').each(function () {
var $this = $(this)
Expand All @@ -47,7 +47,7 @@
this.toggleSubmit()
}

Validator.VERSION = '0.11.3'
Validator.VERSION = '0.11.5'

Validator.INPUT_SELECTOR = ':input:not([type="hidden"], [type="submit"], [type="reset"], button)'

Expand Down Expand Up @@ -285,56 +285,62 @@
this.$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())
}

Validator.prototype.onReset = function (e) {
var self = this
var options = this.options

window.setTimeout(function () {
self.destroy()
Plugin.call(self.$element, options)
}, 0)
}

Validator.prototype.defer = function ($el, callback) {
callback = $.proxy(callback, this, $el)
if (!this.options.delay) return callback()
window.clearTimeout($el.data('bs.validator.timeout'))
$el.data('bs.validator.timeout', window.setTimeout(callback, this.options.delay))
}

Validator.prototype.destroy = function () {
this.$element
.removeAttr('novalidate')
.removeData('bs.validator')
.off('.bs.validator')
.find('.form-control-feedback')
.removeClass([this.options.feedback.error, this.options.feedback.success].join(' '))
Validator.prototype.reset = function () {
this.$element.find('.form-control-feedback')
.removeClass(this.options.feedback.error)
.removeClass(this.options.feedback.success)

this.$inputs
.off('.bs.validator')
.removeData(['bs.validator.errors', 'bs.validator.deferred'])
.each(function () {
var $this = $(this)
var timeout = $this.data('bs.validator.timeout')
window.clearTimeout(timeout) && $this.removeData('bs.validator.timeout')
})

this.$element.find('.help-block.with-errors').each(function () {
var $this = $(this)
var originalContent = $this.data('bs.validator.originalContent')
this.$element.find('.help-block.with-errors')
.each(function () {
var $this = $(this)
var originalContent = $this.data('bs.validator.originalContent')

$this
.removeData('bs.validator.originalContent')
.html(originalContent)
})
$this
.removeData('bs.validator.originalContent')
.html(originalContent)
})

this.$element.find('input[type="submit"], button[type="submit"]').removeClass('disabled')
this.$btn.removeClass('disabled')

this.$element.find('.has-error, .has-danger, .has-success').removeClass('has-error has-danger has-success')

return this
}

Validator.prototype.destroy = function () {
this.reset()

this.$element
.removeAttr('novalidate')
.removeData('bs.validator')
.off('.bs.validator')

this.$inputs
.off('.bs.validator')

this.options = null
this.validators = null
this.$element = null
this.$btn = null

return this
}

// VALIDATOR PLUGIN DEFINITION
// ===========================

Expand Down
4 changes: 2 additions & 2 deletions dist/validator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d22b879

Please sign in to comment.