PageSourceSearch

https://dental-pro.online/local/templates/dental/js/new-dental-legacy.js?v=1779957283

js dental-pro.online collected 2026-10-02 05:42:55 UTC 13,857 bytes, 497 lines download raw bytes

1(function() {
2	function ready(callback) {
3		if (document.readyState === 'loading') {
4			document.addEventListener('DOMContentLoaded', callback);
5			return;
6		}
7		callback();
8	}
9
10	function toArray(list) {
11		return Array.prototype.slice.call(list || []);
12	}
13
14	function closest(element, selector) {
15		while (element && element.nodeType === 1) {
16			if (element.matches && element.matches(selector)) {
17				return element;
18			}
19			element = element.parentElement;
20		}
21		return null;
22	}
23
24	function initMobileShell() {
25		var body = document.body;
26		var menuButton = document.querySelector('.mobile-header__menu-btn');
27		var mobileMenu = document.querySelector('.mobile-menu');
28		var submenuItems = toArray(document.querySelectorAll('.mobile-submenu'));
29
30		function closeMobileSubmenu() {
31			submenuItems.forEach(function(item) {
32				item.classList.remove('active');
33				item.setAttribute('aria-hidden', 'true');
34			});
35		}
36
37		function closeMobileMenu() {
38			body.classList.remove('mobile-menu-open');
39			if (menuButton) {
40				menuButton.setAttribute('aria-expanded', 'false');
41			}
42			if (mobileMenu) {
43				mobileMenu.setAttribute('aria-hidden', 'true');
44			}
45			closeMobileSubmenu();
46		}
47
48		if (menuButton && mobileMenu) {
49			menuButton.addEventListener('click', function() {
50				var isOpen = body.classList.toggle('mobile-menu-open');
51				menuButton.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
52				mobileMenu.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
53			});
54		}
55
56		document.addEventListener('click', function(event) {
57			var closeButton = closest(event.target, '.mobile-menu__close');
58			if (closeButton) {
59				event.preventDefault();
60				closeMobileMenu();
61				return;
62			}
63
64			var submenuOpen = closest(event.target, '.js-mobile-submenu-open');
65			if (submenuOpen && window.innerWidth <= 767) {
66				event.preventDefault();
67				closeMobileSubmenu();
68				var targetId = submenuOpen.getAttribute('data-submenu');
69				var target = targetId ? document.getElementById(targetId) : null;
70				if (target) {
71					target.classList.add('active');
72					target.setAttribute('aria-hidden', 'false');
73				}
74				return;
75			}
76
77			var submenuBack = closest(event.target, '.js-mobile-submenu-back');
78			if (submenuBack) {
79				event.preventDefault();
80				closeMobileSubmenu();
81				return;
82			}
83
84			var menuLink = closest(event.target, '.mobile-menu a');
85			if (menuLink && window.innerWidth <= 767 && !menuLink.classList.contains('js-mobile-submenu-open')) {
86				closeMobileMenu();
87			}
88		});
89
90
91	}
92
93	function initWhoLikes() {
94		toArray(document.querySelectorAll('[data-who-likes-root]')).forEach(function(root) {
95			var selected = root.querySelector('.tabs-selected span');
96			var triggers = toArray(root.querySelectorAll('[data-tab]'));
97			var contents = toArray(root.querySelectorAll('[data-tab-content]'));
98
99			triggers.forEach(function(trigger) {
100				trigger.addEventListener('click', function(event) {
101					event.preventDefault();
102					event.stopPropagation();
103					if (typeof event.stopImmediatePropagation === 'function') {
104						event.stopImmediatePropagation();
105					}
106					var code = trigger.getAttribute('data-tab');
107					triggers.forEach(function(item) { item.classList.toggle('active', item === trigger); });
108					contents.forEach(function(item) { item.classList.toggle('active', item.getAttribute('data-tab-content') === code); });
109					if (selected) {
110						selected.textContent = trigger.getAttribute('data-title') || trigger.textContent;
111					}
112				});
113			});
114
115			toArray(root.querySelectorAll('.accordion__trigger')).forEach(function(trigger) {
116				trigger.addEventListener('click', function() {
117					var item = closest(trigger, '.accordion__item');
118					var list = closest(trigger, '.accordion');
119					if (!item || !list) {
120						return;
121					}
122					toArray(list.querySelectorAll('.accordion__item')).forEach(function(row) {
123						if (row !== item) {
124							row.classList.remove('active');
125						}
126					});
127					item.classList.toggle('active');
128				});
129			});
130		});
131	}
132
133	function initFaq() {
134		function setFaqItemState(row, isOpen) {
135			var head = row.querySelector('.faq-item__head');
136			var body = row.querySelector('.faq-item__body');
137
138			row.classList.toggle('active', isOpen);
139
140			if (head) {
141				head.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
142			}
143
144			if (body) {
145				body.style.display = isOpen ? 'block' : 'none';
146			}
147		}
148
149		toArray(document.querySelectorAll('.faq-list')).forEach(function(list) {
150			toArray(list.querySelectorAll('.faq-item')).forEach(function(row) {
151				setFaqItemState(row, row.classList.contains('active'));
152			});
153		});
154
155		toArray(document.querySelectorAll('.faq-item__head')).forEach(function(button) {
156			if (button.dataset.legacyFaqReady === '1') {
157				return;
158			}
159
160			button.dataset.legacyFaqReady = '1';
161			button.addEventListener('click', function(event) {
162				var item = closest(button, '.faq-item');
163				var list = closest(button, '.faq-list');
164				if (!item || !list) {
165					return;
166				}
167
168				event.preventDefault();
169				event.stopImmediatePropagation();
170
171				var shouldOpen = !item.classList.contains('active');
172				toArray(list.querySelectorAll('.faq-item')).forEach(function(row) {
173					setFaqItemState(row, row === item && shouldOpen);
174				});
175			}, true);
176		});
177	}
178
179	function initSwipers() {
180		if (typeof Swiper === 'undefined') {
181			return;
182		}
183		toArray(document.querySelectorAll('.implementation-slider')).forEach(function(slider) {
184			if (slider.dataset.legacySwiperReady === '1') {
185				return;
186			}
187			slider.dataset.legacySwiperReady = '1';
188			new Swiper(slider, {
189				slidesPerView: 'auto',
190				spaceBetween: 24,
191				watchOverflow: true,
192				navigation: {
193					nextEl: '.implementation-nav__button--next',
194					prevEl: '.implementation-nav__button--prev'
195				},
196				pagination: {
197					el: '.implementation .swiper-pagination',
198					clickable: true
199				}
200			});
201		});
202
203		toArray(document.querySelectorAll('.clients-slider')).forEach(function(slider) {
204			if (slider.dataset.legacySwiperReady === '1') {
205				return;
206			}
207
208			var root = closest(slider, '.clients');
209			var nextButton = root ? root.querySelector('.clients-nav__button--next') : null;
210			var prevButton = root ? root.querySelector('.clients-nav__button--prev') : null;
211			var pagination = root ? root.querySelector('.swiper-pagination') : null;
212			var originalSlides = toArray(slider.querySelectorAll('.swiper-wrapper > .swiper-slide')).filter(function(slide) {
213				return !slide.classList.contains('swiper-slide-duplicate');
214			});
215			var shouldLoop = originalSlides.length >= 5;
216
217			slider.dataset.legacySwiperReady = '1';
218			new Swiper(slider, {
219				autoplay: shouldLoop ? {
220					delay: 1000,
221					disableOnInteraction: false,
222					pauseOnMouseEnter: true
223				} : false,
224				loop: shouldLoop,
225				rewind: !shouldLoop,
226				slidesPerView: 3.9,
227				spaceBetween: 30,
228				watchOverflow: true,
229				navigation: {
230					nextEl: nextButton,
231					prevEl: prevButton
232				},
233				pagination: {
234					el: pagination,
235					clickable: true
236				},
237				breakpoints: {
238					0: {
239						slidesPerView: 1.12,
240						spaceBetween: 12
241					},
242					768: {
243						slidesPerView: 3.9,
244						spaceBetween: 30
245					}
246				}
247			});
248		});
249	}
250
251
252	function initLegacyHeaderStickyFix() {
253		var headerBottom = document.querySelector('body.new-dental-legacy-page .js-header-bottom');
254		var headerPlaceholder = document.querySelector('body.new-dental-legacy-page .header__bottom-placeholder');
255
256		if (!headerBottom || !headerPlaceholder) {
257			return;
258		}
259
260		var header = closest(headerBottom, '.header');
261		var stickyStart = 0;
262
263		function unlockLegacyHeader() {
264			if (!header) {
265				return;
266			}
267			header.classList.remove('header_minShow');
268			header.style.transform = '';
269		}
270
271		function disableSticky() {
272			unlockLegacyHeader();
273			headerBottom.classList.remove('header__bottom--fixed');
274			headerBottom.style.removeProperty('top');
275			headerPlaceholder.style.display = 'none';
276			headerPlaceholder.style.height = '0px';
277		}
278
279		function enableSticky() {
280			unlockLegacyHeader();
281			headerPlaceholder.style.display = 'block';
282			headerPlaceholder.style.height = headerBottom.offsetHeight + 'px';
283			headerBottom.classList.add('header__bottom--fixed');
284			headerBottom.style.setProperty('top', '0px', 'important');
285		}
286
287		function updateSticky() {
288			if (window.innerWidth <= 767) {
289				disableSticky();
290				return;
291			}
292
293			if (window.pageYOffset >= stickyStart) {
294				enableSticky();
295				return;
296			}
297
298			disableSticky();
299		}
300
301		function recalcSticky() {
302			if (window.innerWidth <= 767) {
303				disableSticky();
304				return;
305			}
306
307			headerBottom.classList.remove('header__bottom--fixed');
308			headerBottom.style.removeProperty('top');
309			headerPlaceholder.style.display = 'none';
310			headerPlaceholder.style.height = '0px';
311			unlockLegacyHeader();
312			stickyStart = headerBottom.getBoundingClientRect().top + window.pageYOffset;
313			if (stickyStart < 0) {
314				stickyStart = 0;
315			}
316			updateSticky();
317		}
318
319		recalcSticky();
320		window.addEventListener('load', recalcSticky);
321		window.addEventListener('scroll', updateSticky, { passive: true });
322		window.addEventListener('resize', recalcSticky);
323		window.addEventListener('orientationchange', recalcSticky);
324	}
325
326	function initLegacyLazyImages() {
327		function loadImage(image) {
328			var src = image.getAttribute('data-src');
329			var srcset = image.getAttribute('data-srcset');
330
331			if (src && image.getAttribute('src') !== src) {
332				image.setAttribute('src', src);
333			}
334
335			if (srcset && image.getAttribute('srcset') !== srcset) {
336				image.setAttribute('srcset', srcset);
337			}
338
339			image.setAttribute('data-loaded', 'true');
340		}
341
342		function loadSource(source) {
343			var srcset = source.getAttribute('data-srcset');
344
345			if (srcset && source.getAttribute('srcset') !== srcset) {
346				source.setAttribute('srcset', srcset);
347			}
348		}
349
350		function loadBackground(element) {
351			var background = element.getAttribute('data-background-image');
352
353			if (background) {
354				element.style.backgroundImage = "url('" + background + "')";
355				element.setAttribute('data-loaded', 'true');
356			}
357		}
358
359		function loadAll() {
360			toArray(document.querySelectorAll('body.new-dental-legacy-page picture source[data-srcset]')).forEach(loadSource);
361			toArray(document.querySelectorAll('body.new-dental-legacy-page img.lozad[data-src], body.new-dental-legacy-page img.lozad[data-srcset]')).forEach(loadImage);
362			toArray(document.querySelectorAll('body.new-dental-legacy-page .lozad[data-background-image]')).forEach(loadBackground);
363		}
364
365		loadAll();
366		window.addEventListener('load', loadAll);
367		window.setTimeout(loadAll, 300);
368		window.setTimeout(loadAll, 1000);
369	}
370
371
372	function initImageModals() {
373		document.addEventListener('click', function(event) {
374			var button = closest(event.target, '[data-modal-image]');
375			if (!button) {
376				return;
377			}
378			var root = closest(button, '[data-who-likes-root]');
379			var modal = root ? document.getElementById(root.id + '-modal') : document.querySelector('[data-who-likes-modal]');
380			var image = modal ? modal.querySelector('.who-likes-modal__image') : null;
381			if (!modal || !image) {
382				return;
383			}
384			event.preventDefault();
385			image.src = button.getAttribute('data-modal-image');
386			modal.classList.add('is-open');
387			modal.setAttribute('aria-hidden', 'false');
388		});
389
390		document.addEventListener('click', function(event) {
391			var close = closest(event.target, '[data-who-likes-close]');
392			if (!close) {
393				return;
394			}
395			var modal = closest(close, '[data-who-likes-modal]');
396			var image = modal ? modal.querySelector('.who-likes-modal__image') : null;
397			if (modal) {
398				modal.classList.remove('is-open');
399				modal.setAttribute('aria-hidden', 'true');
400			}
401			if (image) {
402				image.removeAttribute('src');
403			}
404		});
405	}
406
407
408	function initLegacyFormModal() {
409		var overlay = document.querySelector('body.new-dental-legacy-page > .overlay') || document.querySelector('body.new-dental-legacy-page .overlay');
410
411		if (!overlay) {
412			return;
413		}
414
415		var body = document.body;
416
417		function getModal(code) {
418			return overlay.querySelector('[data-modal="' + code + '"]');
419		}
420
421		function closeModal() {
422			overlay.classList.remove('active');
423			toArray(overlay.querySelectorAll('.modal.active')).forEach(function(modal) {
424				modal.classList.remove('active');
425			});
426			body.classList.remove('lock');
427		}
428
429		function openModal(code, trigger) {
430			var modal = getModal(code);
431
432			if (!modal) {
433				return false;
434			}
435
436			toArray(overlay.querySelectorAll('.modal.active')).forEach(function(item) {
437				item.classList.remove('active');
438			});
439
440			var title = modal.querySelector('.modal-title');
441			var modalTitle = trigger ? trigger.getAttribute('data-modal-title') : '';
442
443			if (title && modalTitle) {
444				title.innerHTML = modalTitle;
445			}
446
447			overlay.classList.add('active');
448			modal.classList.add('active');
449			body.classList.add('lock');
450			return true;
451		}
452
453		document.addEventListener('click', function(event) {
454			var formTrigger = closest(event.target, '[data-btn="modal1"]');
455
456			if (formTrigger) {
457				if (openModal('modal1', formTrigger)) {
458					event.preventDefault();
459					event.stopImmediatePropagation();
460				}
461				return;
462			}
463
464			if (!overlay.classList.contains('active')) {
465				return;
466			}
467
468			if (closest(event.target, '[data-close]')) {
469				event.preventDefault();
470				event.stopImmediatePropagation();
471				closeModal();
472				return;
473			}
474
475			if (event.target === overlay || closest(event.target, '.modal-wr') && !closest(event.target, '.modal')) {
476				closeModal();
477			}
478		}, true);
479
480		document.addEventListener('keydown', function(event) {
481			if (event.key === 'Escape' && overlay.classList.contains('active')) {
482				closeModal();
483			}
484		}, true);
485	}
486
487	ready(function() {
488		initMobileShell();
489		initLegacyHeaderStickyFix();
490		initLegacyFormModal();
491		initWhoLikes();
492		initFaq();
493		initSwipers();
494		initImageModals();
495		initLegacyLazyImages();
496	});
497})();

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.