/** * Main JS file for Horace behaviours */ (function ($) { "use strict"; var $body = $('body'); $(document).ready(function(){ // Responsive video embeds $('.post-content').fitVids(); // Scroll to top $('#top-button').on('click', function(e) { $('html, body').animate({ 'scrollTop': 0 }); e.preventDefault(); }); // Sidebar $('#sidebar-show, #sidebar-hide').on('click', function(e){ $body.toggleClass('sidebar--opened'); $(this).blur(); e.preventDefault(); }); $('#site-overlay').on('click', function(e){ $body.removeClass('sidebar--opened'); e.preventDefault(); }); // Show comments var interval = setInterval(function() { var disqusHeight = $('#disqus_thread').height(); if ( disqusHeight > 100 ) { $('#comments-area').addClass('comments--loaded'); clearInterval(interval); } }, 100); $('#comments-overlay, #comments-show').on('click', function(e){ $('#comments-area').removeClass('comments--loaded').addClass('comments--opened'); e.preventDefault(); }); }); }(jQuery));