PageSourceSearch

https://techbbq.dk/wp-content/themes/techbbq/assets/js/beyond-the-summit.js?ver=1.4.158

js techbbq.dk collected 2026-09-25 04:28:21 UTC 4,873 bytes, 210 lines download raw bytes

1/**
2 * TechBBQ Beyond the Summit — Swiper carousel + nav (≤1439px); grid at 1440+.
3 */
4( function () {
5	'use strict';
6
7	const WIDE_QUERY = '(min-width: 1440px)';
8
9	const syncNavState = ( root, swiper ) => {
10		if ( ! root || ! swiper ) {
11			return;
12		}
13
14		if ( swiper.params.loop ) {
15			root.querySelectorAll( '.techbbq-carousel-nav__btn' ).forEach( ( button ) => {
16				button.disabled = false;
17			} );
18			return;
19		}
20
21		const atStart = swiper.isBeginning;
22		const atEnd = swiper.isEnd;
23
24		root.querySelectorAll( '.techbbq-carousel-nav__btn--prev' ).forEach( ( button ) => {
25			button.disabled = atStart;
26		} );
27
28		root.querySelectorAll( '.techbbq-carousel-nav__btn--next' ).forEach( ( button ) => {
29			button.disabled = atEnd;
30		} );
31	};
32
33	const bindNavigation = ( root, swiper ) => {
34		if ( root.techbbqBeyondSummitNavAbort ) {
35			root.techbbqBeyondSummitNavAbort.abort();
36		}
37
38		root.techbbqBeyondSummitNavAbort = new AbortController();
39		const { signal } = root.techbbqBeyondSummitNavAbort;
40
41		root.querySelectorAll( '.techbbq-carousel-nav__btn--prev' ).forEach( ( button ) => {
42			button.addEventListener(
43				'click',
44				() => {
45					swiper.slidePrev();
46					button.blur();
47				},
48				{ signal }
49			);
50		} );
51
52		root.querySelectorAll( '.techbbq-carousel-nav__btn--next' ).forEach( ( button ) => {
53			button.addEventListener(
54				'click',
55				() => {
56					swiper.slideNext();
57					button.blur();
58				},
59				{ signal }
60			);
61		} );
62
63		const sync = () => syncNavState( root, swiper );
64
65		swiper.on( 'slideChange', sync );
66		swiper.on( 'reachBeginning', sync );
67		swiper.on( 'reachEnd', sync );
68		swiper.on( 'resize', sync );
69		swiper.on( 'update', sync );
70
71		sync();
72	};
73
74	const setViewAccessibility = ( root, isWide ) => {
75		const grid = root.querySelector( '.techbbq-beyond-the-summit__grid' );
76		const carousel = root.querySelector( '.techbbq-beyond-the-summit__carousel' );
77		const nav = root.querySelector( '.techbbq-carousel-nav--footer' );
78
79		if ( grid ) {
80			grid.setAttribute( 'aria-hidden', isWide ? 'false' : 'true' );
81		}
82
83		if ( carousel ) {
84			carousel.setAttribute( 'aria-hidden', isWide ? 'true' : 'false' );
85		}
86
87		if ( nav ) {
88			nav.setAttribute( 'aria-hidden', isWide ? 'true' : 'false' );
89		}
90	};
91
92	const destroyCarousel = ( root ) => {
93		const swiperEl = root.querySelector( '.techbbq-beyond-the-summit__swiper' );
94
95		if ( swiperEl && window.TechBBQ?.Swiper ) {
96			window.TechBBQ.Swiper.destroy( swiperEl );
97		}
98
99		if ( root.techbbqBeyondSummitNavAbort ) {
100			root.techbbqBeyondSummitNavAbort.abort();
101			root.techbbqBeyondSummitNavAbort = null;
102		}
103
104		delete root.dataset.techbbqBeyondSummitReady;
105	};
106
107	const initCarousel = async ( root ) => {
108		if ( ! root || ! window.TechBBQ?.Swiper ) {
109			return;
110		}
111
112		const swiperEl = root.querySelector( '.techbbq-beyond-the-summit__swiper' );
113
114		if ( ! swiperEl ) {
115			return;
116		}
117
118		const swiper = await window.TechBBQ.Swiper.createInstance( swiperEl );
119
120		if ( ! swiper ) {
121			return;
122		}
123
124		bindNavigation( root, swiper );
125		root.dataset.techbbqBeyondSummitReady = '1';
126	};
127
128	const initWidget = async ( root ) => {
129		if ( ! root ) {
130			return;
131		}
132
133		const isWide = window.matchMedia( WIDE_QUERY ).matches;
134
135		setViewAccessibility( root, isWide );
136
137		if ( isWide ) {
138			destroyCarousel( root );
139			return;
140		}
141
142		if ( '1' === root.dataset.techbbqBeyondSummitReady ) {
143			return;
144		}
145
146		await initCarousel( root );
147	};
148
149	const registerResizeHandler = ( root ) => {
150		if ( root.techbbqBeyondSummitMedia ) {
151			return;
152		}
153
154		const media = window.matchMedia( WIDE_QUERY );
155		const onChange = () => {
156			delete root.dataset.techbbqBeyondSummitReady;
157			initWidget( root );
158		};
159
160		if ( typeof media.addEventListener === 'function' ) {
161			media.addEventListener( 'change', onChange );
162		} else if ( typeof media.addListener === 'function' ) {
163			media.addListener( onChange );
164		}
165
166		root.techbbqBeyondSummitMedia = media;
167	};
168
169	const bootWidget = ( root ) => {
170		registerResizeHandler( root );
171		initWidget( root );
172	};
173
174	const registerElementorHook = () => {
175		if ( ! window.elementorFrontend?.hooks ) {
176			return;
177		}
178
179		window.elementorFrontend.hooks.addAction(
180			'frontend/element_ready/techbbq-beyond-the-summit.default',
181			( $scope ) => {
182				const root = $scope[ 0 ]?.querySelector( '.techbbq-beyond-the-summit' ) || $scope[ 0 ];
183
184				if ( root ) {
185					delete root.dataset.techbbqBeyondSummitReady;
186					bootWidget( root );
187				}
188			}
189		);
190	};
191
192	const boot = () => {
193		if ( ! window.elementorFrontend?.utils?.swiper ) {
194			return;
195		}
196
197		document.querySelectorAll( '.techbbq-beyond-the-summit' ).forEach( ( root ) => {
198			bootWidget( root );
199		} );
200	};
201
202	window.addEventListener( 'elementor/frontend/init', boot );
203	window.addEventListener( 'elementor/frontend/init', registerElementorHook );
204
205	if ( window.elementorFrontend?.utils?.swiper ) {
206		boot();
207	}
208
209	registerElementorHook();
210}() );

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.