annotate 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
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@0 17 function detailsToggle(matches) {
Chris@0 18 if (matches) {
Chris@0 19 $details.attr('open', true);
Chris@0 20 $summaries.attr('aria-expanded', true);
Chris@0 21 $summaries.on('click.details-open', false);
Chris@0 22 } else {
Chris@0 23 var $notPressed = $details.find('> summary[aria-pressed!=true]').attr('aria-expanded', false);
Chris@0 24 $notPressed.parent('details').attr('open', false);
Chris@0 25
Chris@0 26 $summaries.off('.details-open');
Chris@0 27 }
Chris@0 28 }
Chris@0 29
Chris@0 30 function handleDetailsMQ(event) {
Chris@0 31 detailsToggle(event.matches);
Chris@0 32 }
Chris@0 33
Chris@0 34 var $summaries = $details.find('> summary');
Chris@0 35 var mql = window.matchMedia('(min-width:48em)');
Chris@0 36 mql.addListener(handleDetailsMQ);
Chris@0 37 detailsToggle(mql.matches);
Chris@0 38 }
Chris@0 39 };
Chris@0 40 })(jQuery, Drupal);