comparison core/themes/seven/js/responsive-details.js @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 function detailsToggle(matches) {
18 if (matches) {
19 $details.attr('open', true);
20 $summaries.attr('aria-expanded', true);
21 $summaries.on('click.details-open', false);
22 } else {
23 var $notPressed = $details.find('> summary[aria-pressed!=true]').attr('aria-expanded', false);
24 $notPressed.parent('details').attr('open', false);
25
26 $summaries.off('.details-open');
27 }
28 }
29
30 function handleDetailsMQ(event) {
31 detailsToggle(event.matches);
32 }
33
34 var $summaries = $details.find('> summary');
35 var mql = window.matchMedia('(min-width:48em)');
36 mql.addListener(handleDetailsMQ);
37 detailsToggle(mql.matches);
38 }
39 };
40 })(jQuery, Drupal);