Heavily customized version of smokesignal - https://whtwnd.com/kayrozen.com/3lpwe4ymowg2t
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 96 lines 3.9 kB view raw
1<div class="calendar-mini"> 2 <div class="field"> 3 <label class="label">{{ t("select-date") | default("Select Date") }}</label> 4 <div class="control"> 5 <input 6 id="mini-calendar-picker" 7 type="date" 8 class="input" 9 style="display: none;"> 10 </div> 11 </div> 12</div> 13 14<script> 15function initializeMiniCalendar() { 16 // Initialize the Bulma Calendar 17 const calendarElement = document.getElementById('mini-calendar-picker'); 18 if (calendarElement && typeof bulmaCalendar !== 'undefined') { 19 // Check if calendar is already initialized and destroy it 20 if (calendarElement.bulmaCalendar) { 21 calendarElement.bulmaCalendar.destroy(); 22 } 23 24 // Map current locale to determine language for labels 25 const currentLocale = '{{ current_locale | default("fr-ca") }}'; 26 const isFrench = currentLocale && currentLocale.startsWith('fr'); 27 28 // Get bookmarked event dates for highlighting 29 const bookmarkedDates = window.bookmarkedEventDates || []; 30 console.log('Bookmarked dates for calendar:', bookmarkedDates); 31 32 // Simple initialization with minimal options 33 const calendar = new bulmaCalendar(calendarElement, { 34 type: 'date', 35 displayMode: 'inline', 36 // Add French labels when language is French 37 cancelLabel: isFrench ? 'Annuler' : 'Cancel', 38 clearLabel: isFrench ? 'Effacer' : 'Clear', 39 todayLabel: isFrench ? "Aujourd'hui" : 'Today', 40 nowLabel: isFrench ? 'Maintenant' : 'Now', 41 validateLabel: isFrench ? 'Valider' : 'Validate', 42 // Callback to highlight dates after calendar is ready 43 onReady: function(instance) { 44 console.log('Calendar ready, highlighting bookmarked dates...'); 45 highlightBookmarkedDates(bookmarkedDates, isFrench); 46 } 47 }); 48 49 // Add event listener for date selection 50 if (calendar) { 51 calendar.on('select', function(date) { 52 console.log('Date selected:', date); 53 // You can add custom logic here when a date is selected 54 // For example, trigger an HTMX request to update events 55 // htmx.trigger('#some-element', 'dateChanged', {detail: {date: date}}); 56 }); 57 } 58 } 59} 60 61// Function to highlight bookmarked dates 62function highlightBookmarkedDates(bookmarkedDates, isFrench) { 63 if (!bookmarkedDates || bookmarkedDates.length === 0) return; 64 65 bookmarkedDates.forEach(dateStr => { 66 const targetDay = parseInt(dateStr.split('-')[2]).toString(); 67 console.log('Highlighting day:', targetDay, 'from date:', dateStr); 68 69 // Find date items in current month 70 const dateItems = document.querySelectorAll('.datepicker-date.is-current-month .date-item'); 71 72 dateItems.forEach((item) => { 73 if (item.textContent.trim() === targetDay) { 74 console.log('Found and highlighting day:', targetDay); 75 item.classList.add('has-bookmark-event'); 76 item.style.backgroundColor = '#ff6b6b'; 77 item.style.color = 'white'; 78 item.style.fontWeight = 'bold'; 79 item.style.borderRadius = '50%'; 80 item.title = isFrench ? 'Événement marqué' : 'Bookmarked event'; 81 } 82 }); 83 }); 84} 85 86// Initialize on page load 87document.addEventListener('DOMContentLoaded', initializeMiniCalendar); 88 89// Reinitialize after HTMX updates 90document.addEventListener('htmx:afterSettle', function(event) { 91 // Check if the updated content contains our calendar 92 if (event.target.id === 'mini-calendar' || event.target.querySelector('#mini-calendar-picker')) { 93 initializeMiniCalendar(); 94 } 95}); 96</script>