Enhance signature management functionality
Added a new button in `EnvelopeViewer.razor` for creating or modifying signatures, with dynamic styling and tooltips based on the signature state. Enhanced `OpenSignaturePopup` and `OnPopupShownAsync` methods to preload and display existing signatures in the popup and canvas. Introduced new "success" button styles in `envelope-viewer.css` for better visual feedback. Added `loadExistingSignature` function in `receiver-signature.js` to render existing signatures on the canvas and updated the public API to expose this functionality.
This commit is contained in:
@@ -316,6 +316,23 @@ window.receiverSignature = (() => {
|
||||
function getTypedDataUrl(id) { const c = document.getElementById(id); const s = typedSignatures.get(id); return (c && s && s.hasSignature) ? c.toDataURL('image/png') : null; }
|
||||
function getImageDataUrl(id) { const c = document.getElementById(id); const s = imageSignatures.get(id); return (c && s && s.hasSignature) ? c.toDataURL('image/png') : null; }
|
||||
|
||||
function loadExistingSignature(canvasId, dataUrl) {
|
||||
const canvas = document.getElementById(canvasId);
|
||||
const state = pads.get(canvasId);
|
||||
if (!canvas || !state || !dataUrl) return;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
const img = new Image();
|
||||
|
||||
img.onload = () => {
|
||||
_clear(canvas);
|
||||
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
state.hasSignature = true;
|
||||
};
|
||||
|
||||
img.src = dataUrl;
|
||||
}
|
||||
|
||||
// ?? Public API ??????????????????????????????????????????????????????????
|
||||
return {
|
||||
startTyped: startTyped,
|
||||
@@ -329,6 +346,8 @@ window.receiverSignature = (() => {
|
||||
renderTypedSignature: renderTypedSignature,
|
||||
getDataUrl: getDataUrl,
|
||||
getTypedDataUrl: getTypedDataUrl,
|
||||
getImageDataUrl: getImageDataUrl
|
||||
getImageDataUrl: getImageDataUrl,
|
||||
loadExistingSignature: loadExistingSignature
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user