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

Merge branch 'metadata' of github.com:24eme/signaturepdf into metadata

This commit is contained in:
Vincent LAURENT 2023-04-19 17:27:33 +02:00
commit a2843a329c
4 changed files with 43 additions and 3 deletions

View File

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

View File

@ -87,19 +87,34 @@ var pageRender = async function(pageIndex) {
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) {
if (confirm("Souhaitez-vous supprimer ce champ ?") === false) return;
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);
@ -107,6 +122,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) {

View File

@ -903,6 +903,11 @@ var createEventsListener = function() {
zoomChange(1) zoomChange(1)
}); });
window.addEventListener('beforeunload', function(event) {
event.preventDefault();
return true;
});
if(hash) { if(hash) {
updateNbLayers(); updateNbLayers();
setInterval(function() { setInterval(function() {

View File

@ -57,7 +57,7 @@
</div> </div>
<form id="form_metadata_add"> <form id="form_metadata_add">
<div class="input-group mt-3"> <div class="input-group mt-3">
<input name="metadata_key" type="text" class="form-control" placeholder="Ma nouvelle metadonnée" aria-label="Recipient's username"> <input name="metadata_key" type="text" class="form-control" placeholder="Ma nouvelle metadonnée" required aria-label="Recipient's username">
<button class="btn btn-outline-secondary" type="submit">Ajouter</button> <button class="btn btn-outline-secondary" type="submit">Ajouter</button>
</div> </div>
</form> </form>