/*============================================ Navigation ==============================================*/ $('.nav-toggle').on('touchstart click', function(e) { e.preventDefault(); $( this ).toggleClass( 'active' ); }); $(function dw_hidenav() { var headerHeight = $('.navbar').height(); $(window).on('scroll', { previousTop: 0 }, function() { var currentTop = $(window).scrollTop(); if (currentTop < this.previousTop) { if (currentTop > 0 && $('.navbar').hasClass('fixed')) { $('.navbar').addClass('visible'); } else { $('.navbar').removeClass('visible fixed'); } } else { $('.navbar').removeClass('visible'); if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed'); } this.previousTop = currentTop; } ); }); /*============================================ Comments ==============================================*/ $('#comments').hide(); $('.toggle-comments').on('touchstart click', function(e) { e.preventDefault(); $('#comments').toggle('slow', function() { var anchor = $('.toggle-comments'); var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments'; $(anchor).text(anchorText); }); }); $('#commentform').validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 20 } }, messages: { author: 'Please enter in your name.', email: 'Please enter a valid email address.', comment: 'Nothing to Say?' }, errorElement: 'div', errorPlacement: function(error, element) { element.before(error); } }); /*============================================ EU GDPR cookie notification ==============================================*/ $( document ).ready( function() { cookieNotification(); }); var hideCookieNotification = function() { $( '.js-cookie-notification' ).delay(5000).fadeOut( "slow" ); Cookies.set('EU-GDPR-Cookie', 'true', { expires: 365 }); }; var cookieNotification = function() { var setCookieNotification = function() { $( '.js-cookie-notification' ).fadeOut( "slow" ); Cookies.set('EU-GDPR-Cookie', 'true', { expires: 365 }); return false; }; if ( Cookies.get('EU-GDPR-Cookie') === 'true' ) { console.log('EU GDPR cookie notification set'); } else { console.log('EU GDPR cookie notification not set'); $('.js-cookie-notification').css({ 'display' : 'block'}); $('.js-cookie-notification').find('.js-cookie-notification-hide').click( setCookieNotification ); }; }