jQuery(document).ready(function($) { function masonryGo() { // Set Masonry element id/class $('.masonry-wrapper').masonry({ itemSelector: '.hentry' }); $('.footer-widgets').masonry({ itemSelector: '.footer-widgets .widget' }); } // Go Masonry! masonryGo(); $(document).ready( function() { setTimeout( function() { masonryGo(); }, 500); }); $(document).ready( function() { setTimeout( function() { masonryGo(); }, 1000); }); $(document).ready( function() { setTimeout( function() { masonryGo(); }, 1500); }); $(window).load( function() { masonryGo(); }); $(window).resize( function() { masonryGo(); }); window.addEventListener("orientationchange", function() { masonryGo(); }); // Smooth scroll to header $('.tothetop').click(function(){ $('html,body').animate({scrollTop: 0}, 500); $(this).unbind("mouseenter mouseleave"); return false; }); // Toggle the search form below the main menu $(".search-toggle").click(function(){ $(".mm-search-form").slideToggle('slow', function(){ $('.search-toggle').toggleClass('active'); }); // Optional return false to avoid the page "jumping" when clicked return false; }); // Focus the search field $('.search-toggle').click(function(){ $('.menu-search-field').focus(); }); // Sticky content and sidebar (js/sticky.js) jQuery('.content-area, .widget-area').theiaStickySidebar({ // Settings additionalMarginTop: 85 }); // Make menu sticky when it reaches the top and screen width in higher than 750px (js/scrollfix.js) var watcher = $('.main-navigation').scrollFix(); $(window).resize(function () { if ($(this).width() > 750) { // attach if (!watcher.attached) { watcher.attach(); } } else { // detach and unfix if (watcher.attached) { watcher.detach(); } if (watcher.fixed) { watcher.unfix(); watcher.fixed = false; } } }); // initial update $(window).resize(); });