') .parent().hide() .appendTo('body'); $('.footer-navigation').clone().attr('class', 'mobile-menu footer').appendTo(menu_wrapper); } else { menu_wrapper = $('.'+mts_customscript.nav_menu+'-navigation') .clone().attr('class', 'mobile-menu ' + mts_customscript.nav_menu) .wrap('
').parent().hide() .appendTo('body'); } $('.toggle-mobile-menu').click(function(e) { e.preventDefault(); e.stopPropagation(); $('#mobile-menu-wrapper').show(); $('body').toggleClass('mobile-menu-active'); }); // prevent propagation of scroll event to parent $(document).on('DOMMouseScroll mousewheel', '#mobile-menu-wrapper', function(ev) { var $this = $(this), scrollTop = this.scrollTop, scrollHeight = this.scrollHeight, height = $this.height(), delta = (ev.type == 'DOMMouseScroll' ? ev.originalEvent.detail * -40 : ev.originalEvent.wheelDelta), up = delta > 0; var prevent = function() { ev.stopPropagation(); ev.preventDefault(); ev.returnValue = false; return false; } if (!up && -delta > scrollHeight - height - scrollTop) { // Scrolling down, but this will take us past the bottom. $this.scrollTop(scrollHeight); return prevent(); } else if (up && delta > scrollTop) { // Scrolling up, but this will take us past the top. $this.scrollTop(0); return prevent(); } }); }).click(function() { jQuery('body').removeClass('mobile-menu-active'); }); if( $(".block_fixed").length > 0 && $(".article").length > 0) { var block_fixed = $(".block_fixed").offset(); var full_post = $(".article").offset(); var full_post_height = $(".article").height(); var height_fixed = $(".block_fixed").height(); var full_post = full_post.top + full_post_height; $(window).resize(function() { var block_fixed = $(".block_fixed").offset(); var full_post = $(".article").offset(); var full_post_height = $(".article").height(); var height_fixed = $(".block_fixed").height(); var full_post = full_post.top + full_post_height; }); $(window).scroll(function() { var scroll_top = $(window).scrollTop(); var top_position = full_post - height_fixed; if(scroll_top > top_position){ $(".block_fixed").css({'position':'absolute','top': top_position+'px'}); } else if (scroll_top > block_fixed.top ) { $(".block_fixed").css({'position':'fixed','top':'10%'}); } else { $(".block_fixed").css({'position':'static'}); } }); } /*----------------------------------------------------/* Dropdown menu/* ------------------------------------------------- */$(function($) { $('#navigation ul.sub-menu, #navigation ul.children').hide(); // hides the submenus in mobile menu too $('#navigation li').hover( function() { $(this).children('ul.sub-menu, ul.children').slideDown('fast'); }, function() { $(this).children('ul.sub-menu, ul.children').hide(); } );}); }); } if (window.addEventListener) window.addEventListener("load", loadJQuery, false); else if (window.attachEvent) window.attachEvent("onload", loadJQuery); else window.onload = loadJQuery;