mirror of
https://github.com/bigchaindb/site.git
synced 2024-12-24 02:16:10 +01:00
Matthias Kretschmann
6ede38abfc
- start linting scss based on Airbnb style guide - add includePaths to css & js tasks
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
|
|
//=include parsleyjs/dist/parsley.js
|
|
|
|
var Forms = (function(w, d, $) {
|
|
|
|
'use strict'
|
|
|
|
var app, _private, _config
|
|
|
|
_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, jQuery)
|