PageSourceSearch

https://www.mitsubishielectric-edm.de/wp-content/themes/mitsubishi-electric-theme/js/scripts.js

js mitsubishielectric-edm.de collected 2026-10-08 01:23:03 UTC 20,631 bytes, 592 lines download raw bytes

1(function (jQuery, root, undefined) {
2
3	// Spracherkennung für dynamische Texte (GLOBAL)
4	function getCurrentLanguage() {
5		// Versuche die Sprache aus dem HTML-Tag zu lesen
6		const htmlLang = document.documentElement.lang;
7		if (htmlLang && htmlLang.startsWith('en')) {
8			return 'en';
9		}
10		// Fallback: Deutsch
11		return 'de';
12	}
13
14	// Übersetzungen (GLOBAL)
15	var translations = {
16		de: {
17			closeForm: 'Formular schließen',
18			requestOffer: 'Angebot anfordern',
19			requestConsultation: 'Beratungstermin anfragen'
20		},
21		en: {
22			closeForm: 'Close form',
23			requestOffer: 'Request offer',
24			requestConsultation: 'Request consultation appointment'
25		}
26	};
27
28	// Erkenne den Formular-Modus (GLOBAL)
29	function getFormMode() {
30		const urlParams = new URLSearchParams(window.location.search);
31		return urlParams.get('mode') === 'consultation' ? 'consultation' : 'offer';
32	}
33
34	var currentLang = getCurrentLanguage();
35	var t = translations[currentLang];
36	var formMode = getFormMode();
37
38	jQuery(function () {
39
40		'use strict';
41
42		/* Akkoredon-Effekt */
43
44		var acc = document.getElementsByClassName("accordion");
45				var i;
46
47				for (i = 0; i < acc.length; i++) {
48				  acc[i].addEventListener("click", function() {
49					/* Toggle between adding and removing the "active" class,
50					to highlight the button that controls the panel */
51					this.classList.toggle("active");
52
53					/* Toggle between hiding and showing the active panel */
54					var panel = this.nextElementSibling;
55					if (panel.style.display === "block") {
56					  panel.style.display = "none";
57					} else {
58					  panel.style.display = "block";
59					}
60				  });
61				}
62
63			jQuery('.main-link').click(function() {
64				event.preventDefault();
65				jQuery('.subnav').removeClass('is-open');
66				jQuery(this).parent().find(".subnav").toggleClass('is-open');
67				if (jQuery(this).hasClass("is-active")){
68					jQuery(this).toggleClass("is-active");
69					jQuery(this).parent().find(".subnav").toggleClass('is-open');
70				}
71				else {
72					jQuery('.main-link').removeClass("is-active");
73					jQuery(this).toggleClass("is-active");
74				}
75			});
76
77			jQuery('.close-menu').click(function() {
78				event.preventDefault();
79				jQuery(this).parent().removeClass('is-open');
80				jQuery('.main-link').removeClass("is-active");
81			});
82
83			jQuery('.has-sublist').click(function() {
84				event.preventDefault();
85				if (jQuery(this).hasClass("is-active")){
86					jQuery(this).toggleClass('is-active');
87					jQuery('.sub-list').removeClass('is-open');
88				}
89				else {
90					jQuery('.has-sublist').removeClass('is-active');
91					jQuery(this).toggleClass('is-active');
92					jQuery('.sub-list').removeClass('is-open');
93					jQuery(this).parent().find('.sub-list').toggleClass('is-open');
94				}
95			});
96
97			jQuery("dt").click(function(){
98				jQuery(this).next("dd").slideToggle("fast");
99			});
100
101			jQuery(".mobile-nav-button a").click(function(){
102				event.preventDefault();
103				jQuery(".mainnav").toggleClass("is-mobile");
104				jQuery(".mobile-nav-button").toggleClass("active");
105			});
106
107			jQuery('.back-button').click(function() {
108				event.preventDefault();
109				jQuery(this).closest(".sub-list, .subnav").toggleClass('is-open');
110			});
111
112			jQuery('#filter').submit(function(){
113			var filter = jQuery('#filter');
114			jQuery.ajax({
115				url:filter.attr('action'),
116				data:filter.serialize(), // form data
117				type:filter.attr('method'), // POST
118				beforeSend:function(xhr){
119					filter.find('button').text('Processing...'); // changing the button label
120				},
121				success:function(data){
122					filter.find('button').text('Apply filter'); // changing the button label back
123					jQuery('.profilearticles').html(data); // insert data
124				}
125			});
126		return false;
127	});
128
129		});
130
131		var position = jQuery(window).scrollTop();
132
133		jQuery(window).scroll(function() {
134		    var scroll = jQuery(window).scrollTop();
135		    if(scroll > position && scroll > 500) {
136		        jQuery("header").addClass("ausblenden");
137		    } else {
138		        jQuery("header").removeClass("ausblenden");
139		    }
140		    position = scroll;
141		});
142
143		jQuery(window).scroll(function() {
144			var scroll = jQuery(window).scrollTop();
145
146			 //>=, not <=
147			if (scroll >= 500) {
148				//clearHeader, not clearheader - caps H
149
150			}
151			else if (scroll < 500) {
152
153				}
154		});
155			
156
157		function plzsearch() {
158			let lastPlzLookup = false;
159
160			setInterval(function() {
161				let plz = document.getElementById('zipsearch').value;
162
163				if (lastPlzLookup !== plz) {
164					var lis = document.getElementsByClassName('salesbox');
165
166					for (i = 0; i < lis.length; i++) {
167						if(plz.length >= 1 && plz.length <= 3) {
168							// Remove the line that resets the country selection
169							jQuery('.salesbox').removeAttr("style");
170						}
171						else if (plz.length == 5) {
172							var str = lis[i].innerHTML;
173							var str = str.substring(str.indexOf('plzlist'));                                    
174							let isMatch = new RegExp(''+plz+'', 'i').test(str);
175							if (isMatch === true) {
176								lis[i].classList.add('showme');
177							}
178						}
179						else {
180							lis[i].classList.remove('showme');
181						}
182					}
183				}
184			}, 250)
185		}
186
187
188		jQuery(document).ready(function(){
189			
190			  jQuery('.bio-toggle').on('click', function(e) {
191				e.preventDefault();
192				var referentName = jQuery(this).data('referent');
193				var referentBio = jQuery(this).data('bio');
194
195				jQuery('#modalName').text(referentName);
196				jQuery('#modalBio').html(referentBio);
197
198				jQuery('#bioModal').addClass('active');
199				jQuery('body').addClass('modal-open');
200			});
201
202			jQuery('.close-modal').on('click', function() {
203				closeModal();
204			});
205
206			jQuery('#bioModal').on('click', function(e) {
207				if (e.target === this) {
208					closeModal();
209				}
210			});
211
212			jQuery(document).keydown(function(e) {
213				if (e.key === "Escape" && jQuery('#bioModal').hasClass('active')) {
214					closeModal();
215				}
216			});
217
218			function closeModal() {
219				jQuery('#bioModal').removeClass('active');
220				jQuery('body').removeClass('modal-open');
221			}
222
223
224			setTimeout(function(){
225
226			jQuery('.grid').masonry({
227			  itemSelector: '.grid-item',
228				columnWidth: '.grid-sizer',
229				gutter:10,
230				percentPosition: true
231			});
232
233			},0);
234
235			tabhoehe = jQuery('.tab-content').height();
236			jQuery('ul.tabs').css('height',tabhoehe);
237
238			jQuery( "#zipsearch" ).focus(function() {
239		  	plzsearch();
240			});
241
242			jQuery('.tabs label').click(function() {
243				var tabhoehe = jQuery(this).closest('li').find('.tab-content').height();
244				jQuery('ul.tabs').css('height',tabhoehe);
245			});
246			
247			jQuery('.dataprotection').click(function() {
248				event.preventDefault();
249				UC_UI.showSecondLayer();
250			});
251
252			jQuery('.gs18-HeaderLang__Lang-Current').click(function() {
253				event.preventDefault();
254				jQuery('.gs18-HeaderLang').toggleClass('is-open');
255			});
256
257			jQuery('#countries').change(function() {
258				jQuery('.salesbox').removeAttr("style");
259				jQuery('#zipsearch').val("");
260				var country = jQuery(this).val();
261
262				if (country === "germany" || country === "deutschland") {
263					jQuery('.zipcode').css('display', 'block');
264				} else {
265					jQuery('.zipcode').css('display', 'none');
266
267					jQuery('.salesbox').each(function() {
268						var countriesList = jQuery(this).find('.countrysel');
269						var countryText = countriesList.text().toLowerCase(); // Convert text to lowercase for case-insensitive comparison
270						var countryListArray = countryText.split(',').map(function(country) {
271							return country.trim();
272						});
273
274						// Check if the country name exists in the list of countries
275						if (countryListArray.includes(country.toLowerCase())) {
276							jQuery(this).css('display', 'block');
277						} else {
278							jQuery(this).css('display', 'none');
279						}
280					});
281				}
282			});
283
284			jQuery('.countryselect').find('select').change(function() {
285				country = jQuery(this).val();
286				if((country == "germany") || (country == "deutschland")) {
287					jQuery('.zipger').css('display','block');
288				}
289				else {
290					jQuery('.zipger').css('display','none');
291				}
292			});
293
294
295			// Alte Routine
296			//jQuery('#countries').change(function() {
297			//	 country = jQuery(this).val();
298			//	 jQuery('#zipsearch').val("");
299			//	 jQuery('.fedstate').removeAttr("style");
300			//	 jQuery('.salesbox').removeAttr("style");
301			//	 jQuery('li.salesbox:contains('+country+')').css('display','block');
302			//});
303
304			jQuery('section.contents').has('div.highlight').css('padding-bottom', '0');
305
306			// Der Button wird mit JavaScript erzeugt und vor dem Ende des body eingebunden.
307			var back_to_top_button = ['<a href="#top" class="back-to-top" title="Scroll to the Top"></a>'].join("");
308			jQuery("body").append(back_to_top_button)
309
310			// Der Button wird ausgeblendet
311			jQuery(".back-to-top").hide();
312
313			// Funktion für das Scroll-Verhalten
314			jQuery(function () {
315				jQuery(window).scroll(function () {
316					if (jQuery(this).scrollTop() > 100) { // Wenn 100 Pixel gescrollt wurde
317						jQuery('.back-to-top').fadeIn();
318					} else {
319						jQuery('.back-to-top').fadeOut();
320					}
321				});
322
323			});
324
325			jQuery('.fedstate').click(function() {
326				 event.preventDefault();
327				 jQuery('#countries').prop('selectedIndex',0);
328				 var state = jQuery(this).text();
329				 jQuery('#zipsearch').val("");
330				 jQuery('.fedstate').removeAttr("style");
331				 jQuery('.salesbox').removeAttr("style");
332				 jQuery(this).css('background','red');
333				 jQuery(this).css('color','white');
334				 jQuery('li.salesbox:contains('+state+')').css('display','block');
335			 });
336
337 		jQuery('#contact-button').click(function() {
338					jQuery('#direct-contact').toggleClass('einblenden');
339					jQuery('#contact-button').toggleClass('contact-black');
340			});
341
342			jQuery('.load-more-items').click(function() {
343				  event.preventDefault();
344					jQuery(this).parent().find('.grid-item').toggleClass('threeplus');
345					jQuery('.grid').masonry('layout');
346					jQuery('html, body').animate({
347					  scrollTop: jQuery(this).closest(".block-wrapper").offset().top -100
348					});
349					jQuery(this).text(function(_,txt) {
350			        var ret='';
351			        if ( txt == translation.more_features ) {
352			           ret = translation.more_features;
353			        }else{
354			           ret = translation.less_features;
355			        }
356			        return ret;
357			    });
358			    return false;
359			});
360
361			 jQuery(window).scroll(function(){
362				 jQuery('#direct-contact').removeClass('einblenden');
363				 jQuery('#contact-button').addClass('contact-black');
364			 });
365
366			 jQuery('.quick-navigation').on('click', 'li', function() {
367		    jQuery(this).toggleClass('active');
368		});
369
370
371			var pro = '';
372	    // Iterate through the DIV and read its contents.
373	    jQuery('.contents h2').each(function (i,e) {
374					if(jQuery(e).attr('id')){
375		        pro = jQuery(this).text();
376						protrim = pro.replace(/[^a-z0-9+]+/gi, '');
377						jQuery('#autosubnav').append('<option value="' +  protrim + '">' + pro + '</option>');
378					}
379	    });
380
381
382			jQuery('#autosubnav').on('change', function(){
383				var selectedId = this.value;
384				jQuery('html, body').animate({
385						scrollTop: jQuery("#" + selectedId + "").offset().top
386				}, 500);
387			});
388
389            // UNIVERSELLE WORKSHOP & FAQ ACCORDION LÖSUNG
390            // Objekt zum Speichern der ursprünglichen Button-Texte
391            const originalButtonTexts = {};
392            
393            // Speichere die ursprünglichen Texte beim Laden der Seite
394            jQuery('.workshop-header').each(function() {
395                const workshopId = this.getAttribute('aria-controls');
396                if (workshopId) {
397                    const workshopNumber = workshopId.replace('workshop-content-', '');
398                    const bookingText = document.getElementById('booking-text-' + workshopNumber);
399                    if (bookingText) {
400                        originalButtonTexts[workshopNumber] = bookingText.textContent.trim();
401                    }
402                }
403            });
404            
405            // WICHTIG: Entferne alle bestehenden Click-Handler für Workshop-Headers und FAQ
406            jQuery('.workshop-header, .faq-question').off('click');
407            
408            // Workshop Accordion Click Handler
409            jQuery('.workshop-header').on('click', function(e) {
410                e.preventDefault();
411
412                const clickedHeader = this;
413                const workshopId = clickedHeader.getAttribute('aria-controls');
414                const workshopNumber = workshopId.replace('workshop-content-', '');
415                const content = document.getElementById(workshopId);
416                const bookingText = document.getElementById('booking-text-' + workshopNumber);
417
418                if (!content) return;
419                
420                // Aktueller Status des Panels
421                const isCurrentlyExpanded = clickedHeader.getAttribute('aria-expanded') === 'true';
422                
423                // Schließe alle anderen Workshop-Panels und setze ihre Buttons zurück
424                jQuery('.workshop-header').each(function() {
425                    if (this !== clickedHeader) {
426                        const otherWorkshopId = this.getAttribute('aria-controls');
427                        const otherContent = document.getElementById(otherWorkshopId);
428                        const otherNumber = otherWorkshopId.replace('workshop-content-', '');
429                        const otherBookingText = document.getElementById('booking-text-' + otherNumber);
430                        
431                        // Schließe andere Panels
432                        this.setAttribute('aria-expanded', 'false');
433                        if (otherContent) {
434                            otherContent.hidden = true;
435                        }
436                        
437                        // Setze andere Button-Texte zurück (nur wenn Button existiert)
438                        if (otherBookingText && originalButtonTexts[otherNumber]) {
439                            otherBookingText.textContent = originalButtonTexts[otherNumber];
440                        }
441                    }
442                });
443                
444                // Toggle des aktuellen Panels
445                if (isCurrentlyExpanded) {
446                    // Panel schließen
447                    clickedHeader.setAttribute('aria-expanded', 'false');
448                    content.hidden = true;
449                    // Button-Text zurücksetzen (nur wenn Button existiert)
450                    if (bookingText) {
451                        // Verwende den richtigen Text basierend auf dem Modus
452                        const closedText = formMode === 'consultation' ? t.requestConsultation : t.requestOffer;
453                        bookingText.textContent = closedText;
454                    }
455                } else {
456                    // Panel öffnen
457                    clickedHeader.setAttribute('aria-expanded', 'true');
458                    content.hidden = false;
459                    // Button-Text ändern (nur wenn Button existiert)
460                    if (bookingText) {
461                        bookingText.textContent = t.closeForm;
462                    }
463                }
464            });
465            
466            // FAQ Accordion Click Handler (falls vorhanden)
467            jQuery('.faq-question').on('click', function(e) {
468                e.preventDefault();
469                
470                const clickedQuestion = this;
471                const contentId = clickedQuestion.getAttribute('aria-controls');
472                const content = document.getElementById(contentId);
473                
474                if (!content) return;
475                
476                const isCurrentlyExpanded = clickedQuestion.getAttribute('aria-expanded') === 'true';
477                
478                // Schließe alle anderen FAQ-Panels
479                jQuery('.faq-question').each(function() {
480                    if (this !== clickedQuestion) {
481                        const otherContentId = this.getAttribute('aria-controls');
482                        const otherContent = document.getElementById(otherContentId);
483                        
484                        this.setAttribute('aria-expanded', 'false');
485                        if (otherContent) {
486                            otherContent.hidden = true;
487                        }
488                    }
489                });
490                
491                // Toggle des aktuellen Panels
492                if (isCurrentlyExpanded) {
493                    clickedQuestion.setAttribute('aria-expanded', 'false');
494                    content.hidden = true;
495                } else {
496                    clickedQuestion.setAttribute('aria-expanded', 'true');
497                    content.hidden = false;
498                }
499            });
500            
501            // Fallback: Stelle sicher, dass alle Panels initial geschlossen sind
502            jQuery('.workshop-header, .faq-question').each(function() {
503                const contentId = this.getAttribute('aria-controls');
504                const content = document.getElementById(contentId);
505                
506                this.setAttribute('aria-expanded', 'false');
507                if (content) {
508                    content.hidden = true;
509                }
510            });
511            
512            // Optional: Globale Funktion zum Zurücksetzen aller Button-Texte
513            window.resetWorkshopButtonTexts = function() {
514                Object.keys(originalButtonTexts).forEach(workshopNumber => {
515                    const bookingText = document.getElementById('booking-text-' + workshopNumber);
516                    if (bookingText) {
517                        bookingText.textContent = originalButtonTexts[workshopNumber];
518                    }
519                });
520            };
521
522		// LEGACY SUPPORT: Falls alte Templates noch den alten Accordion-Code aufrufen
523		// Diese Funktionen fangen alte Aufrufe ab und leiten sie an das neue System weiter
524		window.swissToggleAccordion = function(element, otherSelectors) {
525			// Trigger click event auf dem neuen System
526			jQuery(element).trigger('click');
527		};
528
529		window.toggleAccordion = function(element, otherSelectors) {
530			// Trigger click event auf dem neuen System  
531			jQuery(element).trigger('click');
532		};
533
534	});
535
536	// YouTube Video Loader mit Cookie-Consent
537	// Wird aufgerufen, wenn der User YouTube-Cookies akzeptiert
538	window.loadYouTubeVideo = function() {
539		var placeholder = document.querySelector('.youTubeUrl');
540		if (!placeholder) return;
541
542		var videoUrl = placeholder.getAttribute('data-url');
543		if (!videoUrl) return;
544
545		// Erstelle iframe mit korrekten Permissions
546		var iframe = document.createElement('iframe');
547		iframe.className = 'responsive-iframe';
548		iframe.src = videoUrl;
549		iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
550		iframe.setAttribute('frameborder', '0');
551		iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen');
552		iframe.setAttribute('allowfullscreen', '');
553		iframe.style.width = '100%';
554		iframe.style.height = '100%';
555		iframe.style.aspectRatio = '16 / 9';
556
557		// Ersetze den Placeholder mit dem iframe
558		placeholder.innerHTML = '';
559		placeholder.appendChild(iframe);
560	};
561
562	// Override UC_UI.acceptService für YouTube
563	if (typeof UC_UI !== 'undefined') {
564		var originalAcceptService = UC_UI.acceptService;
565		UC_UI.acceptService = function(serviceId) {
566			// Rufe die Original-Funktion auf
567			if (originalAcceptService) {
568				originalAcceptService.call(this, serviceId);
569			}
570			// Lade YouTube-Video, wenn YouTube-Service akzeptiert wurde
571			if (serviceId === 'BJz7qNsdj-7') {
572				setTimeout(function() {
573					loadYouTubeVideo();
574				}, 100);
575			}
576		};
577	}
578
579	// Prüfe beim Laden, ob YouTube bereits akzeptiert wurde
580	jQuery(document).ready(function() {
581		// Warte kurz, bis UC_UI vollständig geladen ist
582		setTimeout(function() {
583			if (typeof UC_UI !== 'undefined' && UC_UI.getServicesBaseInfo) {
584				var services = UC_UI.getServicesBaseInfo();
585				if (services && services['BJz7qNsdj-7'] && services['BJz7qNsdj-7'].consent) {
586					loadYouTubeVideo();
587				}
588			}
589		}, 1000);
590	});
591
592})(jQuery, this);

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.