24
1
Fork 0
drop.chapril.org-firefoxsend/app/ui/shareDialog.js

65 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-03-10 02:59:06 +01:00
const html = require('choo/html');
/* Possible strings for l10n
shareLinkDescription = Share the link to your file:
shareLinkButton = Share link
2019-03-10 05:40:06 +01:00
shareMessage = Download "{ $name }" with { -send-brand }: simple, safe file sharing
2019-03-10 02:59:06 +01:00
*/
module.exports = function(name, url) {
return function(state, emit, close) {
return html`
<send-share-dialog
class="flex flex-col items-center text-center p-4 max-w-sm m-auto"
>
<h1 class="font-bold my-4">
${state.translate('notifyUploadEncryptDone')}
</h1>
<p class="font-normal leading-normal text-grey-darkest word-break-all">
Share the link to your file:<br />
${name}
</p>
<input
type="text"
id="share-url"
class="w-full my-4 border rounded-lg leading-loose h-12 px-2 py-1"
value="${url}"
readonly="true"
/>
<button
class="btn rounded-lg w-full flex-no-shrink focus:outline"
onclick="${share}"
title="Share link"
>
Share link
</button>
<button
class="text-blue-dark hover:text-blue-darker focus:text-blue-darker my-4 font-medium cursor-pointer focus:outline"
onclick="${close}"
title="${state.translate('okButton')}"
>
${state.translate('okButton')}
</button>
</send-share-dialog>
`;
async function share(event) {
event.stopPropagation();
try {
await navigator.share({
title: state.translate('-send-brand'),
2019-03-10 05:40:06 +01:00
text: `Download "${name}" with Firefox Send: simple, safe file sharing`,
2019-03-10 02:59:06 +01:00
//state.translate('shareMessage', { name }),
url
});
} catch (e) {
2019-03-10 05:40:06 +01:00
if (e.code === e.ABORT_ERR) {
return;
}
2019-03-10 02:59:06 +01:00
console.error(e);
}
2019-03-10 05:40:06 +01:00
close();
2019-03-10 02:59:06 +01:00
}
};
};