Skip to content

Commit

Permalink
VACMS-18267 Remove old accordion toggle function (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
randimays authored Jun 5, 2024
1 parent e8c3427 commit 4bd74ce
Showing 1 changed file with 24 additions and 60 deletions.
84 changes: 24 additions & 60 deletions src/site/layouts/event.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

<!-- CTA -->
{% if fieldLink or fieldEventCta or fieldAdditionalInformationAbo %}
<div class="registration vads-u-margin-top--4 vads-u-margin-bottom--1 vads-u-padding-x--1p5">
<div class="registration vads-u-margin-top--4 vads-u-margin-bottom--1 vads-u-padding-x--1p5 medium-screen:vads-u-padding--0">
{% if start_timestamp < current_timestamp %}
<p class="vads-u-margin--0 vads-u-color--secondary vads-u-font-weight--bold">This event already happened.</p>
{% else %}
Expand Down Expand Up @@ -306,65 +306,29 @@
</div>

<script nonce="**CSP_NONCE**" type="text/javascript">
function onExpandRecurringEventsClick() {
var expandRecurringEventsButton = document.getElementById('expand-recurring-events');
var expandRecurringEventsIcon = document.getElementById('expand-recurring-events-icon');
var recurringEvents = document.getElementById('recurring-events');
// Escape early if we are not able to find the elements.
if (!expandRecurringEventsButton || !expandRecurringEventsIcon || !recurringEvents) {
return;
}
// Toggle the bottom borders of the button.
if (expandRecurringEventsButton.style.borderBottomLeftRadius === '0px') {
expandRecurringEventsButton.style.borderBottomLeftRadius = '5px';
expandRecurringEventsButton.style.borderBottomRightRadius = '5px';
} else {
expandRecurringEventsButton.style.borderBottomLeftRadius = '0px';
expandRecurringEventsButton.style.borderBottomRightRadius = '0px';
}
// Toggle the visibility of the recurring events.
recurringEvents.classList.toggle('vads-u-display--none');
recurringEvents.classList.toggle('vads-u-display--flex');
// Toggle the icon.
expandRecurringEventsIcon.classList.toggle('fa-plus');
expandRecurringEventsIcon.classList.toggle('fa-minus');
}
function onShowAllRecurringEventsClick() {
// Derive recurring event items.
var recurringEventItems = document.querySelectorAll('.recurring-event');
// Show all recurring events.
for (var index = 0; index < recurringEventItems.length; index++) {
if (recurringEventItems[index]) {
recurringEventItems[index].classList.remove('vads-u-display--none');
}
}
// Hide the show all recurring events button.
var showAllRecurringEventsButton = document.getElementById('show-all-recurring-events');
// Hide the button if we find it.
if (showAllRecurringEventsButton) {
showAllRecurringEventsButton.classList.add('vads-u-display--none');
}
}
var expandRecurringEventsButton = document.getElementById('expand-recurring-events');
if (expandRecurringEventsButton) {
expandRecurringEventsButton.addEventListener('click', onExpandRecurringEventsClick);
}
var showAllRecurringEventsButton = document.getElementById('show-all-recurring-events');
if (showAllRecurringEventsButton) {
showAllRecurringEventsButton.addEventListener('click', onShowAllRecurringEventsClick);
}</script>
function onShowAllRecurringEventsClick() {
// Derive recurring event items.
var recurringEventItems = document.querySelectorAll('.recurring-event');
// Show all recurring events.
for (var index = 0; index < recurringEventItems.length; index++) {
if (recurringEventItems[index]) {
recurringEventItems[index].classList.remove('vads-u-display--none');
}
}
// Hide the show all recurring events button.
var showAllRecurringEventsButton = document.getElementById('show-all-recurring-events');
// Hide the button if we find it.
if (showAllRecurringEventsButton) {
showAllRecurringEventsButton.classList.add('vads-u-display--none');
}
}
var showAllRecurringEventsButton = document.getElementById('show-all-recurring-events');
if (showAllRecurringEventsButton) {
showAllRecurringEventsButton.addEventListener('click', onShowAllRecurringEventsClick);
}
</script>

{% include "src/site/includes/footer.html" %}
{% include "src/site/includes/debug.drupal.liquid" %}

0 comments on commit 4bd74ce

Please sign in to comment.