mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 17:02:17 -05:00
Merge pull request #104 from whiteout-io/dev/WO-498
[WO-498] Add newsletter signup
This commit is contained in:
commit
d278afb253
@ -19,6 +19,9 @@ define(function(require) {
|
|||||||
// scope functions
|
// scope functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue to key import screen
|
||||||
|
*/
|
||||||
$scope.importKey = function() {
|
$scope.importKey = function() {
|
||||||
if (!$scope.state.agree) {
|
if (!$scope.state.agree) {
|
||||||
$scope.onError({
|
$scope.onError({
|
||||||
@ -27,9 +30,15 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sing up to newsletter
|
||||||
|
$scope.signUpToNewsletter();
|
||||||
|
// go to key import
|
||||||
$location.path('/login-new-device');
|
$location.path('/login-new-device');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue to set passphrase screen for keygen
|
||||||
|
*/
|
||||||
$scope.setPassphrase = function() {
|
$scope.setPassphrase = function() {
|
||||||
if (!$scope.state.agree) {
|
if (!$scope.state.agree) {
|
||||||
$scope.onError({
|
$scope.onError({
|
||||||
@ -38,9 +47,46 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sing up to newsletter
|
||||||
|
$scope.signUpToNewsletter();
|
||||||
|
// go to set passphrase screen
|
||||||
$scope.setState(states.SET_PASSPHRASE);
|
$scope.setState(states.SET_PASSPHRASE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [signUpToNewsletter description]
|
||||||
|
* @param {Function} callback (optional)
|
||||||
|
*/
|
||||||
|
$scope.signUpToNewsletter = function(callback) {
|
||||||
|
if (!$scope.state.newsletter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var address = emailDao._account.emailAddress;
|
||||||
|
var uri = 'https://whiteout.us8.list-manage.com/subscribe/post?u=52ea5a9e1be9e1d194f184158&id=6538e8f09f';
|
||||||
|
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('EMAIL', address);
|
||||||
|
formData.append('b_52ea5a9e1be9e1d194f184158_6538e8f09f', '');
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('post', uri, true);
|
||||||
|
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (callback) {
|
||||||
|
callback(null, xhr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.onerror = function(err) {
|
||||||
|
if (callback) {
|
||||||
|
callback(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.send(formData);
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Taken from jQuery validate.password plug-in 1.0
|
* Taken from jQuery validate.password plug-in 1.0
|
||||||
* http://bassistance.de/jquery-plugins/jquery-plugin-validate.password/
|
* http://bassistance.de/jquery-plugins/jquery-plugin-validate.password/
|
||||||
|
@ -37,6 +37,10 @@ textarea {
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
border: 1px solid $color-grey-lighter;
|
||||||
|
}
|
||||||
|
|
||||||
// Basic layout
|
// Basic layout
|
||||||
.main-app-view {
|
.main-app-view {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -119,11 +119,24 @@
|
|||||||
|
|
||||||
.view-login-initial {
|
.view-login-initial {
|
||||||
.content {
|
.content {
|
||||||
|
form {
|
||||||
|
.option {
|
||||||
|
width: 90%;
|
||||||
|
font-size: $font-size-small;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.terms {
|
.terms {
|
||||||
|
margin-top: 30px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsletter {
|
||||||
margin-bottom: 40px;
|
margin-bottom: 40px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.view-login-privatekey-download {
|
.view-login-privatekey-download {
|
||||||
.content {
|
.content {
|
||||||
|
@ -9,11 +9,16 @@
|
|||||||
<p><b>PGP key.</b> You can either import an existing PGP key or generate a new one. Your private key remains on your device and is not sent to our servers.</p>
|
<p><b>PGP key.</b> You can either import an existing PGP key or generate a new one. Your private key remains on your device and is not sent to our servers.</p>
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
<div class="terms">
|
<div class="option terms">
|
||||||
<input type="checkbox" ng-model="state.agree" id="cb-agree">
|
<input type="checkbox" ng-model="state.agree" id="cb-agree">
|
||||||
<label for="cb-agree">I agree to the Whiteout Networks <a href="https://whiteout.io/terms.html" target="_blank">Terms of Service</a> and have read the <a href="https://whiteout.io/privacy-service.html" target="_blank">Privacy Policy</a>.</label>
|
<label for="cb-agree">I agree to the Whiteout Networks <a href="https://whiteout.io/terms.html" target="_blank">Terms of Service</a> and have read the <a href="https://whiteout.io/privacy-service.html" target="_blank">Privacy Policy</a>.</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="option newsletter">
|
||||||
|
<input type="checkbox" ng-model="state.newsletter" id="cb-newsletter">
|
||||||
|
<label for="cb-newsletter">Stay up to date on Whiteout Networks products and important announcements.</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button wo-touch="importKey()" class="btn btn-alt">Import existing key</button>
|
<button wo-touch="importKey()" class="btn btn-alt">Import existing key</button>
|
||||||
<button type="submit" wo-touch="setPassphrase()" class="btn"tabindex="3">Generate new key</button>
|
<button type="submit" wo-touch="setPassphrase()" class="btn"tabindex="3">Generate new key</button>
|
||||||
|
@ -62,12 +62,69 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('signUpToNewsletter', function() {
|
||||||
|
var xhrMock, requests;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
xhrMock = sinon.useFakeXMLHttpRequest();
|
||||||
|
requests = [];
|
||||||
|
|
||||||
|
xhrMock.onCreate = function(xhr) {
|
||||||
|
requests.push(xhr);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
xhrMock.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not signup', function() {
|
||||||
|
scope.state.newsletter = false;
|
||||||
|
|
||||||
|
scope.signUpToNewsletter();
|
||||||
|
expect(requests.length).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail', function(done) {
|
||||||
|
scope.state.newsletter = true;
|
||||||
|
|
||||||
|
scope.signUpToNewsletter(function(err, xhr) {
|
||||||
|
expect(err).to.exist;
|
||||||
|
expect(xhr).to.not.exist;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(requests.length).to.equal(1);
|
||||||
|
requests[0].onerror('err');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work without callback', function() {
|
||||||
|
scope.state.newsletter = true;
|
||||||
|
|
||||||
|
scope.signUpToNewsletter();
|
||||||
|
|
||||||
|
expect(requests.length).to.equal(1);
|
||||||
|
requests[0].respond(200, {
|
||||||
|
"Content-Type": "text/plain"
|
||||||
|
}, 'foobar!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('go to import key', function() {
|
describe('go to import key', function() {
|
||||||
|
var signUpToNewsletterStub;
|
||||||
|
beforeEach(function() {
|
||||||
|
signUpToNewsletterStub = sinon.stub(scope, 'signUpToNewsletter');
|
||||||
|
});
|
||||||
|
afterEach(function() {
|
||||||
|
signUpToNewsletterStub.restore();
|
||||||
|
});
|
||||||
|
|
||||||
it('should not continue if terms are not accepted', function(done) {
|
it('should not continue if terms are not accepted', function(done) {
|
||||||
scope.state.agree = undefined;
|
scope.state.agree = undefined;
|
||||||
|
|
||||||
scope.onError = function(err) {
|
scope.onError = function(err) {
|
||||||
expect(err.message).to.contain('Terms');
|
expect(err.message).to.contain('Terms');
|
||||||
|
expect(signUpToNewsletterStub.called).to.be.false;
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -77,6 +134,7 @@ define(function(require) {
|
|||||||
it('should work', function() {
|
it('should work', function() {
|
||||||
scope.state.agree = true;
|
scope.state.agree = true;
|
||||||
scope.importKey();
|
scope.importKey();
|
||||||
|
expect(signUpToNewsletterStub.calledOnce).to.be.true;
|
||||||
expect(location.$$path).to.equal('/login-new-device');
|
expect(location.$$path).to.equal('/login-new-device');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -124,11 +182,20 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('setPassphrase', function() {
|
describe('setPassphrase', function() {
|
||||||
|
var signUpToNewsletterStub;
|
||||||
|
beforeEach(function() {
|
||||||
|
signUpToNewsletterStub = sinon.stub(scope, 'signUpToNewsletter');
|
||||||
|
});
|
||||||
|
afterEach(function() {
|
||||||
|
signUpToNewsletterStub.restore();
|
||||||
|
});
|
||||||
|
|
||||||
it('should not continue if terms are not accepted', function(done) {
|
it('should not continue if terms are not accepted', function(done) {
|
||||||
scope.state.agree = undefined;
|
scope.state.agree = undefined;
|
||||||
|
|
||||||
scope.onError = function(err) {
|
scope.onError = function(err) {
|
||||||
expect(err.message).to.contain('Terms');
|
expect(err.message).to.contain('Terms');
|
||||||
|
expect(signUpToNewsletterStub.called).to.be.false;
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,6 +207,7 @@ define(function(require) {
|
|||||||
|
|
||||||
var setStateStub = sinon.stub(scope, 'setState', function(state) {
|
var setStateStub = sinon.stub(scope, 'setState', function(state) {
|
||||||
expect(setStateStub.calledOnce).to.be.true;
|
expect(setStateStub.calledOnce).to.be.true;
|
||||||
|
expect(signUpToNewsletterStub.calledOnce).to.be.true;
|
||||||
expect(state).to.equal(2);
|
expect(state).to.equal(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user