1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-22 17:50:07 +01:00

js cleanup and small refactor

This commit is contained in:
Matthias Kretschmann 2016-02-23 00:15:54 +01:00
parent 743546f0e7
commit e2b66d95ae
5 changed files with 17 additions and 127 deletions

View File

@ -105,11 +105,17 @@ var GoogleAnalytics = (function(w,d,$) {
_private.gaViewport(); _private.gaViewport();
_private.gaPixelDensity(); _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() { gaEventNewsletterError: function() {
ga('send', 'event', 'signup', 'early_access_form', 'error'); ga('send', 'event', 'newsletter', 'subscribe', 'error');
}, },
// contact forms // contact forms

View File

@ -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);

View File

@ -23,7 +23,10 @@ var Newsletter = (function(w, d, $) {
_config.newsletter.find('.input-group').addClass('hide'); _config.newsletter.find('.input-group').addClass('hide');
// send GA event // send GA event
ga('send', 'event', 'newsletter', 'subscribe', 'success', true); if (!_dntEnabled()) {
GoogleAnalytics.gaEventNewsletterSuccess();
}
} }
if (resp.result === 'error') { if (resp.result === 'error') {
_config.newsletter.find('.btn') _config.newsletter.find('.btn')
@ -31,7 +34,9 @@ var Newsletter = (function(w, d, $) {
.text('Subscribe'); .text('Subscribe');
// send GA event // send GA event
ga('send', 'event', 'newsletter', 'subscribe', 'error', true); if (!_dntEnabled()) {
GoogleAnalytics.gaEventNewsletterError();
}
} }
} }
} }

View File

@ -48,18 +48,3 @@
.section-whitepaper { .section-whitepaper {
@extend .text-center; @extend .text-center;
} }
.section-earlyaccess {
form {
max-width: $screen-sm-min;
margin: auto;
}
.form-control {
&:focus {
border-color: #fff;
}
}
}

View File

@ -1,37 +0,0 @@
<form id="form-earlyaccess" class="js-parsley" action="https://formkeep.com/f/908add3a6df4" method="POST" accept-charset="UTF-8">
<p class="form-group">
<input class="form-control" type="text" id="name" name="name" required>
<label class="form-label" for="name">Your Name</label>
</p>
<p class="form-group">
<input class="form-control" type="email" id="email" name="email" required>
<label class="form-label" for="email">Your Email</label>
</p>
<p class="form-group">
<textarea class="form-control" id="comment" name="comment" rows="1"></textarea>
<label class="form-label" for="comment">Your Comment (optional)</label>
</p>
<p class="form-group">
<input class="btn btn-primary" type="submit" value="Send">
</p>
<div class="alert alert-success animation-slide-in-from-bottom hide">
<svg class="alert__icon icon icon-success">
<use xlink:href="/assets/img/sprite.svg#icon-success"></use>
</svg>
<p>
<strong class="alert__title">Great to hear youre interested!</strong>
Well get in touch soon to discuss how we can work together.
</p>
</div>
<div class="alert alert-danger hide">
<svg class="alert__icon icon icon-fail">
<use xlink:href="/assets/img/sprite.svg#icon-fail"></use>
</svg>
<p>
<strong class="alert__title">Ops, there was an error</strong>
Would you mind trying again?
</p>
</div>
</form>