1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 01:14:21 +01:00

update validator.js

This commit is contained in:
kakwa 2015-11-02 23:12:12 +01:00
parent 93cd8a40f6
commit 8833fe6df6

View File

@ -1,5 +1,5 @@
/* ======================================================================== /* ========================================================================
* Bootstrap (plugin): validator.js v0.8.1 * Bootstrap (plugin): validator.js v0.9.0
* ======================================================================== * ========================================================================
* The MIT License (MIT) * The MIT License (MIT)
* *
@ -29,7 +29,6 @@
+function ($) { +function ($) {
'use strict'; 'use strict';
var inputSelector = ':input:not([type="submit"], button):enabled:visible'
// VALIDATOR CLASS DEFINITION // VALIDATOR CLASS DEFINITION
// ========================== // ==========================
@ -61,6 +60,8 @@
}) })
} }
Validator.INPUT_SELECTOR = ':input:not([type="submit"], button):enabled:visible'
Validator.DEFAULTS = { Validator.DEFAULTS = {
delay: 500, delay: 500,
html: false, html: false,
@ -72,7 +73,7 @@
}, },
feedback: { feedback: {
success: 'glyphicon-ok', success: 'glyphicon-ok',
error: 'glyphicon-warning-sign' error: 'glyphicon-remove'
} }
} }
@ -81,11 +82,11 @@
var el = $el[0] var el = $el[0]
return el.checkValidity ? el.checkValidity() : true return el.checkValidity ? el.checkValidity() : true
}, },
match: function ($el) { 'match': function ($el) {
var target = $el.data('match') var target = $el.data('match')
return !$el.val() || $el.val() === $(target).val() return !$el.val() || $el.val() === $(target).val()
}, },
minlength: function ($el) { 'minlength': function ($el) {
var minlength = $el.data('minlength') var minlength = $el.data('minlength')
return !$el.val() || $el.val().length >= minlength return !$el.val() || $el.val().length >= minlength
} }
@ -163,7 +164,7 @@
var delay = this.options.delay var delay = this.options.delay
this.options.delay = 0 this.options.delay = 0
this.$element.find(inputSelector).trigger('input.bs.validator') this.$element.find(Validator.INPUT_SELECTOR).trigger('input.bs.validator')
this.options.delay = delay this.options.delay = delay
return this return this
@ -214,7 +215,7 @@
return !!($(this).data('bs.validator.errors') || []).length return !!($(this).data('bs.validator.errors') || []).length
} }
return !!this.$element.find(inputSelector).filter(fieldErrors).length return !!this.$element.find(Validator.INPUT_SELECTOR).filter(fieldErrors).length
} }
Validator.prototype.isIncomplete = function () { Validator.prototype.isIncomplete = function () {
@ -224,7 +225,7 @@
$.trim(this.value) === '' $.trim(this.value) === ''
} }
return !!this.$element.find(inputSelector).filter('[required]').filter(fieldIncomplete).length return !!this.$element.find(Validator.INPUT_SELECTOR).filter('[required]').filter(fieldIncomplete).length
} }
Validator.prototype.onSubmit = function (e) { Validator.prototype.onSubmit = function (e) {
@ -234,11 +235,12 @@
Validator.prototype.toggleSubmit = function () { Validator.prototype.toggleSubmit = function () {
if(!this.options.disable) return if(!this.options.disable) return
var $btn = $('button[type="submit"], input[type="submit"]') var $btn = $('button[type="submit"], input[type="submit"]')
.filter('[form="' + this.$element.attr('id') + '"]') .filter('[form="' + this.$element.attr('id') + '"]')
.add(this.$element.find('input[type="submit"], button[type="submit"]')) .add(this.$element.find('input[type="submit"], button[type="submit"]'))
$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors()) $btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())
.css({'pointer-events': 'all', 'cursor': 'pointer'})
} }
Validator.prototype.defer = function ($el, callback) { Validator.prototype.defer = function ($el, callback) {
@ -254,7 +256,7 @@
.removeData('bs.validator') .removeData('bs.validator')
.off('.bs.validator') .off('.bs.validator')
this.$element.find(inputSelector) this.$element.find(Validator.INPUT_SELECTOR)
.off('.bs.validator') .off('.bs.validator')
.removeData(['bs.validator.errors', 'bs.validator.deferred']) .removeData(['bs.validator.errors', 'bs.validator.deferred'])
.each(function () { .each(function () {