From 369ac99a165535d8c11c6e77b616eccd8e6ed7e4 Mon Sep 17 00:00:00 2001 From: Dimitrios Kaitantzidis Date: Sat, 14 Oct 2023 00:03:08 +0300 Subject: [PATCH] Fixes issue. --- .idea/.gitignore | 8 ++++++++ .../static/js/multitool/PdfActionsManager.js | 11 +++++++++++ .../static/js/multitool/PdfContainer.js | 18 +++++++++++++++--- src/main/resources/templates/multi-tool.html | 16 +++++++++++++++- 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/main/resources/static/js/multitool/PdfActionsManager.js b/src/main/resources/static/js/multitool/PdfActionsManager.js index 4bff39e3..3a4fd33d 100644 --- a/src/main/resources/static/js/multitool/PdfActionsManager.js +++ b/src/main/resources/static/js/multitool/PdfActionsManager.js @@ -55,6 +55,17 @@ class PdfActionsManager { deletePageButtonCallback(e) { var imgContainer = this.getPageContainer(e.target); this.pagesContainer.removeChild(imgContainer); + if (this.pagesContainer.childElementCount === 0) { + const filenameInput = document.getElementById('filename-input'); + const filenameParagraph = document.getElementById('filename'); + const downloadBtn = document.getElementById('export-button'); + + filenameInput.disabled = true; + filenameInput.value = ""; + filenameParagraph.innerText = ""; + + downloadBtn.disabled = true; + } }; insertFileButtonCallback(e) { diff --git a/src/main/resources/static/js/multitool/PdfContainer.js b/src/main/resources/static/js/multitool/PdfContainer.js index f7ffec36..570db8a5 100644 --- a/src/main/resources/static/js/multitool/PdfContainer.js +++ b/src/main/resources/static/js/multitool/PdfContainer.js @@ -34,8 +34,12 @@ class PdfContainer { window.rotateAll = this.rotateAll; const filenameInput = document.getElementById('filename-input'); + const filenameParagraph = document.getElementById('filename'); + filenameInput.onkeyup = this.updateFilename; filenameInput.disabled = true; + filenameInput.innerText = ""; + filenameParagraph.innerText = ""; } movePageTo(startElement, endElement, scrollTo = false) { @@ -70,8 +74,17 @@ class PdfContainer { const files = e.target.files; if (files.length > 0) { const filenameInput = document.getElementById('filename-input'); + const pagesContainer = document.getElementById('pages-container'); + const downloadBtn = document.getElementById('export-button'); + filenameInput.disabled = false; + downloadBtn.disabled = false; + + if (pagesContainer.childElementCount === 0) { + filenameInput.value = ""; + } } + this.addPdfsFromFiles(files, nextSiblingElement); } @@ -228,16 +241,15 @@ class PdfContainer { setDownloadAttribute() { console.log('inside setDownloadAttribute ' + this.filename); - this.downloadLink.setAttribute("download", this.filename); + this.downloadLink.setAttribute("download", this.filename ? this.filename : 'managed.pdf'); } updateFilename() { const filenameInput = document.getElementById('filename-input'); const filenameParagraph = document.getElementById('filename'); - console.log('updatedFilename fired ' + filenameInput.value); this.filename = filenameInput.value; - filenameParagraph.innerText = this.filename; + filenameParagraph.innerText = this.filename + ".pdf"; } } diff --git a/src/main/resources/templates/multi-tool.html b/src/main/resources/templates/multi-tool.html index 4266a795..2df41c0a 100644 --- a/src/main/resources/templates/multi-tool.html +++ b/src/main/resources/templates/multi-tool.html @@ -23,7 +23,7 @@
- +

Final name of file:

@@ -136,6 +136,20 @@ #global-buttons-container input:disabled { color: #3D3D3D !important; } + + #global-buttons-container input:disabled::-webkit-input-placeholder { /* WebKit browsers */ + color: #6E6865; + } + #global-buttons-container input:disabled:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ + color: #6E6865; + } + #global-buttons-container input:disabled::-moz-placeholder { /* Mozilla Firefox 19+ */ + color: #6E6865; + } + #global-buttons-container input:disabled:-ms-input-placeholder { /* Internet Explorer 10+ */ + color: #6E6865; + } + #global-buttons-container svg { width: 20px; height: 20px;