PageSourceSearch

https://eliskasestakova.cz/wp-content/themes/mioweb3/library/visualeditor/js/front.js?ver=1790215222

js eliskasestakova.cz collected 2026-09-24 11:55:00 UTC 56,696 bytes, 2,005 lines download raw bytes

1
2jQuery(function ($) {
3
4	$('.background_video iframe').mwBackgroundVideo();
5	$('.open_element_lightbox').mwElementPopup();
6	$('.open_mw_popup').mwPopup();
7	$('.mw_cookie_management_container').mwCookieBar();
8	mw_init_videos();
9	$('.mw_phone_input_container').mwPhoneInput();
10	//$('.mw_tabs_container').mwFrontTabs();
11	mw_init_tabs(".mw_tabs_container");
12
13	mw_init_contact_form('.ve_contact_form');
14	mw_init_form('.ve_check_form');
15	mw_init_webinar_registration_form('.ve_webinar_registration_form');
16
17	$(window).on('scroll', function (e) {
18		setParallaxScroll();
19	});
20	setParallaxScroll(true);
21
22	setFixedHeader();
23
24	// delay show
25	$(".row_container_delay").each(function () {
26		var $this = $(this);
27		setTimeout(function () {
28			/** Fade in to "flex" instead of "block" @see https://stackoverflow.com/a/28906733 */
29			$this
30				.css("display", "flex")
31				.hide()
32				.fadeIn("slow");
33		}, $this.attr('data-delay') * 1000);
34	});
35
36	$(".element_container_delay").each(function () {
37		var $this = $(this);
38		setTimeout(function () {
39			$this.fadeIn("slow");
40		}, $this.attr('data-delay') * 1000);
41	});
42
43	$(".video_element_gdpr_agree_but").click(function () {
44		var container = $(this).closest('.video_element_gdpr_content');
45		if(container.find('input').prop('checked'))
46		{
47			$('.video_element_gdpr_content').remove();
48			var date = new Date();
49			date.setDate(date.getDate() + 365);
50			document.cookie = "mw_allow_video_youtube=1;expires=" + date.toGMTString() + "; path=/";
51		}
52		else
53		{
54			container.remove();
55		}
56		return false;
57	});
58
59	$('body').on('click', '.mw_header_search_icon', function (e) {
60		e.preventDefault();
61		$('#header').addClass('mw_show_header_search');
62		$('.mw_header_search_container input').focus();
63		setTimeout(function () {
64			$(document).on("click.closeHeaderSearch", function (event) {
65				if (!$(event.target).closest(".mw_header_search_container .mw_search_form").length) {
66					$('#header').removeClass('mw_show_header_search');
67					$(document).off("click.closeHeaderSearch");
68				}
69			});
70		}, 0);
71	});
72
73	/* ********************* Expanded text/block  ******************** */
74	$('body').on('click', '.mw_expand_more', function () {
75		let $container = $(this).closest('div');
76		let $expandedContainer = $container.find('.mw_expanded_container');
77		let $link = $(this);
78		let max_height = $container.find('.mw_expanded_content').outerHeight();
79		if ($expandedContainer.hasClass('mw_expanded')) {
80			$expandedContainer.removeClass('mw_expanded');
81			$expandedContainer.animate({ maxHeight: $expandedContainer.data('height') }, 400, function() {
82				$link.removeClass('mw_expanded');
83				$expandedContainer.css('max-height','');
84			});
85			if ($container[0].getBoundingClientRect().top < 0) {
86				$("html, body").animate({
87					scrollTop: $container.offset().top - 30
88				}, 400);
89			}
90		} else {
91			$expandedContainer.data('height', $expandedContainer.css('max-height'));
92			$expandedContainer.animate({ maxHeight: max_height }, 400, function() {
93				$expandedContainer.addClass('mw_expanded');
94				$link.addClass('mw_expanded');
95			});
96		}
97	});
98
99	/* ********************* Scroll  ******************** */
100	$('body').on('click', '.mw_scroll_tonext', function () {
101		var position = $(this).offset().top + 66;
102
103
104		// Subtract fixed header height
105		if (jQuery('.ve_fixed_header').length) {
106			position -= jQuery('#header').height()
107		}
108
109		$('html,body').animate({
110			scrollTop: position
111		}, 1000);
112		return false;
113	});
114
115	/* ********************* Toggle target ******************** */
116	$('body').on('click', '.mw_toggle_container', function (event) {
117		var $this = $(this);
118		var tar = $this.attr('data-target');
119		if ($this.is('input[type=checkbox]')) {
120			var checked = $this.prop('checked');
121			if (checked)
122				$('#' + tar).show();
123			else
124				$('#' + tar).hide();
125		} else {
126			$('#' + tar).toggle();
127		}
128	});
129
130	// for table responsivity in blog article
131	$('#blog-content table').each(function(){
132		let $table = $(this);
133		let headers = [];
134		let th_count = 0;
135
136		$table.find('thead th').each(function(){
137			headers.push($(this).text().trim());
138			th_count++;
139		});
140
141		if (th_count > 0) {
142			$table.addClass('mw_responsive_table');
143			$table.find('tbody tr').each(function(){
144				$(this).find('td').each(function(i){
145					$(this).attr('data-label', headers[i] || '');
146				});
147			});
148		}
149
150	});
151
152	$(window).resize(mw_debouncer(mw_recalculate_fb_page_plugin_width, 500))
153});
154
155(function($) {
156	$.fn.mwVideo = function(options) {
157
158		return this.each(function() {
159
160			let $container = $(this);
161			let isMejs = $container.hasClass('mw_mejs_container');
162			let isMobile = $container.hasClass('mw_video_mobile');
163			const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
164			let isOwn = $container.hasClass('mw_video_own');
165			let isVertical = $container.hasClass('mw_video_vertical');
166			var $video = $(this).find('.mw_video');
167			if (isOwn) {
168				$video = $(this).find('iframe');
169			}
170			let videoType = $container.data('type');
171			this.isLazy = $container.hasClass('mw_video_lazy') && !isMejs;
172			this.vimeoPlayer = null;
173			let obj = this;
174
175			if ($container.hasClass('mw_video_initialized')) {
176				if (isMejs) {
177					$video[1].player.pause();
178				}
179				return;
180			}
181
182			$container.addClass('mw_video_initialized');
183
184			let loadVimeo = function () {
185				if (obj.vimeoPlayer === null) {
186					let selector = $video[0];
187					if (isMejs) {
188						selector = $container.find('iframe')[0];
189					}
190					obj.vimeoPlayer = new Vimeo.Player(selector);
191				}
192			}
193
194			if (isMejs) {
195				let features = ['playpause', 'progress', 'current', 'duration', 'volume', 'fullscreen'];
196
197				if (videoType === 'vimeo' && isSafari && isMobile) {
198					features.pop(); // remove fullscreen from control
199				}
200
201				let fakeFullscreen = false;
202				if (videoType === 'vimeo' && isSafari) {
203					fakeFullscreen = true;
204				}
205
206				let createMuteButton = function(player) {
207					const button = document.createElement('div');
208					button.className = 'mejs-button mejs-volume-button mejs-mw-mute-button';
209					button.innerHTML = '<button type="button"></button>';
210
211					// mute and unmute on click
212					button.addEventListener('click', function() {
213						if (player.media.muted) {
214							player.setMuted(false);
215							button.classList.add('mejs-mute');
216							button.classList.remove('mejs-unmute');
217						} else {
218							player.setMuted(true);
219							button.classList.remove('mejs-mute');
220							button.classList.add('mejs-unmute');
221						}
222					});
223					return button;
224				}
225
226				let videoSetting = {
227					videoWidth: '100%',
228					videoHeight: '100%',
229					useFakeFullscreen: fakeFullscreen, // only for safari on pc
230					features: features,
231					youtube: {
232						playsinline: 1,
233						showinfo: 0
234					},
235					success: function (media, originalNode, player) {
236						let mwLayer = $('<div class="mejs-mw-layer"></div>');
237						$(player.layers).append(mwLayer);
238
239						mwLayer.on('click', function () {
240							if (media.paused) {
241								media.play();
242							} else {
243								media.pause();
244							}
245						});
246
247						// custom mobile safari vimeo fullscreen
248						if (videoType === 'vimeo' && isSafari && isMobile) {
249							let fullButton = document.createElement('div');
250							fullButton.className = 'mejs-button mejs-fullscreen-button mw-vimeo-fullscreen';
251							fullButton.innerHTML = '<button type="button"></button>';
252							$(player.container).find('.mejs-controls').append(fullButton);
253						}
254
255						// speed control
256						let speeds = ['0.50', '0.75', '1.00', '1.25', '1.50', '2.00'];
257						let speedButton = document.createElement('div');
258						speedButton.className = 'mejs_mw_speed-button';
259						speedButton.innerHTML = '<span>1.00x</span>';
260						let menu = document.createElement('ul');
261						menu.className = 'mejs_mw_speed-selector';
262						speeds.forEach(function (speed) {
263							let item = document.createElement('li');
264							item.setAttribute('data-speed', speed);
265							item.innerHTML = speed + 'x';
266							if (speed === '1.0') {
267								item.className = 'current';
268							}
269							menu.appendChild(item);
270						});
271						speedButton.appendChild(menu);
272						$(player.container).find('.mejs-fullscreen-button').before(speedButton);
273
274						if (videoType === 'vimeo') {
275							loadVimeo();
276
277							// vimeo duration
278							obj.vimeoPlayer.getDuration().then(function (duration) {
279								media.duration = duration;
280								let formattedTime = mejs.Utility.secondsToTimeCode(duration, false);
281								$container.find('.mejs-duration').html(formattedTime);
282							});
283
284							// vimeo subtitles
285							obj.vimeoPlayer.getTextTracks().then(function(tracks) {
286								if (tracks.length) {
287									let tracksButton = document.createElement('div');
288									tracksButton.className = 'mejs-button mejs-captions-button';
289									tracksButton.innerHTML = '<button type="button">CC</button>';
290									let menu = document.createElement('ul');
291									menu.className = 'mejs_mw_captions-selector';
292									menu.innerHTML = '<li data-lang="">Off</li>';
293									tracks.forEach(function (track) {
294										let item = document.createElement('li');
295										item.setAttribute('data-lang', track.language);
296										item.innerHTML = track.label;
297										menu.appendChild(item);
298									});
299
300									tracksButton.appendChild(menu);
301									if ($(player.container).find('.mejs-volume-button').length) {
302										$(player.container).find('.mejs-volume-button').after(tracksButton);
303									} else {
304										$(player.container).find('.mejs-time').after(tracksButton);
305									}
306
307
308									$container.find('.mejs-captions-button li').on('click', function(e) {
309										let lang = $(this).data('lang');
310										$container.find('.mejs_mw_captions-selector li').removeClass('current');
311										$(this).addClass('current');
312										if (videoType === 'youtube') {
313
314										} else if (videoType === 'vimeo') {
315											if (lang === "") {
316												obj.vimeoPlayer.disableTextTrack()
317											} else {
318												obj.vimeoPlayer.enableTextTrack(lang);
319											}
320										}
321									});
322								}
323							})
324						}
325
326						// mute and unmute button on mobile devices
327						if ($(player.container).find('.mejs-volume-button').length === 0) {
328							let muteButton = createMuteButton(player);
329
330							$(media).on('play', function () {
331								if (player.media.muted) {
332									muteButton.classList.add('mejs-unmute');
333									muteButton.classList.remove('mejs-mute');
334								} else {
335									muteButton.classList.add('mejs-mute');
336								}
337								muteButton.style.display = 'block';
338							});
339
340							$(media).on('pause', function () {
341								muteButton.style.display = 'none';
342							});
343
344							$(player.container).find('.mejs-time').after(muteButton);
345						}
346
347						// set size for vertical videos
348						if (isVertical) {
349							let width = $container.find('.mw_video_frame').width();
350							player.setPlayerSize(width, width * 1.777);
351						}
352
353						// z-index fix on safari on fake fullscreen
354						if (isSafari && isMobile) {
355							$container.find('.mejs-fullscreen-button').on('click', function(e) {
356								if ($container.find('.mejs-container').hasClass('mejs-container-fullscreen')) {
357									$container.closest('.element_container').css('z-index', 3);
358									$container.closest('.col').css('z-index', 3);
359								} else {
360									$container.closest('.element_container').css('z-index', 2);
361									$container.closest('.col').css('z-index', 2);
362								}
363							});
364						}
365					}
366				};
367
368				// prevent move video on arrows key if container has class mw_video_hide_progress
369				if ($container.hasClass('mw_video_hide_progress')) {
370					videoSetting.keyActions = [
371						{
372							keys: [37, 39], // right and left arrows keys
373							action: function(player, media, key, event) {
374								event.preventDefault();
375							}
376						},
377					];
378				}
379
380				$video.mediaelementplayer(videoSetting);
381			}
382
383			// video chapters
384			$container.find('.mw_video_chapters a').on('click', function(e) {
385				e.preventDefault();
386				let time = $(this).data('time');
387				if (time !== undefined) {
388					seekVideo(time);
389				}
390			});
391
392			$container.find('.mw-vimeo-fullscreen').on('click', function(e) {
393				loadVimeo();
394				obj.vimeoPlayer.getPaused().then(function(paused) {
395					if(paused){
396						obj.vimeoPlayer.play().then(function() {
397							obj.vimeoPlayer.requestFullscreen();
398						});
399					} else {
400						obj.vimeoPlayer.requestFullscreen();
401					}
402				});
403			});
404
405			$container.find('.mejs_mw_speed-button li').on('click', function(e) {
406				let speed = $(this).data('speed');
407				$container.find('.mejs_mw_speed-button span').html(speed + 'x');
408				$container.find('.mejs_mw_speed-button li').removeClass('current');
409				$(this).addClass('current');
410				if (videoType === 'youtube') {
411					$container.find('iframe')[0].contentWindow.postMessage('{"event":"command","func":"setPlaybackRate","args":[' + speed + ', true]}', '*');
412				} else if (videoType === 'vimeo') {
413					loadVimeo();
414					obj.vimeoPlayer.setPlaybackRate(speed);
415				}
416			});
417
418			// video popups
419			$container.find('.mw_video_open_popup').click(function(e) {
420				e.preventDefault();
421				$container.addClass('mw_video_popup_opened');
422				$container.closest('.col').addClass('mw_col_with_popup_opened');
423				$('body').addClass('mw_element_popup_opened');
424
425				if (videoType === 'vimeo' && isMejs) {
426					let ratio = 0.5625;
427					if (isVertical) {
428						ratio = 1.777;
429					}
430					let popupWidth = $container.find('.mw_video_frame').width();
431					$video[0].player.setPlayerSize(popupWidth, popupWidth * ratio);
432				}
433
434				playVideo();
435			});
436
437			$container.find('.mw_video_popup_content').click(function(e) {
438				e.stopPropagation();
439			});
440
441			let onPlaying = function() {
442				$video[0].player.pause();
443				$video[0].player.media.removeEventListener('playing', onPlaying);
444			};
445
446			$container.find('.mw_video_popup_container').click(function(e) {
447				e.preventDefault();
448				$container.removeClass('mw_video_popup_opened');
449				$container.closest('.col').removeClass('mw_col_with_popup_opened');
450				$('body').removeClass('mw_element_popup_opened');
451				if (isMejs) {
452					if(!$video[0].player.paused) {
453						$video[0].player.media.addEventListener('pause', function onPause() {
454							$video[0].player.media.removeEventListener('playing', onPlaying);
455							$video[0].player.media.removeEventListener('pause', onPause);
456						});
457						$video[0].player.media.addEventListener('playing', onPlaying);
458					}
459					$video[0].player.pause();
460				} else if (videoType === 'youtube') {
461					$video[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
462				} else if (videoType === 'vimeo') {
463					loadVimeo();
464					obj.vimeoPlayer.pause();
465				}
466
467			});
468
469			$container.find('.mw_video_poster_container').click(function(e) {
470				e.preventDefault();
471
472				playVideo();
473			});
474
475			// play video
476
477			let playVideo = function () {
478				if (obj.isLazy) {
479					$container.find('.mw_video_poster_container').addClass('cms_nodisp');
480					let video_url = $video.data("src");
481					if (!$video.attr("src") && video_url) {
482						$video.attr("src", video_url);
483						$video.on('load', function() {
484							play();
485						});
486					} else if ($video.attr("src")) {
487						play();
488					}
489				} else {
490					play();
491				}
492			}
493
494			let play = function () {
495				if (isMejs) {
496					$video[0].player.play();
497				} else if (videoType === 'youtube') {
498					$video[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
499				} else if (videoType === 'vimeo') {
500					loadVimeo();
501					obj.vimeoPlayer.play();
502				}
503			}
504
505			// seek video
506
507			let seekVideo = function (time) {
508				if (obj.isLazy) {
509					$container.find('.mw_video_poster_container').addClass('cms_nodisp');
510					let video_url = $video.data("src");
511					if (!$video.attr("src") && video_url) {
512						$video.attr("src", video_url);
513						$video.on('load', function() {
514							seek(time);
515						});
516					} else if ($video.attr("src")) {
517						seek(time);
518					}
519				} else {
520					seek(time);
521				}
522			}
523
524			let seek = function (time) {
525				if (isMejs) {
526					$video[0].player.setCurrentTime(time);
527					$video[0].player.play();
528				} else if (videoType === 'youtube') {
529					$video[0].contentWindow.postMessage('{"event":"command","func":"seekTo","args":[' + time + ', true]}', '*');
530				} else if (videoType === 'vimeo') {
531					loadVimeo();
532					obj.vimeoPlayer.setCurrentTime(time);
533					obj.vimeoPlayer.play();
534				}
535			}
536
537		});
538	};
539})(jQuery);
540
541function mw_init_video(target) {
542	jQuery(target).mwVideo();
543}
544
545function mw_init_videos() {
546	var $allContainers = jQuery('.mw_video_container:not(.ve_popup_container .mw_video_container)');
547	var $eager = $allContainers.not('.mw_video_lazy_init');
548	var $lazy = $allContainers.filter('.mw_video_lazy_init');
549
550	$eager.mwVideo();
551
552	if (!$lazy.length) {
553		return;
554	}
555
556	if (typeof IntersectionObserver === 'undefined') {
557		// Fallback for very old browsers without IntersectionObserver — initialize all eagerly.
558		$lazy.removeClass('mw_video_lazy_init').mwVideo();
559		return;
560	}
561
562	var observer = new IntersectionObserver(function (entries, obs) {
563		entries.forEach(function (entry) {
564			if (entry.isIntersecting) {
565				var $container = jQuery(entry.target);
566				$container.removeClass('mw_video_lazy_init');
567				$container.mwVideo();
568				obs.unobserve(entry.target);
569			}
570		});
571	}, { rootMargin: '500px' });
572
573	$lazy.each(function () {
574		observer.observe(this);
575	});
576}
577
578function mw_recalculate_fb_page_plugin_width() {
579	var $fb = jQuery('.fb-page');
580	if (!$fb.length) {
581		return;
582	}
583
584	var init = false;
585
586	$fb.each(function () {
587		var $this = jQuery(this);
588		var elementWidth = parseInt($this.width());
589		var containerWidth = parseInt($this.parent().width());
590
591		if (containerWidth && elementWidth) {
592			var maxWidth = $this.attr('data-max-width') || 500;
593			var minWidth = 180;
594
595			containerWidth = Math.max(Math.min(containerWidth, maxWidth), minWidth);
596			if (elementWidth !== containerWidth) {
597				$this.attr('data-width', containerWidth);
598				$this.removeAttr('fb-iframe-plugin-query');
599				$this.html('');
600
601				init = true;
602			}
603		}
604	});
605
606	if (init) {
607		mw_init_facebook();
608	}
609}
610
611function mw_debouncer(func, timeout) {
612	var timeoutID, timeout = timeout || 200;
613	return function () {
614		var scope = this, args = arguments;
615		clearTimeout(timeoutID);
616		timeoutID = setTimeout(function () {
617			func.apply(scope, Array.prototype.slice.call(args));
618		}, timeout);
619	}
620}
621
622function mw_init_contact_form(target) {
623	jQuery(target).mwForm({
624		onsubmit: function (self, $form) {
625			var form = $form.serialize();
626			var button = self.$el.find("button");
627			button.addClass('working');
628			jQuery.post(ajaxurl, 'action=ve_send_contact_form&' + form, function (data) {
629
630				if (data.redirect) {
631					const target = self.$el.find('input[name="form_redirect_url"]').attr('data-target');
632					if (target === 'parent') {
633						parent.location.replace(data.redirect);
634					} else {
635						window.location.replace(data.redirect);
636					}
637				} else {
638					self.showMessage(data);
639					button.removeClass('working');
640				}
641			}).fail(function () {
642
643				self.showMessage({'sended': 'error', 'message': front_texts.nosended});
644				button.removeClass('working');
645
646			});
647			return false;
648		}
649	});
650}
651
652function mw_init_facebook() {
653	if (typeof FB.XFBML.parse === "undefined") {
654		console.log('Function "FB.XFBML.parse" is undefined')
655		return;
656	}
657
658	FB.XFBML.parse();
659}
660
661function mw_init_form(target) {
662	jQuery(target).mwForm();
663}
664
665function mw_init_tabs(target) {
666	jQuery(target).mwFrontTabs();
667}
668
669function mw_init_webinar_registration_form(target) {
670	const $forms = jQuery(target);
671
672	if ($forms.length === 0) {
673		return;
674	}
675
676	const isPopupWindowOpen = function(popupWindow) {
677		return popupWindow && !popupWindow.closed && typeof popupWindow.closed !== 'undefined';
678	};
679
680	// Check and refresh webinar cache
681	const refreshedWebinars = new Set();
682
683	$forms.each(function() {
684		const $form = jQuery(this);
685		const $container = $form.closest('.in_element_content');
686		const needsRefresh = $container.attr('data-webinar-needs-refresh') === '1';
687		const platform = $container.attr('data-webinar-platform');
688		const webinarId = $container.attr('data-webinar-id');
689		const cacheNonce = $container.attr('data-webinar-cache-nonce');
690
691		if (needsRefresh && platform && webinarId && cacheNonce) {
692			const webinarKey = platform + webinarId;
693
694			if (!refreshedWebinars.has(webinarKey)) {
695				refreshedWebinars.add(webinarKey);
696
697				jQuery.post(ajaxurl, {
698					action: 've_refresh_webinar_cache',
699					platform: platform,
700					webinar_id: webinarId,
701					_wpnonce: cacheNonce
702				});
703			}
704		}
705	});
706
707	// Open blank window on button click (Safari requires this in direct click handler)
708	$forms.each(function() {
709		const $form = jQuery(this);
710		const willOpenNewTab = $form.data('open-new-tab') === 1;
711
712		if (willOpenNewTab) {
713			$form.find('button[type="submit"]').on('click.webinarPopup', function() {
714				const newWindow = window.open('about:blank', '_blank');
715
716				if (newWindow) {
717					try {
718						// Prevent reverse-tabnabbing
719						newWindow.opener = null;
720					} catch (e) {
721						// Browser has already restricted access to the opener
722					}
723
724					// Inject spinner HTML
725					try {
726						const $container = $form.closest('.in_element_content');
727						const platform = $container.attr('data-webinar-platform') || '';
728						const platformTitle = platform === 'webinarjam' ? 'WebinarJam' : platform === 'everwebinar' ? 'EverWebinar' : '';
729
730						const doc = newWindow.document;
731						doc.open();
732						doc.close();
733
734						doc.title = platformTitle;
735
736						const style = doc.createElement('style');
737						style.textContent = 'body{margin:0;display:flex;justify-content:center;align-items:center;height:100vh;height:100dvh;background:#fff}.spinner{width:70px;height:70px;border:4px solid rgba(200,200,200,0.3);border-top-color:#27a8d7;border-radius:50%;animation:spin 0.8s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}';
738						doc.head.appendChild(style);
739
740						const spinner = doc.createElement('div');
741						spinner.className = 'spinner';
742						doc.body.appendChild(spinner);
743					} catch (e) {
744						// Spinner not injected, keep about:blank
745					}
746
747					$form.data('webinar-popup-window', newWindow);
748				}
749			});
750
751			// Close popup if validation fails (validation adds error classes or error messages)
752			let validationObserver = null;
753
754			$form.on('submit.webinarPopupCleanup', function() {
755				// Defensive check to prevent multiple observers in case of unexpected behavior
756				if (validationObserver) {
757					validationObserver.disconnect();
758				}
759
760				validationObserver = new MutationObserver(function(mutations) {
761					const hasErrors = $form.find('.ve_form_error_message').length > 0;
762
763					if (hasErrors) {
764						const popupWindow = $form.data('webinar-popup-window');
765						if (isPopupWindowOpen(popupWindow)) {
766							popupWindow.close();
767						}
768						$form.removeData('webinar-popup-window');
769						validationObserver.disconnect();
770					}
771				});
772
773				validationObserver.observe($form[0], {
774					attributes: true,
775					attributeFilter: ['class'],
776					childList: true,
777					subtree: true
778				});
779
780				// Store observer reference for cleanup
781				$form.data('webinar-validation-observer', validationObserver);
782			});
783		}
784	});
785
786	$forms.mwForm({
787		onsubmit: function (self, $form) {
788			let form = $form.serialize();
789
790			const urlParams = new URLSearchParams(window.location.search);
791			const utmParams = [];
792
793			// Get all UTM parameters from the URL
794			for (const [key, value] of urlParams) {
795				if (key.startsWith('utm_')) {
796					utmParams.push('utm_params[' + encodeURIComponent(key) + ']=' + encodeURIComponent(value));
797				}
798			}
799
800			// Add UTM parameters to form data
801			if (utmParams.length > 0) {
802				form += '&' + utmParams.join('&');
803			}
804
805			const button = self.$el.find("button");
806			button.addClass('working');
807
808			// Get the pre-opened window from click handler (Safari requirement)
809			const newWindow = $form.data('webinar-popup-window') || null;
810			$form.removeData('webinar-popup-window');
811
812			// Disconnect validation observer since validation passed and we're proceeding with AJAX
813			const validationObserver = $form.data('webinar-validation-observer');
814			if (validationObserver) {
815				validationObserver.disconnect();
816				$form.removeData('webinar-validation-observer');
817			}
818
819			jQuery.post(ajaxurl, 'action=ve_process_webinar_registration&' + form, function (data) {
820				if (data.popup_url || data.thank_you_url) {
821					const doRedirect = function (url) {
822						const target = self.$el.find('input[name="form_redirect_url"]').attr('data-target');
823
824						if (target === 'parent') {
825							parent.location.assign(url);
826						} else {
827							window.location.assign(url);
828						}
829					};
830
831					if (data.target_blank) {
832						if (isPopupWindowOpen(newWindow)) {
833							// Popup is open - redirect popup to webinar/payment URL
834							if (data.popup_url) {
835								newWindow.location.href = data.popup_url;
836							} else {
837								// URL is missing, something failed unexpectedly, close popup
838								newWindow.close();
839							}
840
841							// If thank you page is set, redirect origin page to it, otherwise show message
842							if (data.thank_you_url) {
843								doRedirect(data.thank_you_url);
844							} else {
845								self.showMessage({'sended': 'ok', 'message': data.message});
846								button.removeClass('working');
847							}
848						} else {
849							// Popup is blocked - redirect origin page to webinar/payment URL (higher priority than thank you page)
850							if (data.popup_url) {
851								doRedirect(data.popup_url);
852							} else {
853								// URL is missing, something failed unexpectedly, show error message
854								self.showMessage({'sended': 'error', 'message': front_texts.nosended});
855								button.removeClass('working');
856							}
857						}
858					} else {
859						if (data.thank_you_url) {
860							doRedirect(data.thank_you_url);
861						} else {
862							// URL is missing, unable to redirect, show message instead
863							self.showMessage({'sended': 'ok', 'message': data.message});
864							button.removeClass('working');
865						}
866					}
867				} else {
868					// No redirect - close popup if it was opened
869					if (isPopupWindowOpen(newWindow)) {
870						newWindow.close();
871					}
872					self.showMessage(data);
873					button.removeClass('working');
874				}
875
876				if (data.new_nonce) {
877					self.$el.find('input[name="mw_wpnonce_webinar_reg"]').val(data.new_nonce);
878				}
879			}).fail(function () {
880				// AJAX failed - close popup if it was opened
881				if (isPopupWindowOpen(newWindow)) {
882					newWindow.close();
883				}
884				self.showMessage({'sended': 'error', 'message': front_texts.nosended});
885				button.removeClass('working');
886			});
887
888			return false;
889		}
890	});
891}
892
893function mw_init_password_input(target) {
894	jQuery(target).mwPasswordInput();
895}
896
897function mw_load_added_ss_form(target, content) {
898	var $target = jQuery(target);
899
900	var old = window.document.write;
901	window.document.write = function (html) {
902		$target.html(html);
903		window.document.write = old;
904	}
905
906	$target.html(content);
907}
908
909function mw_load_added_script(target, url, html) {
910	var $target = jQuery(target);
911
912	if(html)
913		$target.html(html);
914
915	var script = document.createElement("script");
916	script.async = true;
917	script.src = url;
918	$target.append(script);
919}
920
921function mw_load_added_fapi_form(target, but_class, content, clientDetails) {
922	var $target = jQuery(target);
923
924	var old = window.document.write;
925	window.document.write = function (html) {
926		$target.html(html);
927		window.document.write = old;
928
929		mw_fill_fapi_form_old(clientDetails);
930		$target.find("#frm-submit").addClass(but_class);
931	}
932
933	mw_fill_fapi_form_new(clientDetails)
934
935	var wrapper = document.createElement('div');
936	wrapper.innerHTML= content;
937	var script = document.createElement('script');
938	script.src = wrapper.firstChild.src;
939	script.type = 'text/javascript';
940
941	$target.html('');
942	document.querySelector(target).append(script);
943
944	// Remove possibly loaded Fapi scripts because Fapi will load them again in it's internal initialization
945	var fapiInternalScripts = ['https://form.fapi.cz/js/jQueryFapi.js', 'https://form.fapi.cz/js/netteFormsFapi.js'];
946	jQuery('script').each(function () {
947		if (fapiInternalScripts.indexOf(this.src) !== -1) {
948			this.parentNode.removeChild(this);
949		}
950	});
951}
952
953function mw_load_fapi_form(target, but_class, clientDetails) {
954	var $target = jQuery(target);
955	mw_fill_fapi_form_old(clientDetails);
956	mw_fill_fapi_form_new(clientDetails)
957	$target.find("#frm-submit").addClass(but_class);
958}
959
960function mw_fill_fapi_form_old(clientDetails) {
961	if (clientDetails && clientDetails !== 'null') {
962		clientDetails = jQuery.parseJSON(clientDetails);
963		var $form = jQuery("#frm-showUserForm");
964		if (!$form.length) {
965			return;
966		}
967
968		var inputNames = ["name", "surname", "email", "mobil", "street", "city", "postcode", "company", "ic", "dic"];
969		for (var i in inputNames) {
970			var name = inputNames[i];
971			var value = clientDetails[name];
972			if (value !== undefined) {
973				$form.find("[name=" + name + "]").val(value);
974			}
975		}
976	}
977}
978
979function mw_fill_fapi_form_new(clientDetails) {
980	set_singleton_event_listener('fapiFormMounted', function (e) {
981		if (clientDetails && clientDetails !== 'null') {
982			var values = jQuery.parseJSON(clientDetails);
983			var formWrapper = e.detail.formWrapper || null;
984			if (formWrapper !== null) {
985				var inputNames = ["email", "phone", "first_name", "last_name", "company", "ico", "dic", "street", "city", "zip"];
986				for (var i in inputNames) {
987					var name = inputNames[i];
988					var value = values[name];
989					if (value !== undefined) {
990						var input = formWrapper.querySelector("[name=" + name + "]");
991						if (input !== null) {
992							input.value = value;
993						}
994					}
995				}
996			}
997		}
998	});
999}
1000
1001/** @see https://stackoverflow.com/a/17391426 */
1002var set_singleton_event_listener = (function(element){
1003	var handlers = {};
1004	return function(evtName, func){
1005		handlers.hasOwnProperty(evtName) && element.removeEventListener(evtName, handlers[evtName]);
1006		if (func) {
1007			handlers[evtName] = func;
1008			element.addEventListener(evtName, func);
1009		} else {
1010			delete handlers[evtName];
1011		}
1012	};
1013})(document);
1014
1015
1016/* ********************* Fixed header  ******************** */
1017function setFixedHeader() {
1018	if (jQuery('.ve_fixed_header').length) {
1019		var header_position = jQuery(".ve_fixed_header").offset();
1020
1021		jQuery(window).on('scroll load', function (e) {
1022			var header_height = jQuery('#header').height();
1023			var padding_bottom = header_height;
1024			if (jQuery('.ve_fixed_header').length === 0) padding_bottom = 0;
1025			if (jQuery('.mw_transparent_header').length) padding_bottom = 0;
1026
1027			var scroll = jQuery(window).scrollTop();
1028			var fixed_desktop_only = jQuery(".ve_fixed_header").hasClass('ve_fixed_desktop_only');
1029			if (scroll > header_position.top && (!fixed_desktop_only || jQuery(window).width() >= 767)) {
1030				jQuery(".ve_fixed_header").addClass("ve_fixed_header_scrolled");
1031				jQuery("header").css('paddingBottom', padding_bottom);
1032
1033				if (e.type === 'load' && window.location.hash) {
1034					var anchor = document.querySelector(window.location.hash);
1035					if (anchor !== null) {
1036						var isScrolledToAnchor = Math.floor(anchor.getBoundingClientRect().top) === 0;
1037						if (isScrolledToAnchor) {
1038							// jQuery(window).scrollTop(scroll - header_height);
1039							jQuery('html, body').animate({scrollTop: '-=' + header_height + 'px'}, 0);
1040						}
1041					}
1042				}
1043			} else {
1044				jQuery(".ve_fixed_header_scrolled").removeClass("ve_fixed_header_scrolled");
1045				jQuery("header").css('paddingBottom', '0');
1046				//jQuery("header").height('auto');
1047			}
1048		});
1049	}
1050}
1051
1052function setParallaxScroll(init = false) {
1053	if (jQuery('.background_parallax').length) {
1054		jQuery('.background_parallax').each(function () {
1055			var $el = jQuery(this);
1056			updateParallax($el);
1057		});
1058	}
1059}
1060
1061function updateParallax($el) {
1062
1063	var diff = jQuery(window).scrollTop() - $el.closest('.row').offset().top;
1064	var yPos = +(diff * 0.4);
1065
1066	var coords = yPos + 'px';
1067
1068	$el.css({
1069		backgroundPositionY: coords
1070	});
1071}
1072
1073
1074/* ********************* FAQ  ******************** */
1075function faqClick(element, cssid) {
1076	jQuery(element).toggleClass('ve_faq_question_open');
1077	jQuery(element).toggleClass('ve_faq_question_close');
1078	jQuery(element).next(cssid + " .ve_faq_answer").slideToggle();
1079}
1080
1081// smooth link scroll
1082
1083jQuery(function () {
1084	jQuery('.menu a[href*="#"]:not([href="#"]),.ve_content_button[href*="#"]:not([href="#"]),.element_image a[href*="#"]:not([href="#"]),.entry_content a[href*="#"]:not([href="#"]),.mw_feature_title_link[href*="#"],.mw_feature_icon[href*="#"],.mw_icon_text a[href*="#"], .link_element_container a[href*="#"]:not([href="#"]), .mw_element_item a[href*="#"]:not([href="#"])').on('click', function () {
1085		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
1086			var target = jQuery(this.hash);
1087			var $fixedHeader = jQuery('.ve_fixed_header');
1088			var fixedHeaderHeight = $fixedHeader.height() || 0;
1089			var fixedAndNotScrolled = $fixedHeader.hasClass('mw_transparent_header') && !$fixedHeader.hasClass('ve_fixed_header_scrolled');
1090
1091			if (fixedAndNotScrolled) {
1092				// Because transparent header has absolute position
1093				$fixedHeader.removeClass('mw_transparent_header');
1094			}
1095
1096			target = target.length ? target : jQuery('[name=' + this.hash.slice(1) + ']');
1097			if (target.length) {
1098				jQuery('html,body').animate({
1099					scrollTop: (target.offset().top - fixedHeaderHeight)
1100				}, 1000, 'swing', function() {
1101					if (fixedAndNotScrolled) {
1102						$fixedHeader.addClass('mw_transparent_header');
1103					}
1104				});
1105				if (jQuery('#mobile_nav').is(':visible')) {
1106					jQuery('#header .header_nav_container').removeClass('open');
1107					jQuery('.mw_mobile_nav_close_overlay').remove();
1108					jQuery('body').removeClass('mobile_menu_opened');
1109				}
1110				return false;
1111			}
1112		}
1113	});
1114});
1115
1116
1117function initialize_google_maps() {
1118	jQuery('.mw_google_map_container').each(function () {
1119		var def_setting = {
1120			address: 'Praha',
1121			zoom: 12,
1122			scrollwheel: false,
1123		};
1124
1125		var setting = JSON.parse(jQuery(this).attr('data-setting'));
1126
1127		setting = jQuery.extend(def_setting, setting);
1128
1129		initialize_google_map(jQuery(this).attr('id'), setting);
1130
1131	});
1132}
1133
1134function initialize_google_map(map_id, setting) {
1135	var address = setting.address;
1136	var geocoder = new google.maps.Geocoder();
1137	var map = new google.maps.Map(document.getElementById(map_id), {
1138		zoom: setting.zoom,
1139		scrollwheel: setting.scrollwheel,
1140		center: {lat: -25.363, lng: 131.044},
1141	});
1142	if (geocoder) {
1143		geocoder.geocode({
1144			'address': address
1145		}, function (results, status) {
1146			if (status === google.maps.GeocoderStatus.OK) {
1147				if (results && results[0]) {
1148					map.setCenter(results[0].geometry.location);
1149
1150					var infowindow = new google.maps.InfoWindow({
1151						content: '<b>' + address + '</b>',
1152					});
1153
1154					var marker = new google.maps.Marker({
1155						position: results[0].geometry.location,
1156						map: map,
1157						title: address
1158					});
1159
1160					marker.addListener('click', function () {
1161						infowindow.open(map, marker);
1162					});
1163
1164				} else {
1165					jQuery('#' + map_id + '_error').show();
1166				}
1167			} else {
1168				jQuery('#' + map_id + '_error').show();
1169			}
1170		});
1171	}
1172
1173	var mapdata = {
1174		map: map,
1175		address: address
1176	};
1177	jQuery('#' + map_id).data('map', mapdata);
1178}
1179
1180;(function (factory) {
1181
1182	if (typeof define === 'function' && define.amd) {
1183		define(['jquery'], factory);
1184	} else if (typeof exports !== 'undefined') {
1185		module.exports = factory(require('jquery'));
1186	} else {
1187		factory(jQuery);
1188	}
1189
1190})(function ($) {
1191	// background video
1192	var MwBackgroundVideo = (function (element) {
1193
1194		function _MwBackgroundVideo(element) {
1195
1196			this.$el = $(element);
1197			this.$el.hide();
1198			var self = this;
1199
1200			$(element).load(function () {
1201				self.sizeTheVideo();
1202				self.$el.show();
1203			});
1204			$(window).resize(function () {
1205				self.sizeTheVideo();
1206				console.log('resize');
1207			});
1208
1209		}
1210
1211		return _MwBackgroundVideo;
1212
1213	})();
1214
1215	MwBackgroundVideo.prototype.sizeTheVideo = function () {
1216
1217		var w = this.$el.closest('div').width();
1218		var h = this.$el.closest('div').height();
1219
1220		if (w > (h / 9 * 16)) {
1221			this.$el.css({
1222				'width': w + 'px',
1223				'height': w / 16 * 9 + 'px',
1224				'margin-left': -w / 2 + 'px',
1225				'margin-top': -w / 32 * 9 + 'px'
1226			});
1227		} else {
1228			this.$el.css({
1229				'width': h / 9 * 16 + 'px',
1230				'height': h + 'px',
1231				'margin-left': -h / 9 * 8 + 'px',
1232				'margin-top': -h / 2 + 'px'
1233			});
1234		}
1235
1236	}
1237
1238	$.fn.mwBackgroundVideo = function (options) {
1239		return this.each(function (index, el) {
1240			el.MwBackgroundVideo = new MwBackgroundVideo(el, options);
1241		});
1242	};
1243
1244	// popup
1245	var MwPopup = (function (options) {
1246
1247		/**
1248		 * Buffer of keys to open parent popups
1249		 * @type {Array}
1250		 */
1251		var buffer = [];
1252
1253		function _MwPopup(element, options) {
1254			this.$el = $(element);
1255			var self = this;
1256
1257			let defaults = {
1258				open: false,
1259				key: false
1260			};
1261
1262			// setting
1263			let settings = $.extend( {}, defaults, options );
1264			if(settings.key && settings.open) {
1265				open(self, settings.key);
1266			} else {
1267				this.$el.click(function () {
1268					var key = $(this).attr('data-id');
1269					open(self, key);
1270					return false;
1271				});
1272			}
1273
1274		}
1275
1276		function open(self, key) {
1277			let id = $("#ve_popup_container_" + key);
1278			let popup_width = id.attr('data-width');
1279			let background = id.attr('data-bg');
1280			buffer.push(key);
1281
1282			$.mwFrontLightbox({
1283				width: "90%",
1284				maxWidth: popup_width,
1285				inline: true,
1286				href: "#ve_popup_container_" + key,
1287				class: 'mw_popup_transparent_content',
1288				overlayColor: background,
1289				onComplete: function () {
1290
1291					$("#ve_popup_container_" + key + ' .ve_content_button').click(function () {
1292						self.setCookie(key);
1293					});
1294
1295				},
1296				onClosed: function () {
1297					self.setCookie(key);
1298
1299					buffer.pop() // Remove current key
1300					if (buffer.length >= 1) {
1301						// Open parent popup if there is still some key in buffer
1302						open(self, buffer.pop())
1303					}
1304				}
1305			});
1306
1307		}
1308
1309		return _MwPopup;
1310	})();
1311
1312	MwPopup.prototype.setCookie = function (key) {
1313		var delay = $("#ve_popup_container_" + key).attr('data-delay');
1314
1315		var now = new Date();
1316		var time = now.getTime();
1317		var expireTime = time + 1000 * 3600 * delay * 24;
1318		now.setTime(expireTime);
1319		if (delay > 0) document.cookie = "ve_popup_" + key + "=1;expires=" + now.toGMTString() + "; path=/";
1320	}
1321
1322	$.fn.mwPopup = function (options) {
1323
1324		if(this.length > 0) {
1325			return this.each(function (index, el) {
1326				el.MwPopup = new MwPopup(el, options);
1327			});
1328		}
1329
1330	};
1331
1332	$.mwPopup  = function (options) {
1333		options.open = true;
1334		new MwPopup(this, options);
1335	};
1336
1337	// element popup
1338	var MwElementPopup = (function (element) {
1339
1340		function _MwElementPopup(element) {
1341			this.$el = $(element);
1342			var self = this;
1343
1344			this.$el.mwFrontLightbox({
1345				inline: true,
1346				href: self.$el.attr('data-popup'),
1347				maxWidth: "90%",
1348				width: "600px",
1349			});
1350
1351		}
1352
1353		return _MwElementPopup;
1354
1355	})();
1356
1357	$.fn.mwElementPopup = function (options) {
1358		return this.each(function (index, el) {
1359			el.MwElementPopup = new MwElementPopup(el, options);
1360		});
1361	};
1362
1363	// password input
1364	let MwPasswordInput = (function (element) {
1365
1366		function _MwPasswordInput(element) {
1367			this.$el = $(element);
1368			this.$input = this.$el.find('input');
1369			this.$hideIcon = this.$el.find('.mw_password_input_hide');
1370			this.$showIcon = this.$el.find('.mw_password_input_show');
1371			let self = this;
1372
1373			this.$hideIcon.click(function(){
1374				self.$input.attr('type', 'password');
1375				$(this).hide();
1376				self.$showIcon.show();
1377			});
1378			this.$showIcon.click(function(){
1379				self.$input.attr('type', 'text');
1380				$(this).hide();
1381				self.$hideIcon.show();
1382			});
1383
1384		}
1385
1386		return _MwPasswordInput;
1387
1388	})();
1389
1390	$.fn.mwPasswordInput = function (options) {
1391		return this.each(function (index, el) {
1392			el.MwPasswordInput = new MwPasswordInput(el, options);
1393		});
1394	};
1395
1396	// contact form
1397	var MwForm = (function (element) {
1398
1399		function _MwForm(element, settings) {
1400			this.$el = $(element);
1401
1402			this.defaults = {
1403				onsubmit: null,
1404			};
1405			this.settings = $.extend({}, this, this.defaults, settings);
1406
1407			var self = this;
1408
1409			if (this.$el.hasClass("ve_content_form_antispam")) {
1410				this.$el.attr('action', this.$el.attr('data-action'));
1411			}
1412
1413			this.$el.submit(function (e) {
1414				var error = false;
1415				var err_class = "ve_error_form";
1416
1417				self.$el.find(".ve_error_form").removeClass("ve_error_form");
1418				self.$el.find(".ve_form_checkbox_container_error").removeClass("ve_form_checkbox_container_error");
1419				self.$el.find(".ve_form_error_message").remove();
1420
1421				self.$el.find(".ve_form_required").each(function () {
1422					if ($(this).hasClass('ve_form_checkbox')) {
1423						if (!$(this).is(':checked')) error = true;
1424					} else if ($(this).hasClass('ve_form_checkbox_container')) {
1425
1426						if ($('input:checkbox:checked', this).length < 1) {
1427							error = true;
1428							err_class = "ve_form_checkbox_container_error";
1429						}
1430
1431					} else if ($(this).hasClass('ve_form_radio_container')) {
1432
1433						if ($('input:radio:checked', this).length < 1) {
1434							error = true;
1435							err_class = "ve_form_checkbox_container_error";
1436						}
1437
1438					} else {
1439						if ($(this).val() == "") error = true;
1440					}
1441
1442					if (error) {
1443						$(this).addClass(err_class);
1444						var err = $(this).attr('data-errorm');
1445						if (!err) err = front_texts.required;
1446
1447						if ($(this).hasClass('ve_form_checkbox')) {
1448							$(this).closest('label').after('<div class="ve_form_error_message">' + err + '</p>');
1449						} else $(this).after('<div class="ve_form_error_message">' + err + '</p>');
1450
1451						self.scrollOnError($(this));
1452
1453						return false;
1454					}
1455				});
1456
1457				//check number
1458				if (!error) {
1459					self.$el.find(".ve_form_number").each(function () {
1460						var value = $(this).val() || '';
1461						var number = value.trim();
1462
1463						if (!$.isNumeric(number)) {
1464							$(this).addClass("ve_error_form");
1465							alert(front_texts.wrongnumber);
1466							self.scrollOnError($(this));
1467							return false;
1468						}
1469					});
1470				}
1471
1472				if (!error) {
1473					let emailReg = /^([\w-+\.]+@([\w-]+\.)+[\w-]{2,10})?$/;
1474
1475					self.$el.find(".ve_form_email").each(function () {
1476						let emailaddressVal = $(this).val().trim();
1477
1478						$(this).val(emailaddressVal);
1479						if (!emailReg.test(emailaddressVal)) {
1480							$(this).addClass("ve_error_form");
1481							$(this).after('<div class="ve_form_error_message">' + front_texts.wrongemail + '</p>');
1482							self.scrollOnError($(this));
1483							error = true;
1484						}
1485					});
1486				}
1487
1488				// Validate phone numbers via AJAX (server-side PhoneNumberUtil)
1489				if (!error) {
1490					let phoneInputs = [];
1491					let cellPhone = self.$el.find('.ve_form_row_df_cellphone input.ve_form_text');
1492					let phone = self.$el.find('.ve_form_row_df_phone input.ve_form_text');
1493					let contactPhone = self.$el.find('input[name="contact_phone"]');
1494
1495					if (cellPhone.length !== 0 && cellPhone.val().length) {
1496						phoneInputs.push(cellPhone);
1497					}
1498					if (phone.length !== 0 && phone.val().length) {
1499						phoneInputs.push(phone);
1500					}
1501					if (contactPhone.length !== 0 && contactPhone.val().length) {
1502						phoneInputs.push(contactPhone);
1503					}
1504
1505					// _phoneValidated flag: set to true after successful validation, which skips AJAX on programmatic re-submit; then reset below
1506					if (phoneInputs.length && !self._phoneValidated && !self.$el.hasClass('g-recaptcha-form')) {
1507						e.preventDefault();
1508
1509						let button = self.$el.find("button");
1510						let pending = phoneInputs.length;
1511						let hasError = false;
1512
1513						button.addClass('working');
1514
1515						// Collect all responses before showing errors (in order to display them all at once)
1516						let results = [];
1517
1518						// Process results once all AJAX calls have completed (success or failure)
1519						let onAllComplete = function () {
1520							button.removeClass('working');
1521
1522							results.forEach(function (result) {
1523								if (!result.data.valid) {
1524									hasError = true;
1525									result.input.addClass("ve_error_form");
1526									result.input.after('<div class="ve_form_error_message">' + result.data.message + '</div>');
1527								}
1528							});
1529
1530							if (!hasError) {
1531								self._phoneValidated = true;
1532								self.$el.submit();
1533							} else {
1534								// Scroll to the topmost invalid phone field
1535								let firstError = results.filter(function (r) { return !r.data.valid; })
1536									.reduce(function (a, b) {
1537										return a.input.offset().top < b.input.offset().top ? a : b;
1538									});
1539
1540								self.scrollOnError(firstError.input);
1541							}
1542						};
1543
1544						phoneInputs.forEach(function (input, index) {
1545							$.post(ajaxurl, {action: 'mw_validate_phone', phone: input.val()})
1546								.done(function (data) {
1547									results[index] = {input: input, data: data};
1548								})
1549								.fail(function () {
1550									results[index] = {input: input, data: {valid: false, message: front_texts.nosended}};
1551								})
1552								.always(function () {
1553									pending--;
1554
1555									if (pending === 0) {
1556										onAllComplete();
1557									}
1558								});
1559						});
1560
1561						return false;
1562					}
1563				}
1564
1565				// Reset flag so next manual submit triggers validation again
1566				self._phoneValidated = false;
1567
1568				if (error) {
1569					return false;
1570				}
1571				// contact form sending
1572				else {
1573
1574					if (self.settings.onsubmit) {
1575						self.settings.onsubmit.call(this, self, $(this));
1576						return false;
1577					}
1578
1579					if (typeof ajaxurl !== 'undefined') {
1580						var fbEmail = self.$el.find('input[type="email"]').val();
1581						if (fbEmail) {
1582							$.post(ajaxurl, {action: 'mw_fbc_complete_registration', email: fbEmail});
1583						}
1584					}
1585
1586					if(self.$el.hasClass('mw_funnel_contact_conversion')) {
1587						var mail = self.$el.find(".ve_form_email").val();
1588						var funnel_id = self.$el.attr('data-funnel');
1589						$.ajax({
1590							type: 'POST',
1591							data: {"action": "mwSendMailConversion", "contact": mail, "funnel_id": funnel_id},
1592							url: ajaxurl,
1593							success: function (content) {
1594								self.$el.off("submit");
1595								self.$el.submit();
1596								//console.log(content);
1597							}
1598						});
1599						return false;
1600					}
1601				}
1602
1603
1604			});
1605
1606			this.$el.on("click", ".ve_error_form", function () {
1607				$(this).removeClass("ve_error_form");
1608				$(this).closest('.ve_form_row').find('.ve_form_error_message').remove();
1609			});
1610			this.$el.find(".ve_form_message").click(function () {
1611				self.closeMessage();
1612			});
1613
1614		}
1615
1616		return _MwForm;
1617
1618	})();
1619
1620	MwForm.prototype.scrollOnError = function (element) {
1621		let elementOffset = element.offset().top - 50;
1622		let scrollTo = elementOffset;
1623		let scrollSelector = 'html, body';
1624		let offsetSelector = 'body';
1625
1626		if(element.closest('.mw_popup_container').length) {
1627			scrollSelector = '.mw_popup_container';
1628			offsetSelector = '.mw_popup_box';
1629			scrollTo = elementOffset - $(offsetSelector).offset().top;
1630		}
1631
1632		if (elementOffset > $(offsetSelector).offset().top) {
1633			$(scrollSelector).animate({
1634				scrollTop: scrollTo
1635			}, 500);
1636		}
1637	}
1638
1639	MwForm.prototype.showMessage = function (data) {
1640		this.$el.find('.ve_form_message span').html(data.message);
1641		this.$el.find('.ve_form_message').removeClass('ve_form_message_error ve_form_message_ok').addClass('ve_form_message_' + data.sended).fadeIn(200);
1642		if (data.sended === 'ok') {
1643			this.clearForm();
1644		}
1645	}
1646
1647	MwForm.prototype.closeMessage = function () {
1648		this.$el.find('.ve_form_message').fadeOut(200, function () {
1649			$(this).find('span').html('');
1650			$(this).removeClass('ve_form_message_error ve_form_message_ok');
1651		});
1652	}
1653	MwForm.prototype.clearForm = function () {
1654		this.$el.find(".ve_form_row input").each(function () {
1655			$(this).val("");
1656		});
1657		this.$el.find(".ve_form_row textarea").val('');
1658		this.$el.find(".ve_form_row select").val('');
1659	}
1660
1661	$.fn.mwForm = function (options) {
1662		return this.each(function (index, el) {
1663			el.MwForm = new MwForm(el, options);
1664		});
1665	};
1666
1667	// cookie bar
1668	var MwCookieBar = (function (element) {
1669
1670		function _MwCookieBar(element) {
1671			this.$el = $(element);
1672			var obj = this;
1673
1674			if(this.showCookieBar()) {
1675				this.$el.show();
1676			}
1677
1678			this.$el.find(".mw_cookie_open_setting").click(function () {
1679				obj.$el.find(".mw_cookie_bar").hide();
1680
1681				const $source = obj.$el.find(".mw_cookie_setting_popup_content");
1682
1683				let $popup = $('.mw_cookie_setting_popup');
1684				if (!$popup.length) {
1685					$popup = $('<div class="mw_cookie_setting_popup"></div>').appendTo('body');
1686				}
1687
1688				$popup.append($source.children().clone(true, true));
1689
1690				//obj.$el.find(".mw_cookie_setting_popup").show();
1691
1692				var cookie = obj.getCookie();
1693				var preferences = false;
1694				var marketing = false;
1695				var analytics = false;
1696
1697				if(cookie) {
1698					var cookieData = JSON.parse(cookie);
1699					preferences = Boolean(cookieData.permissions.preferences);
1700					marketing = Boolean(cookieData.permissions.marketing);
1701					analytics = Boolean(cookieData.permissions.analytics);
1702				}
1703
1704				$popup.find(".mw_cookie_setting_switch_preferences input").prop('checked', preferences);
1705				$popup.find(".mw_cookie_setting_switch_marketing input").prop('checked', marketing);
1706				$popup.find(".mw_cookie_setting_switch_analytics input").prop('checked', analytics);
1707
1708				$popup.find(".mw_cookie_setting_form_item_head").click(function () {
1709					var container = $(this).closest('.mw_cookie_setting_form_item');
1710					container.find('.mw_cookie_setting_form_item_text').slideToggle();
1711					container.find('.mw_cookie_setting_arrow').toggleClass('opened');
1712				});
1713
1714				$popup.find(".mw_switch").click(function(e) {
1715					e.stopPropagation();
1716				});
1717
1718				// close popup
1719				$popup.find(".mw_cookie_setting_popup_close").click(function(e) {
1720					obj.$el.find(".mw_cookie_bar").show();
1721					$popup.remove();
1722					return false;
1723				});
1724
1725				// allow all
1726				$popup.find(".mw_cookie_allow_all_button").click(function () {
1727					obj.saveCookie();
1728					obj.remove();
1729					return false;
1730				});
1731
1732				// deny all
1733				$popup.find(".mw_cookie_deny_all_button").click(function () {
1734					obj.saveCookie(0,0,0,0);
1735					obj.remove();
1736
1737					return false;
1738				});
1739
1740				// save setting
1741				$popup.find(".mw_cookie_save_setting").click(function () {
1742					var preferences = 0;
1743					var marketing = 0;
1744					var analytics = 0;
1745					var others = 0;
1746					if($popup.find('input:checked[name=preferences]').length)
1747					{
1748						preferences = 1;
1749					}
1750					if($popup.find('input:checked[name=marketing]').length && $popup.find('input[name=marketing]'))
1751					{
1752						marketing = 1;
1753					}
1754					if($popup.find('input:checked[name=analytics]').length)
1755					{
1756						analytics = 1;
1757					}
1758					obj.saveCookie(preferences, marketing, analytics, others);
1759					obj.remove();
1760					return false;
1761				});
1762
1763				return false;
1764			});
1765
1766			// allow all
1767			this.$el.find(".mw_cookie_bar .mw_cookie_allow_all_button").click(function () {
1768				obj.saveCookie();
1769				obj.remove();
1770				return false;
1771			});
1772
1773			// deny all
1774			this.$el.find(".mw_cookie_bar .mw_cookie_deny_all_button").click(function () {
1775				obj.saveCookie(0,0,0,0);
1776				obj.remove();
1777
1778				return false;
1779			});
1780		}
1781
1782		return _MwCookieBar;
1783
1784	})();
1785
1786	MwCookieBar.prototype.remove = function () {
1787		if(this.$el.hasClass('mw_cookie_bar_management_container'))
1788		{
1789			this.$el.remove();
1790		}
1791		$(".mw_cookie_setting_popup").remove();
1792	}
1793
1794	MwCookieBar.prototype.showCookieBar = function () {
1795		var cookie = this.getCookie();
1796		if(cookie) {
1797			return false;
1798		}
1799		else {
1800			return true;
1801		}
1802	}
1803
1804	MwCookieBar.prototype.getCookie = function() {
1805		const name = "mw_cookie_permissions=";
1806		const cDecoded = decodeURIComponent(document.cookie); //to be careful
1807		const cArr = cDecoded.split('; ');
1808		let res = null;
1809		cArr.forEach(val => {
1810			if (val.indexOf(name) === 0) res = val.substring(name.length);
1811		})
1812		return res
1813	}
1814
1815	MwCookieBar.prototype.saveCookie = function (preferences = 1, marketing = 1, analytics = 1, others = 1) {
1816		var date = new Date();
1817		var id = this.getId();
1818
1819		var json_str = JSON.stringify({
1820			'id': id,
1821			'date': date.toGMTString(),
1822			'permissions': {
1823				'preferences': preferences,
1824				'marketing': marketing,
1825				'analytics': analytics,
1826				'others': others,
1827			}
1828		});
1829
1830		let mGranted = marketing ? 'granted' : 'denied';
1831		let aGranted = analytics ? 'granted' : 'denied';
1832		let pGranted = preferences ? 'granted' : 'denied';
1833
1834		if (typeof gtag === 'function') {
1835			gtag('consent', 'update', {
1836				'ad_storage': mGranted,
1837				'ad_personalization': mGranted,
1838				'ad_user_data': mGranted,
1839				'analytics_storage': aGranted,
1840				'personalization_storage': pGranted,
1841				'security_storage': 'granted',
1842				'functionality_storage': 'granted',
1843			});
1844		}
1845
1846		if (typeof window.dataLayer !== 'undefined') {
1847			window.dataLayer.push({
1848				'event': 'consent_update',
1849				'analytics_consent': aGranted,
1850				'preferences_consent': pGranted,
1851				'ad_consent': mGranted,
1852			});
1853		}
1854
1855		date.setDate(date.getDate() + 365);
1856		document.cookie = 'mw_cookie_permissions=' + json_str + '; path=/; expires=' + date.toGMTString();
1857		if(!analytics)
1858		{
1859			document.cookie = 'mw_allow_video_youtube=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT';
1860		}
1861
1862		// save to db
1863		$.ajax({
1864			type: 'POST',
1865			data: {
1866				'action': 'mwSaveCookieConsent',
1867				'id': id,
1868				'preferences': preferences,
1869				'marketing': marketing,
1870				'analytics': analytics,
1871			},
1872			url: ajaxurl,
1873		});
1874	}
1875
1876	MwCookieBar.prototype.getId = function ()
1877	{
1878		var cookie = this.getCookie();
1879
1880		if(cookie) {
1881			var cookieData = JSON.parse(cookie);
1882			if(cookieData.id)
1883			{
1884				return cookieData.id;
1885			}
1886		}
1887
1888		var d = new Date().getTime();
1889		if (window.performance && typeof window.performance.now === "function")
1890		{
1891			d += performance.now();
1892			// use high-precision timer if available
1893		}
1894		var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c)
1895		{
1896			var r = (d + Math.random() * 16) % 16 | 0;
1897			d = Math.floor(d / 16);
1898			return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
1899		});
1900	    return uuid;
1901	}
1902
1903	$.fn.mwCookieBar = function (options) {
1904		return this.each(function (index, el) {
1905			el.MwCookieBar = new MwCookieBar(el, options);
1906		});
1907	};
1908
1909	// phone input
1910	let MwPhoneInput = (function (element) {
1911
1912		function _MwPhoneInput(element) {
1913			this.$el = $(element);
1914			let obj = this;
1915
1916			this.$el.find(".mw_phone_slected_country").click(function () {
1917				obj.$el.find('.mw_phone_country_dropdown').toggle();
1918			});
1919
1920			this.$el.find(".mw_phone_input").focusout(function () {
1921				obj.$el.find('.mw_phone_country_dropdown').hide();
1922			});
1923
1924			this.$el.mouseleave(function () {
1925				obj.$el.find('.mw_phone_country_dropdown').hide();
1926			});
1927
1928			this.$el.find(".mw_phone_country_dropdown a").click(function () {
1929				obj.$el.find('.mw_phone_slected_country input').val($(this).data('value'));
1930				obj.$el.find('.mw_phone_slected_country span').attr('class', $(this).find('.mw_flag').attr('class'));
1931				obj.$el.find('.mw_phone_country_dropdown').hide();
1932				obj.$el.find(".mw_phone_input").focus();
1933			});
1934		}
1935
1936		return _MwPhoneInput;
1937
1938	})();
1939
1940	$.fn.mwPhoneInput = function (options) {
1941		return this.each(function (index, el) {
1942			el.MwPhoneInput = new MwPhoneInput(el, options);
1943		});
1944	};
1945
1946	// tabs
1947	var MwFrontTabs = (function (element, settings) {
1948		function _MwFrontTabs(element, settings) {
1949
1950			this.$el = $(element);
1951
1952			this.defaults = {
1953				change: null,
1954			};
1955			this.settings = $.extend({}, this, this.defaults, settings);
1956
1957			let identificator = this.$el.find('.mw_tabs').data('tabs');
1958
1959			var obj = this;
1960
1961			// clear button
1962			this.$el.children('.mw_tabs').find('a').on('click', function (e) {
1963				e.preventDefault();
1964				const tabId = $(this).attr('href').replace(/^#/, "");
1965				const target = '.mw_tab_' + tabId;
1966				const url = new URL(window.location);
1967
1968				obj.$el.find('.mw_tabs li').removeClass("active");
1969				$(this).closest('li').addClass("active");
1970				obj.$el.find(".mw_tab").hide();
1971				obj.$el.find(target).show();
1972
1973				url.searchParams.set(identificator, tabId);
1974				window.history.pushState({}, '', url);
1975
1976				const parentUrl = new URL(window.parent.location);
1977				parentUrl.searchParams.set(identificator, tabId);
1978				window.parent.history.pushState({}, '', parentUrl);
1979			});
1980
1981			window.addEventListener('popstate', function () {
1982				const urlParams = new URLSearchParams(window.location.search);
1983				const tabId = urlParams.get(identificator);
1984
1985				if (tabId) {
1986					const target = '.mw_tab_' + tabId;
1987
1988					obj.$el.find('.mw_tabs li').removeClass("active");
1989					obj.$el.find(`.mw_tabs a[href="${tabId}"]`).closest('li').addClass("active");
1990
1991					obj.$el.find(".mw_tab").hide();
1992					obj.$el.find(target).show();
1993				}
1994			});
1995		}
1996		return _MwFrontTabs;
1997	})();
1998
1999	$.fn.mwFrontTabs = function (options) {
2000		return this.each(function (index, el) {
2001			el.MwFrontTabs = new MwFrontTabs(el, options);
2002		});
2003	};
2004
2005});

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.