]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1280384 - [a11y] Make the different module titles headings and their expand/colla...
authorDavid Lawrence <dkl@mozilla.com>
Fri, 17 Feb 2017 17:30:16 +0000 (17:30 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Fri, 17 Feb 2017 17:30:16 +0000 (17:30 +0000)
extensions/BugModal/template/en/default/bug_modal/module.html.tmpl
extensions/BugModal/web/bug_modal.css
extensions/BugModal/web/bug_modal.js

index 92b37543ac7de3d4fd61a73d3931c8d713ad2d10..e322cba0ea3bb011c62982c69069c59261f37df7 100644 (file)
@@ -21,7 +21,7 @@
   #   not be remembered between page loads
   #%]
 
-<div class="module
+<section class="module
     [%~ " edit-hide" IF hide_on_edit %]
     [%~ " edit-show" IF hide_on_view && !hide_on_edit %]"
     [% IF hide_on_view +%] style="display:none"[% END %]
     [%~ ' data-non-stick="1"' IF no_collapse_persist %]
 >
   [% IF title %]
-    <div class="module-header">
-      <div class="module-latch">
-        <div class="module-spinner">[% collapsed ? "&#9656;" : "&#9662;" %]</div>
-        <div class="module-title">[% title FILTER html %]</div>
+    <header id="module-[% title.replace FILTER id %]-header" class="module-header">
+      <div class="module-latch"
+           data-label-expanded="Collapse [% title FILTER html %] section"
+           data-label-collapsed="Expand [% title FILTER html %] section">
+        <div class="module-spinner" role="button" tabindex="0"
+             aria-controls="module-[% title.replace FILTER id %]-content"
+             aria-expanded="[% collapsed ? "false" : "true" %]"
+             aria-labeledby="module-[% title.replace FILTER id %]-title"
+             aria-describedby="module-[% title.replace FILTER id %]-subtitle"></div>
+        <h2 class="module-title" id="module-[% title.replace FILTER id %]-title">[% title FILTER html %]</h2>
         [% IF subtitle != "" && subtitle.size %]
-          <div class="module-subtitle">
+          <h3 class="module-subtitle" id="module-[% title.replace FILTER id %]-subtitle">
             ([% FOREACH st IN subtitle.list %]
               [% IF st.unfiltered.defined %]
                 [% st.unfiltered FILTER none %]
               [% END %]
               [% ", " UNLESS loop.last %]
             [% END %])
-          </div>
+          </h3>
         [% END %]
       </div>
-    </div>
+    </header>
   [% END %]
-  <div class="module-content" [% ' style="display:none"' IF collapsed %] >
+  <div class="module-content"
+      [%~ IF title %] id="module-[% title.replace FILTER id %]-content"[% END %]
+      [%~ ' style="display:none"' IF collapsed %]
+  >
     [% content FILTER none %]
   </div>
-</div>
+</section>
index 2ef56619e6003a434c87cd2f6424c8544ba2498f..d1509fd7da4cff944165587a67622cda17aa7d80 100644 (file)
@@ -107,8 +107,6 @@ a.activity-ref {
 
 .module-header {
     background: #eee;
-    padding: 2px 5px;
-    cursor: pointer;
     -webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
     -moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
     box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
@@ -119,9 +117,8 @@ a.activity-ref {
 }
 
 .module-latch {
-    display: table-cell;
-    padding-left: 5px;
-    padding-right: 5px;
+    padding: 2px 10px;
+    cursor: pointer;
 }
 
 .module-spinner {
@@ -130,11 +127,20 @@ a.activity-ref {
     width: 10px;
 }
 
+.module-spinner::before {
+    content: "\25BE";
+}
+
+.module-spinner[aria-expanded="false"]::before {
+    content: "\25B8";
+}
+
 .module-title {
     font-weight: bold;
 }
 
 .module-title, .module-subtitle {
+    font-size: 13px;
     display: table-cell;
     padding-left: 5px;
 }
index cfeec2271a8fde6adb4eb1399391e32520764cb1..894745016e27a9bf94a3f3a6124ffa17abbd29dc 100644 (file)
@@ -10,13 +10,16 @@ function slide_module(module, action, fast) {
     if (!module.attr('id'))
         return;
     var latch = module.find('.module-latch');
-    var spinner = $(latch.children('.module-spinner')[0]);
+    var spinner = module.find('.module-spinner');
     var content = $(module.children('.module-content')[0]);
     var duration = fast ? 0 : 200;
 
     function slide_done() {
         var is_visible = content.is(':visible');
-        spinner.html(is_visible ? '&#9662;' : '&#9656;');
+        spinner.attr({
+            'aria-expanded': is_visible,
+            'aria-label': is_visible ? latch.data('label-expanded') : latch.data('label-collapsed'),
+        });
         if (BUGZILLA.user.settings.remember_collapsed)
             localStorage.setItem(module.attr('id') + '.visibility', is_visible ? 'show' : 'hide');
     }
@@ -94,10 +97,17 @@ $(function() {
     }
 
     // expand/colapse module
-    $('.module-header')
+    $('.module-latch')
         .click(function(event) {
             event.preventDefault();
             slide_module($(this).parents('.module'));
+        })
+        .keydown(function(event) {
+            // expand/colapse module with the enter or space key
+            if (event.keyCode === 13 || event.keyCode === 32) {
+                event.preventDefault();
+                slide_module($(this).parents('.module'));
+            }
         });
 
     // toggle obsolete attachments