2018-10-25 02:07:10 +00:00
|
|
|
const html = require('choo/html');
|
2019-03-01 20:56:10 +00:00
|
|
|
const assets = require('../../common/assets');
|
2019-02-08 17:44:21 +00:00
|
|
|
const { bytes, platform } = require('../utils');
|
2019-02-12 19:50:06 +00:00
|
|
|
const { canceledSignup, submittedSignup } = require('../metrics');
|
2018-10-25 02:07:10 +00:00
|
|
|
|
2019-02-12 19:50:06 +00:00
|
|
|
module.exports = function(trigger) {
|
2018-10-25 02:07:10 +00:00
|
|
|
return function(state, emit, close) {
|
2019-02-26 18:39:50 +00:00
|
|
|
const DAYS = Math.floor(state.LIMITS.MAX_EXPIRE_SECONDS / 86400);
|
2019-02-08 17:44:21 +00:00
|
|
|
const hidden = platform() === 'android' ? 'hidden' : '';
|
|
|
|
let submitting = false;
|
2018-10-25 02:07:10 +00:00
|
|
|
return html`
|
2019-03-01 20:56:10 +00:00
|
|
|
<send-signup-dialog
|
2019-03-02 00:19:55 +00:00
|
|
|
class="flex flex-col lg:flex-row justify-center px-8 md:px-24 w-full h-full"
|
2019-03-01 20:56:10 +00:00
|
|
|
>
|
2019-03-01 22:12:23 +00:00
|
|
|
<img
|
|
|
|
src="${assets.get('firefox_logo-only.svg')}"
|
|
|
|
class="h-16 mt-1 mb-4"
|
|
|
|
/>
|
2019-03-02 00:19:55 +00:00
|
|
|
<section
|
|
|
|
class="flex flex-col flex-no-shrink self-center lg:mx-6 lg:max-w-xs"
|
|
|
|
>
|
|
|
|
<h1 class="font-bold text-center lg:text-left">
|
|
|
|
${state.translate('accountBenefitTitle')}
|
|
|
|
</h1>
|
|
|
|
<ul
|
|
|
|
class="leading-normal text-grey-darkest my-2 mt-4 pl-4 md:self-center"
|
|
|
|
>
|
2019-03-01 20:56:10 +00:00
|
|
|
<li>
|
|
|
|
${state.translate('accountBenefitLargeFiles', {
|
|
|
|
size: bytes(state.LIMITS.MAX_FILE_SIZE)
|
|
|
|
})}
|
|
|
|
</li>
|
2019-03-04 22:13:18 +00:00
|
|
|
<li>${state.translate('accountBenefitDownloadCount')}</li>
|
2019-03-01 20:56:10 +00:00
|
|
|
<li>
|
2019-03-04 22:13:18 +00:00
|
|
|
${state.translate('accountBenefitTimeLimit', { count: DAYS })}
|
2019-03-01 20:56:10 +00:00
|
|
|
</li>
|
|
|
|
<li>${state.translate('accountBenefitSync')}</li>
|
2019-03-04 22:13:18 +00:00
|
|
|
<li>${state.translate('accountBenefitMoz')}</li>
|
2019-03-01 20:56:10 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
2019-03-02 00:19:55 +00:00
|
|
|
<section
|
|
|
|
class="flex flex-col flex-grow m-4 md:self-center md:w-128 lg:max-w-xs"
|
|
|
|
>
|
2019-03-01 20:56:10 +00:00
|
|
|
<form onsubmit=${submitEmail} data-no-csrf>
|
|
|
|
<input
|
|
|
|
id="email-input"
|
2019-03-03 01:05:58 +00:00
|
|
|
type="email"
|
2019-03-01 20:56:10 +00:00
|
|
|
class="${hidden} border rounded-lg w-full px-2 py-1 h-12 mb-3 text-lg text-grey-darker leading-loose"
|
2019-03-04 22:13:18 +00:00
|
|
|
placeholder=${state.translate('emailPlaceholder')}
|
2019-03-01 20:56:10 +00:00
|
|
|
/>
|
|
|
|
<input
|
|
|
|
class="btn rounded-lg w-full flex flex-no-shrink items-center justify-center"
|
2019-03-04 22:13:18 +00:00
|
|
|
value="${state.translate('signInButton')}"
|
|
|
|
title="${state.translate('signInButton')}"
|
2019-03-01 20:56:10 +00:00
|
|
|
id="email-submit"
|
|
|
|
type="submit"
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
<button
|
|
|
|
class="my-3 text-blue-dark hover:text-blue-darker focus:text-blue-darker font-medium"
|
|
|
|
title="${state.translate('deletePopupCancel')}"
|
|
|
|
onclick=${cancel}
|
|
|
|
>
|
|
|
|
${state.translate('deletePopupCancel')}
|
|
|
|
</button>
|
|
|
|
</section>
|
|
|
|
</send-signup-dialog>
|
|
|
|
`;
|
2018-10-25 02:07:10 +00:00
|
|
|
|
2018-12-21 19:40:52 +00:00
|
|
|
function emailish(str) {
|
|
|
|
if (!str) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// just check if it's the right shape
|
|
|
|
const a = str.split('@');
|
|
|
|
return a.length === 2 && a.every(s => s.length > 0);
|
|
|
|
}
|
|
|
|
|
2019-02-12 19:50:06 +00:00
|
|
|
function cancel(event) {
|
|
|
|
canceledSignup({ trigger });
|
|
|
|
close(event);
|
|
|
|
}
|
|
|
|
|
2018-10-25 02:07:10 +00:00
|
|
|
function submitEmail(event) {
|
|
|
|
event.preventDefault();
|
2019-02-08 17:44:21 +00:00
|
|
|
if (submitting) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
submitting = true;
|
|
|
|
|
2018-10-25 02:07:10 +00:00
|
|
|
const el = document.getElementById('email-input');
|
|
|
|
const email = el.value;
|
2019-02-12 19:50:06 +00:00
|
|
|
submittedSignup({ trigger });
|
2018-12-21 19:40:52 +00:00
|
|
|
emit('login', emailish(email) ? email : null);
|
2018-10-25 02:07:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|