Mercurial > hg > cmmr2012-drupal-site
annotate core/misc/details-aria.es6.js @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * @file |
Chris@0 | 3 * Add aria attribute handling for details and summary elements. |
Chris@0 | 4 */ |
Chris@0 | 5 |
Chris@4 | 6 (function($, Drupal) { |
Chris@0 | 7 /** |
Chris@0 | 8 * Handles `aria-expanded` and `aria-pressed` attributes on details elements. |
Chris@0 | 9 * |
Chris@0 | 10 * @type {Drupal~behavior} |
Chris@0 | 11 */ |
Chris@0 | 12 Drupal.behaviors.detailsAria = { |
Chris@0 | 13 attach() { |
Chris@4 | 14 $('body') |
Chris@4 | 15 .once('detailsAria') |
Chris@4 | 16 .on('click.detailsAria', 'summary', event => { |
Chris@4 | 17 const $summary = $(event.currentTarget); |
Chris@4 | 18 const open = |
Chris@4 | 19 $(event.currentTarget.parentNode).attr('open') === 'open' |
Chris@4 | 20 ? 'false' |
Chris@4 | 21 : 'true'; |
Chris@0 | 22 |
Chris@4 | 23 $summary.attr({ |
Chris@4 | 24 'aria-expanded': open, |
Chris@4 | 25 'aria-pressed': open, |
Chris@4 | 26 }); |
Chris@0 | 27 }); |
Chris@0 | 28 }, |
Chris@0 | 29 }; |
Chris@4 | 30 })(jQuery, Drupal); |