MediaWiki:Common.js: Difference between revisions

From DM Live - the Depeche Mode live encyclopedia for the masses
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:
/* 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. */


function UpdateTableHeaders() {
originalHeaderRow = $("tr:first", this);
  $("div.divTableWithFloatingHeader").each(function() {
originalHeaderRow.before(originalHeaderRow.clone());
      offset = $(this).offset();
      scrollTop = $(window).scrollTop();
      if ((scrollTop > offset.top) && (scrollTop < offset.top + $(this).height())) {
          $(".tableFloatingHeader", this).css("visibility", "visible");
          $(".tableFloatingHeader", this).css("top", Math.min(scrollTop - offset.top, $(this).height() - $(".tableFloatingHeader", this).height()) + "px");
      }
      else {
          $(".tableFloatingHeader", this).css("visibility", "hidden");
          $(".tableFloatingHeader", this).css("top", "0px");
      }
  })
}


$(document).ready(function() {
// original css rules and stuff
  $("table.tableWithFloatingHeader").each(function() {
 
      $(this).wrap("<div class="divTableWithFloatingHeader" style="position:relative"></div>");
clonedHeaderRow.children().each( function( index ) {
      $("tr:first", this).before($("tr:first", this).clone());
    $(this).append("<div class='widthFix'></div>");
      clonedHeaderRow = $("tr:first", this)
    $(this).css("padding-left", "0");
      clonedHeaderRow.addClass("tableFloatingHeader");
    $(this).css("padding-right", "0");
      clonedHeaderRow.css("position", "absolute");
    $('.widthFix', this).width( originalHeaderRow.children().get( index ).clientWidth );
      clonedHeaderRow.css("top", "0px");
      clonedHeaderRow.css("left", "0px");
      clonedHeaderRow.css("visibility", "hidden");
  });
  UpdateTableHeaders();
  $(window).scroll(UpdateTableHeaders);
});
});

Revision as of 02:51, 17 August 2019

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

originalHeaderRow = $("tr:first", this);
originalHeaderRow.before(originalHeaderRow.clone());

// original css rules and stuff

clonedHeaderRow.children().each( function( index ) {
    $(this).append("<div class='widthFix'></div>");
    $(this).css("padding-left", "0");
    $(this).css("padding-right", "0");
    $('.widthFix', this).width( originalHeaderRow.children().get( index ).clientWidth );
});