PageSourceSearch

https://ipi.media/wp-content/themes/ipi-theme/assets/js/theme.js?ver=202505041042

js ipi.media collected 2026-09-24 07:04:25 UTC 7,013 bytes, 227 lines download raw bytes

1/*--------------------------------------------------------------
2Theme JS
3--------------------------------------------------------------*/
4
5jQuery(function ($) {
6  // Close offcanvas on click a, keep .dropdown-menu open (see https://github.com/bootscore/bootscore/discussions/347)
7  $('.offcanvas a:not(.dropdown-toggle, .remove_from_cart_button)').on('click', function () {
8    $('.offcanvas').offcanvas('hide');
9  });
10
11  // Searchform focus
12  $('#collapse-search').on('shown.bs.collapse', function () {
13    $('.top-nav-search input:first-of-type').trigger('focus');
14  });
15
16  // Close collapse if click outside searchform
17  $(document).on('click', function (event) {
18    if ($(event.target).closest('#collapse-search').length === 0) {
19      $('#collapse-search').collapse('hide');
20    }
21  });
22
23  // Scroll to top Button
24  $(window).on('scroll', function () {
25    var scroll = $(window).scrollTop();
26
27    if (scroll >= 500) {
28      $('.top-button').addClass('visible');
29    } else {
30      $('.top-button').removeClass('visible');
31    }
32  });
33
34  // div height, add class to your content
35  $('.height-50').css('height', 0.5 * $(window).height());
36  $('.height-75').css('height', 0.75 * $(window).height());
37  $('.height-85').css('height', 0.85 * $(window).height());
38  $('.height-100').css('height', 1.0 * $(window).height());
39
40
41	// Menu behaviour on scroll
42	$(document).ready(function() {
43		var lastScrollTop = 0; // Variable to store the last scroll position
44		
45		$(window).scroll(function() {
46			var currentScroll = $(this).scrollTop(); // Get the current scroll position
47			
48			// When scrolling down, and scroll position is greater than 300px, add the class
49			if (currentScroll > 300) {
50				$('#masthead').addClass('scrolled shadow');
51			} else {
52				$('#masthead').removeClass('scrolled shadow');
53			}
54			
55			// Remove class when scrolling up (only if it was previously added)
56			if (currentScroll < lastScrollTop) {
57				$('#masthead').removeClass('scrolled');
58			}
59	
60			// Update lastScrollTop to current position for next scroll event
61			lastScrollTop = currentScroll;
62		});
63
64	});
65
66	// Smooth scrolling for anchor links
67	// $(document).ready(function() {
68
69	// 	$('a[href^="#"]').on('click', function(e) {
70	// 		e.preventDefault();  // Prevent default anchor click behavior
71
72	// 		var target = $(this.getAttribute('href'));
73	// 		var targetOffset = target.offset().top;
74	// 		var navbarHeight = 150; // Adjust this value to match the height of your navigation bar
75
76	// 		// Animate the scroll, accounting for the navbar height
77	// 		$('html, body').animate({
78	// 			scrollTop: targetOffset - navbarHeight
79	// 		}, 300);  // Duration of the smooth scroll (in ms)
80	// 	});
81
82	// });
83		
84}( jQuery ) );
85
86
87
88/*!
89 * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
90 * Copyright 2011-2024 The Bootstrap Authors
91 * Licensed under the Creative Commons Attribution 3.0 Unported License.
92 */
93
94function darkMode() {
95
96		'use strict'
97
98		const getStoredTheme = () => localStorage.getItem('theme')
99		const setStoredTheme = theme => localStorage.setItem('theme', theme)
100
101		const getPreferredTheme = () => {
102			const storedTheme = getStoredTheme()
103			if (storedTheme) {
104				return storedTheme
105			}
106
107			return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
108		}
109
110		const setTheme = theme => {
111			if (theme === 'auto') {
112				document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
113			} else {
114				document.documentElement.setAttribute('data-bs-theme', theme)
115			}
116		}
117
118		setTheme(getPreferredTheme())
119
120		const showActiveTheme = (theme, focus = false) => {
121			const themeSwitcher = document.querySelector('#bd-theme')
122
123			if (!themeSwitcher) {
124				return
125			}
126
127			const themeSwitcherText = document.querySelector('#bd-theme-text')
128			//const activeThemeIcon = document.querySelector('.theme-icon-active use')
129			const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
130			//const svgOfActiveBtn = btnToActive.querySelector('svg use').getAttribute('href')
131
132			document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
133				element.classList.remove('active')
134				element.setAttribute('aria-pressed', 'false')
135			})
136
137			btnToActive.classList.add('active')
138			btnToActive.setAttribute('aria-pressed', 'true')
139			//activeThemeIcon.setAttribute('href', svgOfActiveBtn)
140			const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`
141			themeSwitcher.setAttribute('aria-label', themeSwitcherLabel)
142
143			if (focus) {
144				themeSwitcher.focus()
145			}
146		}
147
148		window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
149			const storedTheme = getStoredTheme()
150			if (storedTheme !== 'light' && storedTheme !== 'dark') {
151				setTheme(getPreferredTheme())
152			}
153		})
154
155		window.addEventListener('DOMContentLoaded', () => {
156			showActiveTheme(getPreferredTheme())
157
158			document.querySelectorAll('[data-bs-theme-value]')
159				.forEach(toggle => {
160					toggle.addEventListener('click', () => {
161						const theme = toggle.getAttribute('data-bs-theme-value')
162						setStoredTheme(theme)
163						setTheme(theme)
164						showActiveTheme(theme, true)
165					})
166				})
167		})
168	};
169//darkMode();
170
171
172document.addEventListener('DOMContentLoaded', function () {
173// Select all the parent dropdowns (with class 'dropdown')
174const dropdowns = document.querySelectorAll('.dropdown');
175
176	dropdowns.forEach(function (dropdown) {  
177		// Stop propagation for any child/grandchild item click
178		const submenus = dropdown.querySelectorAll('.dropdown-menu');
179		submenus.forEach(function (submenu) {
180		submenu.addEventListener('click', function (event) {
181			event.stopPropagation();  // Prevent the click from closing the parent dropdown
182		});
183		});
184	});
185
186});
187
188  
189
190
191
192// Social icons
193document.addEventListener('DOMContentLoaded', function() {
194	const nativeShareButton = document.getElementById('native-share-btn');
195	const desktopShareButtons = document.getElementById('html-share');
196
197	// Return if no share buttons
198	if (!nativeShareButton && !desktopShareButtons) {
199		return;
200	}
201
202	// Check if Web Share API is supported and is mobile screen
203	if (navigator.share && window.matchMedia('(max-width: 767px)').matches) {
204		// Web Share API is supported on mobile
205		// Display native share button
206		nativeShareButton.style.display = 'flex';
207		desktopShareButtons.style.display = 'none';
208
209		nativeShareButton.addEventListener('click', () => {
210			const title = nativeShareButton.getAttribute('data-title');
211			const text = nativeShareButton.getAttribute('data-text');
212			const url = nativeShareButton.getAttribute('data-url');
213
214			navigator.share({
215				title: title,
216				text: text,
217				url: url,
218			})
219			.then(() => console.log('Successfully shared'))
220			.catch((error) => console.error('Error sharing:', error));
221		});
222	} else {
223		// Fallback for desktop or unsupported browsers
224		// Display desktop share buttons
225		desktopShareButtons.style.display = 'block';
226	}
227});

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.