PageSourceSearch

https://www.etz-hayyim-hania.org/wp-content/themes/net22/src/js/main.js?ver=2.1.5

js etz-hayyim-hania.org collected 2026-10-02 12:28:47 UTC 19,238 bytes, 909 lines download raw bytes

1jQuery(document).ready(function($) {
2
3	/*
4	 * FLat Picker
5	 */
6	if($('#date--1').length > 0) {
7
8		let $flatpickr_input = flatpickr("#date--1", {
9			dateFormat: "d/m/Y",
10			minDate: 'today',
11			disableMobile: "true",
12			locale: "gr",
13		});
14
15	};
16	if($('#date--2').length > 0) {
17
18		let $flatpickr_input = flatpickr("#date--2", {
19			dateFormat: "d/m/Y",
20			minDate: 'today',
21			disableMobile: "true",
22			locale: "gr",
23		});
24
25	};
26
27	if($('#date--3').length > 0) {
28
29		let $flatpickr_input = flatpickr("#date--3", {
30			dateFormat: "d/m/Y",
31			minDate: 'today',
32			disableMobile: "true",
33			locale: "gr",
34		});
35
36	};
37
38	if($('#date--4').length > 0) {
39
40		let $flatpickr_input = flatpickr("#date--4", {
41			dateFormat: "d/m/Y",
42			minDate: 'today',
43			disableMobile: "true",
44			locale: "gr",
45		});
46
47	};
48
49	/*
50	 * Contact
51	 */
52	$('.template--contact-forms__controls ul li').on('click', function(e) {
53
54		e.preventDefault();
55
56		let $this = $(this),
57
58			$target = $($this.attr('data-target'));
59
60		if($target.is(':visible')) {
61
62			return;
63
64		};
65
66		$('.template--contact-forms__main > div').hide();
67
68		$target.fadeIn('slow');
69
70		$('.template--contact-forms__controls ul li').removeClass('active');
71
72		$this.addClass('active');
73
74	});
75
76	/*
77	 * Main Menu
78	 */
79
80	// your existing click handler
81	$('.main--menu').on('click', 'li.menu-item-has-children > a', function (e) {
82		e.preventDefault();
83		e.stopPropagation();
84
85		let $icon    = $(this);
86		let $li      = $icon.closest('li.menu-item-has-children');
87		let $submenu = $li.children('.sub-menu');
88
89		if (!$submenu.length) return;
90
91		function closeLi($x) {
92			$x.removeClass('active');
93			$x.children('.sub-menu').stop(true, true).slideUp(200);
94			$x.find('li.menu-item-has-children.active')
95				.removeClass('active')
96				.children('.sub-menu').stop(true, true).slideUp(200);
97		}
98
99		if ($li.hasClass('active')) {
100			closeLi($li);
101			return;
102		}
103
104		let $siblings = $li.siblings('li.menu-item-has-children');
105		$siblings.each(function () { closeLi($(this)); });
106
107		$li.parents('li.menu-item-has-children').each(function () {
108			let $p = $(this);
109			$p.addClass('active');
110			$p.children('.sub-menu').stop(true, true).slideDown(200);
111		});
112
113		$li.addClass('active');
114		$submenu.stop(true, true).slideDown(200);
115	});
116
117	// ✅ AUTO-OPEN PARENTS OF CURRENT MENU ITEM (NOT its own children)
118	(function openParentsOfCurrentMenuItem() {
119
120		let $current = $('.main--menu li.current-menu-item, .main--menu li.current_page_item').last();
121		if (!$current.length) return;
122
123		// open only parents (ancestors)
124		$current.parents('li.menu-item-has-children').each(function () {
125			let $p = $(this);
126			$p.addClass('active');
127			$p.children('.sub-menu').stop(true, true).slideDown(0);
128		});
129
130		// scroll the overflow container to current item (delay + retry until visible)
131		let $container = $('#full--navigation > .cols .main--menu');
132		if (!$container.length) return;
133
134		function tryScroll(attempt) {
135			attempt = attempt || 0;
136
137			// wait until container is visible + has height (common in overlays)
138			if (!$container.is(':visible') || $container[0].clientHeight === 0) {
139				if (attempt < 15) return setTimeout(function(){ tryScroll(attempt + 1); }, 80);
140				return;
141			}
142
143			// robust relative calc using boundingClientRect (better than offset in many layouts)
144			let cRect = $container[0].getBoundingClientRect();
145			let iRect = $current[0].getBoundingClientRect();
146
147			let pad = 80; // space from top inside container
148			let target = $container.scrollTop() + (iRect.top - cRect.top) - pad;
149
150			$container.stop(true).animate({ scrollTop: Math.max(0, target) }, 250);
151		}
152
153		setTimeout(function(){ tryScroll(0); }, 60);
154
155	})();
156
157
158
159
160	/*
161	 * Template Donations Texts
162	 */
163	if ($('#variation---texts').length > 0) {
164
165		$('#variation---texts .text.editor').each(function (i) {
166			var $targetLi = $('#wcdp_1_suggestion-designate-to > li').eq(i);
167			if (!$targetLi.length) return;
168
169			// avoid duplicates if this runs more than once
170			$targetLi.find('> .text.editor').remove();
171
172			// CLONE keeps your HTML + your classes exactly
173			$targetLi.append($(this).clone());
174		});
175
176		$('#wcdp_1_suggestion-designate-to li:first-child .text.editor').show();
177
178		$(document).on('change', '#wcdp_1_suggestion-designate-to li input', function(){
179
180			$('#wcdp_1_suggestion-designate-to li .text.editor').slideUp();
181
182			$(this).parent().find('.text.editor').slideDown();			
183
184		});
185
186	};
187
188	/*
189	 * Read More Button
190	 */
191	if($('.template--donations-extra').length > 0) {
192
193		$('.read--more-button').on('click', function(e) {
194
195			e.preventDefault();
196
197			let $this = $(this),
198
199				more_text = $this.attr('data-more'),
200
201				less_text = $this.attr('data-less'),
202
203				$target = $this.siblings('.read--more-text');
204
205			if($target.is(':visible')) {
206
207				$this.find('.cta--border-text').text(more_text);
208
209				$target.slideUp();
210
211				return;
212
213			};
214
215			$this.find('.cta--border-text').text(less_text);
216
217			$target.slideDown();
218
219		});
220
221	};
222
223	/*
224	 * Lenis Scroll
225	 */
226	function enable_lenis(disable_classes = []) {
227		const lenis = new Lenis({
228			duration: 1.9,
229			easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), 
230			direction: 'vertical',
231			gestureDirection: 'vertical',
232			smooth: true,
233			mouseMultiplier: 1.6,
234			smoothTouch: false,
235			touchMultiplier: 1.1,
236			infinite: false,
237		});
238
239		lenis.on('scroll', ({ scroll, limit, velocity, direction, progress }) => {
240			//console.log({ scroll, limit, velocity, direction, progress })
241		});
242
243		function raf(time) {
244			lenis.raf(time);
245			requestAnimationFrame(raf);
246		}
247		requestAnimationFrame(raf);
248
249		const html = document.documentElement;
250		const originalRaf = lenis.raf.bind(lenis);
251
252		const disableList = Array.isArray(disable_classes)
253		? disable_classes
254		: [disable_classes];
255
256		const isDisabled = () => disableList.some(cls => html.classList.contains(cls));
257		let paused = isDisabled();
258
259		if (paused) {
260			try {
261				lenis.scrollTo(lenis.scroll, { immediate: true });
262			} catch (e) {
263				console.log('lenis scrollTo error', e);
264			}
265		}
266
267		lenis.raf = function (time) {
268			paused = isDisabled();
269			if (paused) {
270				if (!lenis.__pausedOnce) {
271					try {
272						lenis.scrollTo(lenis.scroll, { immediate: true });
273					} catch (e) {}
274					lenis.__pausedOnce = true;
275				}
276				return;
277			}
278			lenis.__pausedOnce = false;
279			return originalRaf(time);
280		};
281
282		const shouldBlock = () => isDisabled();
283
284		window.addEventListener('wheel', (e) => {
285			if (shouldBlock()) e.preventDefault();
286		}, { passive: false });
287
288		window.addEventListener('touchmove', (e) => {
289			if (shouldBlock()) e.preventDefault();
290		}, { passive: false });
291
292		const blockKeys = new Set([
293			'Space', 'PageUp', 'PageDown', 'Home', 'End', 'ArrowUp', 'ArrowDown',
294		]);
295
296		window.addEventListener('keydown', (e) => {
297			if (shouldBlock() && blockKeys.has(e.code)) e.preventDefault();
298		});
299
300		new MutationObserver(() => {
301			if (isDisabled()) {
302				try {
303					lenis.scrollTo(lenis.scroll, { immediate: true });
304				} catch (e) {}
305				lenis.__pausedOnce = true;
306			}
307		}).observe(html, { attributes: true, attributeFilter: ['class'] });
308	};
309
310	//enable_lenis(['menu--visible']);
311
312
313	/*
314	 * Event Value
315	 */
316	if($('#your-event').length > 0) {
317
318		$('#your-event').val($('.single--events-form').attr('data-title'));
319
320	};
321
322	/*
323	 * Map
324	 */
325
326	if($('#map').length > 0) {
327
328		var coords_x = $('#map').attr('data-coords-x'),
329			coords_y = $('#map').attr('data-coords-y'),
330
331			map = L.map('map', {
332				scrollWheelZoom: false
333			}).setView([coords_x, coords_y], 16);
334
335		L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
336			attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/">CARTO</a>',
337			subdomains: 'abcd',
338			maxZoom: 20
339		}).addTo(map);
340
341		var customIcon = L.icon({
342			iconUrl: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 256 256"><path fill="%235C6C0E" d="M128 16a88.1 88.1 0 0 0-88 88c0 75.3 80 132.17 83.41 134.55a8 8 0 0 0 9.18 0C136 236.17 216 179.3 216 104a88.1 88.1 0 0 0-88-88m0 56a32 32 0 1 1-32 32a32 32 0 0 1 32-32"/></svg>',
343			iconSize: [40, 40],
344			iconAnchor: [20, 40], 
345			popupAnchor: [0, -40]
346		});
347
348		var marker = L.marker([coords_x, coords_y], { icon: customIcon }).addTo(map);
349
350	}
351
352
353	/*
354	 * Visitor Information
355	 */
356	/*$('.template--visitor-information .cols .col--left .single').on('click', function(e) {
357
358		e.preventDefault();
359
360		let $this = $(this),
361
362			$this_target = $('.template--visitor-information .cols .col--right .single[data-target="' + $this.attr('data-target') + '"]');
363
364		if($this.hasClass('active')) return;
365
366		$('.template--visitor-information .cols .col--left .single').removeClass('active');
367
368		$this.addClass('active');
369
370		$('.template--visitor-information .cols .col--right .single').hide();
371
372		$this_target.fadeIn('slow');
373
374		if(window.matchMedia('(max-width:991px)').matches) {
375			$([document.documentElement, document.body]).animate({
376
377				scrollTop: ($this_target.offset().top - $('#header').outerHeight() - 20)
378
379			}, 500);
380		}
381
382	});
383
384	/*
385	 * Slider Controls
386	 */
387	$('.slider--controls > span').on('click', function(e) {
388
389		e.preventDefault();
390
391		let $this = $(this),
392
393			$parent = $this.parents('.carousel--parent'),
394
395			action = $this.hasClass('prev') ? 'prev' : 'next';
396
397		$parent.find('.owl-nav .owl-' + action).trigger('click');
398
399	});
400
401	/*
402	 * Navigation Images
403	 */
404	if($('#full--navigation > .cols .col--right .image img').length > 0) {
405
406		let menu_hovertimer;
407
408		$('.main--menu li a').hover(function() {
409
410			let $this = $(this),
411
412				$image = $($this.attr('data-target'));
413
414			if($image.hasClass('active')) return;
415
416			menu_hovertimer = setTimeout(function() {
417
418				$('#full--navigation > .cols .col--right .image img').removeClass('active');
419
420				$image.addClass('active');
421
422			}, 100);
423
424		}, function () {
425
426			clearTimeout(menu_hovertimer);
427
428		});
429
430	};
431
432	/*
433	 * Header Scroll
434	*/
435	$(window).on('scroll', function() {
436
437		var scrolled = window.scrollY || document.documentElement.scrollTop;
438
439		if (scrolled > 50) {
440
441			$('html').addClass('header--scrolled');
442
443		}
444
445		else  {
446
447			$('html').removeClass('header--scrolled');
448
449		}
450
451	});
452
453	/*
454	 * Burger Action
455	*/
456	$('.burger').on('click',function(e) {
457
458		e.preventDefault();
459
460		$('html').toggleClass('menu--visible');
461
462		$('#full--navigation').fadeToggle();
463
464		/*if($('#full--navigation').is(':visible')) {
465
466			$('.burger .burger--text').text($('.burger').attr('data-close'));	
467
468		} else {
469
470			$('.burger .burger--text').text($('.burger').attr('data-open'));	
471
472		};*/
473
474	});
475
476
477	/*
478	 * AOS
479	*/
480	/*AOS.init({
481		disable: function() {
482			var maxWidth = 1181;
483			return window.innerWidth < maxWidth;
484		}
485	});*/
486
487	/*
488	 * Sliders
489	*/
490	if ($('.homepage-top-carousel.owl-carousel').length > 0) {
491		$('.homepage-top-carousel.owl-carousel').owlCarousel({
492			loop: true,
493			margin:0,
494			autoplay:true,
495			autoplayTimeout:6000,
496			slideSpeed: 5000,
497			paginationSpeed: 2000,
498			smartSpeed: 1300,
499			animateIn: 'fadeIn',
500			animateOut: 'fadeOut',
501			nav:true,
502			navText : ["Prev","Next"],
503			responsive:{
504				0:{
505					items:1
506				},
507				480:{
508					items:1
509				},
510				750:{
511					items:1
512				},
513				1000:{
514					items:1
515				}
516			}
517		});
518	};
519
520	if ($('.discover--slider.owl-carousel').length > 0) {
521		$('.discover--slider.owl-carousel').owlCarousel({
522			loop: true,
523			autoplay:true,
524			autoplayTimeout:5000,
525			slideSpeed: 2000,
526			paginationSpeed: 2000,
527			smartSpeed: 1300,
528			nav:false,
529			dots:false,
530			responsive:{
531				0:{
532					items:1,
533					margin:10
534				},
535				768:{
536					items:2,
537					margin:20,
538				},
539				992:{
540					items:3,
541					margin:20,
542				}
543			}
544		});
545	};
546
547	/*
548	 * Set data-src as background-image src
549	*/
550	if($('[data-src]').length > 0) {
551
552		$('[data-src]').each(function(i,e) {
553
554			let $this = $(this),
555
556				this_src = $this.attr('data-src');
557
558			$this.attr('style', 'background-image:url("' + this_src + '")').removeAttr('data-src');
559
560		});
561
562	};
563
564	/*
565	 * Back to Top
566	 */
567	$('#back--to-top').on('click',function(e) {
568
569		e.preventDefault();
570
571		$([document.documentElement, document.body]).animate({
572
573			scrollTop: ($('html').offset().top)
574
575		}, 500);
576
577	});
578
579	/*
580	 * Galleries
581	*/
582	if($('.enable-lightbox').length > 0) {
583
584		lc_lightbox('.enable-lightbox a', {
585			wrap_class: 'lcl_fade_oc',
586			gallery : true,	
587			thumb_attr: 'data-thumb', 
588			skin: 'minimal',
589			radius: 0,
590			padding	: 0,
591			border_w: 0,
592		});	
593
594		$('.enable-lightbox a').on('click', function() {
595
596			//Fix bug caused by owl carousel cloning its elements, causing lightbox to duplicate elements
597			let lightbox_elements = document.querySelectorAll('.lcl_tn_image');
598
599			let lightbox_background_urls = {};
600
601			lightbox_elements.forEach((lightbox_element) => {
602
603				var background_url = lightbox_element.style.backgroundImage;
604
605				if (lightbox_background_urls[background_url]) {
606
607					$(lightbox_element).remove();
608
609				} else {
610
611					lightbox_background_urls[background_url] = true;
612
613				};
614
615			});
616
617			$('ul.lcl_tn_inner').css('opacity', '1');
618
619		});
620
621	};
622	
623	if($('.text.editor div.gallery').length > 0) {
624
625		$('.text.editor div.gallery').each(function() {
626			let $gallery = $(this);
627
628			if (!$gallery.hasClass('owl-carousel')) {
629				$gallery.addClass('owl-carousel');
630			}
631			
632			$('.gallery').children('br').remove();
633
634			$gallery.owlCarousel({
635				loop: false,
636				margin: 0,
637				nav: true,
638				dots: false,
639				autoHeight: false,
640				navText: [
641					'<span aria-label="Previous image">&#8592;</span>',
642					'<span aria-label="Next image">&#8594;</span>'
643				],
644				responsive: {
645					0: {
646						items: 1
647					}
648				}
649			});
650		});
651		
652		$('.text.editor div.gallery .gallery-item a').off('click');
653		$('.text.editor div.gallery .gallery-item a').on('click', function(e) {
654			e.preventDefault();
655		});
656
657		lc_lightbox('.text.editor div.gallery .gallery-item a', {
658			wrap_class: 'lcl_fade_oc',
659			gallery : true,	
660			thumb_attr: 'data-thumb', 
661			skin: 'minimal',
662			radius: 0,
663			padding	: 0,
664			border_w: 0,
665		});	
666
667		$('.text.editor div.gallery .gallery-item a').on('click', function() {
668
669			//Fix bug caused by owl carousel cloning its elements, causing lightbox to duplicate elements
670			let lightbox_elements = document.querySelectorAll('.lcl_tn_image');
671
672			let lightbox_background_urls = {};
673
674			lightbox_elements.forEach((lightbox_element) => {
675
676				var background_url = lightbox_element.style.backgroundImage;
677
678				if (lightbox_background_urls[background_url]) {
679
680					$(lightbox_element).remove();
681
682				} else {
683
684					lightbox_background_urls[background_url] = true;
685
686				};
687
688			});
689
690			$('ul.lcl_tn_inner').css('opacity', '1');
691
692		});
693
694	};
695
696	/*
697	 * Disable default browser actions
698	*/
699	$('a[href="#"]').on('click', function(e){
700
701		e.preventDefault();
702
703	});
704
705	/*
706	 * Scroll to top in contact form has errors
707	*/
708	$(document).on('wpcf7invalid', function(event) {
709
710		setTimeout(function() {
711
712			$([document.documentElement, document.body]).animate({
713
714				scrollTop: ($('.wpcf7-form.invalid').offset().top - $('#header').outerHeight() - 20)
715
716			}, 500);
717
718		}, 200);	
719
720	});
721
722	/*
723	 * Completed contact form 7 email
724	*/
725	$(document).on('wpcf7mailsent', function(event) {
726
727		$('.page--form').hide();
728
729		$('.message__sent-actions').show();
730
731	});
732
733	$('.send__another-message').on('click', function(e) {
734
735		e.preventDefault();
736
737		$('.message__sent-actions').hide();
738
739		$('.page--form').css('display', 'grid');
740
741	});
742
743
744	/*
745 * Single Product Form Checkout
746 */
747	if ($('.single-product-embed').length > 0) {
748
749		var $embed = $('.single-product-embed').first();
750		var $checkoutContainer = $('#embedded-checkout');
751		var $loader = $embed.find('.spf-loader-overlay');
752
753		if (!$checkoutContainer.length) {
754			return;
755		}
756
757		if (!$loader.length) {
758			$loader = $(
759				'<div class="spf-loader-overlay" aria-hidden="true">' +
760				'<div class="spf-loader-spinner" role="status" aria-label="Loading"></div>' +
761				'</div>'
762			).prependTo($embed);
763		}
764
765		function showLoader() {
766			$loader.addClass('is-active');
767		}
768
769		function hideLoader() {
770			$loader.removeClass('is-active');
771		}
772
773		/*
774	 * The checkout form may already exist because WooCommerce has an
775	 * active cart, but checkout and Stripe Express Checkout must remain
776	 * hidden until the user presses Donate.
777	 */
778		var checkoutIsReady =
779			$checkoutContainer.find('form.checkout').length > 0;
780
781		var shouldOpenCheckout = false;
782
783		try {
784			shouldOpenCheckout =
785				sessionStorage.getItem(
786				'n22_open_donation_checkout'
787			) === '1';
788		} catch (error) {}
789
790		/*
791	 * Display the embedded checkout and Stripe Express Checkout only
792	 * after the donation form has been submitted and the page reloaded.
793	 */
794		if (checkoutIsReady && shouldOpenCheckout) {
795
796			$embed.addClass('donation-checkout-open');
797			$checkoutContainer.show();
798
799			/*
800		 * Remove the temporary flag after it has been used.
801		 */
802			try {
803				sessionStorage.removeItem(
804					'n22_open_donation_checkout'
805				);
806			} catch (error) {}
807
808			setTimeout(function () {
809
810				var headerHeight =
811					$('#header').outerHeight() || 0;
812
813				$('html, body').stop(true).animate({
814					scrollTop: Math.max(
815						0,
816						$checkoutContainer.offset().top -
817						headerHeight -
818						20
819					)
820				}, 300);
821
822			}, 250);
823
824		} else {
825
826			$embed.removeClass('donation-checkout-open');
827			$checkoutContainer.hide();
828		}
829
830		/*
831 * Submit the donation selection without navigating or reloading.
832 * The AJAX GET updates the WooCommerce cart session, then we reveal
833 * the already-initialized embedded checkout and refresh its totals.
834 */
835		$(document).on('submit', '#wcdp-get-send', function (event) {
836
837			event.preventDefault();
838
839			var $form = $(this);
840			var $button = $form.find('button[type="submit"]').first();
841			var requestMethod = ($form.attr('method') || 'POST').toUpperCase();
842			var actionUrl = $form.attr('action') || window.location.href;
843
844			$button.prop('disabled', true).addClass('is-loading');
845			showLoader();
846
847			$.ajax({
848				url: actionUrl,
849				type: requestMethod,
850				data: $form.serialize(),
851				cache: false
852			})
853				.done(function () {
854
855				var $checkoutForm = $checkoutContainer.find('form.checkout');
856
857				if ($checkoutForm.length) {
858
859					/*
860             * Checkout + Stripe already exist in the DOM.
861             * Reveal them and let WooCommerce re-fetch the totals.
862             */
863					hideLoader();
864					$button.prop('disabled', false).removeClass('is-loading');
865
866					$embed.addClass('donation-checkout-open');
867					$checkoutContainer.show();
868
869					$(document.body).trigger('update_checkout');
870
871					var headerHeight = $('#header').outerHeight() || 0;
872
873					$('html, body').stop(true).animate({
874						scrollTop: Math.max(
875							0,
876							$checkoutContainer.offset().top - headerHeight - 20
877						)
878					}, 300);
879
880				} else {
881
882					/*
883             * First visit with an empty cart: [woocommerce_checkout]
884             * rendered nothing, so one reload is needed to print it.
885             */
886					try {
887						sessionStorage.setItem('n22_open_donation_checkout', '1');
888					} catch (error) {}
889
890					window.location.reload();
891				}
892			})
893				.fail(function () {
894
895				hideLoader();
896				$button.prop('disabled', false).removeClass('is-loading');
897
898				/* Fallback to the plugin's native behaviour. */
899				if ($form[0]) {
900					$form[0].submit();
901				}
902			});
903		});
904
905	};
906
907
908
vendor: 3 bytes, line 909
909});

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.