Difference between revisions of "MediaWiki: Common.js"

From Knowledge Federation
Jump to: navigation, search
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
$(document).ready(function () {
+
 
    var scroll_pos = 0;
+
 
    $("#mw-head").scroll(function () {
+
window.onscroll = () => {
        scroll_pos = $(this).scrollTop();
+
  const nav = document.querySelector('#navbar');
        if (scroll_pos > 210) {
+
  if(this.scrollY <= 10) nav.className = ''; else nav.className = 'scroll';
            $("#mw-head").css('background-color', '#1A1A1A');
+
};
        } else {
 
            $("#mw-head").css('background-color', 'red');
 
        }
 
        console.log(scroll_pos);
 
    });
 
});
 
  
 
/*javascript:alert("hello world");
 
/*javascript:alert("hello world");
Line 19: Line 13:
 
     $('#mw-head').data('size','big');
 
     $('#mw-head').data('size','big');
 
});
 
});
 +
 +
 +
 +
 +
  
 
$(window).scroll(function(){
 
$(window).scroll(function(){

Revision as of 17:00, 27 November 2018

/* Any JavaScript here will be loaded for all users on every page load. */



window.onscroll = () => {
  const nav = document.querySelector('#navbar');
  if(this.scrollY <= 10) nav.className = ''; else nav.className = 'scroll';
};

/*javascript:alert("hello world");

$(function(){
    $('#mw-head').data('size','big');
});






$(window).scroll(function(){
    if($(document).scrollTop() > 0)
    {
        if($('#mw-head').data('size') == 'big')
        {
            $('#mw-head').data('size','small');
            $('#mw-head').stop().animate({
                height:'65'
            },600);
        }
    }
    else
    {
        if($('#mw-head').data('size') == 'small')
        {
            $('#mw-head').data('size','big');
            $('#mw-head').stop().animate({
                height:'100px'
            },600);
        }  
    }
});*/