From a576cc0198477578473e1407567c224d3866ed2d Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 24 Jul 2017 12:42:16 -0700 Subject: [PATCH 1/2] dealing with invalid drag and drops --- frontend/src/upload.js | 7 +++++++ public/locales/send.en-US.ftl | 1 + 2 files changed, 8 insertions(+) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 85c6fedc..ca8835e5 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -143,6 +143,13 @@ $(document).ready(function() { let file = ''; if (event.type === 'drop') { + if (!event.originalEvent.dataTransfer.files[0]) { + $('.upload-window').removeClass('ondrag'); + document.l10n.formatValue('uploadValidFile').then(str => { + alert(str); + }); + return; + } if ( event.originalEvent.dataTransfer.files.length > 1 || event.originalEvent.dataTransfer.files[0].size === 0 diff --git a/public/locales/send.en-US.ftl b/public/locales/send.en-US.ftl index bf6bae19..c9a9503d 100644 --- a/public/locales/send.en-US.ftl +++ b/public/locales/send.en-US.ftl @@ -11,6 +11,7 @@ uploadPageSizeMessage = For the most reliable operation, it’s best to keep you uploadPageBrowseButton = Select a file on your computer .title = {uploadPageBrowseButtonTitle} uploadPageMultipleFilesAlert = Uploading multiple files or a folder is currently not supported. +uploadValidFile = Please drag a valid file to upload. uploadPageBrowseButtonTitle = Upload file From c3be5228cbaae3eedf3b00af8f633e2e83921f55 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 24 Jul 2017 13:35:40 -0700 Subject: [PATCH 2/2] removing dialog --- frontend/src/upload.js | 3 --- public/locales/send.en-US.ftl | 1 - 2 files changed, 4 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index ca8835e5..6d658505 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -145,9 +145,6 @@ $(document).ready(function() { if (event.type === 'drop') { if (!event.originalEvent.dataTransfer.files[0]) { $('.upload-window').removeClass('ondrag'); - document.l10n.formatValue('uploadValidFile').then(str => { - alert(str); - }); return; } if ( diff --git a/public/locales/send.en-US.ftl b/public/locales/send.en-US.ftl index c9a9503d..bf6bae19 100644 --- a/public/locales/send.en-US.ftl +++ b/public/locales/send.en-US.ftl @@ -11,7 +11,6 @@ uploadPageSizeMessage = For the most reliable operation, it’s best to keep you uploadPageBrowseButton = Select a file on your computer .title = {uploadPageBrowseButtonTitle} uploadPageMultipleFilesAlert = Uploading multiple files or a folder is currently not supported. -uploadValidFile = Please drag a valid file to upload. uploadPageBrowseButtonTitle = Upload file