Mercurial > hg > isophonics-drupal-site
annotate core/themes/seven/js/responsive-details.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * DO NOT EDIT THIS FILE. |
Chris@0 | 3 * See the following change record for more information, |
Chris@0 | 4 * https://www.drupal.org/node/2815083 |
Chris@0 | 5 * @preserve |
Chris@0 | 6 **/ |
Chris@0 | 7 |
Chris@0 | 8 (function ($, Drupal) { |
Chris@0 | 9 Drupal.behaviors.responsiveDetails = { |
Chris@0 | 10 attach: function attach(context) { |
Chris@0 | 11 var $details = $(context).find('details').once('responsive-details'); |
Chris@0 | 12 |
Chris@0 | 13 if (!$details.length) { |
Chris@0 | 14 return; |
Chris@0 | 15 } |
Chris@0 | 16 |
Chris@17 | 17 var $summaries = $details.find('> summary'); |
Chris@17 | 18 |
Chris@0 | 19 function detailsToggle(matches) { |
Chris@0 | 20 if (matches) { |
Chris@0 | 21 $details.attr('open', true); |
Chris@0 | 22 $summaries.attr('aria-expanded', true); |
Chris@0 | 23 $summaries.on('click.details-open', false); |
Chris@0 | 24 } else { |
Chris@0 | 25 var $notPressed = $details.find('> summary[aria-pressed!=true]').attr('aria-expanded', false); |
Chris@0 | 26 $notPressed.parent('details').attr('open', false); |
Chris@0 | 27 |
Chris@0 | 28 $summaries.off('.details-open'); |
Chris@0 | 29 } |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 function handleDetailsMQ(event) { |
Chris@0 | 33 detailsToggle(event.matches); |
Chris@0 | 34 } |
Chris@0 | 35 |
Chris@0 | 36 var mql = window.matchMedia('(min-width:48em)'); |
Chris@0 | 37 mql.addListener(handleDetailsMQ); |
Chris@0 | 38 detailsToggle(mql.matches); |
Chris@0 | 39 } |
Chris@0 | 40 }; |
Chris@0 | 41 })(jQuery, Drupal); |