(function($) { 'use strict'; // ===================== // Post Card Images Fade // ===================== $('.js-fadein, .wp-post-image').viewportChecker({ classToAdd: 'is-inview', // Class to add to the elements when they are visible offset: 100, removeClassAfterAnimation: true }); // ===================== // Responsive videos // ===================== $('.c-content, .comment-content').fitVids({ 'customSelector': [ 'iframe[src*="ted.com"]' , '[src*="videopress.com"]' , 'iframe[src*="facebook.com"]' , 'iframe[src*="player.twitch.tv"]' , 'iframe[src*="dailymotion.com"]' ] }); // ===================== // Off Canvas menu // ===================== $('.js-off-canvas-toggle').click(function(e) { e.preventDefault(); $('.js-off-canvas-content, .js-off-canvas-container').toggleClass('is-active'); }); // ===================== // Search // ===================== var search_field = $('.js-search-input'), toggle_search = $('.js-search-toggle'); toggle_search.click(function(e) { e.preventDefault(); $('.js-search').addClass('is-active'); // If off-canvas is active, just disable it $('.js-off-canvas-container').removeClass('is-active'); setTimeout(function() { search_field.focus(); }, 500); }); $('.c-search, .js-search-close, .js-search-close .icon').on('click keyup', function(event) { if (event.target == this || event.target.classList.contains('js-search-close') || event.target.classList.contains('icon') || event.keyCode == 27) { $('.c-search').removeClass('is-active'); } }); // ===================== // Instagram Feed // ===================== if ($('#instafeed-post').length) { var instagramFeedPost = new Instafeed({ get: 'user', target: 'instafeed-post', limit: bisonno_instagram_widget_config.limit, resolution: 'thumbnail', userId: bisonno_instagram_widget_config.userId, accessToken: bisonno_instagram_widget_config.accessToken, template: '
{{caption}}
' }); instagramFeedPost.run(); } if ($('#instafeed-footer').length) { var instagramFeedFooter = new Instafeed({ get: 'user', target: 'instafeed-footer', limit: bisonno_instagram_widget_config.limit, resolution: 'thumbnail', userId: bisonno_instagram_widget_config.userId, accessToken: bisonno_instagram_widget_config.accessToken, template: '
{{caption}}
' }); instagramFeedFooter.run(); } // ===================== // Ajax Load More // ===================== var bisonno_load_posts_button = $('.js-load-posts'), bisonno_page_number_next = bisonno_config.bisonno_page_number_next, bisonno_page_link_next = bisonno_config.bisonno_page_link_next; bisonno_load_posts_button.click(function(e) { e.preventDefault(); var bisonno_next_link = bisonno_page_link_next.replace('9999999999', bisonno_page_number_next); $.ajax({ url: bisonno_next_link, beforeSend: function() { bisonno_load_posts_button.text(bisonno_config.bisonno_loading); bisonno_load_posts_button.addClass('c-btn--loading'); } }).done(function(data) { var posts = $('.js-post-card-wrap', data); bisonno_load_posts_button.text(bisonno_config.bisonno_load_more); bisonno_load_posts_button.removeClass('c-btn--loading'); $('.js-grid').append(posts); $('.js-fadein').viewportChecker({ classToAdd: 'is-inview', offset: 100, removeClassAfterAnimation: true }); bisonno_page_number_next++; // If you are on the last pagination page, hide the load more button if (bisonno_page_number_next > bisonno_config.bisonno_page_number_max) { bisonno_load_posts_button.addClass('c-btn--disabled').attr('disabled', true); } }); }); })(jQuery);