1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-12-24 18:36:11 +01:00

prepare form interaction, send GA events

This commit is contained in:
Matthias Kretschmann 2016-02-18 16:09:37 +01:00
parent 988743f901
commit b9b10fcfb8
2 changed files with 28 additions and 13 deletions

View File

@ -12,22 +12,33 @@ var Newsletter = (function(w, d, $) {
}, },
_private = { _private = {
parsley: function() {
if (_config.newsletter.length > 0) {
_config.newsletter.parsley({
trigger: 'change'
});
}
},
ajaxChimp: function() { ajaxChimp: function() {
_config.newsletter.ajaxChimp(); _config.newsletter.ajaxChimp({
callback: formCallback
});
function formCallback (resp) {
if (resp.result === 'success') {
_config.newsletter.find('.input-group').addClass('hide');
// send GA event
ga('send', 'event', 'newsletter', 'subscribe', 'success', true);
}
if (resp.result === 'error') {
_config.newsletter.find('.btn')
.removeClass('disabled')
.text('Subscribe');
// send GA event
ga('send', 'event', 'newsletter', 'subscribe', 'error', true);
}
}
} }
}; };
app = { app = {
init: function() { init: function() {
_private.parsley();
_private.ajaxChimp(); _private.ajaxChimp();
} }
}; };

View File

@ -57,7 +57,7 @@ For e.g. 'http://blahblah.us1.list-manage.com/subscribe/post-json?u=5afsdhfuhdsi
var form = $(elem); var form = $(elem);
var email = form.find('input[type=email]'); var email = form.find('input[type=email]');
var feedback = form.find('.form-control-feedback'); var feedback = form.find('.form-control-feedback');
var formgroup = form.find('.form-group'); var formgroup = form.find('.input-group');
var settings = $.extend({ var settings = $.extend({
'url': form.attr('action'), 'url': form.attr('action'),
@ -135,7 +135,7 @@ For e.g. 'http://blahblah.us1.list-manage.com/subscribe/post-json?u=5afsdhfuhdsi
}); });
// Translate and display submit message // Translate and display submit message
var submitMsg = 'Submitting...'; var submitMsg = 'Sending...';
if( if(
settings.language !== 'en' settings.language !== 'en'
&& $.ajaxChimp.translations && $.ajaxChimp.translations
@ -144,7 +144,11 @@ For e.g. 'http://blahblah.us1.list-manage.com/subscribe/post-json?u=5afsdhfuhdsi
) { ) {
submitMsg = $.ajaxChimp.translations[settings.language]['submit']; submitMsg = $.ajaxChimp.translations[settings.language]['submit'];
} }
feedback.html(submitMsg).show(2000); form.find('.btn')
.addClass('disabled')
.text(submitMsg);
//feedback.html(submitMsg).show(2000);
return false; return false;
}); });