Add PDF viewer, signature, and typing enhancements
Enhanced `appsettings.json` with `ApiOptions` and `PdfViewerOptions` for better customization of rendering and zoom behaviors. Added comprehensive styles in `envelope-viewer.css` for the layout, toolbar, thumbnails, and responsive design of the envelope viewer. Introduced `receiver-signature.js` to manage signature functionality, including drawing, typed, and image-based signatures, as well as dynamic annotation checkboxes. Integrated `Typed.js` (UMD version) for typing animations with configurable speeds, looping, and event hooks.
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"ApiOptions": {
|
||||||
|
"BaseUrl": ""
|
||||||
|
},
|
||||||
|
"PdfViewerOptions": {
|
||||||
|
"ThumbnailBaseScale": 0.75,
|
||||||
|
"ThumbnailEnableHiDPI": true,
|
||||||
|
"ThumbnailMaxDPR": 2.0,
|
||||||
|
"MainCanvasEnableHiDPI": true,
|
||||||
|
"MainCanvasMaxDPR": 2.0,
|
||||||
|
"EnableSmoothZoom": true,
|
||||||
|
"ZoomTransitionDuration": 900,
|
||||||
|
"RenderingOpacity": 0.85,
|
||||||
|
"ThumbnailRenderDelay": 50,
|
||||||
|
"ZoomStepPercentage": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,767 @@
|
|||||||
|
.envelope-viewer-layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-action-bar {
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
border-bottom: 3px solid rgba(126, 34, 206, 0.3);
|
||||||
|
padding: 1.25rem 2rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-action-bar__inner {
|
||||||
|
max-width: 1600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-logo svg {
|
||||||
|
filter: drop-shadow(0 2px 4px rgba(126, 34, 206, 0.3));
|
||||||
|
color: #7e22ce;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-title {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1e293b;
|
||||||
|
letter-spacing: -0.025em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-key {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
color: #64748b;
|
||||||
|
font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-content {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 1.5rem;
|
||||||
|
position: relative;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-viewer-container {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails {
|
||||||
|
position: relative;
|
||||||
|
width: 260px;
|
||||||
|
background: rgba(255, 255, 255, 0.98);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
border-radius: 16px 0 0 16px;
|
||||||
|
box-shadow:
|
||||||
|
0 8px 32px rgba(0, 0, 0, 0.12),
|
||||||
|
0 0 0 1px rgba(126, 34, 206, 0.1);
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.15);
|
||||||
|
border-right: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content::-webkit-scrollbar-track {
|
||||||
|
background: rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content::-webkit-scrollbar-thumb {
|
||||||
|
background: linear-gradient(135deg, #7e22ce 0%, #2a5298 100%);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: linear-gradient(135deg, #6b1cb0 0%, #1e3a72 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-splitter {
|
||||||
|
width: 4px;
|
||||||
|
background: transparent;
|
||||||
|
cursor: col-resize;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
z-index: 10;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-splitter::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: -4px;
|
||||||
|
right: -4px;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
/* Enlarged hitbox for easier grabbing */
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-splitter:hover,
|
||||||
|
.pdf-splitter.resizing {
|
||||||
|
background: linear-gradient(90deg,
|
||||||
|
rgba(126, 34, 206, 0.4) 0%,
|
||||||
|
rgba(42, 82, 152, 0.4) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-splitter:active {
|
||||||
|
background: linear-gradient(90deg,
|
||||||
|
rgba(126, 34, 206, 0.6) 0%,
|
||||||
|
rgba(42, 82, 152, 0.6) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prevent text selection during resize */
|
||||||
|
body.resizing {
|
||||||
|
user-select: none;
|
||||||
|
cursor: col-resize !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail {
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: white;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail:hover {
|
||||||
|
border-color: rgba(126, 34, 206, 0.3);
|
||||||
|
box-shadow: 0 4px 16px rgba(126, 34, 206, 0.2);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail--active {
|
||||||
|
border-color: #7e22ce;
|
||||||
|
box-shadow:
|
||||||
|
0 4px 16px rgba(126, 34, 206, 0.3),
|
||||||
|
0 0 0 3px rgba(126, 34, 206, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail__preview {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 210 / 297;
|
||||||
|
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail__canvas {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
object-position: center;
|
||||||
|
image-rendering: -webkit-optimize-contrast;
|
||||||
|
image-rendering: crisp-edges;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail__label {
|
||||||
|
padding: 0.5rem;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #64748b;
|
||||||
|
background: rgba(126, 34, 206, 0.03);
|
||||||
|
border-top: 1px solid rgba(126, 34, 206, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnail--active .pdf-thumbnail__label {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.1) 0%, rgba(42, 82, 152, 0.1) 100%);
|
||||||
|
color: #7e22ce;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--toggle {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.08) 0%, rgba(42, 82, 152, 0.08) 100%);
|
||||||
|
border-color: rgba(126, 34, 206, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--toggle:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.15) 0%, rgba(42, 82, 152, 0.15) 100%);
|
||||||
|
border-color: rgba(126, 34, 206, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar {
|
||||||
|
background: rgba(255, 255, 255, 0.98);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1.5rem;
|
||||||
|
box-shadow:
|
||||||
|
0 4px 16px rgba(0, 0, 0, 0.1),
|
||||||
|
0 0 0 1px rgba(126, 34, 206, 0.1);
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.15);
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__section {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-section {
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex: 1;
|
||||||
|
max-width: 400px;
|
||||||
|
min-width: 280px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__divider {
|
||||||
|
width: 1px;
|
||||||
|
height: 32px;
|
||||||
|
background: linear-gradient(180deg, transparent 0%, rgba(126, 34, 206, 0.2) 50%, transparent 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.05) 0%, rgba(42, 82, 152, 0.05) 100%);
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.2);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #1e293b;
|
||||||
|
min-width: 34px;
|
||||||
|
min-height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.1) 0%, rgba(42, 82, 152, 0.1) 100%);
|
||||||
|
border-color: rgba(126, 34, 206, 0.4);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(126, 34, 206, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn:active:not(:disabled) {
|
||||||
|
transform: translateY(0);
|
||||||
|
box-shadow: 0 2px 6px rgba(126, 34, 206, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
background: rgba(0, 0, 0, 0.02);
|
||||||
|
border-color: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--preset {
|
||||||
|
padding: 0.5rem 0.875rem;
|
||||||
|
font-size: 0.813rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #475569;
|
||||||
|
min-width: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--preset svg {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__page-input-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
background: white;
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.2);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.25rem 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__page-input {
|
||||||
|
width: 48px;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1e293b;
|
||||||
|
background: transparent;
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__page-input::-webkit-outer-spin-button,
|
||||||
|
.pdf-toolbar__page-input::-webkit-inner-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__page-total {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider-container {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 180px;
|
||||||
|
max-width: 350px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: linear-gradient(90deg,
|
||||||
|
rgba(126, 34, 206, 0.1) 0%,
|
||||||
|
rgba(126, 34, 206, 0.2) 50%,
|
||||||
|
rgba(126, 34, 206, 0.1) 100%);
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider::-webkit-slider-thumb {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: linear-gradient(135deg, #7e22ce 0%, #2a5298 100%);
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 2px 8px rgba(126, 34, 206, 0.3);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider::-webkit-slider-thumb:hover {
|
||||||
|
transform: scale(1.15);
|
||||||
|
box-shadow: 0 4px 12px rgba(126, 34, 206, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider::-moz-range-thumb {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: linear-gradient(135deg, #7e22ce 0%, #2a5298 100%);
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 2px 8px rgba(126, 34, 206, 0.3);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider::-moz-range-thumb:hover {
|
||||||
|
transform: scale(1.15);
|
||||||
|
box-shadow: 0 4px 12px rgba(126, 34, 206, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #7e22ce;
|
||||||
|
letter-spacing: 0.025em;
|
||||||
|
min-width: 45px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Signature Navigation Styles */
|
||||||
|
.pdf-toolbar__signature-nav {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.05) 0%, rgba(42, 82, 152, 0.05) 100%);
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.2);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-nav {
|
||||||
|
min-width: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
padding: 0.25rem;
|
||||||
|
background: white;
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-nav:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, #7e22ce 0%, #2a5298 100%);
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-nav:hover:not(:disabled) svg {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__signature-counter {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
padding: 0 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__signature-counter svg {
|
||||||
|
color: #7e22ce;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__signature-counter-text {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1e293b;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__signature-badge {
|
||||||
|
font-size: 0.625rem;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 0.1875rem 0.5rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.1) 0%, rgba(42, 82, 152, 0.1) 100%);
|
||||||
|
color: #7e22ce;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__signature-badge--complete {
|
||||||
|
background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
|
||||||
|
color: #059669;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset Button Styles */
|
||||||
|
.pdf-toolbar__btn--reset {
|
||||||
|
background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(220, 38, 38, 0.08) 100%);
|
||||||
|
border-color: rgba(239, 68, 68, 0.3);
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--reset:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
|
||||||
|
border-color: transparent;
|
||||||
|
color: white;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--reset svg {
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--reset:hover:not(:disabled) svg {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Success Button Styles (Signature Created) */
|
||||||
|
.pdf-toolbar__btn--success {
|
||||||
|
background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
|
||||||
|
border-color: rgba(16, 185, 129, 0.3);
|
||||||
|
color: #059669;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--success:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
||||||
|
border-color: transparent;
|
||||||
|
color: white;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--success svg {
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--success:hover:not(:disabled) svg {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Signature Change Button */
|
||||||
|
.pdf-toolbar__btn--signature-change {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
min-width: auto;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.05) 0%, rgba(42, 82, 152, 0.05) 100%);
|
||||||
|
border: 1px solid rgba(126, 34, 206, 0.2);
|
||||||
|
color: #7e22ce;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-change:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, rgba(126, 34, 206, 0.1) 0%, rgba(42, 82, 152, 0.1) 100%);
|
||||||
|
border-color: rgba(126, 34, 206, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-change-active {
|
||||||
|
background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.08) 100%);
|
||||||
|
border-color: rgba(16, 185, 129, 0.25);
|
||||||
|
color: #059669;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-change-active:hover:not(:disabled) {
|
||||||
|
background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(5, 150, 105, 0.12) 100%);
|
||||||
|
border-color: rgba(16, 185, 129, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--signature-change:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn-text {
|
||||||
|
font-size: 0.813rem;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-frame {
|
||||||
|
background: white;
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow:
|
||||||
|
0 25px 50px -12px rgba(0, 0, 0, 0.25),
|
||||||
|
0 0 0 1px rgba(255, 255, 255, 0.1);
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
width: 95%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-frame::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4px;
|
||||||
|
background: linear-gradient(90deg, #7e22ce 0%, #2a5298 100%);
|
||||||
|
z-index: 1;
|
||||||
|
border-radius: 16px 16px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-canvas-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-page-container {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-canvas {
|
||||||
|
display: block;
|
||||||
|
vertical-align: top;
|
||||||
|
image-rendering: -webkit-optimize-contrast;
|
||||||
|
image-rendering: crisp-edges;
|
||||||
|
transition: opacity 0.15s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-canvas.rendering {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-text-layer {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
opacity: 1;
|
||||||
|
line-height: 1.0;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-text-layer > span {
|
||||||
|
color: transparent;
|
||||||
|
position: absolute;
|
||||||
|
white-space: pre;
|
||||||
|
cursor: text;
|
||||||
|
transform-origin: 0% 0%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-text-layer ::selection {
|
||||||
|
background: rgba(126, 34, 206, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-text-layer ::-moz-selection {
|
||||||
|
background: rgba(126, 34, 206, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-signature-layer {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
overflow: visible;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-signature-layer .signature-button {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature-button {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature-button:focus {
|
||||||
|
outline: 2px solid #7e22ce;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature-button:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
border-radius: 12px;
|
||||||
|
border: none;
|
||||||
|
padding: 2rem;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-danger {
|
||||||
|
background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
|
||||||
|
color: #be123c;
|
||||||
|
border-left: 4px solid #e11d48;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-warning {
|
||||||
|
background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
|
||||||
|
color: #92400e;
|
||||||
|
border-left: 4px solid #f59e0b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-border {
|
||||||
|
border-width: 0.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.envelope-content {
|
||||||
|
padding: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails {
|
||||||
|
width: 180px;
|
||||||
|
border-radius: 0 0 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-thumbnails__content {
|
||||||
|
padding: 0.75rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding: 0.625rem 1rem;
|
||||||
|
gap: 0.75rem;
|
||||||
|
width: 98%;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__divider {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-section {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__zoom-slider {
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-toolbar__btn--preset {
|
||||||
|
padding: 0.425rem 0.75rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-frame {
|
||||||
|
border-radius: 12px;
|
||||||
|
width: 98%;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdf-canvas-wrapper {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-action-bar {
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-action-bar__inner {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-key {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.envelope-logo svg {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,353 @@
|
|||||||
|
window.receiverSignature = (() => {
|
||||||
|
|
||||||
|
// ?? State ???????????????????????????????????????????????????????????????
|
||||||
|
const pads = new Map();
|
||||||
|
const typedSignatures = new Map();
|
||||||
|
const imageSignatures = new Map();
|
||||||
|
const overlayButtons = new Map(); // annotationId -> { btn, signed }
|
||||||
|
let _dotNetRef = null;
|
||||||
|
|
||||||
|
// DevExpress Blazor Report Viewer selectors (confirmed via debugDumpViewerDom)
|
||||||
|
const PAGE_IMG_SEL = '.dxbrv-report-preview-content-img';
|
||||||
|
const SCROLL_CONTAINER_SEL = '.dxbrv-surface-wrapper';
|
||||||
|
const VIEWER_WRAPPER_SEL = '.receiver-viewer-wrapper';
|
||||||
|
|
||||||
|
// DX report coordinate space (1/100 inch, A4)
|
||||||
|
const DX_PAGE_WIDTH = 827.0;
|
||||||
|
const DX_PAGE_HEIGHT = 1169.0;
|
||||||
|
|
||||||
|
// Signature field size in DX units
|
||||||
|
const SIG_WIDTH_DX = 230.0;
|
||||||
|
const SIG_HEIGHT_DX = 154.0;
|
||||||
|
|
||||||
|
// ?? Annotation Checkboxes ????????????????????????????????????????????????
|
||||||
|
|
||||||
|
// Active install context — holds everything needed to reposition on resize/scroll
|
||||||
|
let _installCtx = null;
|
||||||
|
|
||||||
|
function installAnnotationCheckboxes(annotations, checkedIds, dotNetRef) {
|
||||||
|
_dotNetRef = dotNetRef;
|
||||||
|
|
||||||
|
// Tear down previous install completely
|
||||||
|
_teardownCheckboxes();
|
||||||
|
|
||||||
|
if (!annotations || annotations.length === 0) return;
|
||||||
|
|
||||||
|
const ctx = {
|
||||||
|
annotations,
|
||||||
|
checkedIds: new Set(Array.isArray(checkedIds) ? checkedIds : []),
|
||||||
|
scrollEl: null,
|
||||||
|
pageEls: [],
|
||||||
|
resizeObs: null,
|
||||||
|
onScroll: null,
|
||||||
|
onResize: null,
|
||||||
|
resizeTimer: null,
|
||||||
|
};
|
||||||
|
_installCtx = ctx;
|
||||||
|
|
||||||
|
_waitForCheckboxPages(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _teardownCheckboxes() {
|
||||||
|
document.querySelectorAll('.annot-sig-cb-wrapper').forEach(el => el.remove());
|
||||||
|
overlayButtons.clear();
|
||||||
|
|
||||||
|
if (!_installCtx) return;
|
||||||
|
const ctx = _installCtx;
|
||||||
|
|
||||||
|
if (ctx.resizeObs) { ctx.resizeObs.disconnect(); ctx.resizeObs = null; }
|
||||||
|
if (ctx.scrollEl && ctx.onScroll) ctx.scrollEl.removeEventListener('scroll', ctx.onScroll);
|
||||||
|
if (ctx.onResize) window.removeEventListener('resize', ctx.onResize);
|
||||||
|
if (ctx.resizeTimer) clearTimeout(ctx.resizeTimer);
|
||||||
|
|
||||||
|
_installCtx = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _waitForCheckboxPages(ctx) {
|
||||||
|
const wrapper = document.querySelector(VIEWER_WRAPPER_SEL);
|
||||||
|
if (!wrapper) return;
|
||||||
|
|
||||||
|
if (!_tryInstallCheckboxes(ctx)) {
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
if (_tryInstallCheckboxes(ctx)) observer.disconnect();
|
||||||
|
});
|
||||||
|
observer.observe(wrapper, { childList: true, subtree: true });
|
||||||
|
setTimeout(() => observer.disconnect(), 15000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _tryInstallCheckboxes(ctx) {
|
||||||
|
const scrollEl = document.querySelector(SCROLL_CONTAINER_SEL);
|
||||||
|
if (!scrollEl) return false;
|
||||||
|
|
||||||
|
const pageEls = Array.from(document.querySelectorAll(PAGE_IMG_SEL));
|
||||||
|
if (pageEls.length === 0) return false;
|
||||||
|
|
||||||
|
if (getComputedStyle(scrollEl).position === 'static')
|
||||||
|
scrollEl.style.position = 'relative';
|
||||||
|
|
||||||
|
ctx.scrollEl = scrollEl;
|
||||||
|
ctx.pageEls = pageEls;
|
||||||
|
|
||||||
|
// Initial render
|
||||||
|
_renderAllCheckboxes(ctx);
|
||||||
|
|
||||||
|
// ResizeObserver — watches every page image for size changes (zoom in/out)
|
||||||
|
const ro = new ResizeObserver(() => _repositionAll(ctx));
|
||||||
|
pageEls.forEach(el => ro.observe(el));
|
||||||
|
ctx.resizeObs = ro;
|
||||||
|
|
||||||
|
// Scroll — reposition when user scrolls the viewer
|
||||||
|
ctx.onScroll = () => _repositionAll(ctx);
|
||||||
|
scrollEl.addEventListener('scroll', ctx.onScroll, { passive: true });
|
||||||
|
|
||||||
|
// Window resize — debounced 60 ms
|
||||||
|
ctx.onResize = () => {
|
||||||
|
if (ctx.resizeTimer) clearTimeout(ctx.resizeTimer);
|
||||||
|
ctx.resizeTimer = setTimeout(() => _repositionAll(ctx), 60);
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', ctx.onResize, { passive: true });
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _repositionAll(ctx) {
|
||||||
|
if (!ctx || !ctx.scrollEl) return;
|
||||||
|
|
||||||
|
const scrollEl = ctx.scrollEl;
|
||||||
|
const pageEls = Array.from(document.querySelectorAll(PAGE_IMG_SEL)); // re-query in case DOM changed
|
||||||
|
if (pageEls.length === 0) return;
|
||||||
|
|
||||||
|
const scrollRect = scrollEl.getBoundingClientRect();
|
||||||
|
|
||||||
|
ctx.annotations.forEach(ann => {
|
||||||
|
const wrapper = document.querySelector(`.annot-sig-cb-wrapper[data-annot-id="${ann.id}"]`);
|
||||||
|
if (!wrapper) return;
|
||||||
|
|
||||||
|
const pageEl = pageEls[(ann.page || 1) - 1] ?? pageEls[pageEls.length - 1];
|
||||||
|
if (!pageEl) return;
|
||||||
|
|
||||||
|
const pageRect = pageEl.getBoundingClientRect();
|
||||||
|
if (pageRect.width === 0 || pageRect.height === 0) return;
|
||||||
|
|
||||||
|
const scaleX = pageRect.width / DX_PAGE_WIDTH;
|
||||||
|
const scaleY = pageRect.height / DX_PAGE_HEIGHT;
|
||||||
|
|
||||||
|
const absLeft = pageRect.left - scrollRect.left + scrollEl.scrollLeft + (ann.x || 0) * scaleX;
|
||||||
|
const absTop = pageRect.top - scrollRect.top + scrollEl.scrollTop + (ann.y || 0) * scaleY;
|
||||||
|
const boxW = SIG_WIDTH_DX * scaleX;
|
||||||
|
const boxH = SIG_HEIGHT_DX * scaleY;
|
||||||
|
|
||||||
|
wrapper.style.left = Math.round(absLeft) + 'px';
|
||||||
|
wrapper.style.top = Math.round(absTop) + 'px';
|
||||||
|
wrapper.style.width = Math.round(boxW) + 'px';
|
||||||
|
wrapper.style.height = Math.round(boxH) + 'px';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function _renderAllCheckboxes(ctx) {
|
||||||
|
const scrollEl = ctx.scrollEl;
|
||||||
|
const pageEls = ctx.pageEls;
|
||||||
|
const scrollRect = scrollEl.getBoundingClientRect();
|
||||||
|
|
||||||
|
ctx.annotations.forEach(ann => {
|
||||||
|
const pageEl = pageEls[(ann.page || 1) - 1] ?? pageEls[pageEls.length - 1];
|
||||||
|
if (!pageEl) return;
|
||||||
|
|
||||||
|
const pageRect = pageEl.getBoundingClientRect();
|
||||||
|
if (pageRect.width === 0 || pageRect.height === 0) return;
|
||||||
|
|
||||||
|
const scaleX = pageRect.width / DX_PAGE_WIDTH;
|
||||||
|
const scaleY = pageRect.height / DX_PAGE_HEIGHT;
|
||||||
|
|
||||||
|
const absLeft = pageRect.left - scrollRect.left + scrollEl.scrollLeft + (ann.x || 0) * scaleX;
|
||||||
|
const absTop = pageRect.top - scrollRect.top + scrollEl.scrollTop + (ann.y || 0) * scaleY;
|
||||||
|
const boxW = SIG_WIDTH_DX * scaleX;
|
||||||
|
const boxH = SIG_HEIGHT_DX * scaleY;
|
||||||
|
|
||||||
|
const isChecked = ctx.checkedIds.has(ann.id);
|
||||||
|
_createCheckboxOverlay(ann.id, scrollEl, absLeft, absTop, boxW, boxH, isChecked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createCheckboxOverlay(annotationId, container, left, top, width, height, isChecked) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.className = 'annot-sig-cb-wrapper' + (isChecked ? ' annot-sig-cb-wrapper--checked' : '');
|
||||||
|
wrapper.setAttribute('data-annot-id', String(annotationId));
|
||||||
|
|
||||||
|
Object.assign(wrapper.style, {
|
||||||
|
position: 'absolute',
|
||||||
|
left: Math.round(left) + 'px',
|
||||||
|
top: Math.round(top) + 'px',
|
||||||
|
width: Math.round(width) + 'px',
|
||||||
|
height: Math.round(height) + 'px',
|
||||||
|
zIndex: '9999',
|
||||||
|
cursor: 'pointer',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
});
|
||||||
|
|
||||||
|
const cb = document.createElement('input');
|
||||||
|
cb.type = 'checkbox';
|
||||||
|
cb.checked = isChecked;
|
||||||
|
cb.className = 'annot-sig-cb';
|
||||||
|
cb.setAttribute('aria-label', 'Unterschriftsfeld bestaetigen');
|
||||||
|
|
||||||
|
const label = document.createElement('span');
|
||||||
|
label.className = 'annot-sig-cb__label';
|
||||||
|
label.textContent = isChecked ? '\u2713 Bestaetigt' : '\u270e Hier unterschreiben';
|
||||||
|
|
||||||
|
wrapper.appendChild(cb);
|
||||||
|
wrapper.appendChild(label);
|
||||||
|
|
||||||
|
wrapper.addEventListener('click', (e) => {
|
||||||
|
if (e.target !== cb) cb.checked = !cb.checked;
|
||||||
|
const checked = cb.checked;
|
||||||
|
wrapper.classList.toggle('annot-sig-cb-wrapper--checked', checked);
|
||||||
|
label.textContent = checked ? '\u2713 Bestaetigt' : '\u270e Hier unterschreiben';
|
||||||
|
if (_installCtx) {
|
||||||
|
if (checked) _installCtx.checkedIds.add(annotationId);
|
||||||
|
else _installCtx.checkedIds.delete(annotationId);
|
||||||
|
}
|
||||||
|
if (_dotNetRef)
|
||||||
|
_dotNetRef.invokeMethodAsync('OnAnnotationToggled', annotationId, checked);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.appendChild(wrapper);
|
||||||
|
overlayButtons.set(annotationId, { btn: wrapper, signed: isChecked });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ?? Signature Pad ???????????????????????????????????????????????????????
|
||||||
|
|
||||||
|
function _pos(canvas, event) {
|
||||||
|
const r = canvas.getBoundingClientRect();
|
||||||
|
const s = (event.touches && event.touches.length) ? event.touches[0] : event;
|
||||||
|
return { x: (s.clientX - r.left) * (canvas.width / r.width), y: (s.clientY - r.top) * (canvas.height / r.height) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function _clear(canvas) { canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height); }
|
||||||
|
|
||||||
|
function initialize(canvasId) {
|
||||||
|
const canvas = document.getElementById(canvasId);
|
||||||
|
if (!canvas || pads.has(canvasId)) return;
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.lineWidth = 2.5; ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.strokeStyle = '#111';
|
||||||
|
const state = { drawing: false, hasSignature: false };
|
||||||
|
pads.set(canvasId, state);
|
||||||
|
const start = e => { e.preventDefault(); const p = _pos(canvas, e); state.drawing = true; ctx.beginPath(); ctx.moveTo(p.x, p.y); };
|
||||||
|
const move = e => { if (!state.drawing) return; e.preventDefault(); const p = _pos(canvas, e); ctx.lineTo(p.x, p.y); ctx.stroke(); state.hasSignature = true; };
|
||||||
|
const end = e => { if (!state.drawing) return; e.preventDefault(); state.drawing = false; };
|
||||||
|
canvas.addEventListener('mousedown', start);
|
||||||
|
canvas.addEventListener('mousemove', move);
|
||||||
|
window.addEventListener('mouseup', end);
|
||||||
|
canvas.addEventListener('touchstart', start, { passive: false });
|
||||||
|
canvas.addEventListener('touchmove', move, { passive: false });
|
||||||
|
canvas.addEventListener('touchend', end, { passive: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeTyped(canvasId) {
|
||||||
|
const canvas = document.getElementById(canvasId);
|
||||||
|
if (!canvas || typedSignatures.has(canvasId)) return;
|
||||||
|
typedSignatures.set(canvasId, { hasSignature: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeImage(inputId, canvasId) {
|
||||||
|
const input = document.getElementById(inputId);
|
||||||
|
const canvas = document.getElementById(canvasId);
|
||||||
|
if (!input || !canvas || imageSignatures.has(canvasId)) return;
|
||||||
|
const state = { hasSignature: false };
|
||||||
|
imageSignatures.set(canvasId, state);
|
||||||
|
input.addEventListener('change', () => {
|
||||||
|
const file = input.files && input.files[0];
|
||||||
|
if (!file || !file.type.startsWith('image/')) { _clear(canvas); state.hasSignature = false; return; }
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = () => {
|
||||||
|
const ctx = canvas.getContext('2d'); _clear(canvas);
|
||||||
|
const p = 10, mw = canvas.width - p * 2, mh = canvas.height - p * 2;
|
||||||
|
const s = Math.min(mw / img.width, mh / img.height, 1);
|
||||||
|
ctx.drawImage(img, (canvas.width - img.width * s) / 2, (canvas.height - img.height * s) / 2, img.width * s, img.height * s);
|
||||||
|
state.hasSignature = true;
|
||||||
|
};
|
||||||
|
img.src = reader.result;
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear(canvasId) {
|
||||||
|
const c = document.getElementById(canvasId); const s = pads.get(canvasId);
|
||||||
|
if (c && s) { _clear(c); s.hasSignature = false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearTyped(canvasId) {
|
||||||
|
const c = document.getElementById(canvasId); const s = typedSignatures.get(canvasId);
|
||||||
|
if (c && s) { _clear(c); s.hasSignature = false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearImage(inputId, canvasId) {
|
||||||
|
const inp = document.getElementById(inputId); const c = document.getElementById(canvasId); const s = imageSignatures.get(canvasId);
|
||||||
|
if (c && s) { if (inp) inp.value = ''; _clear(c); s.hasSignature = false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTypedSignature(canvasId, text, fontFamily) {
|
||||||
|
const canvas = document.getElementById(canvasId); const state = typedSignatures.get(canvasId);
|
||||||
|
if (!canvas || !state) return;
|
||||||
|
const value = (text || '').trim(); _clear(canvas);
|
||||||
|
if (!value) { state.hasSignature = false; return; }
|
||||||
|
const ctx = canvas.getContext('2d'); let fs = 54;
|
||||||
|
do { ctx.font = 'italic ' + fs + 'px ' + (fontFamily || 'cursive'); fs -= 2; }
|
||||||
|
while (ctx.measureText(value).width > canvas.width - 30 && fs > 24);
|
||||||
|
ctx.fillStyle = '#111'; ctx.textBaseline = 'middle'; ctx.textAlign = 'center';
|
||||||
|
ctx.fillText(value, canvas.width / 2, canvas.height / 2);
|
||||||
|
state.hasSignature = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTyped(elementId, text, typeSpeed) {
|
||||||
|
if (typeof Typed === 'undefined') return;
|
||||||
|
new Typed('#' + elementId, {
|
||||||
|
strings: [text],
|
||||||
|
typeSpeed: typeSpeed || 15,
|
||||||
|
showCursor: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDataUrl(id) { const c = document.getElementById(id); const s = pads.get(id); return (c && s && s.hasSignature) ? c.toDataURL('image/png') : null; }
|
||||||
|
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,
|
||||||
|
installAnnotationCheckboxes: installAnnotationCheckboxes,
|
||||||
|
initialize: initialize,
|
||||||
|
initializeTyped: initializeTyped,
|
||||||
|
initializeImage: initializeImage,
|
||||||
|
clear: clear,
|
||||||
|
clearTyped: clearTyped,
|
||||||
|
clearImage: clearImage,
|
||||||
|
renderTypedSignature: renderTypedSignature,
|
||||||
|
getDataUrl: getDataUrl,
|
||||||
|
getTypedDataUrl: getTypedDataUrl,
|
||||||
|
getImageDataUrl: getImageDataUrl,
|
||||||
|
loadExistingSignature: loadExistingSignature
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t||self).Typed=s()}(this,function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},t.apply(this,arguments)}var s={strings:["These are the default values...","You know what you should do?","Use your own!","Have a great day!"],stringsElement:null,typeSpeed:0,startDelay:0,backSpeed:0,smartBackspace:!0,shuffle:!1,backDelay:700,fadeOut:!1,fadeOutClass:"typed-fade-out",fadeOutDelay:500,loop:!1,loopCount:Infinity,showCursor:!0,cursorChar:"|",autoInsertCss:!0,attr:null,bindInputFocusEvents:!1,contentType:"html",onBegin:function(t){},onComplete:function(t){},preStringTyped:function(t,s){},onStringTyped:function(t,s){},onLastStringBackspaced:function(t){},onTypingPaused:function(t,s){},onTypingResumed:function(t,s){},onReset:function(t){},onStop:function(t,s){},onStart:function(t,s){},onDestroy:function(t){}},e=new(/*#__PURE__*/function(){function e(){}var n=e.prototype;return n.load=function(e,n,i){if(e.el="string"==typeof i?document.querySelector(i):i,e.options=t({},s,n),e.isInput="input"===e.el.tagName.toLowerCase(),e.attr=e.options.attr,e.bindInputFocusEvents=e.options.bindInputFocusEvents,e.showCursor=!e.isInput&&e.options.showCursor,e.cursorChar=e.options.cursorChar,e.cursorBlinking=!0,e.elContent=e.attr?e.el.getAttribute(e.attr):e.el.textContent,e.contentType=e.options.contentType,e.typeSpeed=e.options.typeSpeed,e.startDelay=e.options.startDelay,e.backSpeed=e.options.backSpeed,e.smartBackspace=e.options.smartBackspace,e.backDelay=e.options.backDelay,e.fadeOut=e.options.fadeOut,e.fadeOutClass=e.options.fadeOutClass,e.fadeOutDelay=e.options.fadeOutDelay,e.isPaused=!1,e.strings=e.options.strings.map(function(t){return t.trim()}),e.stringsElement="string"==typeof e.options.stringsElement?document.querySelector(e.options.stringsElement):e.options.stringsElement,e.stringsElement){e.strings=[],e.stringsElement.style.cssText="clip: rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;";var r=Array.prototype.slice.apply(e.stringsElement.children),o=r.length;if(o)for(var a=0;a<o;a+=1)e.strings.push(r[a].innerHTML.trim())}for(var u in e.strPos=0,e.currentElContent=this.getCurrentElContent(e),e.currentElContent&&e.currentElContent.length>0&&(e.strPos=e.currentElContent.length-1,e.strings.unshift(e.currentElContent)),e.sequence=[],e.strings)e.sequence[u]=u;e.arrayPos=0,e.stopNum=0,e.loop=e.options.loop,e.loopCount=e.options.loopCount,e.curLoop=0,e.shuffle=e.options.shuffle,e.pause={status:!1,typewrite:!0,curString:"",curStrPos:0},e.typingComplete=!1,e.autoInsertCss=e.options.autoInsertCss,e.autoInsertCss&&(this.appendCursorAnimationCss(e),this.appendFadeOutAnimationCss(e))},n.getCurrentElContent=function(t){return t.attr?t.el.getAttribute(t.attr):t.isInput?t.el.value:"html"===t.contentType?t.el.innerHTML:t.el.textContent},n.appendCursorAnimationCss=function(t){var s="data-typed-js-cursor-css";if(t.showCursor&&!document.querySelector("["+s+"]")){var e=document.createElement("style");e.setAttribute(s,"true"),e.innerHTML="\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n ",document.body.appendChild(e)}},n.appendFadeOutAnimationCss=function(t){var s="data-typed-fadeout-js-css";if(t.fadeOut&&!document.querySelector("["+s+"]")){var e=document.createElement("style");e.setAttribute(s,"true"),e.innerHTML="\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n ",document.body.appendChild(e)}},e}()),n=new(/*#__PURE__*/function(){function t(){}var s=t.prototype;return s.typeHtmlChars=function(t,s,e){if("html"!==e.contentType)return s;var n=t.substring(s).charAt(0);if("<"===n||"&"===n){var i;for(i="<"===n?">":";";t.substring(s+1).charAt(0)!==i&&!(1+ ++s>t.length););s++}return s},s.backSpaceHtmlChars=function(t,s,e){if("html"!==e.contentType)return s;var n=t.substring(s).charAt(0);if(">"===n||";"===n){var i;for(i=">"===n?"<":"&";t.substring(s-1).charAt(0)!==i&&!(--s<0););s--}return s},t}());/*#__PURE__*/
|
||||||
|
return function(){function t(t,s){e.load(this,s,t),this.begin()}var s=t.prototype;return s.toggle=function(){this.pause.status?this.start():this.stop()},s.stop=function(){this.typingComplete||this.pause.status||(this.toggleBlinking(!0),this.pause.status=!0,this.options.onStop(this.arrayPos,this))},s.start=function(){this.typingComplete||this.pause.status&&(this.pause.status=!1,this.pause.typewrite?this.typewrite(this.pause.curString,this.pause.curStrPos):this.backspace(this.pause.curString,this.pause.curStrPos),this.options.onStart(this.arrayPos,this))},s.destroy=function(){this.reset(!1),this.options.onDestroy(this)},s.reset=function(t){void 0===t&&(t=!0),clearInterval(this.timeout),this.replaceText(""),this.cursor&&this.cursor.parentNode&&(this.cursor.parentNode.removeChild(this.cursor),this.cursor=null),this.strPos=0,this.arrayPos=0,this.curLoop=0,t&&(this.insertCursor(),this.options.onReset(this),this.begin())},s.begin=function(){var t=this;this.options.onBegin(this),this.typingComplete=!1,this.shuffleStringsIfNeeded(this),this.insertCursor(),this.bindInputFocusEvents&&this.bindFocusEvents(),this.timeout=setTimeout(function(){0===t.strPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],t.strPos):t.backspace(t.strings[t.sequence[t.arrayPos]],t.strPos)},this.startDelay)},s.typewrite=function(t,s){var e=this;this.fadeOut&&this.el.classList.contains(this.fadeOutClass)&&(this.el.classList.remove(this.fadeOutClass),this.cursor&&this.cursor.classList.remove(this.fadeOutClass));var i=this.humanizer(this.typeSpeed),r=1;!0!==this.pause.status?this.timeout=setTimeout(function(){s=n.typeHtmlChars(t,s,e);var i=0,o=t.substring(s);if("^"===o.charAt(0)&&/^\^\d+/.test(o)){var a=1;a+=(o=/\d+/.exec(o)[0]).length,i=parseInt(o),e.temporaryPause=!0,e.options.onTypingPaused(e.arrayPos,e),t=t.substring(0,s)+t.substring(s+a),e.toggleBlinking(!0)}if("`"===o.charAt(0)){for(;"`"!==t.substring(s+r).charAt(0)&&(r++,!(s+r>t.length)););var u=t.substring(0,s),p=t.substring(u.length+1,s+r),c=t.substring(s+r+1);t=u+p+c,r--}e.timeout=setTimeout(function(){e.toggleBlinking(!1),s>=t.length?e.doneTyping(t,s):e.keepTyping(t,s,r),e.temporaryPause&&(e.temporaryPause=!1,e.options.onTypingResumed(e.arrayPos,e))},i)},i):this.setPauseStatus(t,s,!0)},s.keepTyping=function(t,s,e){0===s&&(this.toggleBlinking(!1),this.options.preStringTyped(this.arrayPos,this));var n=t.substring(0,s+=e);this.replaceText(n),this.typewrite(t,s)},s.doneTyping=function(t,s){var e=this;this.options.onStringTyped(this.arrayPos,this),this.toggleBlinking(!0),this.arrayPos===this.strings.length-1&&(this.complete(),!1===this.loop||this.curLoop===this.loopCount)||(this.timeout=setTimeout(function(){e.backspace(t,s)},this.backDelay))},s.backspace=function(t,s){var e=this;if(!0!==this.pause.status){if(this.fadeOut)return this.initFadeOut();this.toggleBlinking(!1);var i=this.humanizer(this.backSpeed);this.timeout=setTimeout(function(){s=n.backSpaceHtmlChars(t,s,e);var i=t.substring(0,s);if(e.replaceText(i),e.smartBackspace){var r=e.strings[e.arrayPos+1];e.stopNum=r&&i===r.substring(0,s)?s:0}s>e.stopNum?(s--,e.backspace(t,s)):s<=e.stopNum&&(e.arrayPos++,e.arrayPos===e.strings.length?(e.arrayPos=0,e.options.onLastStringBackspaced(),e.shuffleStringsIfNeeded(),e.begin()):e.typewrite(e.strings[e.sequence[e.arrayPos]],s))},i)}else this.setPauseStatus(t,s,!1)},s.complete=function(){this.options.onComplete(this),this.loop?this.curLoop++:this.typingComplete=!0},s.setPauseStatus=function(t,s,e){this.pause.typewrite=e,this.pause.curString=t,this.pause.curStrPos=s},s.toggleBlinking=function(t){this.cursor&&(this.pause.status||this.cursorBlinking!==t&&(this.cursorBlinking=t,t?this.cursor.classList.add("typed-cursor--blink"):this.cursor.classList.remove("typed-cursor--blink")))},s.humanizer=function(t){return Math.round(Math.random()*t/2)+t},s.shuffleStringsIfNeeded=function(){this.shuffle&&(this.sequence=this.sequence.sort(function(){return Math.random()-.5}))},s.initFadeOut=function(){var t=this;return this.el.className+=" "+this.fadeOutClass,this.cursor&&(this.cursor.className+=" "+this.fadeOutClass),setTimeout(function(){t.arrayPos++,t.replaceText(""),t.strings.length>t.arrayPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],0):(t.typewrite(t.strings[0],0),t.arrayPos=0)},this.fadeOutDelay)},s.replaceText=function(t){this.attr?this.el.setAttribute(this.attr,t):this.isInput?this.el.value=t:"html"===this.contentType?this.el.innerHTML=t:this.el.textContent=t},s.bindFocusEvents=function(){var t=this;this.isInput&&(this.el.addEventListener("focus",function(s){t.stop()}),this.el.addEventListener("blur",function(s){t.el.value&&0!==t.el.value.length||t.start()}))},s.insertCursor=function(){this.showCursor&&(this.cursor||(this.cursor=document.createElement("span"),this.cursor.className="typed-cursor",this.cursor.setAttribute("aria-hidden",!0),this.cursor.innerHTML=this.cursorChar,this.el.parentNode&&this.el.parentNode.insertBefore(this.cursor,this.el.nextSibling)))},t}()});
|
||||||
|
//# sourceMappingURL=typed.umd.js.map
|
||||||
Reference in New Issue
Block a user