1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00

metadata: suppression metadonnée

This commit is contained in:
Gabriel Poma 2023-04-19 13:00:30 +02:00
parent b037685c57
commit cbea7de840
2 changed files with 30 additions and 2 deletions

View File

@ -63,6 +63,15 @@
border-color: transparent !important; border-color: transparent !important;
} }
.delete-metadata {
cursor: pointer;
position: absolute;
right: -20px;
top: 0;
font-size: 1.2rem;
user-select: none;
}
@media (max-width: 480px) { @media (max-width: 480px) {
.subtitle { .subtitle {
font-size: .875em font-size: .875em

View File

@ -52,19 +52,32 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
var addMetadata = function(key, value) { var addMetadata = function(key, value) {
let div = document.createElement('div'); let div = document.createElement('div');
div.classList.add('form-floating'); div.classList.add('form-floating', 'mt-3', 'input-metadata');
div.classList.add('mt-3');
let input = document.createElement('input'); let input = document.createElement('input');
input.value = value; input.value = value;
input.classList.add('form-control'); input.classList.add('form-control');
let label = document.createElement('label'); let label = document.createElement('label');
label.innerText = key; label.innerText = key;
let deleteButton = document.createElement('div')
deleteButton.innerHTML = "×"
deleteButton.classList.add('delete-metadata')
div.appendChild(input); div.appendChild(input);
div.appendChild(label); div.appendChild(label);
div.appendChild(deleteButton);
document.getElementById('form-metadata-container').appendChild(div); document.getElementById('form-metadata-container').appendChild(div);
input.focus(); input.focus();
} }
const deleteMetadata = function(el) {
const input = el.closest('.input-metadata')
input.remove()
}
var createEventsListener = function() { var createEventsListener = function() {
document.getElementById('form_metadata_add').addEventListener('submit', function(e) { document.getElementById('form_metadata_add').addEventListener('submit', function(e) {
let formData = new FormData(this); let formData = new FormData(this);
@ -72,6 +85,12 @@ var createEventsListener = function() {
this.reset(); this.reset();
e.preventDefault(); e.preventDefault();
}) })
document.addEventListener('click', function (event) {
if (event.target.closest(".delete-metadata")) {
deleteMetadata(event.target)
}
})
} }
async function getPDFBlobFromCache(cacheUrl) { async function getPDFBlobFromCache(cacheUrl) {