-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shs-5963): fixes in js scripts and templates
- Loading branch information
Showing
22 changed files
with
246 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
docroot/themes/humsci/humsci_basic/src/js/shared/addtocal/addtocal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
(function (Drupal, once) { | ||
Drupal.behaviors.accordionToggleAllBehavior = { | ||
attach(context) { | ||
function addToCalAria() { | ||
const addToCal = once('add-to-cal-event', '.addtocal', context); | ||
const body = document.querySelector('body'); | ||
const addToCal = once('addtocal', '.addtocal', context); | ||
|
||
// For each .addtocal button, when clicked, change aria-expanded to true. | ||
addToCal.forEach((button) => { | ||
button.addEventListener('click', () => { | ||
if (button.getAttribute('aria-expanded') === 'true') { | ||
button.setAttribute('aria-expanded', 'false'); | ||
} else { | ||
button.setAttribute('aria-expanded', 'true'); | ||
} | ||
}); | ||
}); | ||
// Do nothing if no add to cal button found. | ||
if (addToCal.length === 0) { | ||
return; | ||
} | ||
|
||
// When the body except button is clicked, change aria-expanded to false. | ||
body.addEventListener('click', (e) => { | ||
addToCal.forEach((button) => { | ||
if (e.target !== button) { | ||
button.setAttribute('aria-expanded', 'false'); | ||
} | ||
}); | ||
// For each .addtocal button, when clicked, change aria-expanded to true. | ||
addToCal.forEach((button) => { | ||
button.addEventListener('click', () => { | ||
if (button.getAttribute('aria-expanded') === 'true') { | ||
button.setAttribute('aria-expanded', 'false'); | ||
} else { | ||
button.setAttribute('aria-expanded', 'true'); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
addToCalAria(); | ||
// When the body except button is clicked, change aria-expanded to false. | ||
const body = document.querySelector('body'); | ||
body.addEventListener('click', (e) => { | ||
addToCal.forEach((button) => { | ||
if (e.target !== button) { | ||
button.setAttribute('aria-expanded', 'false'); | ||
} | ||
}); | ||
}); | ||
}, | ||
}; | ||
// eslint-disable-next-line no-undef | ||
}(Drupal, once)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,5 +96,4 @@ | |
} | ||
}, | ||
}; | ||
// eslint-disable-next-line no-undef | ||
}(Drupal, window, once)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
...t/themes/humsci/humsci_basic/src/js/shared/main-content-fallback/main-content-fallback.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
(function (Drupal, once) { | ||
Drupal.behaviors.addMainContentFallback = { | ||
attach(context) { | ||
// Return if main content target is found, nothing to do. | ||
if (once('main-content-target', '#main-content', context)[0]) { | ||
const [mainElement] = once('main-content-fallback', 'main', context); | ||
|
||
// No main element or behavior already executed. | ||
if (!mainElement) { | ||
return; | ||
} | ||
|
||
const mainElement = once('main-element', 'main', context)[0]; | ||
if (mainElement) { | ||
mainElement.insertAdjacentHTML( | ||
'afterbegin', | ||
'<div id="main-content" class="visually-hidden" tabindex="-1">Main content start</div>', | ||
); | ||
// Return if main content target is found, nothing to do. | ||
if (document.querySelector('#main-content')) { | ||
return; | ||
} | ||
|
||
mainElement.insertAdjacentHTML( | ||
'afterbegin', | ||
'<div id="main-content" class="visually-hidden" tabindex="-1">Main content start</div>', | ||
); | ||
}, | ||
}; | ||
// eslint-disable-next-line no-undef | ||
}(Drupal, once)); |
Oops, something went wrong.