Plugin Directory

Changeset 1677780

Timestamp:
06/13/2017 04:22:27 PM (7 years ago)
Author:
JoeFusco
Message:

Improve ARIA for Tab module

Location:
accessible-divi/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • accessible-divi/trunk/divi-accessibility.php

    r1672828 r1677780  
    1515 * @wordpress-plugin
    1616 * Plugin Name:       Divi Accessibility
    17  * Plugin URI:        https://github.com/campuspress/divi-accessibility
     17 * Plugin URI:        https://
    1818 * Description:       Improve Divi accessibility in accordance with WCAG 2.0 guidelines.
    1919 * Version:           1.0.0
    20  * Author:            Joseph Fusco
     20 * Author:           
    2121 * Author URI:        https://campuspress.com
    2222 * License:           GPL-2.0+
  • accessible-divi/trunk/includes/class-divi-accessibility.php

    r1672828 r1677780  
    9494        $this->da11y         = 'divi_accessibility';
    9595        $this->da11y_options = 'divi_accessibility_options';
    96         $this->version       = '1.0.0';
     96        $this->version       = '1.0.';
    9797
    9898        $this->load_dependencies();
  • accessible-divi/trunk/public/partials/divi-accessibility-embedded-css.php

    r1672828 r1677780  
    4141
    4242?>
    43 *:active.keyboard-outline,
    44 *:focus.keyboard-outline {
     43.keyboard-outline {
    4544    <?php
    4645
     
    5958button:focus.keyboard-outline,
    6059input:active.keyboard-outline,
    61 input:focus.keyboard-outline {
     60input:focus.keyboard-outline,
     61a[role="tab"].keyboard-outline {
    6262    outline-offset: -5px;
    6363}
     
    6565    padding-left: 15px;
    6666    padding-right: 15px;
     67
     68
     69
     70
    6771}
    6872<?php
  • accessible-divi/trunk/public/partials/divi-accessibility-embedded-js.php

    r1672828 r1677780  
    228228
    229229            $(document).keyup(function (e) {
    230                 // Enter
     230                // Enter
    231231                if (e.which === 13) {
    232232                    // Expand Accordion & Toggle modules when enter is hit while focused.
     
    323323
    324324            /**
    325              * Add aria-selected="false".
     325             * Add inital state:
     326             *
     327             * aria-selected="false"
     328             * aria-expanded="false"
     329             * tabindex=-1
    326330             *
    327331             * @divi-module  Tab
     
    329333            $('.et_pb_tabs_controls li:not(.et_pb_tab_active) a').each(function () {
    330334                $(this).attr('aria-selected', 'false');
    331             });
    332 
    333             /**
    334              * Add aria-selected="true".
    335              *
    336              * @divi-module  Tab
     335                $(this).attr('aria-expanded', 'false');
     336                $(this).attr('tabindex', -1);
     337            });
     338
     339            /**
     340            * Add inital state:
     341            *
     342            * aria-selected="true"
     343            * aria-expanded="true"
     344            * tabindex=-1
     345            *
     346            * @divi-module  Tab
    337347             */
    338348            $('.et_pb_tabs_controls li.et_pb_tab_active a').each(function () {
    339349                $(this).attr('aria-selected', 'true');
     350
     351
    340352            });
    341353
     
    387399             */
    388400            $('.et_pb_tabs').each(function (e) {
    389                 $(this).attr('data-a11y-id', 'et_pb_tab_module_' + e);
     401                $(this).attr('data-a11y-id', 'et_pb_tab_module_' + e);
    390402            });
    391403
     
    397409            $('.et_pb_tabs_controls a').on('click', function () {
    398410                var id = $(this).attr('id');
    399                 var namespace = $(this).closest('.et_pb_tabs').attr('data-a11y-id'); // Used as a selector to scope changes to current module.
    400 
    401                 // Reset all tab controls to be aria-selected="false".
    402                 $('#' + namespace + ' .et_pb_tabs_controls a').attr('aria-selected', 'false');
    403 
    404                 // Make active tab control aria-selected="true".
    405                 $(this).attr('aria-selected', 'true');
     411                var namespace = $(this).closest('.et_pb_tabs').attr('data-da11y-id'); // Used as a selector to scope changes to current module.
     412
     413                // Reset all tab controls to be aria-selected="false" & aria-expanded="false".
     414                $('[data-da11y-id="' + namespace + '"] .et_pb_tabs_controls a')
     415                    .attr('aria-selected', 'false')
     416                    .attr('aria-expanded', 'false')
     417                    .attr('tabindex', -1);
     418
     419                // Make active tab control aria-selected="true" & aria-expanded="true".
     420                $(this)
     421                    .attr('aria-selected', 'true')
     422                    .attr('aria-expanded', 'true')
     423                    .attr('tabindex', 0);
    406424
    407425                // Reset all tabs to be aria-hidden="true".
    408                 $('#' + namespace + ' .et_pb_tab').attr('aria-hidden', 'true');
     426                $('#' + namespace + ' .et_pb_tab')
     427                    .attr('aria-hidden', 'true');
    409428
    410429                // Label active tab panel as aria-hidden="false".
    411                 $('[aria-labelledby="' + id + '"]').attr('aria-hidden', 'false');
     430                $('[aria-labelledby="' + id + '"]')
     431                    .attr('aria-hidden', 'false');
     432            });
     433
     434            // Arrow navigation for tab modules
     435            $('.et_pb_tabs_controls a').keyup(function (e) {
     436                var namespace = $(this).closest('.et_pb_tabs').attr('data-da11y-id');
     437                var module = $('[data-da11y-id="' + namespace + '"]');
     438
     439                if (e.which === 39 || e.which === 40) { // Down & Right.
     440                    var next = module.find('li.et_pb_tab_active').next();
     441
     442                    if (next.length > 0) {
     443                        next.find('a').trigger('click');
     444                    } else {
     445                        module.find('li:first a').trigger('click');
     446                    }
     447                } else if (e.which === 37 || e.which === 38) { // Up & Left.
     448                    var next = module.find('li.et_pb_tab_active').prev();
     449
     450                    if (next.length > 0) {
     451                        next.find('a').trigger('click');
     452                    } else {
     453                        module.find('li:last a').trigger('click');
     454                    }
     455                }
     456
     457                $('.et_pb_tabs_controls a').removeClass('keyboard-outline');
     458                module.find('li.et_pb_tab_active a').addClass('keyboard-outline');
    412459            });
    413460
     
    419466             */
    420467            $('.et_pb_search').each(function (e) {
    421                 $(this).attr('data-a11y-id', 'et_pb_search_module_' + e);
     468                $(this).attr('data-a11y-id', 'et_pb_search_module_' + e);
    422469            });
    423470
  • accessible-divi/trunk/readme.txt

    r1672828 r1677780  
    4747== Changelog ==
    4848
     49
     50
     51
    4952= 1.0.0 =
    5053* Initial Release
Note: See TracChangeset for help on using the changeset viewer.