Skip to content

Commit

Permalink
disable increment/decrement instead of hide
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickson-adbe committed Aug 8, 2024
1 parent 5125742 commit da3b700
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions blocks/gmo-program-details/gmo-program-details.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ body {
transform: rotate(180deg);
}
}
&.disabled {
background-color: #c6c6c6;
cursor: default;
}
}
& .current-year {
line-height: 32px;
Expand Down
8 changes: 5 additions & 3 deletions scripts/program-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export async function buildCalendar(dataObj, block, type, mappingArray, period)
// get array of all years to be included
let years = calendarYears(viewStartYear, viewEndYear);

// disable increment/decrement if only one year in view
if (years.length === 1) {
document.querySelector('.inc-dec-wrapper > .year-switch').classList.add('inactive');
document.querySelector('.inc-dec-wrapper > .current-year').classList.add('single');
document.querySelector('.inc-dec-wrapper > .year-switch').classList.add('disabled');
}

// build the calendar background here as we already know the period and style
Expand Down Expand Up @@ -261,7 +261,9 @@ export async function buildCalendar(dataObj, block, type, mappingArray, period)
document.querySelector('.gmo-program-details.block').addEventListener('click', dismissDropdown);
block.querySelectorAll('.year-switch > .year-toggle').forEach((control) => {
control.removeEventListener('click', changePeriod);
control.addEventListener('click', changePeriod);
if (years.length > 1) {
control.addEventListener('click', changePeriod);
}
});
block.querySelector('.right-controls .today-button').addEventListener('click', () => {
const calendarWrapper = document.querySelector('.calendar-wrapper')
Expand Down

0 comments on commit da3b700

Please sign in to comment.