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

[organization] Dedicated button for deleting and rotating selected pages

This commit is contained in:
Vincent LAURENT 2022-05-11 09:29:46 +02:00
parent a7ab90c698
commit 17b0b22f8e
2 changed files with 30 additions and 30 deletions

View File

@ -107,18 +107,9 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
return false;
});
canvasContainer.querySelector('.btn-delete').addEventListener('click', function(e) {
let pages = getPagesSelected();
if(!pages.length) {
pages[pageIndex] = this.parentNode;
}
for(index in pages) {
let checkbox = pages[index].querySelector('input[type=checkbox]');
checkbox.checked = !checkbox.checked;
stateCheckbox(checkbox);
}
if(isSelectionMode()) {
document.querySelector('#btn_cancel_select').click();
}
let checkbox = this.parentNode.querySelector('input[type=checkbox]');
checkbox.checked = !checkbox.checked;
stateCheckbox(checkbox);
});
canvasContainer.querySelector('.btn-select').addEventListener('click', function(e) {
let checkbox = this.parentNode.querySelector('input[type=checkbox].input-select');
@ -140,11 +131,6 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
}
});
canvasContainer.querySelector('.btn-download').addEventListener('click', function(e) {
if(isSelectionMode()) {
document.querySelector('#save-select').click();
return false;
}
let container = this.parentNode;
let pageValue = container.querySelector('.checkbox-page').value;
let orientation = degreesToOrientation(container.querySelector('.input-rotate').value);
@ -155,15 +141,9 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
document.querySelector('#form_pdf').submit();
});
canvasContainer.querySelector('.btn-rotate').addEventListener('click', function(e) {
let pages = getPagesSelected();
if(!pages.length) {
pages[pageIndex] = this.parentNode;
}
for(index in pages) {
let inputRotate = pages[index].querySelector('.input-rotate');
inputRotate.value = (parseInt(inputRotate.value) + 90) % 360;
pageRender(index);
}
let inputRotate = this.parentNode.querySelector('.input-rotate');
inputRotate.value = (parseInt(inputRotate.value) + 90) % 360;
pageRender(pageIndex);
})
pageRender(pageIndex);
@ -298,7 +278,23 @@ var createEventsListener = function() {
input.parentNode.querySelector('.btn-select').click();
});
});
document.getElementById('btn_delete_select').addEventListener('click', function(event) {
let pages = getPagesSelected();
for(index in pages) {
let checkbox = pages[index].querySelector('input[type=checkbox]');
checkbox.checked = !checkbox.checked;
stateCheckbox(checkbox);
}
document.querySelector('#btn_cancel_select').click();
});
document.getElementById('btn_rotate_select').addEventListener('click', function(event) {
let pages = getPagesSelected();
for(index in pages) {
let inputRotate = pages[index].querySelector('.input-rotate');
inputRotate.value = (parseInt(inputRotate.value) + 90) % 360;
pageRender(index);
}
});
}
async function getPDFBlobFromCache(cacheUrl) {

View File

@ -68,9 +68,13 @@
<form id="form_pdf" action="/organize" method="post" enctype="multipart/form-data">
<input id="input_pdf" name="pdf[]" type="file" class="d-none" />
<input id="input_pages" type="hidden" value="" name="pages" />
<div id="container-btn-save-select" class="d-grid gap-2 mt-2 d-none">
<button id="btn_cancel_select" type="button" class="btn btn-link">Annuler la sélection</button>
<button class="btn btn-outline-primary" type="submit" id="save-select"><i class="bi bi-download"></i> Télécharger les pages séléctionnées</button>
<div id="container-btn-save-select" class="d-none">
<button id="btn_cancel_select" type="button" class="btn btn-link w-100">Annuler la sélection</button>
<div class="btn-group mb-2 mt-2" role="group">
<button id="btn_delete_select" type="button" class="btn btn-outline-primary"><i class="bi bi-trash"></i> Supprimer</button>
<button id="btn_rotate_select" type="button" class="btn btn-outline-primary"><i class="bi bi-arrow-clockwise"></i> Tourner</button>
</div>
<button class="btn w-100 btn-outline-primary" type="submit" id="save-select"><i class="bi bi-download"></i> Télécharger les pages séléctionnées</button>
</div>
<div id="container-btn-save" class="d-grid gap-2 mt-2">
<button class="btn btn-primary" type="submit" id="save"><i class="bi bi-download"></i> Télécharger le PDF</button>