( function( $ ) { 'use strict'; $(document).ready(function($){ // Fixed header. if ( $( 'body' ).hasClass( 'enabled-sticky-primary-menu' ) ) { $(window).on( 'scroll',function () { if( $(window).scrollTop() > $('#main-navigation,.site-header').offset().top && !($('#main-navigation,.site-header').hasClass('fixed'))){ $('#main-navigation,.site-header').addClass('fixed'); } else if ( 0 === $(window).scrollTop() ){ $('#main-navigation,.site-header').removeClass('fixed'); } }); } // Testimonials carousel. if ( $('.testimonial-carousel-wrapper').length > 0 ) { $('.testimonial-carousel-wrapper').slick(); } // Products carousel. if ( $('.products-carousel-wrapper').length > 0 ) { $('.products-carousel-wrapper').slick(); } // Counter up. if ( $('.counter-nos').length > 0 ) { $('.counter-nos').counterUp(); } // Skills. if ( $('.skill-bar-section').length > 0 ) { $('.skill-bar-section').waypoint(function () { $(this.element).find('.skillbar-item').each(function () { var data_percent = $(this).attr('data-percent'); $(this).find('.skillbar-bar').animate({ 'width': data_percent + '%' }, data_percent * 20 ); }); }, { offset: '50%', triggerOnce: true }); } // Search icon. if( $('.search-icon').length > 0 ) { $('.search-icon').on('click', function(e){ e.preventDefault(); $('.search-box-wrap').slideToggle(); }); $('.btn-close-search').on('click', function(e){ e.preventDefault(); $('.search-box-wrap').slideToggle(); }); } // Implement go to top. var $scroll_obj = $( '#btn-scrollup' ); $( window ).on( 'scroll',function(){ if ( $( this ).scrollTop() > 100 ) { $scroll_obj.fadeIn(); } else { $scroll_obj.fadeOut(); } }); $scroll_obj.on( 'click',function(){ $( 'html, body' ).animate( { scrollTop: 0 }, 600 ); return false; }); // Masonry. if ( $( 'body').hasClass( 'archive-layout-grid' ) && $( '#masonry-loop' ).length > 0 ) { var $blocks = $('#main'); $blocks.imagesLoaded(function(){ $blocks.masonry({ 'columnWidth': '.hentry', 'itemSelector': '.hentry', 'percentPosition': true }); // Fade blocks in after images are ready (prevents jumping and re-rendering). $('.hentry').fadeIn(); }); $(window).on('resize', function() { $blocks.masonry(); }); } }); } )( jQuery );