PageSourceSearch

https://fuentebureba.es/core/themes/olivero/js/tabs.js?v=10.2.7

js fuentebureba.es collected 2026-10-03 01:20:12 UTC 1,813 bytes, 69 lines download raw bytes

1/**
2 * @file
3 * Provides interactivity for showing and hiding the primary tabs at mobile widths.
4 */
5
6((Drupal, once) => {
7  /**
8   * Initialize the primary tabs.
9   *
10   * @param {HTMLElement} el
11   *   The DOM element containing the primary tabs.
12   */
13  function init(el) {
14    const tabs = el.querySelector('.tabs');
15    const expandedClass = 'is-expanded';
16    const activeTab = tabs.querySelector('.is-active');
17
18    /**
19     * Determines if primary tabs are expanded for mobile layouts.
20     *
21     * @return {boolean}
22     *   Whether the tabs trigger element is expanded.
23     */
24    function isTabsMobileLayout() {
25      return tabs.querySelector('.tabs__trigger').clientHeight > 0;
26    }
27
28    /**
29     * Controls primary tab visibility on click events.
30     *
31     * @param {Event} e
32     *   The event object.
33     */
34    function handleTriggerClick(e) {
35      e.currentTarget.setAttribute(
36        'aria-expanded',
37        !tabs.classList.contains(expandedClass),
38      );
39      tabs.classList.toggle(expandedClass);
40    }
41
42    if (isTabsMobileLayout() && !activeTab.matches('.tabs__tab:first-child')) {
43      const newActiveTab = activeTab.cloneNode(true);
44      const firstTab = tabs.querySelector('.tabs__tab:first-child');
45      tabs.insertBefore(newActiveTab, firstTab);
46      tabs.removeChild(activeTab);
47    }
48
49    tabs
50      .querySelector('.tabs__trigger')
51      .addEventListener('click', handleTriggerClick);
52  }
53
54  /**
55   * Initialize the primary tabs.
56   *
57   * @type {Drupal~behavior}
58   *
59   * @prop {Drupal~behaviorAttach} attach
60   *   Display primary tabs according to the screen width.
61   */
62  Drupal.behaviors.primaryTabs = {
63    attach(context) {
64      once('olivero-tabs', '[data-drupal-nav-primary-tabs]', context).forEach(
65        init,
66      );
67    },
68  };
69})(Drupal, once);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.