PageSourceSearch

https://nczd.ru/wp-content/themes/flatsome-child/inc/about-accordion.js?ver=1.0.5

js nczd.ru collected 2026-10-02 05:00:13 UTC 4,193 bytes, 146 lines download raw bytes

1(function () {
2  'use strict';
3
4  var MOBILE_MQ = '(max-width: 849px)';
5
6  function isMobile() {
7    return window.matchMedia(MOBILE_MQ).matches;
8  }
9
10  function initAboutAccordion() {
11    var section = document.querySelector('.section-about-compact');
12    if (!section || section.dataset.aboutAccordionReady === '1') return;
13
14    var stage = section.querySelector('.about-acc-stage');
15    if (!stage) return;
16
17    section.dataset.aboutAccordionReady = '1';
18
19    var openItem = null;
20
21    function resetTitle(item) {
22      var title = item.querySelector('.accordion-title');
23      if (!title) return;
24      title.classList.remove('active');
25      title.setAttribute('aria-expanded', 'false');
26      item.classList.remove('is-open');
27    }
28
29    function returnInnerToItem() {
30      if (!openItem) return;
31      var inner = stage.querySelector('.accordion-inner');
32      if (!inner) {
33        inner = openItem.querySelector('.accordion-inner');
34      }
35      if (inner && inner.parentElement !== openItem) {
36        inner.style.display = 'none';
37        openItem.appendChild(inner);
38      } else if (inner) {
39        inner.style.display = 'none';
40      }
41      stage.classList.remove('is-open');
42      stage.innerHTML = '';
43    }
44
45    function closeOpen() {
46      if (!openItem) return;
47      returnInnerToItem();
48      resetTitle(openItem);
49      openItem = null;
50    }
51
52    function openDesktop(item, title, inner) {
53      title.classList.add('active');
54      title.setAttribute('aria-expanded', 'true');
55      item.classList.add('is-open');
56
57      inner.style.display = 'block';
58      stage.appendChild(inner);
59      stage.classList.add('is-open');
60      openItem = item;
61
62      window.requestAnimationFrame(function () {
63        stage.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
64      });
65    }
66
67    function openMobile(item, title, inner) {
68      title.classList.add('active');
69      title.setAttribute('aria-expanded', 'true');
70      item.classList.add('is-open');
71
72      // Keep panel under the tapped card — do not move into the shared stage.
73      stage.classList.remove('is-open');
74      stage.innerHTML = '';
75      inner.style.display = 'block';
76      if (inner.parentElement !== item) {
77        item.appendChild(inner);
78      }
79      openItem = item;
80
81      window.requestAnimationFrame(function () {
82        item.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
83      });
84    }
85
86    section.querySelectorAll('.about-accordion .accordion-item').forEach(function (item) {
87      var title = item.querySelector('.accordion-title');
88      if (!title) return;
89
90      title.addEventListener(
91        'click',
92        function (e) {
93          e.preventDefault();
94          e.stopImmediatePropagation();
95
96          var wasOpen = item === openItem;
97          closeOpen();
98          if (wasOpen) return;
99
100          var inner = item.querySelector('.accordion-inner');
101          if (!inner) return;
102
103          if (isMobile()) {
104            openMobile(item, title, inner);
105          } else {
106            openDesktop(item, title, inner);
107          }
108        },
109        true
110      );
111    });
112
113    // If viewport crosses the breakpoint while open, re-place the panel.
114    var mq = window.matchMedia(MOBILE_MQ);
115    function onBreakpointChange() {
116      if (!openItem) return;
117      var title = openItem.querySelector('.accordion-title');
118      var inner =
119        openItem.querySelector('.accordion-inner') ||
120        stage.querySelector('.accordion-inner');
121      if (!title || !inner) return;
122
123      returnInnerToItem();
124      openItem.classList.add('is-open');
125      title.classList.add('active');
126      title.setAttribute('aria-expanded', 'true');
127
128      if (isMobile()) {
129        openMobile(openItem, title, inner);
130      } else {
131        openDesktop(openItem, title, inner);
132      }
133    }
134    if (typeof mq.addEventListener === 'function') {
135      mq.addEventListener('change', onBreakpointChange);
136    } else if (typeof mq.addListener === 'function') {
137      mq.addListener(onBreakpointChange);
138    }
139  }
140
141  if (document.readyState === 'loading') {
142    document.addEventListener('DOMContentLoaded', initAboutAccordion);
143  } else {
144    initAboutAccordion();
145  }
146})();

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.