mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
Ajout d'un svg au pdf par un simple click au lieu du double click
This commit is contained in:
parent
559ba53901
commit
3554a607d6
@ -33,6 +33,16 @@ loadingTask.promise.then(function(pdf) {
|
||||
inputRadio.name = "svg_2_add";
|
||||
inputRadio.autocomplete = "off";
|
||||
inputRadio.value = svg.svg;
|
||||
inputRadio.addEventListener('change', function() {
|
||||
canvasEditions.forEach(function(canvasEdition, index) {
|
||||
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
|
||||
if(input_selected) {
|
||||
canvasEdition.defaultCursor = 'copy';
|
||||
} else {
|
||||
canvasEdition.defaultCursor = 'default';
|
||||
}
|
||||
})
|
||||
});
|
||||
var svgButton = document.createElement('label');
|
||||
svgButton.classList.add('position-relative');
|
||||
svgButton.classList.add('btn');
|
||||
@ -55,6 +65,7 @@ loadingTask.promise.then(function(pdf) {
|
||||
svgButton.draggable = true;
|
||||
svgButton.addEventListener('dragstart', function(event) {
|
||||
document.getElementById(this.htmlFor).checked = true;
|
||||
document.getElementById(this.htmlFor).dispatchEvent(new Event("change"));
|
||||
});
|
||||
var svgImg = document.createElement('img');
|
||||
svgImg.src = svg.svg;
|
||||
@ -117,6 +128,20 @@ loadingTask.promise.then(function(pdf) {
|
||||
document.querySelectorAll('label.btn-svg').forEach(function(item) {
|
||||
item.addEventListener('dragstart', function(event) {
|
||||
document.getElementById(this.htmlFor).checked = true;
|
||||
document.getElementById(this.htmlFor).dispatchEvent(new Event("change"));
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('input[name="svg_2_add"]').forEach(function (item) {
|
||||
item.addEventListener('change', function() {
|
||||
canvasEditions.forEach(function(canvasEdition, index) {
|
||||
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
|
||||
if(input_selected) {
|
||||
canvasEdition.defaultCursor = 'copy';
|
||||
} else {
|
||||
canvasEdition.defaultCursor = 'default';
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@ -357,29 +382,28 @@ loadingTask.promise.then(function(pdf) {
|
||||
var canvasEdition = new fabric.Canvas('canvas-edition-' + pageIndex, {'selection' : false});
|
||||
|
||||
document.getElementById('canvas-container-' + pageIndex).addEventListener('drop', function(event) {
|
||||
|
||||
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
|
||||
|
||||
if(!input_selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
addSvgInCanvas(canvasEdition, input_selected.value, event.layerX, event.layerY);
|
||||
input_selected.checked = false;
|
||||
input_selected.dispatchEvent(new Event("change"));
|
||||
});
|
||||
|
||||
canvasEdition.on('mouse:move', function(event) {
|
||||
activeCanvas = this;
|
||||
activeCanvasPointer = event.pointer;
|
||||
});
|
||||
|
||||
canvasEdition.on('mouse:dblclick', function(event) {
|
||||
canvasEdition.on('mouse:down', function(event) {
|
||||
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
|
||||
|
||||
if(!input_selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
addSvgInCanvas(this, input_selected.value, event.pointer.x, event.pointer.y);
|
||||
input_selected.checked = false;
|
||||
input_selected.dispatchEvent(new Event("change"));
|
||||
});
|
||||
|
||||
canvasEditions.push(canvasEdition);
|
||||
|
@ -55,7 +55,6 @@
|
||||
</div>
|
||||
|
||||
<form class="position-fixed bottom-0 pb-2 pe-2" id="form_pdf" action="/<?php echo $key ?>/save" method="post">
|
||||
<p class="fs-6"><small class="text-muted"><i class="bi bi-hand-index"></i> + <i class="bi bi-hand-index"></i> = <i class="bi bi-plus-circle-fill"></i><br />Double-cliquez sur le PDF pour ajouter le motif ou l'élément sélectionné</small></p>
|
||||
<div class="d-grid gap-2">
|
||||
<button class="btn btn-primary" disabled="disabled" type="submit" id="save"><i class="bi bi-download"></i> Télécharger le PDF Signé</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user