Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slimmer appearance of the user interface #2515

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/main/resources/static/js/enable-submit-on-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
document.addEventListener("DOMContentLoaded", () => {
const elementsContainer = document.getElementById("elementsContainer");
const slidersContainer = document.getElementById("sliders-container");
const infoContainer = document.getElementById("infoContainer");
const signaturesResults = document.getElementById("signatures-results");
const signaturesList = document.getElementById("signatures-list");
const canvasesContainer = document.getElementById("canvasesContainer");

const selectedFiles = document.getElementsByClassName("selected-files");
const fileInput = document.getElementById("fileInput-input");

if (!fileInput || !elementsContainer || selectedFiles.length === 0) return;

function toggleVisibility(element, show) {
if (element) {
element.style.display = show ? "block" : "none";
}
}

const observer = new MutationObserver((mutationsList) => {
mutationsList.forEach((mutation) => {
if (mutation.type === "childList") {
const hasChildren = selectedFiles[0]?.childNodes.length > 0;

toggleVisibility(elementsContainer, hasChildren);
toggleVisibility(slidersContainer, hasChildren);
toggleVisibility(infoContainer, hasChildren);
toggleVisibility(canvasesContainer, hasChildren);

if (!hasChildren) {
toggleVisibility(signaturesResults, false);
if (signaturesList) {
signaturesList.textContent = "";
}
}
}
});
});

observer.observe(selectedFiles[0], { childList: true });
});
11 changes: 5 additions & 6 deletions src/main/resources/static/js/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,14 @@ function updateFiles() {

document.querySelector("#resetFileInputBtn").addEventListener("click", ()=>{
let formElement = document.querySelector("#fileInput-input");
formElement.value = '';
clearLiElements();
updateFiles();

formElement.value = '';
clearLiElements();
updateFiles();
});

function clearLiElements(){
let listGroupItemNodeList = document.querySelectorAll(".list-group-item");
for (let i = 0; i < listGroupItemNodeList.length; i++) {
listGroupItemNodeList[i].remove();
};
}
};
}
31 changes: 16 additions & 15 deletions src/main/resources/static/js/pages/add-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ document.getElementById('download-pdf').addEventListener('click', async () => {
link.click();
});
let originalFileName = '';
document.querySelector('input[name=pdf-upload]').addEventListener('change', async (event) => {
document.querySelector('input[name=fileInput]').addEventListener('change', async (event) => {
const fileInput = event.target;
fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
originalFileName = file.name.replace(/\.[^/.]+$/, '');
const pdfData = await file.arrayBuffer();
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdfDoc = await pdfjsLib.getDocument({data: pdfData}).promise;
await DraggableUtils.renderPage(pdfDoc, 0);
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
originalFileName = file.name.replace(/\.[^/.]+$/, '');
const pdfData = await file.arrayBuffer();
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdfDoc = await pdfjsLib.getDocument({data: pdfData}).promise;
await DraggableUtils.renderPage(pdfDoc, 0);

document.querySelectorAll('.show-on-file-selected').forEach((el) => {
el.style.cssText = '';
});
document.querySelectorAll('.show-on-file-selected').forEach((el) => {
el.style.cssText = '';
});
}
}
});
});

document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.show-on-file-selected').forEach((el) => {
el.style.cssText = 'display:none !important';
Expand All @@ -34,9 +37,7 @@ document.addEventListener('DOMContentLoaded', () => {

const imageUpload = document.querySelector('input[name=image-upload]');
imageUpload.addEventListener('change', (e) => {
if (!e.target.files) {
return;
}
if (!e.target.files) return;
for (const imageFile of e.target.files) {
var reader = new FileReader();
reader.readAsDataURL(imageFile);
Expand Down
12 changes: 7 additions & 5 deletions src/main/resources/static/js/pages/adjust-contrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,13 @@ async function downloadPDF() {
document.getElementById('fileInput-input').addEventListener('change', function (e) {
const fileInput = e.target;
fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
inputFileName = file.name;
renderPDFAndSaveOriginalImageData(file);
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
inputFileName = file.name;
renderPDFAndSaveOriginalImageData(file);
}
}
});
});
Expand Down
80 changes: 41 additions & 39 deletions src/main/resources/static/js/pages/change-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,49 @@ var lastPDFFile = null;

fileInput.addEventListener('change', async function () {
fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
while (otherMetadataEntriesDiv.firstChild) {
otherMetadataEntriesDiv.removeChild(otherMetadataEntriesDiv.firstChild);
}
while (customMetadataFormContainer.firstChild) {
customMetadataFormContainer.removeChild(customMetadataFormContainer.firstChild);
}
var url = URL.createObjectURL(file);
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdf = await pdfjsLib.getDocument(url).promise;
const pdfMetadata = await pdf.getMetadata();
lastPDFFile = pdfMetadata?.info;
console.log(pdfMetadata);
if (!pdfMetadata?.info?.Custom || pdfMetadata?.info?.Custom.size == 0) {
customModeCheckbox.disabled = true;
customModeCheckbox.checked = false;
} else {
customModeCheckbox.disabled = false;
}
authorInput.value = pdfMetadata?.info?.Author;
creationDateInput.value = convertDateFormat(pdfMetadata?.info?.CreationDate);
creatorInput.value = pdfMetadata?.info?.Creator;
keywordsInput.value = pdfMetadata?.info?.Keywords;
modificationDateInput.value = convertDateFormat(pdfMetadata?.info?.ModDate);
producerInput.value = pdfMetadata?.info?.Producer;
subjectInput.value = pdfMetadata?.info?.Subject;
titleInput.value = pdfMetadata?.info?.Title;
console.log(pdfMetadata?.info);
const trappedValue = pdfMetadata?.info?.Trapped;
// Get all options in the select element
const options = trappedInput.options;
// Loop through all options to find the one with a matching value
for (let i = 0; i < options.length; i++) {
if (options[i].value === trappedValue) {
options[i].selected = true;
break;
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
while (otherMetadataEntriesDiv.firstChild) {
otherMetadataEntriesDiv.removeChild(otherMetadataEntriesDiv.firstChild);
}
while (customMetadataFormContainer.firstChild) {
customMetadataFormContainer.removeChild(customMetadataFormContainer.firstChild);
}
var url = URL.createObjectURL(file);
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdf = await pdfjsLib.getDocument(url).promise;
const pdfMetadata = await pdf.getMetadata();
lastPDFFile = pdfMetadata?.info;
console.log(pdfMetadata);
if (!pdfMetadata?.info?.Custom || pdfMetadata?.info?.Custom.size == 0) {
customModeCheckbox.disabled = true;
customModeCheckbox.checked = false;
} else {
customModeCheckbox.disabled = false;
}
authorInput.value = pdfMetadata?.info?.Author;
creationDateInput.value = convertDateFormat(pdfMetadata?.info?.CreationDate);
creatorInput.value = pdfMetadata?.info?.Creator;
keywordsInput.value = pdfMetadata?.info?.Keywords;
modificationDateInput.value = convertDateFormat(pdfMetadata?.info?.ModDate);
producerInput.value = pdfMetadata?.info?.Producer;
subjectInput.value = pdfMetadata?.info?.Subject;
titleInput.value = pdfMetadata?.info?.Title;
console.log(pdfMetadata?.info);
const trappedValue = pdfMetadata?.info?.Trapped;
// Get all options in the select element
const options = trappedInput.options;
// Loop through all options to find the one with a matching value
for (let i = 0; i < options.length; i++) {
if (options[i].value === trappedValue) {
options[i].selected = true;
break;
}
}
addExtra();
}
addExtra();
}
});
});
Expand Down
12 changes: 7 additions & 5 deletions src/main/resources/static/js/pages/crop.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ window.addEventListener('resize', function () {

fileInput.addEventListener('change', function (e) {
fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
canvasesContainer.style.display = 'block'; // set for visual purposes
let file = allFiles[0];
renderPageFromFile(file);
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
canvasesContainer.style.display = 'block'; // set for visual purposes
let file = allFiles[0];
renderPageFromFile(file);
}
}
});
});
Expand Down
12 changes: 7 additions & 5 deletions src/main/resources/static/js/pages/pdf-to-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ window.addEventListener('resize', function () {

fileInput.addEventListener('change', function (e) {
fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
canvasesContainer.style.display = 'block'; // set for visual purposes
file = e.target.files[0];
renderPageFromFile(file);
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
canvasesContainer.style.display = 'block'; // set for visual purposes
file = e.target.files[0];
renderPageFromFile(file);
}
}
});
});
Expand Down
29 changes: 16 additions & 13 deletions src/main/resources/static/js/pages/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,24 @@ function addSignatureFromPreview() {
}

let originalFileName = '';
document.querySelector('input[name=pdf-upload]').addEventListener('change', async (event) => {
document.querySelector('input[name=fileInput]').addEventListener('change', async (event) => {
const fileInput = event.target;

fileInput.addEventListener('file-input-change', async (e) => {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
originalFileName = file.name.replace(/\.[^/.]+$/, '');
const pdfData = await file.arrayBuffer();
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdfDoc = await pdfjsLib.getDocument({data: pdfData}).promise;
await DraggableUtils.renderPage(pdfDoc, 0);

document.querySelectorAll('.show-on-file-selected').forEach((el) => {
el.style.cssText = '';
});
if (e.detail) {
const {allFiles} = e.detail;
if (allFiles && allFiles.length > 0) {
const file = allFiles[0];
originalFileName = file.name.replace(/\.[^/.]+$/, '');
const pdfData = await file.arrayBuffer();
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
const pdfDoc = await pdfjsLib.getDocument({data: pdfData}).promise;
await DraggableUtils.renderPage(pdfDoc, 0);

document.querySelectorAll('.show-on-file-selected').forEach((el) => {
el.style.cssText = '';
});
}
}
});
});
Expand Down
15 changes: 8 additions & 7 deletions src/main/resources/templates/auto-split-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
<div
th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}">
</div>
<div class="form-check ms-3">
<input type="checkbox" name="duplexMode" id="duplexMode">
<label for="duplexMode" th:text=#{autoSplitPDF.duplexMode}></label>
</div>
<p>
<a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#info" role="button"
aria-expanded="false" aria-controls="info" th:text="#{info}"></a>
<a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#info" role="button" aria-expanded="false" aria-controls="info" th:text="#{info}"></a>
</p>
<div class="collapse" id="info">
<!-- Added a brief description -->
Expand All @@ -48,8 +43,14 @@
<p><a th:href="@{'/files/Auto%20Splitter%20Divider%20(with%20instructions).pdf'}" download
th:text="#{autoSplitPDF.dividerDownload2}"></a></p>
</div>
<div id="elementsContainer" style="display: none;">
<div class="form-check ms-3">
<input type="checkbox" name="duplexMode" id="duplexMode">
<label for="duplexMode" th:text=#{autoSplitPDF.duplexMode}></label>
</div>

<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{autoSplitPDF.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{autoSplitPDF.submit}"></button>
</div>
</form>
</div>
</div>
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/templates/convert/book-to-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
<br><br>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<h2 th:text="#{BookToPDF.header}"></h2>
<div class="col-md-6 bg-card">
<div class="tool-header">
<span class="material-symbols-rounded tool-header-icon advance">book</span>
<span class="tool-header-text" th:text="#{BookToPDF.header}"></span>
</div>
<form method="post" enctype="multipart/form-data" th:action="@{'/api/v1/convert/book/pdf'}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false)}"></div>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{BookToPDF.submit}"></button>
<div id="elementsContainer" style="display: none;">
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{BookToPDF.submit}"></button>
</div>
</form>
<p class="mt-3" th:text="#{BookToPDF.credit}"></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/convert/file-to-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<a
href="https://help.libreoffice.org/latest/en-US/text/shared/guide/supported_formats.html">https://help.libreoffice.org/latest/en-US/text/shared/guide/supported_formats.html</a>
</div>
<div>
<div id="elementsContainer" style="display: none;">
<br/>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{fileToPDF.submit}"></button>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/main/resources/templates/convert/html-to-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
<span class="tool-header-text" th:text="#{HTMLToPDF.header}"></span>
</div>
<form method="post" enctype="multipart/form-data" th:action="@{'/api/v1/convert/html/pdf'}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='text/html,application/zip' )}"></div>
<div class="mb-3">
<label for="zoom" th:text="#{HTMLToPDF.zoom}" class="form-label"></label>
<input type="number" step="0.1" class="form-control" id="zoom" name="zoom" value="1">
<p class="mt-3" th:text="#{HTMLToPDF.help}"></p>
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='text/html,application/zip')}"></div>
<div id="elementsContainer" style="display: none;">
<div class="mb-3">
<label for="zoom" th:text="#{HTMLToPDF.zoom}" class="form-label"></label>
<input type="number" step="0.1" class="form-control" id="zoom" name="zoom" value="1">
</div>
<br>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{HTMLToPDF.submit}"></button>
</div>
<br>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{HTMLToPDF.submit}"></button>
</form>
<p class="mt-3" th:text="#{HTMLToPDF.help}"></p>
<p class="mt-3" th:text="#{HTMLToPDF.credit}"></p>
</div>
</div>
Expand Down
Loading
Loading