mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-29 07:16:17 +01:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
|
|
//=include ../../../../node_modules/parsleyjs/dist/parsley.js
|
|
|
|
var Forms = (function(w, d) {
|
|
|
|
'use strict'
|
|
|
|
var app, _private, _config
|
|
|
|
// workaround for blog
|
|
var $ = jQuery
|
|
|
|
_config = {
|
|
form: $('form'),
|
|
parsleyForm: $('form.js-parsley')
|
|
}
|
|
|
|
_private = {
|
|
formValidation: function() {
|
|
// kick in Parsley.js but only if its js is present
|
|
// and form has `js-parsley` class
|
|
if ( window.Parsley && _config.form.hasClass('js-parsley') ) {
|
|
_config.parsleyForm.parsley({
|
|
trigger: 'change'
|
|
})
|
|
}
|
|
},
|
|
formEmptyValidation: function() {
|
|
_config.form.find('.form-control').each(function() {
|
|
|
|
if ($(this).val() == '') {
|
|
$(this).addClass('is-empty')
|
|
}
|
|
|
|
$(this).blur(function() {
|
|
if ($(this).val() == '') {
|
|
$(this).addClass('is-empty')
|
|
} else {
|
|
$(this).removeClass('is-empty')
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
app = {
|
|
init: function() {
|
|
_private.formValidation()
|
|
_private.formEmptyValidation()
|
|
}
|
|
}
|
|
|
|
return app
|
|
|
|
})(window, document)
|