Security update for Core, with self-updated composer
[yaffs-website] / web / core / themes / seven / js / nav-tabs.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   function init(i, tab) {
10     var $tab = $(tab);
11     var $target = $tab.find('[data-drupal-nav-tabs-target]');
12     var isCollapsible = $tab.hasClass('is-collapsible');
13
14     function openMenu(e) {
15       $target.toggleClass('is-open');
16     }
17
18     function handleResize(e) {
19       $tab.addClass('is-horizontal');
20       var $tabs = $tab.find('.tabs');
21       var isHorizontal = $tabs.outerHeight() <= $tabs.find('.tabs__tab').outerHeight();
22       $tab.toggleClass('is-horizontal', isHorizontal);
23       if (isCollapsible) {
24         $tab.toggleClass('is-collapse-enabled', !isHorizontal);
25       }
26       if (isHorizontal) {
27         $target.removeClass('is-open');
28       }
29     }
30
31     $tab.addClass('position-container is-horizontal-enabled');
32
33     $tab.on('click.tabs', '[data-drupal-nav-tabs-trigger]', openMenu);
34     $(window).on('resize.tabs', Drupal.debounce(handleResize, 150)).trigger('resize.tabs');
35   }
36
37   Drupal.behaviors.navTabs = {
38     attach: function attach(context, settings) {
39       var $tabs = $(context).find('[data-drupal-nav-tabs]');
40       if ($tabs.length) {
41         var notSmartPhone = window.matchMedia('(min-width: 300px)');
42         if (notSmartPhone.matches) {
43           $tabs.once('nav-tabs').each(init);
44         }
45       }
46     }
47   };
48 })(jQuery, Drupal);