MediaWiki:GlobalNavBehavior.js

/** * GlobalNavBehavior * * Allows user to define show/hide behavior of global nav on scroll. * * @author User:Blaster Niceshot * * @version 1.0 */   // Initialize globalNavBehavior object window.globalNavBehavior = window.globalNavBehavior || {}; if (typeof window.globalNavBehavior.load !== 'undefined') { // Exit function to prevent second load. return; }   var globalNavBehavior = $.extend({            onScrollUp: 'show',            onScrollDown: 'hide',            load: true,        }, window.globalNavBehavior), gNav = $('#globalNavigation'), prevScrollTop = 0; gNav.css({       'top': '0',        'transition': 'top 0.2s ease',    }); // Show and hide functions function showGNav { gNav.css('top', '0'); }   function hideGNav { gNav.css('top', '-55px'); }   // When user scrolls $(window).scroll(       function {            // Determine scroll direction            var curScrollTop = $(this).scrollTop,                dir;            if (curScrollTop <= 60) {                dir = 'top';            } else if (curScrollTop > prevScrollTop) {                dir = 'down';            } else if (curScrollTop < prevScrollTop) {                dir = 'up';            }             prevScrollTop = curScrollTop;            if (gNav.length > 0) {                if (dir === 'top') {                    showGNav;                } else if (dir === 'down') {                    if (globalNavBehavior.onScrollDown === 'show') {                        showGNav;                    } else if (globalNavBehavior.onScrollDown === 'hide') {                        hideGNav;                    }                } else if (dir === 'up') {                    if (globalNavBehavior.onScrollUp === 'show') { showGNav; } else if (globalNavBehavior.onScrollUp === 'hide') { hideGNav; }               }            }        }    ); }) (this, this.jQuery, this.mediaWiki);
 * (function(window, $, mw) {