jQuery( document ).ready( function( $ ) { // Must wait for everything to be loaded before affixing the // navbar because the logic looks at it's y-position and that // can change if not everything is loaded in-place. $( window ).load( function() { /** * The navbar can be fixed to the top when it scrolls off the * top of the screen. This is an administrative option. */ var nav_element = $( '.area-navigation > nav' ); if ( nav_element.length > 0 ) { // Tell Bootstrap to stick the navbar to the top of // the browser when the navbar scrolls offscreen. nav_element.affix({ offset: { top: nav_element.offset().top + 1 } // Note: Without the +1, every other click would toggle between 'affix' and 'affix-top'. }); // Avoid scroll-skipping. $( '.area-navigation' ).height( nav_element.outerHeight() ); } }); });