PageSourceSearch

https://richardkennedy.com/wp-content/themes/richardkennedy/js/home-scripts.js

js richardkennedy.com collected 2026-10-08 10:35:53 UTC 3,359 bytes, 112 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2    document.querySelectorAll('.tab-btn').forEach(button => {
3        button.addEventListener('click', () => {
4            const tabId = button.getAttribute('data-tab');
5            document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
6            document.querySelectorAll('.tab-content').forEach(tab => tab.classList.remove('active'));
7            button.classList.add('active');
8            const tabContent = document.getElementById(tabId);
9            if (tabContent) tabContent.classList.add('active');
10        });
11    });
12
13    const firstHeader = document.querySelector('.accordion-item h3');
14
15    if (firstHeader) {
16        const firstContent = firstHeader.nextElementSibling;
17        firstHeader.classList.add('active');
18        firstContent.style.maxHeight = firstContent.scrollHeight + 'px';
19
20        document.querySelectorAll('.accordion-item h3').forEach(header => {
21            header.addEventListener('click', () => {
22                const content = header.nextElementSibling;
23                const isOpen = header.classList.contains('active');
24
25                document.querySelectorAll('.accordion-item h3').forEach(h => h.classList.remove('active'));
26                document.querySelectorAll('.accordion-item p').forEach(c => c.style.maxHeight = null);
27
28                if (!isOpen) {
29                    header.classList.add('active');
30                    content.style.maxHeight = content.scrollHeight + 'px';
31                }
32            });
33        });
34    }
35
36    const mountIfExists = (selector, options = {}, extensions = null) => {
37        const el = document.querySelector(selector);
38        if (el && typeof Splide !== 'undefined') {
39            try {
40                const splide = new Splide(el, options);
41                splide.mount(extensions || {});
42            } catch (e) {
43                console.error(`Failed to mount Splide on ${selector}:`, e);
44            }
45        }
46    };
47
48    const splideExtensions = typeof Splide !== 'undefined' && Splide.Extensions ? Splide.Extensions : undefined;
49
50    mountIfExists('#home-loop-slider', {
51        type: 'loop',
52        perPage: 14,
53        autoScroll: {
54            speed: 1,
55        },
56    }, splideExtensions);
57
58    mountIfExists('#home-reviews-slider', {
59        type: 'loop',
60        perPage: 1,
61        perMove: 1,
62        speed: 2000,
63    });
64
65    mountIfExists('#home-awards-slider', {
66        type: 'loop',
67        perPage: 5,
68        autoplay: true,
69        perMove: 1,
70        interval: 2000,
71        speed: 2500,
72    });
73
74    mountIfExists('#home-posts-slider', {
75        type: 'loop',
76        perPage: 3,
77        perMove: 1,
78        speed: 2000,
79    });
80
81    mountIfExists('#home-results-slider', {
82        type: 'loop',
83        autoplay: true,
84        perPage: 4,
85        perMove: 1,
86        interval: 2000,
87        speed: 2500,
88    });
89
90    mountIfExists('#home-practice-slider', {
91        type: 'loop',
92        autoplay: true,
93        perPage: 4,
94        perMove: 1,
95        interval: 2000,
96        speed: 2500,
97    });
98
99    mountIfExists('#home-practice-areas', {
100        type: 'loop',
101        perMove: 1,
102        perPage: 3,
103        mediaQuery: 'min',
104        breakpoints: {
105            640: {
106                destroy: true,
107            },
108        },
109    });
110});
111
112

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.