Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 2 ARIA problems with speaker pages #43

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _includes/speaker_box.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="speaker-box text-center" id="{{ speaker.id }}-id" data-speaker-info="#{{ speaker.id }}-info">
<div class="speaker-box-inner">
<img class="clip-circle-lg" src="{{ speaker.image_src | relative_url }}" alt="{{ speaker.name }}">
<h2 class="h4 speaker-name"><a href="#" class="speaker-info-toggle" data-target="#{{ speaker.id }}" aria-expanded="false" aria-controls="{{ speaker.id }}">{{ speaker.name }}</a></h2>
<h2 class="h4 speaker-name"><a href="#" class="speaker-info-toggle" data-target="#{{ speaker.id }}" aria-expanded="false" aria-controls="{{ speaker.id }}-info">{{ speaker.name }}</a></h2>
<div class="speaker-mini">
<p class="speaker-title">{{ speaker.work_title }}</p>
<p class="speaker-inst">{{ speaker.institution }}</p>
Expand Down
11 changes: 9 additions & 2 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jQuery(document).ready(function($){
// }

function toggleSpeaker(target){
var shownHeight;
let shownHeight;

if ($('.speaker-info.show').length){
shownHeight = $('.speaker-info.show').height();
Expand All @@ -96,6 +96,7 @@ jQuery(document).ready(function($){
$('html, body').animate({
scrollTop: $(target+'-id').offset().top - shownHeight
}, 500);

if (!$(target+'-id').hasClass('show')){
$('.speaker-info').removeClass('show');
$('.speaker-box').removeClass('selected');
Expand All @@ -110,7 +111,13 @@ jQuery(document).ready(function($){

$('.speaker-info-toggle').click(function(e){
e.preventDefault();
var target = $(this).data('target');
let toggle = $(this);
// any other expanded bio is now closed & this one is open
$('.speaker-info-toggle')
.filter((idx, el) => $(el).attr('aria-expanded') == 'true')
.attr('aria-expanded', 'false');
toggle.attr('aria-expanded', 'true');
let target = toggle.data('target');
toggleSpeaker(target);
});

Expand Down