Files
cv-site/templates/partials/modals/pdf-modal.html
T

282 lines
12 KiB
HTML
Raw Normal View History

2025-11-12 18:26:18 +00:00
{{define "pdf-modal"}}
<!-- PDF Download Modal - Interactive Thumbnails -->
<dialog id="pdf-modal" class="info-modal pdf-download-modal no-print"
2025-11-14 21:38:09 +00:00
_="on click
if event.target is me
call me.close()
end">
2025-11-12 19:13:52 +00:00
<div class="info-modal-content">
<!-- Close Button -->
<button class="info-modal-close"
onclick="document.getElementById('pdf-modal').close()"
aria-label="{{if eq .Lang "es"}}Cerrar{{else}}Close{{end}}">
2025-11-12 18:26:18 +00:00
<iconify-icon icon="mdi:close" width="24" height="24"></iconify-icon>
</button>
<!-- Header -->
2025-11-12 18:26:18 +00:00
<div class="info-modal-header">
<iconify-icon icon="catppuccin:pdf" width="40" height="40" style="margin-bottom: 0.5rem;"></iconify-icon>
<h2>{{if eq .Lang "es"}}Descargar PDF{{else}}Download PDF{{end}}</h2>
<p class="pdf-modal-subtitle">
{{if eq .Lang "es"}}Elige tu formato preferido{{else}}Choose your preferred format{{end}}
</p>
2025-11-12 18:26:18 +00:00
</div>
<!-- Body: Three Thumbnail Cards -->
<div class="pdf-options-grid">
<!-- Short CV Card -->
<div class="pdf-option-card"
data-cv-format="short"
role="radio"
aria-checked="false"
2025-11-19 17:27:39 +00:00
aria-label="{{if eq .Lang "es"}}CV Corto - 4 páginas, información esencial{{else}}Short CV - 4 pages, essential information{{end}}"
tabindex="0"
_="on click
-- Remove selected from all cards
set cards to .pdf-option-card in #pdf-modal
for card in cards
remove .selected from card
set card's @aria-checked to 'false'
end
-- Add selected to this card
add .selected to me
set my @aria-checked to 'true'
-- Enable download button
set downloadBtn to .pdf-download-btn in #pdf-modal
remove @disabled from downloadBtn
-- Store selected format
set :selectedFormat to my @data-cv-format
-- Announce to screen readers
set announcement to #pdf-selection-announcement
if :selectedFormat is 'short'
set announcement.textContent to '{{if eq .Lang "es"}}Seleccionado: CV Corto - Una página{{else}}Selected: Short CV - One page{{end}}'
end
end
on keydown
if event.key is 'Enter' or event.key is ' '
halt the event
trigger click on me
end
end">
<div class="pdf-thumbnail thumbnail-short">
<!-- Header representation -->
<div class="skeleton-block" style="height: 48px;"></div>
<!-- Content sections (compact) -->
<div class="skeleton-block" style="height: 60px;"></div>
<div class="skeleton-block" style="height: 60px;"></div>
<div class="skeleton-block" style="height: 60px;"></div>
<!-- Page count badge -->
<div class="thumbnail-badge">
{{if eq .Lang "es"}}4 Páginas{{else}}4 Pages{{end}}
</div>
</div>
<div class="pdf-option-info">
2025-11-19 17:27:39 +00:00
<h3>{{if eq .Lang "es"}}CV Corto (4 páginas){{else}}Short CV (4 pages){{end}}</h3>
<p>{{if eq .Lang "es"}}Información esencial{{else}}Essential info{{end}}</p>
</div>
<div class="pdf-option-badge">
<iconify-icon icon="mdi:check-circle" width="32" height="32"></iconify-icon>
</div>
</div>
2025-11-19 17:27:39 +00:00
<!-- Extended CV Card -->
<div class="pdf-option-card"
data-cv-format="long"
role="radio"
aria-checked="false"
2025-11-19 17:27:39 +00:00
aria-label="{{if eq .Lang "es"}}CV Extendido - 8 páginas, versión completa{{else}}Extended CV - 8 pages, full version{{end}}"
tabindex="0"
_="on click
-- Remove selected from all cards
set cards to .pdf-option-card in #pdf-modal
for card in cards
remove .selected from card
set card's @aria-checked to 'false'
end
-- Add selected to this card
add .selected to me
set my @aria-checked to 'true'
-- Enable download button
set downloadBtn to .pdf-download-btn in #pdf-modal
remove @disabled from downloadBtn
-- Store selected format
set :selectedFormat to my @data-cv-format
-- Announce to screen readers
set announcement to #pdf-selection-announcement
if :selectedFormat is 'long'
set announcement.textContent to '{{if eq .Lang "es"}}Seleccionado: CV Completo - Versión completa{{else}}Selected: Long CV - Full version{{end}}'
end
end
on keydown
if event.key is 'Enter' or event.key is ' '
halt the event
trigger click on me
end
end">
<div class="pdf-thumbnail thumbnail-long">
<!-- Header representation -->
<div class="skeleton-block" style="height: 48px;"></div>
<!-- More content sections (detailed) -->
<div class="skeleton-block" style="height: 40px;"></div>
<div class="skeleton-block" style="height: 40px;"></div>
<div class="skeleton-block" style="height: 40px;"></div>
<div class="skeleton-block" style="height: 40px;"></div>
<div class="skeleton-block" style="height: 40px;"></div>
<!-- Page count badge -->
<div class="thumbnail-badge">
{{if eq .Lang "es"}}8 Páginas{{else}}8 Pages{{end}}
</div>
</div>
<div class="pdf-option-info">
2025-11-19 17:27:39 +00:00
<h3>{{if eq .Lang "es"}}CV Extendido (8 páginas){{else}}Extended CV (8 pages){{end}}</h3>
<p>{{if eq .Lang "es"}}Todos los detalles{{else}}All details{{end}}</p>
</div>
<div class="pdf-option-badge">
<iconify-icon icon="mdi:check-circle" width="32" height="32"></iconify-icon>
</div>
</div>
<!-- Current View Card -->
<div class="pdf-option-card"
data-cv-format="current"
role="radio"
aria-checked="false"
aria-label="{{if eq .Lang "es"}}Vista Actual - Como se ve en pantalla{{else}}Current View - As shown on screen{{end}}"
tabindex="0"
_="on click
-- Remove selected from all cards
set cards to .pdf-option-card in #pdf-modal
for card in cards
remove .selected from card
set card's @aria-checked to 'false'
end
-- Add selected to this card
add .selected to me
set my @aria-checked to 'true'
-- Enable download button
set downloadBtn to .pdf-download-btn in #pdf-modal
remove @disabled from downloadBtn
-- Store selected format
set :selectedFormat to my @data-cv-format
-- Announce to screen readers
set announcement to #pdf-selection-announcement
if :selectedFormat is 'current'
set announcement.textContent to '{{if eq .Lang "es"}}Seleccionado: Vista Actual{{else}}Selected: Current View{{end}}'
end
end
on keydown
if event.key is 'Enter' or event.key is ' '
halt the event
trigger click on me
end
end">
<div class="pdf-thumbnail thumbnail-custom">
<!-- Centered icon representing current screen view -->
<div class="custom-placeholder">
<iconify-icon icon="mdi:monitor" width="80" height="80"></iconify-icon>
<p>{{if eq .Lang "es"}}En Pantalla{{else}}On Screen{{end}}</p>
</div>
<!-- Current view badge -->
<div class="thumbnail-badge">
{{if eq .Lang "es"}}Vista Actual{{else}}Current{{end}}
</div>
</div>
<div class="pdf-option-info">
<h3>{{if eq .Lang "es"}}Vista Actual{{else}}Current View{{end}}</h3>
<p>{{if eq .Lang "es"}}Como se ve en pantalla{{else}}As shown on screen{{end}}</p>
</div>
<div class="pdf-option-badge">
<iconify-icon icon="mdi:check-circle" width="32" height="32"></iconify-icon>
</div>
</div>
</div>
<!-- Footer: Download Button -->
<div class="pdf-modal-footer">
<button class="pdf-download-btn"
id="pdf-download-btn"
disabled
onclick="downloadPDF()">
<iconify-icon icon="mdi:download" width="20" height="20"></iconify-icon>
{{if eq .Lang "es"}}Descargar PDF{{else}}Download PDF{{end}}
</button>
2025-11-12 18:26:18 +00:00
</div>
<script>
function downloadPDF() {
const selectedCard = document.querySelector('#pdf-modal .pdf-option-card.selected');
if (!selectedCard) {
console.error('No card selected');
return;
}
const selectedFormat = selectedCard.getAttribute('data-cv-format');
const lang = '{{.Lang}}';
let url;
console.log('Download requested for format:', selectedFormat);
if (selectedFormat === 'short') {
// Short CV: clean version (no skills), detailed length
url = `/export/pdf?lang=${lang}&length=detailed&icons=show&version=clean`;
} else if (selectedFormat === 'long') {
// Long CV: with skills sidebar, extended length
url = `/export/pdf?lang=${lang}&length=extended&icons=show&version=with_skills`;
} else if (selectedFormat === 'current') {
// Current view: use localStorage settings
let currentLength = localStorage.getItem('cv-length') || 'short';
// Map old values to new naming convention
if (currentLength === 'short') currentLength = 'detailed';
if (currentLength === 'long') currentLength = 'extended';
const currentIcons = localStorage.getItem('cv-icons') || 'show';
const currentTheme = localStorage.getItem('cv-theme') || 'default';
const version = currentTheme === 'clean' ? 'clean' : 'with_skills';
url = `/export/pdf?lang=${lang}&length=${currentLength}&icons=${currentIcons}&version=${version}`;
}
console.log('Navigating to:', url);
window.location.href = url;
setTimeout(() => {
document.getElementById('pdf-modal').close();
}, 500);
}
</script>
<!-- Screen Reader Announcement Area -->
<div id="pdf-selection-announcement" class="sr-only" aria-live="polite" aria-atomic="true"></div>
2025-11-12 18:26:18 +00:00
</div>
2025-11-12 19:13:52 +00:00
</dialog>
2025-11-12 18:26:18 +00:00
{{end}}