1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2024-06-04 23:12:25 +02:00

Navigation au clavier

This commit is contained in:
Vincent LAURENT 2021-09-25 15:36:34 +02:00
parent f7db55cb75
commit 5be1947006
2 changed files with 25 additions and 5 deletions

View file

@ -69,20 +69,39 @@ loadingTask.promise.then(function(pdf) {
svgCollections.push(document.getElementById('img-upload').src);
}
displaysSVG();
document.querySelector('#svg_list label:last-child').click();
});
var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
penColor: 'rgb(0, 0, 0)',
minWidth: 0.75,
maxWidth: 1.1
onEnd: function() { document.getElementById('btn_modal_ajouter').focus() }
});
document.querySelectorAll('#modalAddSvg .nav-link').forEach(function(item) { item.addEventListener('shown.bs.tab', function (event) {
var firstInput = document.querySelector(event.target.dataset.bsTarget).querySelector('input');
if(firstInput) {
firstInput.focus();
}
})});
document.getElementById('modalAddSvg').addEventListener('shown.bs.modal', function (event) {
document.querySelector('#modalAddSvg #nav-tab button:first-child').focus()
})
document.getElementById('modalAddSvg').addEventListener('hidden.bs.modal', function (event) {
signaturePad.clear();
document.getElementById('input-text-signature').value = null;
document.getElementById('input-image-upload').value = null;
document.getElementById('img-upload').src = null;
document.getElementById('img-upload').classList.add("d-none");
bootstrap.Tab.getOrCreateInstance(document.querySelector('#modalAddSvg #nav-tab button:first-child')).show();
})
document.getElementById('input-text-signature').addEventListener('keypress', function(event) {
if(event.key == 'Enter') {
document.getElementById('btn_modal_ajouter').click()
}
})
document.getElementById('input-image-upload').addEventListener('change', function(event) {
@ -96,6 +115,7 @@ loadingTask.promise.then(function(pdf) {
var svgImage = "data:image/svg+xml;base64,"+btoa(this.responseText);
document.getElementById('img-upload').src = svgImage;
document.getElementById('img-upload').classList.remove("d-none");
document.getElementById('btn_modal_ajouter').focus();
};
xhr.send( data );

View file

@ -48,7 +48,7 @@
<button class="nav-link" id="nav-import-tab" data-bs-toggle="tab" data-bs-target="#nav-import" type="button" role="tab" aria-controls="nav-import" aria-selected="false"><i class="bi bi-image"></i> Importer</button>
</div>
</nav>
<div class="tab-content mt-3" id="nav-tabContent">
<div class="tab-content mt-3" id="nav-svg-add">
<div class="tab-pane fade show active" id="nav-draw" role="tabpanel" aria-labelledby="nav-draw-tab">
<canvas id="signature-pad" class="border bg-light" width="462" height="175"></canvas>
</div>
@ -57,7 +57,7 @@
</div>
<div class="tab-pane fade" id="nav-import" role="tabpanel" aria-labelledby="nav-import-tab">
<div class="text-center">
<img id="img-upload" class="d-none" style="max-width: 460px;" src="" />
<img id="img-upload" class="d-none" style="max-width: 460px; max-height: 200px;" src="" />
</div>
<form id="form-image-upload" action="/image2svg" method="POST" enctype="multipart/form-data">
<input id="input-image-upload" class="form-control" name="image" type="file">
@ -66,7 +66,7 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
<button tabindex="-1" type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
<button id="btn_modal_ajouter" type="button" class="btn btn-primary" data-bs-dismiss="modal">Ajouter</button>
</div>
</div>