jQuery( function( $ ) { $( '.homepage-featured' ).slick( { lazyLoad: 'ondemand', autoplay: true, autoplaySpeed: 6000, arrows: false, dots: true, pauseOnDotsHover: true, speed: 600 }); $( 'body' ).on( 'click', '.show-comments', function( event ) { event.preventDefault(); $( '.show-comments' ).hide(); $( '#disqus_thread' ).show(); } ); $( 'body' ).fitVids( { customSelector: "iframe[src*='http://www.bbc.co.uk'], iframe[src*='https://w.soundcloud.com/player/?visual=true']"} ); stickyHeader.init(); } ); var stickyHeader = { elements: {}, init: function() { this.getElements(); if(this.elements.main.length) { this.addSpacer(); this.setEvents(); this.setState(); } }, getElements: function() { this.elements.main = jQuery('.sticky-header'); this.elements.offCanvas = jQuery('.off-canvas'); }, addSpacer: function() { this.elements.spacer = jQuery('
'); this.elements.spacer.insertBefore(this.elements.main); }, setEvents: function() { var _self = this; jQuery(window).scroll(function() { _self.setState(); }); }, setState: function() { var topOffset = this.elements.spacer.offset().top; var scrollPosition = jQuery(window).scrollTop(); if(topOffset < scrollPosition) { var height = this.elements.main.height(); this.elements.main.removeClass('sticky-header--pre-scroll'); this.elements.spacer.css('height', height + 'px'); // Uncomment the following to allow correct positioning of mobile menu when the header is sticky //if(this.elements.offCanvas.length) { // this.elements.offCanvas.css('top', height + 'px'); //} } else { this.elements.main.addClass('sticky-header--pre-scroll'); this.elements.spacer.css('height', ''); // Uncomment the following to allow correct positioning of mobile menu when the header is sticky //if(this.elements.offCanvas.length) { // this.elements.offCanvas.css('top', ''); //} } } }; function restricted_content_toggle_topbar_override( logged_in ) { var $ = jQuery; if( logged_in ) { // Desktop $( '.bar-login__text' ).text( 'Logged in' ); $( '.paywall-topbar-login' ).hide(); $( '.paywall-topbar-logout' ).show(); // Mobile $( '.restricted-content-mobile-login' ).hide(); $( '.restricted-content-mobile-logout' ).show(); $( '.menu-main-user-container' ).hide(); $( '.mobile-nav .mobile-user-button .active' ).removeClass( 'active' ); } else { // Desktop $( '.bar-login__text' ).text( 'Log in' ); $( '.paywall-topbar-login' ).show(); $( '.paywall-topbar-logout' ).hide(); // Mobile $( '.restricted-content-mobile-login' ).show(); $( '.restricted-content-mobile-logout' ).hide(); } }