templates/public/events/_calendar.html.twig line 1
<style>.fc-tooltip {position: absolute;background: #ffffff;border: 1px solid var(--color-border-light);padding: 10px 12px;border-radius: 8px;box-shadow: 0 6px 18px rgba(0,0,0,0.15);font-size: 13px;z-index: 9999;max-width: 240px;}.fc-tooltip a {display: inline-block;margin-top: 6px;font-weight: 600;text-decoration: none;color: var(--color-course-icon);}.fc-h-event.fc-event-open,.fc-event.fc-event-open,.fc-event-open .fc-event-main {background: #198754 !important;border-color: #198754 !important;}.fc-h-event.fc-event-muted,.fc-event.fc-event-muted,.fc-event-muted .fc-event-main {background: #dfe3e8 !important;border-color: #dfe3e8 !important;color: #5f6b7a !important;}.fc-daygrid-more-link {color: var(--color-primary) !important;font-weight: 600;}.fc .fc-col-header-cell-cushion {display: block;padding: 8px 4px;white-space: nowrap;text-transform: capitalize;font-size: 0.92rem;}.fc .fc-toolbar-title {font-size: 1.2rem;}@media (max-width: 768px) {.calendar-wrapper {padding: 12px 8px;}.fc .fc-toolbar.fc-header-toolbar {gap: 8px;margin-bottom: 0.85rem;}.fc .fc-toolbar-title {font-size: 1rem;}.fc .fc-button {padding: 0.34rem 0.58rem;font-size: 0.8rem;}.fc .fc-col-header-cell-cushion {padding: 6px 2px;font-size: 0.74rem;letter-spacing: 0.01em;}}@media (max-width: 576px) {.fc .fc-col-header-cell-cushion {padding: 6px 1px;font-size: 0.7rem;}}</style><div class="calendar-wrapper"><div id="calendar"></div></div><script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script><script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/locales-all.global.min.js"></script><script>document.addEventListener('DOMContentLoaded', function () {const calendarEl = document.getElementById('calendar');let tooltip = null;if (!calendarEl) return;const mobileBreakpoint = window.matchMedia('(max-width: 576px)');const tabletBreakpoint = window.matchMedia('(max-width: 768px)');function getResponsiveCalendarOptions() {if (mobileBreakpoint.matches) {return {dayHeaderFormat: { weekday: 'narrow' },aspectRatio: 0.78,dayMaxEventRows: 1,};}if (tabletBreakpoint.matches) {return {dayHeaderFormat: { weekday: 'short' },aspectRatio: 1.0,dayMaxEventRows: 1,};}return {dayHeaderFormat: { weekday: 'long' },aspectRatio: 1.2,dayMaxEventRows: 2,};}const calendar = new FullCalendar.Calendar(calendarEl, {initialView: 'dayGridMonth',height: 'auto',firstDay: 1,locale: 'es',fixedWeekCount: false,dayMaxEvents: true,dayMaxEventRows: getResponsiveCalendarOptions().dayMaxEventRows,moreLinkText: function (n) {return '+' + n + ' más';},aspectRatio: getResponsiveCalendarOptions().aspectRatio,headerToolbar: {left: 'prev,next today',center: 'title',right: ''},buttonText: {today: 'Hoy'},dayHeaderFormat: getResponsiveCalendarOptions().dayHeaderFormat,eventClassNames: function (info) {if (info.event.extendedProps.statusKey === 'open') {return ['fc-event-open'];}return ['fc-event-muted'];},events: [{% for e in events %}{% set today = "now"|date("Y-m-d") %}{% set ini = e.inscripcionesInicio ? e.inscripcionesInicio|date("Y-m-d") : null %}{% set fin = e.inscripcionesFin ? e.inscripcionesFin|date("Y-m-d") : null %}{% set inscriptionStatus = '' %}{% set statusKey = 'open' %}{% if ini and fin %}{% if today >= ini and today <= fin %}{% set inscriptionStatus = 'Inscripciones abiertas' %}{% set statusKey = 'open' %}{% elseif today < ini %}{% set inscriptionStatus = 'Próximamente' %}{% set statusKey = 'upcoming' %}{% else %}{% set inscriptionStatus = 'Inscripciones cerradas' %}{% set statusKey = 'closed' %}{% endif %}{% endif %}{title: '{{ e.name|e("js") }}',start: '{{ e.startDate|date("Y-m-d") }}',end: '{{ e.endDate|date("Y-m-d") }}',url: '{{ path("events_public_ficha", { extCode: e.extCode }) }}',extendedProps: {modality: '{{ e.modality ? e.modality.label|e("js") : "" }}',inscriptionStatus: '{{ inscriptionStatus|e("js") }}',statusKey: '{{ statusKey }}'}},{% endfor %}],eventMouseEnter: function (info) {const event = info.event;tooltip = document.createElement('div');tooltip.className = 'fc-tooltip';tooltip.innerHTML = `<strong>${event.title}</strong><br>${event.extendedProps.modality || ''}<br>${event.extendedProps.inscriptionStatus || ''}`;document.body.appendChild(tooltip);const rect = info.el.getBoundingClientRect();tooltip.style.left =rect.left + window.scrollX + 'px';tooltip.style.top =rect.top + window.scrollY - tooltip.offsetHeight - 8 + 'px';},eventMouseLeave: function () {if (tooltip) {tooltip.remove();tooltip = null;}}});function applyResponsiveOptions() {const responsiveOptions = getResponsiveCalendarOptions();calendar.batchRendering(function () {calendar.setOption('dayHeaderFormat', responsiveOptions.dayHeaderFormat);calendar.setOption('aspectRatio', responsiveOptions.aspectRatio);calendar.setOption('dayMaxEventRows', responsiveOptions.dayMaxEventRows);});}function bindMediaQueryChange(mediaQuery, handler) {if (typeof mediaQuery.addEventListener === 'function') {mediaQuery.addEventListener('change', handler);return;}if (typeof mediaQuery.addListener === 'function') {mediaQuery.addListener(handler);}}bindMediaQueryChange(mobileBreakpoint, applyResponsiveOptions);bindMediaQueryChange(tabletBreakpoint, applyResponsiveOptions);calendar.render();applyResponsiveOptions();});</script>