From a27ddb40beb3d124ab1b1101c4f9cc645bf5e728 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 6 Aug 2023 12:34:26 +0100 Subject: [PATCH] navbar, blank page desc and drag drop append --- src/main/resources/messages_en_GB.properties | 6 +++--- src/main/resources/static/js/fileInput.js | 17 +++++++++++++---- .../resources/templates/fragments/navbar.html | 9 +++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index d66ed9c5..bc01fb5f 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -403,10 +403,10 @@ certSign.submit=Sign PDF #removeBlanks removeBlanks.title=Remove Blanks removeBlanks.header=Remove Blank Pages -removeBlanks.threshold=Threshold: -removeBlanks.thresholdDesc=Threshold for determining how white a white pixel must be +removeBlanks.threshold=Pixel Whiteness Threshold: +removeBlanks.thresholdDesc=Threshold for determining how white a white pixel must be to be classed as 'White'. 0 = Black, 255 pure white. removeBlanks.whitePercent=White Percent (%): -removeBlanks.whitePercentDesc=Percent of page that must be white to be removed +removeBlanks.whitePercentDesc=Percent of page that must be 'white' pixels to be removed removeBlanks.submit=Remove Blanks diff --git a/src/main/resources/static/js/fileInput.js b/src/main/resources/static/js/fileInput.js index 0842462e..9379a7bf 100644 --- a/src/main/resources/static/js/fileInput.js +++ b/src/main/resources/static/js/fileInput.js @@ -6,7 +6,8 @@ function setupFileInput(chooser) { const elementId = chooser.getAttribute('data-element-id'); const filesSelected = chooser.getAttribute('data-files-selected'); const pdfPrompt = chooser.getAttribute('data-pdf-prompt'); - + + let allFiles = []; let overlay; let dragCounter = 0; @@ -42,11 +43,19 @@ function setupFileInput(chooser) { }; const dropListener = function(e) { + e.preventDefault(); const dt = e.dataTransfer; const files = dt.files; + for (let i = 0; i < files.length; i++) { + allFiles.push(files[i]); + } + + const dataTransfer = new DataTransfer(); + allFiles.forEach(file => dataTransfer.items.add(file)); + const fileInput = document.getElementById(elementId); - fileInput.files = files; + fileInput.files = dataTransfer.files; if (overlay) { overlay.remove(); @@ -76,8 +85,8 @@ function setupFileInput(chooser) { }); function handleFileInputChange(inputElement) { - const files = $(inputElement).get(0).files; - const fileNames = Array.from(files).map(f => f.name); + const files = allFiles; + const fileNames = files.map(f => f.name); const selectedFilesContainer = $(inputElement).siblings(".selected-files"); selectedFilesContainer.empty(); fileNames.forEach(fileName => { diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index ef84ef3e..c20a498c 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -40,7 +40,7 @@ -->
-