-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27483 from guardian/pf/accessible-crossword-solut…
…ions Add solutions and instructions to accessible crossword page
- Loading branch information
Showing
5 changed files
with
114 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { initCrosswords } from 'common/modules/crosswords/main'; | ||
import { initCrosswordDiscussion } from 'common/modules/crosswords/comments'; | ||
import { initSeries } from 'common/modules/crosswords/series'; | ||
import {initAccessibleCrosswordSolutionsDisclosure} from "common/modules/crosswords/accessible-crossword-solutions"; | ||
|
||
export const init = () => { | ||
initCrosswords(); | ||
initCrosswordDiscussion(); | ||
initAccessibleCrosswordSolutionsDisclosure() | ||
initSeries(); | ||
}; |
14 changes: 14 additions & 0 deletions
14
static/src/javascripts/projects/common/modules/crosswords/accessible-crossword-solutions.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const initAccessibleCrosswordSolutionsDisclosure = () => { | ||
var disclosureComponent = document.querySelector('[data-component="crossword-solutions-disclosure"]'); | ||
var trigger = disclosureComponent.querySelector('[data-component="crossword-solutions-disclosure-trigger"]'); | ||
var panel = disclosureComponent.querySelector('[data-component="crossword-solutions-disclosure-panel"]'); | ||
var label = trigger.querySelector('[data-component="crossword-solutions-disclosure-trigger-label"]'); | ||
|
||
|
||
trigger.addEventListener('click', function() { | ||
var wasAlreadyExpanded = trigger.getAttribute('aria-expanded') === 'true'; | ||
trigger.setAttribute('aria-expanded', !wasAlreadyExpanded); | ||
label.textContent = wasAlreadyExpanded ? 'Reveal solutions' : 'Hide solutions' | ||
panel.hidden = wasAlreadyExpanded; | ||
}); | ||
} |
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