PageSourceSearch

https://www.toshiba.eu/wp-content/themes/savior-pro/assets/js/savior-pro-scripts.js?ver=1790854262

js toshiba.eu collected 2026-10-01 11:31:59 UTC 12,562 bytes, 389 lines download raw bytes

1/*
2Javascript Name: Savior Pro Scripts
3Author: Savior Admin
4Tags: Tabs, Accordion
5Version: 1.1
6*/
7jQuery(document).ready(function($) {
8	
9	/** ❌ Pages where this script should NOT run **/
10    const excludedPages = [
11        'page-id-4712',
12//         'page-id-1234'
13    ];
14
15    if (excludedPages.some(cls => $('body').hasClass(cls))) {
16        return;
17	}
18	
19	/** Removing text from page title **/
20	if ($('body').hasClass('post-type-archive-insights') || $('body').hasClass('post-type-archive-newsroom')) {
21		var pageTitle = $(document).attr('title');
22		$(document).attr('title', pageTitle.replace('Archive', '').trim());
23	}
24
25	/** External Modal **/
26	$('a[target="_blank"]').addClass('confirm-link').on('click', function (event) {
27
28		const excludedUrls = [
29			'https://www.toshiba.de/',
30			'https://www.toshiba.fr/',
31			'https://www.toshiba.es/'
32		];
33
34		const popupIds = ['2787', '2885', '2630', '2695', '2866', '2827', '2856', '2759'];
35		const currentUrl = window.location.href;
36
37		if (excludedUrls.includes(currentUrl)) {
38			return;
39		}
40
41		event.preventDefault();
42
43		const link = $(this).attr('href');
44
45		showMultiplePopups(popupIds);
46
47		$('#btn-continue a').attr('href', link);
48	});
49
50	function showMultiplePopups(popupIds) {
51		popupIds.forEach(id => {
52			if (id) {
53				elementorProFrontend.modules.popup.showPopup({ id });
54			}
55		});
56	}
57
58	/** OK Button – open link + delayed close */
59	$(document).on('click', '#btn-continue a', function (event) {
60		event.preventDefault();
61
62		const href = $(this).attr('href');
63
64		window.open(href, '_blank');
65
66		// Small delay before closing popup(s)
67		setTimeout(function () {
68			elementorProFrontend.modules.popup.closePopup({}, event);
69		}, 500);
70	});
71
72	/** Close Button – immediate close, no "#" */
73	$(document).on('click', '.em-red .elementor-button', function (event) {
74		event.preventDefault();
75		elementorProFrontend.modules.popup.closePopup({}, event);
76	});
77
78	// Add text after the dropdown
79	/**var dropdown = jQuery("#site-dropdown");
80	setTimeout(function() {
81		jQuery("#loader-text").remove();
82		dropdown.show();
83		var selectedValue = dropdown.find('option[selected]').val();
84		if (selectedValue) {
85			dropdown.val(selectedValue);
86		} else {
87			dropdown.prop('selectedIndex', 0);
88		}
89	});**/
90
91	/** Changing 404 page breadcrumb text **/
92	var breadcrumbItem = $('.error404 .ppbread.elementor-widget-pp-breadcrumbs ul.pp-breadcrumbs li.pp-breadcrumbs-item.pp-breadcrumbs-item-current');
93
94	if (breadcrumbItem.length && breadcrumbItem.text().trim() === "Error 404") {
95		breadcrumbItem.text("Page not found");
96	}
97
98	/** Mobile menu **/
99	var $menuContainer = $('.main-header .ha-wid-con .ha-menu-container');
100	var $menuHamburger = $('.main-header .ha-wid-con .ha-menu-hamburger');
101
102	function toggleMenuClasses() {
103		$menuHamburger.toggleClass('btnActive', $menuContainer.hasClass('active'));
104	}
105
106	$menuHamburger.on('click', function() {
107		setTimeout(toggleMenuClasses, 10);
108	});
109
110	$(document).on('click', function(e) {
111		if (!$menuContainer.is(e.target) && !$menuContainer.has(e.target).length &&
112			!$menuHamburger.is(e.target) && !$menuHamburger.has(e.target).length) {
113			$menuContainer.removeClass('active');
114			$menuHamburger.removeClass('btnActive');
115		}
116	});
117
118	/** Accounts tabs **/
119	if ($('.tab-headings li').length) {
120		$('.tab-headings li').click(function(event) {
121			event.preventDefault(); 
122
123			var tab_id = $(this).data('tab');
124			if (typeof tab_id !== 'undefined' && tab_id !== '') {
125				$('.tab-headings li').removeClass('active');
126				$('.tab-content').removeClass('active').css('display', 'none');
127				$(this).addClass('active');
128				$('#' + tab_id).addClass('active').css('display', 'block');
129			}
130		});
131	}
132
133	/** Accordion functionality **/
134	if ($('.accordion .accordion-button').length) {
135		$('.accordion .accordion-button').click(function() {
136			var $this = $(this);
137			var $accordionItem = $this.closest('.accordion-item');
138			var $collapse = $accordionItem.find('.accordion-collapse');
139
140			if ($accordionItem.hasClass('active')) {
141				$collapse.removeClass('show').css('max-height', 0);
142				$accordionItem.removeClass('active');
143				$this.attr('aria-expanded', 'false');
144			} else {
145				$('.accordion .accordion-item').removeClass('active');
146				$('.accordion .accordion-collapse').removeClass('show').css('max-height', 0);
147
148				$accordionItem.addClass('active');
149
150				var contentHeight = $collapse[0].scrollHeight;
151				$collapse.addClass('show').css('max-height', contentHeight + 'px');
152				$this.attr('aria-expanded', 'true');
153			}
154		});
155
156		// Open the first accordion item by default
157		var $firstAccordionItem = $('.accordion .accordion-item:first');
158		$firstAccordionItem.addClass('active');
159
160		var firstContentHeight = $firstAccordionItem.find('.accordion-collapse')[0].scrollHeight;
161		$firstAccordionItem.find('.accordion-collapse').addClass('show').css('max-height', firstContentHeight + 'px');
162		$firstAccordionItem.find('.accordion-button').attr('aria-expanded', 'true');
163	}
164
165	// Current Menu item should not clickable
166	$('.menu-item.current-menu-item a').on('click', function(e) {
167		e.preventDefault(); // Disable the link
168		$(this).css('cursor', 'default'); // Change cursor to default
169	});
170	if ($('body').hasClass('home')) {
171		$('.main-logo a').on('click', function(e) {
172			e.preventDefault(); // Disable the link
173			$(this).css('cursor', 'default'); // Change cursor to default
174		});
175	}
176
177	/** Equalize heights of headings **/
178	function equalizeCardHeadings() {
179		var $headings = $(".clip-post.elementor-widget-pp-posts .pp-posts-grid .elementor-grid-item .pp-grid-item .clip-card .card-body .top-row .card-head.elementor-widget-heading .elementor-heading-title");
180		if ($headings.length === 0) {
181			return;
182		}
183		$headings.css("min-height", "");
184		if ($(window).width() > 768) {
185			var maxHeight = 0;
186			// Calculate the maximum height
187			$headings.each(function () {
188				var thisHeight = $(this).outerHeight();
189				if (thisHeight > maxHeight) {
190					maxHeight = thisHeight;
191				}
192			});
193			$headings.css("min-height", maxHeight + "px");
194		}
195	}
196	$(window).on("load resize", function () {
197		equalizeCardHeadings();
198	});
199});
200
201/** Ethics card text dynamic height **/
202function equalizeCardTextHeight() {
203	const cards = document.querySelectorAll('.ec-cards .ec-card-group .ec-card .esbox-content .card-txt.elementor-widget-text-editor');
204	cards.forEach(card => card.style.minHeight = '');
205	if (window.innerWidth > 768) {
206		let maxHeight = 0;
207		cards.forEach(card => {
208			const height = card.offsetHeight;
209			if (height > maxHeight) {
210				maxHeight = height;
211			}
212		});
213
214		cards.forEach(card => card.style.minHeight = `${maxHeight}px`);
215	}
216}
217window.addEventListener('load', equalizeCardTextHeight);
218window.addEventListener('resize', equalizeCardTextHeight);
219
220
221document.addEventListener('DOMContentLoaded', function() {
222	// Select all menu toggle links that open submenus
223	const menuToggles = document.querySelectorAll('a.menu-link');
224
225	menuToggles.forEach(toggle => {
226		// Add 'focus-hover' class to parent <li> on focus
227		toggle.addEventListener('focus', function() {
228			const parentLi = toggle.closest('li');
229			parentLi.classList.add('focus-hover');
230		});
231
232		// Remove 'focus-hover' class when focus leaves the menu item or submenu
233		toggle.addEventListener('blur', function() {
234			const parentLi = toggle.closest('li');
235			setTimeout(() => {
236				if (!parentLi.contains(document.activeElement)) {
237					parentLi.classList.remove('focus-hover');
238				}
239			}, 10);
240		});
241
242		// Handle 'Enter' key to open the submenu or follow the link directly
243		toggle.addEventListener('keydown', function(event) {
244			console.log(event);
245			if (event.key === 'Enter') {
246				event.preventDefault();
247				const parentLi = toggle.closest('li');
248				const firstSubmenuItem = parentLi.querySelector('.ha-dropdown a');
249				toggle.click();
250				if (firstSubmenuItem) {
251					// If submenu exists, open it and focus the first item
252					parentLi.classList.add('focus-hover');
253					firstSubmenuItem.focus();
254				} else {
255					// If no submenu, simulate a click to follow the link
256					toggle.click();
257				}
258			}
259		});
260	});
261
262	// Handle focus within the submenu
263	const subMenus = document.querySelectorAll('.ha-dropdown');
264	subMenus.forEach(subMenu => {
265		const parentLi = subMenu.closest('li');
266
267		// Close the submenu if focus moves outside it
268		subMenu.addEventListener('focusout', function() {
269			setTimeout(() => {
270				if (!parentLi.contains(document.activeElement)) {
271					parentLi.classList.remove('focus-hover');
272				}
273			}, 10);
274		});
275	});
276});
277
278/** Navigate video with keyboard **/
279document.addEventListener('DOMContentLoaded', () => {
280	const playButton = document.querySelector('.pp-video-play');
281	const playIcon = document.querySelector('.pp-video-play-icon');
282
283	if (playButton && playIcon) {
284		[playButton, playIcon].forEach(element => {
285			element.setAttribute('tabindex', '0');
286			element.setAttribute('role', 'button');
287			element.setAttribute('aria-label', 'Play/Pause Video');
288			element.addEventListener('focus', () => element.style.outline = '1px solid #000');
289			element.addEventListener('blur', () => element.style.outline = 'none');
290		});
291
292		playIcon.addEventListener('keydown', event => {
293			if (event.key === 'Enter') playIcon.click(); // Trigger play/pause on Enter
294		});
295	}
296});
297
298// Languages Switcher
299const menu = document.querySelector(".main-header .select-menu");
300const [selectBtn, sBtnText] = [menu.querySelector(".select-btn"), menu.querySelector(".sBtn-text")];
301
302sBtnText.addEventListener('focus', () => menu.classList.add('active-focus'));
303
304selectBtn.addEventListener("click", (e) => {
305	e.stopPropagation();
306	menu.classList.toggle("active");
307	menu.classList.remove("active-focus");
308});
309
310menu.querySelectorAll(".option").forEach(option => option.onclick = () => {
311	sBtnText.innerText = option.querySelector(".option-text").innerText;
312	menu.classList.remove("active", "active-focus");
313});
314
315menu.addEventListener('focusout', (e) => {
316	if (!menu.contains(e.relatedTarget)) menu.classList.remove("active-focus");
317});
318
319document.addEventListener('click', (e) => {
320	if (!menu.contains(e.target)) menu.classList.remove("active", "active-focus");
321});
322
323/**
324 * Protecting email addresses on Toshiba Websites
325 */
326document.addEventListener("DOMContentLoaded", function () {
327	// Basic email regex (can be adjusted for stricter rules)
328	const emailRegex = /([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g;
329	// Recursively scan the DOM
330	function protectEmails(node) {
331		if (!node || node.nodeType !== 1) return; // Only element nodes
332		Array.from(node.childNodes).forEach(child => {
333			if (child.nodeType === 3) {
334				const originalText = child.textContent;
335				const matches = [...originalText.matchAll(emailRegex)];
336				if (matches.length > 0) {
337					const span = document.createElement("span");
338					let lastIndex = 0;
339					matches.forEach(match => {
340						const [fullMatch, user, domain] = match;
341						const startIndex = match.index;
342						// Add text before the match
343						if (startIndex > lastIndex) {
344							span.appendChild(document.createTextNode(originalText.slice(lastIndex, startIndex)));
345						}
346						// Add placeholder span to be filled via JS
347						const placeholder = document.createElement("span");
348						placeholder.className = "js-protected-email";
349						placeholder.dataset.user = user;
350						placeholder.dataset.domain = domain;
351						placeholder.textContent = ""; // Hide actual email immediately
352						span.appendChild(placeholder);
353						lastIndex = startIndex + fullMatch.length;
354					});
355					// Add any remaining text
356					if (lastIndex < originalText.length) {
357						span.appendChild(document.createTextNode(originalText.slice(lastIndex)));
358					}
359					// Replace the original text node
360					child.parentNode.replaceChild(span, child);
361				}
362			} else if (child.nodeType === 1) {
363				protectEmails(child); // Recursively check children
364			}
365		});
366	}
367	// Run on body or specific container
368	protectEmails(document.body);
369	// Restore the real emails after short delay
370	setTimeout(() => {
371		document.querySelectorAll('.js-protected-email').forEach(el => {
372			const user = el.dataset.user;
373			const domain = el.dataset.domain;
374			const email = `${user}@${domain}`;
375			const a = document.createElement('a');
376			a.href = `mailto:${email}`;
377			a.textContent = email;
378			el.replaceWith(a);
379		});
380	}, 200); // Adjust delay as needed
381});
382
383/** Current year for Copyright text -- Footer **/
384document.addEventListener('DOMContentLoaded', function () {
385	const year = new Date().getFullYear();
386	document.querySelectorAll('.current-year').forEach(el => {
387		el.textContent = year;
388	});
389});

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.