PageSourceSearch

https://www.caspiansunrise.com/wp-content/themes/caspian-sunrise/js/custom.js

js caspiansunrise.com collected 2026-10-06 17:12:13 UTC 9,341 bytes, 323 lines download raw bytes

1(function ($) {
2	// ===============================================
3	// STICKY HEADER / SIDEBAR
4	// ===============================================
5	jQuery("document").ready(function ($) {
6		sticky_menu();
7
8		function sticky_menu() {
9			hasScrolled();
10
11			var didScroll;
12			var lastScrollTop = 0;
13			var navbarHeight = $("header.header").outerHeight();
14			var delta = navbarHeight;
15
16			$(window).scroll(function (event) {
17				didScroll = true;
18			});
19
20			setInterval(function () {
21				if (didScroll) {
22					hasScrolled();
23					didScroll = false;
24				}
25			}, 250);
26
27			function hasScrolled() {
28				var st = $(this).scrollTop();
29
30				// Make scroll more than delta
31				if (Math.abs(lastScrollTop - st) <= delta) return;
32
33				// If scrolled down and past the navbar, add class .nav-up.
34				if (st > lastScrollTop && st > navbarHeight) {
35					// Scroll Down
36					$("header.header").removeClass("not-sticky reset").addClass("sticky");
37					setTimeout(function () {
38						var logoHeight = $("header.sticky .logo a").outerHeight();
39						var navHeight = $(".header").outerHeight();
40						$("header.sticky .logo a").css(
41							"transform",
42							"translateY(-" + (logoHeight - navHeight) + "px)"
43						);
44						$(".sidebar-inner").css("top", navHeight + 50 + "px");
45					}, 400);
46				} else {
47					if (st >= 0 && st <= 150) {
48						$("header.header")
49							.addClass("reset")
50							.removeClass("not-sticky sticky");
51						$("header .logo a").css("transform", "translate(0)");
52					} else if (st + $(window).height() < $(document).height()) {
53						$("header.header")
54							.removeClass("not-sticky reset")
55							.addClass("sticky");
56					}
57				}
58
59				lastScrollTop = st;
60			}
61		}
62	});
63
64	// -------------------------------------
65	// MISC
66	// -------------------------------------
67
68	jQuery("document").ready(function ($) {
69		var navHeight = $(".header").outerHeight();
70		$(".inner-banner").css("margin-top", navHeight + "px");
71
72		$(".search-trigger").click(function () {
73			$("#search-container").toggleClass("show");
74			setTimeout(function () {
75				$(".search-field").focus();
76			}, 200);
77		});
78
79		$("#search-container .close").click(function () {
80			$("#search-container").toggleClass("show");
81		});
82
83		$("#search-container")
84			.click(function () {
85				$("#search-container").toggleClass("show");
86			})
87			.children()
88			.on("click", function (e) {
89				e.stopPropagation();
90			});
91
92		$("#search-container .search-form").css("margin-top", navHeight + 140);
93	});
94
95	// -----------------------------------------------------------------------------
96	// MOBILE MENU
97	// -----------------------------------------------------------------------------
98
99	jQuery(document).ready(function ($) {
100		var scrollPosition = "0";
101
102		$("#nav_mobile").click(function () {
103			const $body = document.querySelector("body");
104			const $html = document.querySelector("html");
105			const siteNavigation = document.querySelector("#site-navigation");
106
107			// Remove style for desktop
108			var resizeId;
109			function doneResizing() {
110				var windowWidth = $(window).width();
111				if (windowWidth > 1024) {
112					$("nav.mmenu-active .menu-item-has-children > a").removeClass(
113						"submenu-visible"
114					);
115					$html.style.removeProperty("overflow");
116					$body.style.removeProperty("position");
117					$body.style.removeProperty("top");
118					$("ul.sub-menu").removeAttr("style");
119				}
120			}
121
122			// Deactivate menu
123			if ($(this).attr("menu-mobile") == "active") {
124				$(this).attr("menu-mobile", "not-active");
125
126				$html.style.removeProperty("overflow");
127				$body.style.removeProperty("position");
128				$body.style.removeProperty("top");
129				$body.style.removeProperty("width");
130
131				window.scrollTo(0, scrollPosition);
132
133				$("header.header").removeClass("hamb-open");
134				$("nav.header-nav").css("height", "auto");
135				// $("nav.header-nav ul").css("margin-top", "0");
136
137				// Control the aria expanded for site menu
138				siteNavigation.setAttribute("aria-expanded", "false");
139			}
140
141			// Activate menu
142			else {
143				$("header.header").addClass("hamb-open");
144
145				var device_height = $(window).height();
146				var header_height = $(".hamb-open").height();
147
148				$("nav.header-nav.full-height").height("100vh");
149				// $("nav.header-nav >
149 ul").css("margin-top", "10em");
150
151				$(window).resize(function () {
152					clearTimeout(resizeId);
153					resizeId = setTimeout(doneResizing, 200);
154				});
155
156				$(this).attr("menu-mobile", "active");
157				scrollPosition = window.pageYOffset;
158
159				$html.style.overflow = "hidden";
160				$body.style.position = "fixed";
161				$body.style.top = "-" + scrollPosition + "px";
162				$body.style.width = "100%";
163
164				// Control the aria expanded for site menu
165				siteNavigation.setAttribute("aria-expanded", "true");
166			}
167
168			$("html").toggleClass("menu-opened");
169			$(this).prev().toggleClass("mmenu-active");
170
171			// Hamburger menu animation
172			var animationspeed = parseInt(
173				$("#nav_mobile").attr("data-menu-mobile-anim-speed")
174			);
175
176			if ($(this).attr("data-menu-mobile-anim") == "slideDown") {
177				$(this).prev().clearQueue().finish();
178				$(this).prev().slideToggle(animationspeed);
179			}
180			if ($(this).attr("data-menu-mobile-anim") == "slideLeft") {
181				$(this).prev().clearQueue().finish();
182				$(this).prev().animate({ width: "toggle" }, animationspeed);
183			}
184			if ($(this).attr("data-menu-mobile-anim") == "slideRight") {
185				$(this).prev().clearQueue().finish();
186				$(this).prev().css("right", "auto");
187				$(this).prev().css("left", "0");
188				$(this).prev().animate({ width: "toggle" }, animationspeed);
189			}
190			if ($(this).attr("data-menu-mobile-anim") == "fade") {
191				$(this).prev().clearQueue().finish();
192				$(this).prev().css("right", "auto");
193				$(this).prev().css("left", "0");
194				$(this).prev().fadeToggle(animationspeed);
195			}
196
197			// Open submenu with current subpage when collapsed option is selected
198			if ($(".header-nav").hasClass("collapsed")) {
199				$("nav.mmenu-active.collapsed .current-menu-parent a").addClass(
200					"submenu-visible"
201				);
202				$(
203					"nav.mmenu-active.collapsed .current-menu-parent ul.sub-menu"
204				).slideDown(400);
205			}
206		});
207	});
208
209	// Accordion for sub menus
210	$(document).on(
211		"click",
212		"nav.mmenu-active.collapsed.clickable .menu-item-has-children > a",
213		function () {
214			event.preventDefault();
215			$(this).toggleClass("submenu-visible");
216			$(this).next("ul.sub-menu").slideToggle(400);
217		}
218	);
219
220	$(document).on(
221		"click",
222		"nav.mmenu-active.collapsed.not-clickable .menu-item-has-children",
223		function () {
224			if (event.target !== this) return;
225			event.stopPropagation();
226			event.preventDefault();
227			$(this).find("> a").toggleClass("submenu-visible");
228			$(this).find("ul.sub-menu").slideToggle(400);
229		}
230	);
231
232	// -----------------------------------------------------------------------------
233	// b2t
234	// -----------------------------------------------------------------------------
235	jQuery(document).ready(function ($) {
236		var offset = 300,
237			offset_opacity = 1200,
238			scroll_top_duration = 700,
239			$back_to_top = $(".cd-top");
240
241		//hide or show the "back to top" link
242		$(window).scroll(function () {
243			$(this).scrollTop() > offset
244				? $back_to_top.addClass("cd-is-visible")
245				: $back_to_top.removeClass("cd-is-visible cd-fade-out");
246			if ($(this).scrollTop() > offset_opacity) {
247				$back_to_top.addClass("cd-fade-out");
248			}
249		});
250
251		//smooth scroll to top
252		$back_to_top.on("click", function (event) {
253			event.preventDefault();
254			$("body,html").animate(
255				{
256					scrollTop: 0,
257				},
258				scroll_top_duration
259			);
260		});
261	});
262
263	// -----------------------------------------------------------------------------
264	// IFRAME RESIZE
265	// -----------------------------------------------------------------------------
266	window.addEventListener("message", function (event) {
267		var frames = document.getElementsByTagName("iframe");
268		for (var i = 0; i < frames.length; i++) {
269			if (frames[i].contentWindow === event.source) {
270				$(frames[i]).height(event.data + 1);
271				break;
272			}
273		}
274	});
275
276	// -----------------------------------------------------------------------------
277	// ACCORDION
278	// -----------------------------------------------------------------------------
279	jQuery(document).ready(function ($) {
280		var accordion_container = $(
281			".accordion > .wp-block-group__inner-container"
282		);
283		var headings = accordion_container.children("h3");
284		var panels = accordion_container.children(".wp-block-group");
285		panels.not(".open").hide();
286
287		headings.click(function () {
288			if ($(this).hasClass("open")) {
289				$(this).removeClass("open");
290				$(this).next().slideUp();
291				$(this).next().removeClass("open");
292			} else {
293				panels.slideUp();
294				panels.removeClass("open");
295				headings.removeClass("open");
296
297				$(this).addClass("open");
298				$(this).next().slideDown();
299				$(this).next().addClass("open");
300			}
301
302			return false;
303		});
304	});
305
306	// -----------------------------------------------------------------------------
307	// CHILD PAGES WIDGET
308	// -----------------------------------------------------------------------------
309	jQuery(document).ready(function ($) {
310		$("select#child_pages").change(function () {
311			location.href = $(this).val();
312		});
313
314		$("nav li.mega-menu").hover(
315			function () {
316				$(this).find(".mega-menu").css("pointer-events", "all");
317			},
318			function () {
319				$(this).find(".mega-menu").css("pointer-events", "none");
320			}
321		);
322	});
323})(jQuery);

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.