PageSourceSearch

https://www.cashforcars.de/themes/custom/cfc/js/tabs.js?v=1.x

js cashforcars.de collected 2026-10-01 15:39:02 UTC 2,998 bytes, 98 lines download raw bytes

1(function ($, Drupal, drupalSettings) {
2  // new tabs script
3
4  function changeTabs(e) {
5    const target = e.target;
6    const parent = target.parentNode;
7    const grandparent = parent.parentNode;
8
9    // Remove all current selected tabs
10    parent
11      .querySelectorAll('[aria-selected="true"]')
12      .forEach((t) => t.setAttribute("aria-selected", false));
13
14    // Set this tab as selected
15    target.setAttribute("aria-selected", true);
16    target.classList.add("checked-tab");
17
18    // Remove selection for the rest
19    document.querySelectorAll('[role="tab"]').forEach((t) => {
20      if (t !== target) {
21        t.classList.remove("checked-tab");
22      }
23    });
24
25    // Hide all tab panels
26    grandparent
27      .querySelectorAll('[role="tabpanel"]')
28      .forEach((p) => p.setAttribute("hidden", true));
29
30    // Show the selected panel
31    grandparent.parentNode
32      .querySelector(`#${target.getAttribute("aria-controls")}`)
33      .removeAttribute("hidden");
34  }
35
36  const mq = window.matchMedia("(min-width: 993px)");
37  if (mq.matches) {
38    window.addEventListener("DOMContentLoaded", () => {
39      const tabs = document.querySelectorAll('[role="tab"]');
40      if(tabs[0]) {
41       tabs[0].classList.add("checked-tab");
42      }
43      const tabList = document.querySelector('[role="tablist"]');
44      if (!tabList) return;
45
46      // Add a click event handler to each tab
47      tabs.forEach((tab, index) => {
48        tab.addEventListener("click", changeTabs);
49        if (index !== 0) {
50          tab.parentNode.parentNode.parentNode
51            .querySelector(`#${tab.getAttribute("aria-controls")}`)
52            .setAttribute("hidden", true);
53        }
54      });
55
56      // Remove a click event handler on small screens
57
58      const mq = window.matchMedia("(max-width: 992px)");
59      if (mq.matches) {
60        tabs.forEach((tab) => {
61          tab.removeEventListener("click", changeTabs);
62          tab.parentNode.parentNode.parentNode
63            .querySelector(`#${tab.getAttribute("aria-controls")}`)
64            .setAttribute("hidden", false);
65        });
66      }
67
68      // Enable arrow navigation between tabs in the tab list
69      let tabFocus = 0;
70
71      tabList.addEventListener("keydown", (e) => {
72        // Move right
73        if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
74          tabs[tabFocus].setAttribute("tabindex", -1);
75          if (e.key === "ArrowRight") {
76            tabFocus++;
77            // If we're at the end, go to the start
78            if (tabFocus >= tabs.length) {
79              tabFocus = 0;
80            }
81            // Move left
82          } else if (e.key === "ArrowLeft") {
83            tabFocus--;
84            // If we're at the start, move to the end
85            if (tabFocus < 0) {
86              tabFocus = tabs.length - 1;
87            }
88          }
89
90          tabs[tabFocus].setAttribute("tabindex", 0);
91          tabs[tabFocus].focus();
92        }
93      });
94    });
95  }
96
97  // new tabs script ends
98})(jQuery, Drupal, drupalSettings);

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.