From e184203da9763fc5d7c9363b7ebb950b07c7c3da Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 17 Feb 2017 17:08:17 +0000 Subject: Bug 1280397 - [a11y] Make the component, product, and other latches accessible --- .../template/en/default/bug_modal/edit.html.tmpl | 68 ++++++++++-------- extensions/BugModal/web/bug_modal.js | 81 +++++++++++++++------- 2 files changed, 95 insertions(+), 54 deletions(-) (limited to 'extensions') diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index ef2922181..a33cc541a 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -352,13 +352,17 @@ hide_on_edit = can_edit_product help = "describecomponents.cgi?product=$filtered_product" %] - -
- [% bug.product FILTER html %] -
- + + +
+ [% bug.product FILTER html %] +
+ +
[% END %] [% WRAPPER bug_modal/field.html.tmpl field = bug_fields.product @@ -391,16 +395,20 @@ help = "describecomponents.cgi?product=$filtered_product&component=$filtered_component#$filtered_component" %] - -
- [% bug.component FILTER html %] -
- + + +
+ [% bug.component FILTER html %] +
+ +
[% END %] [%# importance %] @@ -697,18 +705,20 @@ [% END %] [% IF bug.cc && bug.cc.size %] - [% IF user.id %] - - - [% END %] - - [% - IF bug.cc.size == 1; - is_cced ? "Just you" : "1 person"; - ELSE; - bug.cc.size _ " people"; - END; - %] + + [% IF user.id %] + + + [% END %] + + [% + IF bug.cc.size == 1; + is_cced ? "Just you" : "1 person"; + ELSE; + bug.cc.size _ " people"; + END; + %] + [% ELSE %] Nobody diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index 8d908873e..25a9d1a73 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -163,20 +163,38 @@ $(function() { // product/component info $('.spin-toggle, #product-latch, #component-latch') .click(function(event) { - event.preventDefault(); - var latch = $($(event.target).data('latch')); - var el_for = $($(event.target).data('for')); - - if (latch.data('expanded')) { - latch.data('expanded', false).html('▸'); - el_for.hide(); - } - else { - latch.data('expanded', true).html('▾'); - el_for.show(); + spin_toggle(event); + }).keydown(function(event) { + // allow space or enter to toggle visibility + if (event.keyCode == 13 || event.keyCode == 32) { + spin_toggle(event); } }); + function spin_toggle(event) { + event.preventDefault(); + var type = $(event.target).data('for'); + var latch = $('#' + type + '-latch'); + var name = $('#' + type + '-name'); + var info = $('#' + type + '-info'); + var label = latch.attr('aria-label'); + + if (latch.data('expanded')) { + label = label.replace(/^hide/, 'show'); + latch.data('expanded', false).html('▸'); + latch.attr('aria-expanded', false); + info.hide(); + } + else { + label = label.replace(/^show/, 'hide'); + latch.data('expanded', true).html('▾'); + latch.attr('aria-expanded', true); + info.show(); + } + latch.attr('aria-label', label); + name.attr('title', label); + } + // cc list function ccListLoading() { @@ -230,24 +248,37 @@ $(function() { $('#cc-summary').addClass('cc-loadable'); $('#cc-latch, #cc-summary') .click(function(event) { - event.preventDefault(); - var latch = $('#cc-latch'); - - if (latch.data('expanded')) { - latch.data('expanded', false).html('▸'); - $('#cc-list').hide(); - } - else { - latch.data('expanded', true).html('▾'); - $('#cc-list').show(); - if (!latch.data('fetched')) { - ccListLoading(); - ccListUpdate(); - } + cc_toggle(event); + }).keydown(function(event) { + // allow space or enter to toggle visibility + if (event.keyCode == 13 || event.keyCode == 32) { + cc_toggle(event); } }); } + function cc_toggle(event) { + event.preventDefault(); + var latch = $('#cc-latch'); + var label = latch.attr('aria-label'); + if (latch.data('expanded')) { + label = label.replace(/^hide/, 'show'); + latch.data('expanded', false).html('▸'); + $('#cc-list').hide(); + } + else { + latch.data('expanded', true).html('▾'); + label = label.replace(/^show/, 'hide'); + $('#cc-list').show(); + if (!latch.data('fetched')) { + ccListLoading(); + ccListUpdate(); + } + } + latch.attr('aria-label', label); + $('#cc-summary').attr('aria-label', label); + } + // copy summary to clipboard function clipboardSummary() { -- cgit v1.2.3-24-g4f1b