2015-12-20 18:03:44 +01:00
|
|
|
|
|
|
|
//=include ../../../../node_modules/parsleyjs/dist/parsley.js
|
|
|
|
|
2016-02-05 00:18:11 +01:00
|
|
|
var Forms = (function(w, d, $) {
|
2015-12-20 18:03:44 +01:00
|
|
|
|
|
|
|
'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
|
|
|
|
|
2016-02-05 00:18:11 +01:00
|
|
|
})(window, document, jQuery)
|