const mqNavbar = window.matchMedia('(min-width: 768px)') const mqSearch = window.matchMedia('(max-width: 1199px)') $(document).ready(function() { // Floating Navigation var nav = $('.navbar'); var wrapped = false; var scrolled = false; function handleLargeChange(e) { if (e.matches) { if ( wrapped && $('.navbar #navigationUser li.dropdown').length ) { $(".navbar #navigationUser li.dropdown > a > span.username").contents().unwrap(); wrapped = false; } else if ( wrapped && $('.navbar .loggedOut').length ) { $(".navbar .loggedOut .menu-item-9 > a > span.username").contents().unwrap(); wrapped = false; } var bufferHeight = nav.outerHeight(true); var shrinkHeader = bufferHeight + 300; var newNav = nav.clone(); $(window).on('scroll.scroll', function(){ var scroll = getCurrentScroll(); if ( scroll >= shrinkHeader && !scrolled ) { $(newNav).wrap('
').parent().prependTo('body'); $('.shrink').css({'top' : '-50px'}).animate({'top' : 0}, 200); scrolled = true; } else if ( scroll <= shrinkHeader && scrolled ) { $('.shrink').animate({'top' : '-50px'}, 200, function() { $('.shrink').remove(); }); scrolled = false; } }); } else { $(window).off('.scroll'); if ( !wrapped && $('.navbar #navigationUser li.dropdown').length ) { $('.navbar #navigationUser li.dropdown > a').wrapInner(''); wrapped = true; } else if ( !wrapped && $('.navbar .loggedOut').length ) { $('.navbar .loggedOut .menu-item-9 > a').wrapInner(''); wrapped = true; } } function getCurrentScroll() { return window.pageYOffset || document.documentElement.scrollTop; } } mqNavbar.addEventListener('change', handleLargeChange) handleLargeChange(mqNavbar) // Search function handleSmallChange(e) { if (e.matches) { $('#main-navigation').append('