// JavaScript Document var homePage = 'https://www2.sprayfo.com/de/home'; var url = window.location.href; var screen_mode = ''; // media listener $( window ).resize(function() { if ($('.sf-intro').width() <= 766 ){ window.screen_mode = 'mobile'; mobileMode() moveLogoMobile(); } else { window.screen_mode = 'desktop'; desktopMode(); moveLogoDesktop(); } }); $(document).ready(function() { if ($('.sf-intro').width() <= 766 ){ window.screen_mode = 'mobile'; mobileMode() moveLogoMobile(); } else { window.screen_mode = 'desktop'; desktopMode(); moveLogoDesktop(); } }); function mobileMode() { // var wH = $(window).height(); // var bH = $('.sf-hamburger-wrapper').height(); // var mH = wH - bH; // $('.sf-menu-l1').height(wH); // $('.sf-intro-swirl').css('bottom',$('.sf-intro-swirl').height()); // $('.sf-intro').height($('.sf-intro-image').height() + $('.sf-intro-category-title').height() + $('.sf-intro-title').height() + 10); $('.sf-menu-wrapper').find('a[class*="sf-menu-l1-link"]').each(function(index) { if (url.indexOf($(this)[0].href) >= 0) { $(this).addClass('sf-menu-l1-active-link'); var childNodes = $(this).next().children('.sf-menu-l2-item').children('.sf-menu-l2-link'); if (childNodes.length > 0) { $(this).next().addClass('sf-menu-l2-show'); } } }); } function desktopMode() { if (url.indexOf('referrer=studio') <= 0) { var genHTML = function(node) { var ihtml = ''; node.each(function(index, element) { ihtml += ''+ $.trim($(this)[0].innerText) +''; if (index < (node.length - 1)) { ihtml += '
'; } }); return ihtml; }; var genHTML2 = function(node) { var ihtml = ''; node.each(function(index, element) { ihtml += ''+ $.trim($(this)[0].innerText) +''; if (index < (node.length - 1)) { ihtml += '
'; } }); return ihtml; }; $('.sf-breadcrumb-l2').css('visibility','hidden'); $('.sf-breadcrumb-l3').css('visibility','hidden'); var crumbPathHTML = ""; var crumbPathHTML2 = ""; /* if (url === homePage) { $('.sf-breadcrumb-l2').css('visibility','hidden'); $('.sf-breadcrumb-l3').css('visibility','hidden'); } else { var crumbPathHTML = ""; var crumbPathHTML2 = ""; }*/ $('.sf-menu-wrapper').find('a[class*="sf-menu-l1-link"]').each(function(index) { if (url.indexOf($(this)[0].href) >= 0) { $(this).addClass('sf-menu-l1-active-link'); var childNodes = $(this).next().children('.sf-menu-l2-item').children('.sf-menu-l2-link'); if (childNodes.length > 0) { crumbPathHTML = genHTML(childNodes); $('.sf-breadcrumb-l2-items').html(crumbPathHTML); $('.sf-breadcrumb-l2').css('visibility','visible'); $('.sf-breadcrumb-l3').css('visibility','hidden'); } else { $('.sf-breadcrumb-l2').css('visibility','hidden'); $('.sf-breadcrumb-l3').css('visibility','hidden'); } } }); if ($('.sf-hidden-category').text().length > 0) { var menuItemText = $('.sf-hidden-category').text(); $('.sf-breadcrumb-l2-items').find('a:contains("'+ menuItemText +'")').parent().children('.sf-breadcrumb-l2-button').each(function(index) { if ( $(this).text() == menuItemText ) { $(this).siblings('.sf-breadcrumb-l2-button').addClass('sf-breadcrumb-button-not-current'); childNodes2 = $('.sf-menu-l2').find('a[href*="'+$(this)[0].pathname+'"]').first().next().children('.sf-menu-l3-item').children('.sf-menu-l3-link'); if (childNodes2.length > 0) { crumbPathHTML2 = genHTML2(childNodes2); $('.sf-breadcrumb-l3-items').html(crumbPathHTML2); $('.sf-breadcrumb-l3').css('visibility','visible'); } else { $('.sf-breadcrumb-l3').css('visibility','hidden'); } } }); } else { $('.sf-breadcrumb-l2-items').find('a[class*="sf-breadcrumb-l2-button"]').each(function(index) { if (url.indexOf($(this)[0].href) >= 0) { $(this).siblings('.sf-breadcrumb-l2-button').addClass('sf-breadcrumb-button-not-current'); // console.log(this); childNodes2 = $('.sf-menu-l2').find('a[href*="'+$(this)[0].pathname+'"]').first().next().children('.sf-menu-l3-item').children('.sf-menu-l3-link'); if (childNodes2.length > 0) { crumbPathHTML2 = genHTML2(childNodes2); $('.sf-breadcrumb-l3-items').html(crumbPathHTML2); $('.sf-breadcrumb-l3').css('visibility','visible'); } else { $('.sf-breadcrumb-l3').css('visibility','hidden'); } } }); } // Set status on active level 3 menu item $('.sf-breadcrumb-l3-items').find('a[class*="sf-breadcrumb-l3-button"]').each(function(index) { if (url.indexOf($(this)[0].href) >= 0) { $(this).siblings('.sf-breadcrumb-l3-button').addClass('sf-breadcrumb-button-not-current'); } }); } } function moveLogoDesktop() { logo = document.querySelector(".sf-menu-home-desktop"); document.onscroll = function(){ if (window.pageYOffset > 10) { if (!logo.classList.contains('moveLogoUp')) { logo.classList.remove("moveLogoDown"); logo.classList.add("moveLogoUp"); } } else { if (logo.classList.contains('moveLogoUp')) { if (!logo.classList.contains('moveLogoDown')) { logo.classList.remove("moveLogoUp"); logo.classList.add("moveLogoDown"); } } } }; } function moveLogoMobile() { logo = document.querySelector(".sf-menu-home-mobile"); document.onscroll = function(){ if (window.pageYOffset > 10) { if (!logo.classList.contains('moveLogoUpMobile')) { logo.classList.remove("moveLogoDownMobile"); logo.classList.add("moveLogoUpMobile"); } } else { if (logo.classList.contains('moveLogoUpMobile')) { if (!logo.classList.contains('moveLogoDownMobile')) { logo.classList.remove("moveLogoUpMobile"); logo.classList.add("moveLogoDownMobile"); } } } }; }