PageSourceSearch

https://www.bitrix24.es/bitrix/templates/landing/js/include_areas/…w_block_basic_list_mobile.js?17894804934419

js bitrix24.es collected 2026-09-24 20:19:16 UTC 4,419 bytes, 134 lines download raw bytes

1BX.ready(function () {
2	if (typeof Glide !== 'function') return;
3
4	const mobileQuery = window.matchMedia('(max-width: 767.98px)');
5
6	function initSlider(wrapper) {
7		if (wrapper.classList.contains('bxw-blocks-wrapper_mobile-slider-ready')) return;
8
9		const blocks = Array.prototype.filter.call(wrapper.children, function (child) {
10			return child.classList.contains('bxw-block-basic-list') && child.classList.contains('menu_target');
11		});
12
13		if (blocks.length < 2) return;
14
15		function getBlockButton(block) {
16			let current = block.nextElementSibling;
17
18			while (current && !current.classList.contains('bxw-block-basic-list')) {
19				if (current.classList.contains('bxw-block-try-picture')) {
20					return current.querySelector('.bxw-block-try-picture__btn-wrapper');
21				}
22
23				current = current.nextElementSibling;
24			}
25
26			return null;
27		}
28
29		const slider = document.createElement('section');
30		const track = document.createElement('div');
31		const slides = document.createElement('ul');
32		const bullets = document.createElement('div');
33		const buttons = document.createElement('div');
34
35		slider.className = 'bxw-block-basic-list-mobile glide';
36		track.className = 'bxw-block-basic-list-mobile__track glide__track';
37		track.setAttribute('data-glide-el', 'track');
38		slides.className = 'bxw-block-basic-list-mobile__slides glide__slides';
39		bullets.className = 'bxw-block-basic-list-mobile__bullets glide__bullets';
40		bullets.setAttribute('data-glide-el', 'controls[nav]');
41		buttons.className = 'bxw-block-basic-list-mobile__buttons';
42
43		blocks.forEach(function (block, index) {
44			const slide = document.createElement('li');
45			const clone = block.cloneNode(true);
46			const bullet = document.createElement('button');
47			const buttonWrapper = clone.querySelector('.bxw-block-basic-list__btn-wrapper');
48			const sourceButtonWrapper = getBlockButton(block);
49
50			clone.removeAttribute('id');
51			clone.classList.remove('menu_target');
52			clone.classList.add('bxw-block-basic-list_mobile');
53
54			if (buttonWrapper) {
55				buttonWrapper.remove();
56			}
57
58			if (sourceButtonWrapper && buttons.children.length === 0) {
59				const mobileButtonWrapper = document.createElement('div');
60
61				mobileButtonWrapper.className = 'bxw-block-basic-list__btn-wrapper';
62				Array.prototype.forEach.call(sourceButtonWrapper.children, function (button) {
63					mobileButtonWrapper.appendChild(button.cloneNode(true));
64				});
65				buttons.appendChild(mobileButtonWrapper);
66			}
67
68			slide.className = 'bxw-block-basic-list-mobile__slide glide__slide';
69			slide.appendChild(clone);
70			slides.appendChild(slide);
71
72			bullet.className = 'bxw-block-basic-list-mobile__bullet glide__bullet';
73			bullet.type = 'button';
74			bullet.setAttribute('data-glide-dir', '=' + index);
75			bullet.setAttribute('aria-label', String(index + 1));
76			bullets.appendChild(bullet);
77		});
78
79		track.appendChild(slides);
80		slider.appendChild(track);
81		slider.appendChild(bullets);
82		if (buttons.children.length > 0) {
83			slider.appendChild(buttons);
84		}
85		wrapper.insertBefore(slider, blocks[0]);
86
87		function updateSliderHeight() {
88			const activeSlide = slider.querySelector('.glide__slide--active');
89
90			if (activeSlide) {
91				track.style.height = activeSlide.offsetHeight + 'px';
92			}
93		}
94
95		const glide = new Glide(slider, {
96			type: 'carousel',
97			perView: 1,
98			gap: 0,
99			animationDuration: 500,
100			dragThreshold: 80,
101			swipeThreshold: 40,
102			// Glide defaults to ltr and computes track offsets for that direction only.
103			// On an rtl page the slides move away from the viewport and the block looks
104			// empty, so the direction has to be passed explicitly.
105			direction: document.documentElement.getAttribute('dir') === 'rtl' ? 'rtl' : 'ltr'
106		});
107
108		Array.prototype.forEach.call(slider.querySelectorAll('img'), function (image) {
109			if (!image.complete) {
110				image.addEventListener('load', updateSliderHeight);
111			}
112		});
113
114		glide.on(['mount.after', 'run.after', 'resize'], updateSliderHeight);
115		glide.mount();
116		updateSliderHeight();
117
118		wrapper.classList.add('bxw-blocks-wrapper_mobile-slider-ready');
119	}
120
121	function initMobileSliders() {
122		if (!mobileQuery.matches) return;
123
124		document.querySelectorAll('.bxw-blocks-wrapper__menu .bxw-blocks-wrapper').forEach(initSlider);
125	}
126
127	initMobileSliders();
128
129	if (mobileQuery.addEventListener) {
130		mobileQuery.addEventListener('change', initMobileSliders);
131	} else {
132		mobileQuery.addListener(initMobileSliders);
133	}
134});

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.