3c62e3cef6af47dfb1d0190b9aa1af256d99fe86
[yaffs-website] / web / core / themes / seven / js / responsive-details.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal) {
9   Drupal.behaviors.responsiveDetails = {
10     attach: function attach(context) {
11       var $details = $(context).find('details').once('responsive-details');
12
13       if (!$details.length) {
14         return;
15       }
16
17       var $summaries = $details.find('> summary');
18
19       function detailsToggle(matches) {
20         if (matches) {
21           $details.attr('open', true);
22           $summaries.attr('aria-expanded', true);
23           $summaries.on('click.details-open', false);
24         } else {
25           var $notPressed = $details.find('> summary[aria-pressed!=true]').attr('aria-expanded', false);
26           $notPressed.parent('details').attr('open', false);
27
28           $summaries.off('.details-open');
29         }
30       }
31
32       function handleDetailsMQ(event) {
33         detailsToggle(event.matches);
34       }
35
36       var mql = window.matchMedia('(min-width:48em)');
37       mql.addListener(handleDetailsMQ);
38       detailsToggle(mql.matches);
39     }
40   };
41 })(jQuery, Drupal);