MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 4: Line 4:
/* mw.loader.load('https://www.zd10.net/new_wiki/skins/pivot/assets/scripts/foundation/foundation.js&action=raw&ctype=text/javascript' ); */
/* mw.loader.load('https://www.zd10.net/new_wiki/skins/pivot/assets/scripts/foundation/foundation.js&action=raw&ctype=text/javascript' ); */


$(document).ready(function() {
    $(document).ready(function() {
   
      var docHeight = $(document).height(),
  var getMax = function(){
      windowHeight = $(window).height(),
    return $(document).height() - $(window).height();
      scrollPercent;
  }
   
  var getValue = function(){
    return $(window).scrollTop();
  }
   
  if ('max' in document.createElement('progress')) {
    // Browser supports progress element
    var progressBar = $('progress');
       
    // Set the Max attr for the first time
    progressBar.attr({ max: getMax() });


    $(document).on('scroll', function(){
      $(window).scroll(function() {
      // On scroll only Value attr needs to be calculated
        scrollPercent = $(window).scrollTop() / (docHeight - windowHeight) * 100;
      progressBar.attr({ value: getValue() });
    });
     
    $(window).resize(function(){
      // On resize, both Max/Value attr needs to be calculated
      progressBar.attr({ max: getMax(), value: getValue() });
    });
 
  } else {


    var progressBar = $('.progress-bar'),
        $('.scroll-progress').width(scrollPercent + '%');
        max = getMax(),
         });
        value, width;
         });
       
    var getWidth = function() {
      // Calculate width in percentage
      value = getValue();           
      width = (value/max) * 100;
      width = width + '%';
      return width;
    }
          
    var setWidth = function(){
      progressBar.css({ width: getWidth() });
    }
          
    $(document).on('scroll', setWidth);
    $(window).on('resize', function(){
      // Need to reset the Max attr
      max = getMax();
      setWidth();
    });
  }
});

Revision as of 13:42, 17 March 2019

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

/* mw.loader.load('https://www.zd10.net/new_wiki/skins/pivot/assets/scripts/vendor/jquery.js&action=raw&ctype=text/javascript' ); */
/* mw.loader.load('https://www.zd10.net/new_wiki/skins/pivot/assets/scripts/foundation/foundation.js&action=raw&ctype=text/javascript' ); */

    $(document).ready(function() {
      var docHeight = $(document).height(),
      windowHeight = $(window).height(),
      scrollPercent;

      $(window).scroll(function() {
        scrollPercent = $(window).scrollTop() / (docHeight - windowHeight) * 100;

        $('.scroll-progress').width(scrollPercent + '%');
        });
        });
We collect cookies to analyze our website traffic and performance; we never collect any personal data.