mirror of
https://github.com/bigchaindb/site.git
synced 2024-12-24 02:16:10 +01:00
js cleanup and small refactor
This commit is contained in:
parent
743546f0e7
commit
e2b66d95ae
@ -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
|
||||
|
@ -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);
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 you’re interested!</strong>
|
||||
We’ll 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>
|
Loading…
Reference in New Issue
Block a user