File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- < button type ="button " class ="btn btn-outline ml-3 toggle-images tooltipped tooltipped-n " id ="js-toggle-images " aria-selected ="true " aria-label ="Toggle images ">
1+ < button type ="button " class ="btn btn-outline ml-3 toggle-images " id ="js-toggle-images " aria-selected ="false " aria-label ="Toggle images ">
22 < span id ="js-hide-text "> {% data ui.toggle_images.hide %}</ span >
33 < span id ="js-show-text "> {% data ui.toggle_images.show %}</ span >
44</ button >
Original file line number Diff line number Diff line change @@ -19,7 +19,14 @@ export default function () {
1919 // The button should say "Hide" by default, so we suppress the "Show" text here.
2020 showText . style . display = 'none'
2121
22+ // The selection state is set to false by default in the button HTML.
23+ let selectionState = toggleImagesBtn . getAttribute ( 'aria-selected' ) !== 'false'
24+
2225 toggleImagesBtn . addEventListener ( 'click' , ( e ) => {
26+ // On click, toggle the selection state.
27+ selectionState = ! selectionState
28+ toggleImagesBtn . setAttribute ( 'aria-selected' , selectionState )
29+
2330 // Check first image to see if images are currently hidden; if so, and there is a click to show them...
2431 if ( images [ 0 ] . style . display === 'none' ) {
2532 // Button should say "Hide"
You can’t perform that action at this time.
0 commit comments