1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-01 15:55:36 +01:00
site/_src/_assets/javascripts/bigchain/form-contact.js

57 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-01-21 13:07:50 +01:00
var FormContact = (function(w, d, $) {
'use strict';
var app, _private, _config;
_config = {
form: $('#form-contact'),
formBtn: $('#form-contact').find('.btn'),
formURL: $('#form-contact').attr('action'),
formMethod: $('#form-contact').attr('method')
};
_private = {
formSubmit: function() {
_config.form.submit(function(e) {
e.preventDefault();
if ( $(this).parsley().isValid() ) {
$.ajax({
url: _config.formURL,
2016-02-10 21:14:19 +01:00
method: _config.formMethod,
data: $(this).serialize(),
dataType: 'json',
2016-01-21 13:07:50 +01:00
beforeSend: function() {
_config.formBtn
.addClass('disabled')
.attr('value', 'Sending...');
},
success: function(data) {
_config.form.find('.form-group').addClass('hide');
_config.form.find('.alert-success').removeClass('hide');
_config.formBtn.removeClass('disabled');
},
error: function(err) {
_config.form.find('.alert-danger').removeClass('hide');
_config.formBtn
.removeClass('disabled')
.attr('value', 'Send');
}
});
}
});
}
};
app = {
init: function() {
_private.formSubmit();
}
};
return app;
})(window, document, jQuery);