PageSourceSearch

https://godlike.host/wp-content/themes/godlike/js/init.js?ver=1.040

js godlike.host collected 2026-10-03 20:17:36 UTC 13,558 bytes, 343 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function() {
2    var APPJS = {};
3
4    // Caching
5    APPJS.window = window;
6    APPJS.document = document;
7    APPJS.body_html = document.querySelector('body,html');
8    APPJS.body = document.body;
9    APPJS.header = document.querySelector('.site-header');
10    APPJS.head = document.head;
11    APPJS.lang = document.documentElement.lang.substring(0, 2);
12    APPJS.bodyWidth = document.body.clientWidth;
13
14    // Prevent white spaces only from input
15    APPJS.body.addEventListener('blur', function(e) {
16        if (e.target.matches('form input[type="text"], form input[type="email"], form input[type="tel"], form textarea')) {
17            var val = e.target.value.trim();
18            if (!val.length) {
19                e.target.value = '';
20            }
21        }
22    }, true);
23
24    // Inputs: only numbers
25    document.querySelectorAll('input.js-numbers-only').forEach(function(input) {
26        ['change', 'keyup', 'input', 'click'].forEach(function(event) {
27            input.addEventListener(event, function() {
28                if (this.value.match(/[^0-9]/g)) {
29                    this.value = this.value.replace(/[^0-9]/g, '');
30                }
31            });
32        });
33    });
34
35    // Inputs: only letters
36    document.querySelectorAll('input.js-letters-only').forEach(function(input) {
37        ['change', 'keyup', 'input', 'click'].forEach(function(event) {
38            input.addEventListener(event, function() {
39                if (this.value.match(/[^a-zA-Zа-яА-Я\s]/g)) {
40                    this.value = this.value.replace(/[^a-zA-Zа-яА-Я\s]/g, '');
41                }
42            });
43        });
44    });
45
46    // Iframe Code
47    document.querySelectorAll('.js-iframe').forEach(function(el) {
48        setTimeout(function() {
49            el.innerHTML = el.getAttribute('data-iframe');
50        }, 200);
51    });
52
53    // Append video
54    APPJS.body.addEventListener('click', function(e) {
55        if (e.target.matches('.js-append-video')) {
56            e.preventDefault();
57            let id = e.target.getAttribute('data-id');
58            let parent = e.target.parentElement;
59            parent.classList.add('loaded');
60            parent.innerHTML = '<iframe src="https://www.youtube.com/embed/' + id + '?autoplay=1" allow="autoplay" allowfullscreen></iframe>';
61        }
62    });
63
64    // Mobile navigation
65    APPJS.body.addEventListener('click', function(e) {
66        if (e.target.closest('.js-mnav-open')) {
67            e.preventDefault();
68            APPJS.body.classList.add('mnav-opened');
69        }
70        if (e.target.closest('.js-mnav-close')) {
71            e.preventDefault();
72            APPJS.body.classList.remove('mnav-opened');
73            APPJS.body.classList.remove('mnav-opened__panel');
74            setTimeout(function() {
75                let mobileNav = document.querySelector('.mobile-navigation');
76                if (mobileNav) mobileNav.classList.remove('level');
77                document.querySelectorAll('.mobile-navigation li').forEach(function(li) {
78                    li.classList.remove('submenu-opened');
79                });
80            }, 200);
81        }
82        if (e.target.closest('.js-mnav-toggle')) {
83            e.preventDefault();
84            APPJS.body.classList.toggle('mnav-opened');
85            setTimeout(function() {
86                let mobileNav = document.querySelector('.mobile-navigation');
87                if (mobileNav) mobileNav.classList.remove('level');
88                document.querySelectorAll('.mobile-navigation li').forEach(function(li) {
89                    li.classList.remove('submenu-opened');
90                });
91            }, 200);
92        }
93        if (e.target.closest('.panel-menu__button')) {
94            e.preventDefault();
95            APPJS.body.classList.toggle('mnav-opened__panel');
96        }
97    });
98
99    // Open mobile submenu
100    APPJS.body.addEventListener('click', function(e) {
101        if (e.target.matches('.mobile-navigation li.menu-item-has-children > a')) {
102            var subnav = e.target.parentElement.querySelector('ul');
103            if (subnav) {
104                e.preventDefault();
105                var nav = e.target.closest('.mobile-navigation');
106                nav.scrollTop = 0;
107                e.target.parentElement.classList.toggle('submenu-opened');
108                nav.classList.toggle('level');
109            }
110        }
111    });
112
113    // Open login submenu
114    APPJS.body.addEventListener('click', function(e) {
115        if (e.target.matches('.js-unav-toggle')) {
116            e.preventDefault();
117            e.target.closest('.header-login').classList.toggle('opened');
118        }
119    });
120
121    // Close login on outside click
122    window.addEventListener('click', function(e) {
123        if (!e.target.closest('.header-login')) {
124            document.querySelectorAll('.header-login').forEach(function(el) {
125                el.classList.remove('opened');
126            });
127        }
128    });
129    window.addEventListener('touchend', function(e) {
130        if (!e.target.closest('.header-login')) {
131            document.querySelectorAll('.header-login').forEach(function(el) {
132                el.classList.remove('opened');
133            });
134        }
135    });
136
137    // Empty space CSS
138    document.querySelectorAll('[data-hidden-css]').forEach(function(el) {
139        var style = document.createElement('style');
140        style.textContent = el.getAttribute('data-hidden-css');
141        APPJS.head.appendChild(style);
142    });
143
144    // Logo click
145    if (document.body.classList.contains('home') && APPJS.header) {
146        var logo = APPJS.header.querySelector('.logo');
147        if (logo) {
148            logo.addEventListener('click', function(e) {
149                e.preventDefault();
150                APPJS.body_html.scrollTo({
151                    top: 0,
152                    behavior: 'smooth'
153                });
154            });
155        }
156    }
157
158    // Click on # in main navigation
159    APPJS.body.addEventListener('click', function(e) {
160        if (e.target.matches('.site-navigation a[href="#"]')) {
161            e.preventDefault();
162        }
163    });
164
165    // Lang select
166    window.addEventListener('click', function(e) {
167        if (!e.target.closest('.lang-select')) {
168            document.querySelectorAll('.lang-select').forEach(function(el) {
169                el.classList.remove('open');
170            });
171        }
172    });
173    window.addEventListener('touchend', function(e) {
174        if (!e.target.closest('.lang-select')) {
175            document.querySelectorAll('.lang-select').forEach(function(el) {
176                el.classList.remove('open');
177            });
178        }
179    });
180
181    APPJS.body.addEventListener('click', function(event) {
182        if (event.target.matches('.lang-select .lang-selected')) {
183            event.preventDefault();
184            event.stopImmediatePropagation();
185            event.target.closest('.lang-select').classList.toggle('open');
186        }
187    });
188
189// FAQ - ИСПРАВЛЕННАЯ ВЕРСИЯ
190    APPJS.body.addEventListener('click', function(e) {
191        if (e.target.matches('.faq-list_point')) {
192            e.target.classList.toggle('active');
193            var bottom = e.target.querySelector('.faq-list_bottom');
194            if (bottom) {
195                if (bottom.style.display === 'none' || window.getComputedStyle(bottom).display === 'none') {
196                    bottom.style.display = 'block';
197                } else {
198                    bottom.style.display = 'none';
199                }
200            }
201            e.preventDefault(); // вместо return false
202        }
203    });
204
205    // Scroll top
206    APPJS.body.addEventListener('click', function(e) {
207        if (e.target.matches('.js-scroll-top')) {
208            APPJS.body_html.scrollTo({
209                top: 0,
210                behavior: 'smooth'
211            });
212            return false;
213        }
214    });
215
216    // Footer spoilers
217    APPJS.body.addEventListener('click', function(e) {
218        if (e.target.matches('.footer-box > span')) {
219            e.target.classList.toggle('active');
220            var menu = e.target.nextElementSibling;
221            if (menu && menu.classList.contains('footer-menu')) {
222                if (menu.style.display === 'none') {
223                    menu.style.display = 'block';
224                } else {
225                    menu.style.display = 'none';
226                }
227            }
228            return false;
229        }
230    });
231
232    // Seo text show more
233    APPJS.body.addEventListener('click', function(event) {
234        if (event.target.matches('.ta-seotext-show-more')) {
235            event.preventDefault();
236            event.stopImmediatePropagation();
237            var b = event.target;
238            var b_text1 = b.dataset.read || b.innerHTML;
239            b.dataset.read = b_text1;
240            var b_text2 = b.getAttribute('data-hide');
241            var cont = b.closest('.ta-seotext-screen').querySelector('.ta-seotext-content');
242            var height = cont.scrollHeight;
243            var wheight = cont.clientHeight;
244
245            if (height !== wheight) {
246                cont.style.height = height + 'px';
247                cont.classList.add('opened');
248                b.classList.add('active');
249                b.innerHTML = b_text2;
250            } else {
251                cont.style.height = '';
252                cont.classList.remove('opened');
253                b.classList.remove('active');
254                b.innerHTML = b_text1;
255            }
256        }
257    });
258
259    // Initialize SEO text heights
260    document.querySelectorAll('.ta-seotext-content').forEach(function(el) {
261        el.style.transition = 'all 0s';
262        el.style.height = 'auto';
263        var h = el.offsetHeight;
264        el.removeAttribute('style');
265        if (h < 400) {
266            el.classList.add('full-opened');
267        }
268    });
269
270    // Seotext navigation
271    //
272    // На вузькому екрані (<=991px) список вкладок схований у CSS, а видимий лише
273    // .seotext__nav--mobile — один рядок, який працює як заголовок дропдауна. Обробник
274    // нижче слухає .seotext__nav li, тобто САМЕ ТОЙ список, що схований, і відкрити його
275    // не було чим: клік по заголовку не підпадав під селектор. Через це на мобільному
276    // лишався доступним тільки перший розділ, решта — недосяжні.
277    var SEOTEXT_MOBILE_BREAKPOINT = 991;
278
279    function seotextIsMobile() {
280        return window.innerWidth < SEOTEXT_MOBILE_BREAKPOINT;
281    }
282
283    // Список показуємо/ховаємо інлайном: у медіа-запиті стоїть display:none, перебити його
284    // класом можна лише правкою CSS, а вона тут не потрібна.
285    function seotextToggleNav(open) {
286        var nav = document.querySelector('.seotext__nav');
287        if (!nav) {
288            return;
289        }
290        nav.style.display = open ? 'block' : 'none';
291        document.querySelectorAll('.seotext__nav--mobile li').forEach(function(item) {
292            item.classList.toggle('active', open); // стрілка заголовка дивиться за станом
293        });
294    }
295
296    APPJS.body.addEventListener('click', function(e) {
297        // Заголовок дропдауна: розкриває або згортає список вкладок.
298        var mobileToggle = e.target.closest('.seotext__nav--mobile li');
299        if (mobileToggle) {
300            var nav = document.querySelector('.seotext__nav');
301            seotextToggleNav(!!nav && getComputedStyle(nav).display === 'none');
302            return;
303        }
304
305        if (e.target.closest('.seotext__nav li')) {
306            var li = e.target.closest('.seotext__nav li');
307            var i = li.dataset.tab;
308            document.querySelectorAll('.seotext__nav li').forEach(function(el) {
309                el.classList.remove('active');
310            });
311            li.classList.add('active');
312
313            document.querySelectorAll('.seotext__body_content').forEach(function(el) {
314                el.style.display = 'none';
315            });
316            var targetContent = document.querySelector('.seotext__body_content[data-content="' + i + '"]');
317            if (targetContent) {
318                targetContent.style.display = 'block';
319            }
320
321            if (seotextIsMobile()) {
322                document.querySelectorAll('.seotext__nav--mobile li').forEach(function(item) {
323                    item.textContent = li.textContent;
324                });
325                seotextToggleNav(false); // вибрали — згортаємо, заголовок показує вибране
326            }
327        }
328    });
329
330    // Поворот екрана або ресайз через мобільну межу: інлайн display, виставлений для
331    // дропдауна, інакше пережив би перехід на десктоп і сховав би там увесь список.
332    window.addEventListener('resize', function() {
333        if (!seotextIsMobile()) {
334            var nav = document.querySelector('.seotext__nav');
335            if (nav) {
336                nav.style.removeProperty('display');
337            }
338            document.querySelectorAll('.seotext__nav--mobile li').forEach(function(item) {
339                item.classList.remove('active');
340            });
341        }
342    });
343});

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.