|
76 | 76 | <div class="events--calendar--head--prev-next">
|
77 | 77 | <div class="events--calendar--head--prev-next--prev">
|
78 | 78 | {% if page.previous %}
|
79 |
| - <a href="{{ page.previous.url }}">< Previous</a> |
| 79 | + <a class="events--calendar--head--prev-next--anchor" href="{{ page.previous.url }}">< Previous</a> |
80 | 80 | {% else %}
|
81 | 81 | <span>Previous</span>
|
82 | 82 | {% endif %}
|
83 | 83 | </div>
|
84 | 84 | <div class="events--calendar--head--prev-next--next">
|
85 | 85 | {% if page.next %}
|
86 |
| - <a href="{{ page.next.url }}">Next ></a> |
| 86 | + <a class="events--calendar--head--prev-next--anchor" href="{{ page.next.url }}">Next ></a> |
87 | 87 | {% else %}
|
88 | 88 | <span>Next ></span>
|
89 | 89 | {% endif %}
|
|
115 | 115 | {% endif %}
|
116 | 116 | <div class="events--calendar--body--week--day--event {{ event_category_classname }}">
|
117 | 117 | <div class="events--calendar--body--week--day--event--name">
|
118 |
| - <a href="{{ event.url }}" tile="{{ event.title }}">{{ event.title }}</a> |
| 118 | + <a class="events--calendar--body--week--day--event--name--anchor" |
| 119 | + href="{{ event.url }}" |
| 120 | + title="{{ event.title }}" |
| 121 | + >{{ event.title }}</a> |
119 | 122 | </div>
|
120 | 123 | <div class="events--calendar--body--week--day--event--details" data-eventurl="{{ event.url }}">
|
121 | 124 | <div class="events--calendar--body--week--day--event--details--close-button">
|
@@ -548,12 +551,20 @@ <h2 class="platform-page--solution--header">Connect with the community</h2>
|
548 | 551 | event.preventDefault();
|
549 | 552 | } else {
|
550 | 553 | // Determine if the click did NOT occur within the card iteself (say for example in a link).
|
551 |
| - // Hide it if there was a a "click-away" event. |
| 554 | + // Hide it if there was a "click-away" event. |
552 | 555 | const detailsCard = e.target.closest('.events--calendar--body--week--day--event--details');
|
553 | 556 | const clickWasInsideCard = detailsCard !== null;
|
554 | 557 | if (!clickWasInsideCard) {
|
555 | 558 | hideEventDetails(currentlyVisibleDetails);
|
556 |
| - event.preventDefault(); |
| 559 | + const allowableAnchorClassNames = [ |
| 560 | + 'events--calendar--head--prev-next--anchor', |
| 561 | + 'events--calendar--body--week--day--event--name--anchor', |
| 562 | + ]; |
| 563 | + if (!allowableAnchorClassNames.some(className => e.target.classList.contains(className))) { |
| 564 | + // If an event name was NOT clicked then prevent the default action. |
| 565 | + // Otherwise allow the navigation to the clicked event to be performed. |
| 566 | + event.preventDefault(); |
| 567 | + } |
557 | 568 | }
|
558 | 569 | }
|
559 | 570 | } else {
|
@@ -667,7 +678,89 @@ <h2 class="platform-page--solution--header">Connect with the community</h2>
|
667 | 678 | });
|
668 | 679 | }
|
669 | 680 | }
|
| 681 | + |
| 682 | + const filterStateStorageName = 'events--calendar--filters'; |
| 683 | + function readFilterState() { |
| 684 | + const filterStateJson = window.sessionStorage.getItem(filterStateStorageName); |
| 685 | + if (filterStateJson) { |
| 686 | + const parsedFilterState = JSON.parse(filterStateJson); |
| 687 | + return parsedFilterState; |
| 688 | + } |
| 689 | + return null; |
| 690 | + } |
| 691 | + |
| 692 | + function writeFilterState() { |
| 693 | + const defaultFilterState = { |
| 694 | + categories: [], |
| 695 | + showInPersonEvents: true, |
| 696 | + }; |
| 697 | + const filteredCategoriesSelector = '.events--calendar.events--calendar__filtered'; |
| 698 | + const selectedCategoriesAttributeName = 'data-filtercategory'; |
| 699 | + const filteredCategories = ( |
| 700 | + document.querySelector( |
| 701 | + filteredCategoriesSelector |
| 702 | + )?.getAttribute?.( |
| 703 | + selectedCategoriesAttributeName |
| 704 | + ) ?? '' |
| 705 | + ).split(',').filter(category => category !== ''); |
| 706 | + const onlineOnlySelector = '.events--calendar.events--calendar__filtered.events--calendar__online-only'; |
| 707 | + const onlineOnly = !!document.querySelector(onlineOnlySelector); |
| 708 | + const filterState = { |
| 709 | + ...defaultFilterState, |
| 710 | + categories: [...filteredCategories], |
| 711 | + showInPersonEvents: !onlineOnly, |
| 712 | + }; |
| 713 | + const filterStateJson = JSON.stringify(filterState, null, 2); |
| 714 | + window.sessionStorage.setItem(filterStateStorageName, filterStateJson); |
| 715 | + } |
| 716 | + |
| 717 | + function initializeFilterStateDOM(filterState) { |
| 718 | + if (!filterState) { |
| 719 | + return; |
| 720 | + } |
| 721 | + const { |
| 722 | + categories = [], |
| 723 | + showInPersonEvents = true |
| 724 | + } = filterState; |
| 725 | + const calendarSelector = '.events--calendar'; |
| 726 | + const eventsCalendarElement = document.querySelector(calendarSelector); |
| 727 | + const selectedCategoriesAttributeName = 'data-filtercategory'; |
| 728 | + const selectedCategoryCount = categories?.length ?? 0; |
| 729 | + if (!showInPersonEvents) { |
| 730 | + const inPersonToggleSelector = '.events--calendar--filters--in-person-toggle'; |
| 731 | + const onlineOnlyClass = 'events--calendar--filters--in-person-toggle__toggled-off'; |
| 732 | + const onlineOnlyCalendarClass = 'events--calendar__online-only'; |
| 733 | + eventsCalendarElement?.classList?.add?.(onlineOnlyCalendarClass); |
| 734 | + document.querySelector(inPersonToggleSelector)?.classList?.add?.(onlineOnlyClass); |
| 735 | + } |
| 736 | + |
| 737 | + if (selectedCategoryCount > 0) { |
| 738 | + const categoryList = categories.join(','); |
| 739 | + const calendarFilteredClassName = 'events--calendar__filtered'; |
| 740 | + eventsCalendarElement?.setAttribute?.(selectedCategoriesAttributeName, categoryList); |
| 741 | + eventsCalendarElement?.classList?.add?.(calendarFilteredClassName); |
| 742 | + |
| 743 | + const categorySelectElementId = 'category-filter-selectorFilter-by-Category'; |
| 744 | + const categorySelectElement = document.getElementById(categorySelectElementId); |
| 745 | + const labelSelector = `label[for="${categorySelectElementId}"]`; |
| 746 | + const labelText = `Filter by Category (${selectedCategoryCount})`; |
| 747 | + const labelElement = document.querySelector(labelSelector); |
| 748 | + |
| 749 | + categories.forEach(category => { |
| 750 | + categorySelectElement?.querySelector?.(`option[value="${category}"]`)?.setAttribute?.('selected', ''); |
| 751 | + addFilterChip(category); |
| 752 | + }); |
| 753 | + if (labelElement) { |
| 754 | + labelElement.textContent = labelText; |
| 755 | + } |
| 756 | + } |
| 757 | + } |
| 758 | + |
670 | 759 | setEventsPageLinksToThisMonthCalendar();
|
671 | 760 | localizeEventDates();
|
| 761 | + initializeFilterStateDOM(readFilterState()); |
| 762 | + window.addEventListener('beforeunload', () => { |
| 763 | + writeFilterState(); |
| 764 | + }); |
672 | 765 | });
|
673 | 766 | </script>
|
0 commit comments