From e2b66d95ae3235b341de77181c105b85917a151d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 23 Feb 2016 00:15:54 +0100 Subject: [PATCH] js cleanup and small refactor --- .../_assets/javascripts/bigchain/analytics.js | 14 ++-- .../javascripts/bigchain/form-earlyaccess.js | 69 ------------------- .../javascripts/bigchain/newsletter.js | 9 ++- _src/_assets/styles/_page-front.scss | 15 ---- _src/_includes/form-earlyaccess.html | 37 ---------- 5 files changed, 17 insertions(+), 127 deletions(-) delete mode 100644 _src/_assets/javascripts/bigchain/form-earlyaccess.js delete mode 100644 _src/_includes/form-earlyaccess.html diff --git a/_src/_assets/javascripts/bigchain/analytics.js b/_src/_assets/javascripts/bigchain/analytics.js index acd5d2c..081fe30 100644 --- a/_src/_assets/javascripts/bigchain/analytics.js +++ b/_src/_assets/javascripts/bigchain/analytics.js @@ -105,11 +105,17 @@ var GoogleAnalytics = (function(w,d,$) { _private.gaViewport(); _private.gaPixelDensity(); }, - gaEventEarlyAccessSuccess: function() { - ga('send', 'event', 'signup', 'early_access_form', 'success'); + + // + // All custom events + // + + // newsletter forms + gaEventNewsletterSuccess: function() { + ga('send', 'event', 'newsletter', 'subscribe', 'success'); }, - gaEventEarlyAccessError: function() { - ga('send', 'event', 'signup', 'early_access_form', 'error'); + gaEventNewsletterError: function() { + ga('send', 'event', 'newsletter', 'subscribe', 'error'); }, // contact forms diff --git a/_src/_assets/javascripts/bigchain/form-earlyaccess.js b/_src/_assets/javascripts/bigchain/form-earlyaccess.js deleted file mode 100644 index 139b20d..0000000 --- a/_src/_assets/javascripts/bigchain/form-earlyaccess.js +++ /dev/null @@ -1,69 +0,0 @@ - -var FormEarlyAccess = (function(w, d, $) { - - 'use strict'; - - var app, _private, _config; - - _config = { - form: $('#form-earlyaccess'), - formBtn: $('#form-earlyaccess').find('.btn'), - formURL: $('#form-earlyaccess').attr('action'), - formMethod: $('#form-earlyaccess').attr('method') - }; - - _private = { - formSubmit: function() { - _config.form.submit(function(e) { - e.preventDefault(); - - if ( $(this).parsley().isValid() ) { - $.ajax({ - url: _config.formURL, - type: _config.formMethod, - accept: { - javascript: 'application/javascript' - }, - data: _config.form.serialize(), - crossDomain: true, - 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'); - - // send GA event - if (!_dntEnabled()) { - GoogleAnalytics.gaEventEarlyAccessSuccess(); - } - }, - error: function(err) { - _config.form.find('.alert-danger').removeClass('hide'); - _config.formBtn - .removeClass('disabled') - .attr('value', 'Send'); - - // send GA event - if (!_dntEnabled()) { - GoogleAnalytics.gaEventEarlyAccessError(); - } - } - }); - } - }); - } - }; - - app = { - init: function() { - _private.formSubmit(); - } - }; - - return app; - -})(window, document, jQuery); diff --git a/_src/_assets/javascripts/bigchain/newsletter.js b/_src/_assets/javascripts/bigchain/newsletter.js index 31cdd9b..ab8c7b1 100644 --- a/_src/_assets/javascripts/bigchain/newsletter.js +++ b/_src/_assets/javascripts/bigchain/newsletter.js @@ -23,7 +23,10 @@ var Newsletter = (function(w, d, $) { _config.newsletter.find('.input-group').addClass('hide'); // send GA event - ga('send', 'event', 'newsletter', 'subscribe', 'success', true); + if (!_dntEnabled()) { + GoogleAnalytics.gaEventNewsletterSuccess(); + } + } if (resp.result === 'error') { _config.newsletter.find('.btn') @@ -31,7 +34,9 @@ var Newsletter = (function(w, d, $) { .text('Subscribe'); // send GA event - ga('send', 'event', 'newsletter', 'subscribe', 'error', true); + if (!_dntEnabled()) { + GoogleAnalytics.gaEventNewsletterError(); + } } } } diff --git a/_src/_assets/styles/_page-front.scss b/_src/_assets/styles/_page-front.scss index bfdf4aa..d47b83d 100644 --- a/_src/_assets/styles/_page-front.scss +++ b/_src/_assets/styles/_page-front.scss @@ -48,18 +48,3 @@ .section-whitepaper { @extend .text-center; } - - -.section-earlyaccess { - - form { - max-width: $screen-sm-min; - margin: auto; - } - - .form-control { - &:focus { - border-color: #fff; - } - } -} diff --git a/_src/_includes/form-earlyaccess.html b/_src/_includes/form-earlyaccess.html deleted file mode 100644 index 8b6f75d..0000000 --- a/_src/_includes/form-earlyaccess.html +++ /dev/null @@ -1,37 +0,0 @@ - -
-

- - -

-

- - -

-

- - -

-

- -

- -
- - - -

- Great to hear you’re interested! - We’ll get in touch soon to discuss how we can work together. -

-
-
- - - -

- Ops, there was an error - Would you mind trying again? -

-
-