2018-10-25 04:07:10 +02:00
|
|
|
/* global LIMITS */
|
|
|
|
const html = require('choo/html');
|
2019-02-08 18:44:21 +01:00
|
|
|
const { bytes, platform } = require('../utils');
|
2018-10-25 04:07:10 +02:00
|
|
|
|
|
|
|
module.exports = function() {
|
|
|
|
return function(state, emit, close) {
|
2019-02-08 18:44:21 +01:00
|
|
|
const hidden = platform() === 'android' ? 'hidden' : '';
|
|
|
|
let submitting = false;
|
2018-10-25 04:07:10 +02:00
|
|
|
return html`
|
2019-01-11 01:22:40 +01:00
|
|
|
<send-signup-dialog class="flex flex-col p-4">
|
2018-10-25 04:07:10 +02:00
|
|
|
<p class="p-8">
|
|
|
|
${state.translate('accountBenefitTitle')}
|
2018-11-02 10:27:59 +01:00
|
|
|
<ul class="my-2 leading-normal">
|
2018-10-25 04:07:10 +02:00
|
|
|
<li>${state.translate('accountBenefitLargeFiles', {
|
|
|
|
size: bytes(LIMITS.MAX_FILE_SIZE)
|
|
|
|
})}</li>
|
|
|
|
<li>${state.translate('accountBenefitExpiry')}</li>
|
|
|
|
<li>${state.translate('accountBenefitSync')}</li>
|
|
|
|
</ul>
|
|
|
|
</p>
|
|
|
|
<form
|
|
|
|
onsubmit=${submitEmail}
|
|
|
|
data-no-csrf>
|
|
|
|
<input
|
|
|
|
id="email-input"
|
|
|
|
type="text"
|
2019-02-08 18:44:21 +01:00
|
|
|
class="${hidden} border rounded w-full px-2 py-1 h-12 mb-4 text-lg text-grey-darker leading-loose"
|
|
|
|
placeholder=${state.translate('emailEntryPlaceholder')} />
|
2018-10-25 04:07:10 +02:00
|
|
|
<input
|
|
|
|
class="hidden"
|
|
|
|
id="email-submit"
|
2019-02-08 18:44:21 +01:00
|
|
|
type="submit" />
|
2018-10-25 04:07:10 +02:00
|
|
|
</form>
|
2019-01-16 21:38:43 +01:00
|
|
|
<label class="btn rounded w-full flex flex-no-shrink items-center justify-center" for="email-submit">
|
2018-10-25 04:07:10 +02:00
|
|
|
${state.translate('signInMenuOption')}
|
|
|
|
</label>
|
|
|
|
<button
|
2019-01-18 09:09:17 +01:00
|
|
|
class="my-4 text-blue hover:text-blue-dark focus:text-blue-darker font-medium"
|
2018-10-25 04:07:10 +02:00
|
|
|
title="${state.translate('deletePopupCancel')}"
|
|
|
|
onclick=${close}>${state.translate('deletePopupCancel')}
|
|
|
|
</button>
|
2019-01-11 01:22:40 +01:00
|
|
|
</send-signup-dialog>`;
|
2018-10-25 04:07:10 +02:00
|
|
|
|
2018-12-21 20:40:52 +01: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);
|
|
|
|
}
|
|
|
|
|
2018-10-25 04:07:10 +02:00
|
|
|
function submitEmail(event) {
|
|
|
|
event.preventDefault();
|
2019-02-08 18:44:21 +01:00
|
|
|
if (submitting) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
submitting = true;
|
|
|
|
|
2018-10-25 04:07:10 +02:00
|
|
|
const el = document.getElementById('email-input');
|
|
|
|
const email = el.value;
|
2018-12-21 20:40:52 +01:00
|
|
|
emit('login', emailish(email) ? email : null);
|
2018-10-25 04:07:10 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|