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
(Undo revision 52871 by Majora101 (talk))
Tag: Undo
 
(26 intermediate revisions by the same user not shown)
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() {
    // Start of custom navbar js
  $("div.divTableWithFloatingHeader").each(function() {
(function($) { // Begin jQuery
      offset = $(this).offset();
  $(function() { // DOM ready
      scrollTop = $(window).scrollTop();
    // If a link has a dropdown, add sub menu toggle.
      if ((scrollTop > offset.top) && (scrollTop < offset.top + $(this).height())) {
    $('nav ul li a:not(:only-child)').click(function(e) {
          $(".tableFloatingHeader", this).css("visibility", "visible");
      $(this).siblings('.nav-dropdown').toggle();
          $(".tableFloatingHeader", this).css("top", Math.min(scrollTop - offset.top, $(this).height() - $(".tableFloatingHeader", this).height()) + "px");
      // Close one dropdown when selecting another
      }
      $('.nav-dropdown').not($(this).siblings()).hide();
      else {
      e.stopPropagation();
          $(".tableFloatingHeader", this).css("visibility", "hidden");
    });
          $(".tableFloatingHeader", this).css("top", "0px");
    // Clicking away from dropdown will remove the dropdown class
      }
    $('html').click(function() {
  })
      $('.nav-dropdown').hide();
}
    });
    // Toggle open and close nav styles on click
    $('#nav-toggle').click(function() {
      $('nav ul').slideToggle();
    });
    // Hamburger to X toggle
    $('#nav-toggle').on('click', function() {
      this.classList.toggle('active');
    });
  }); // end DOM ready
})(jQuery); // end jQuery
    // End of custom navbar


$(document).ready(function() {
// Collapsible menus...
  $("table.tableWithFloatingHeader").each(function() {
$(function() {
      $(this).wrap("<div class="divTableWithFloatingHeader" style="position:relative"></div>");
  var b = $("#toggle-button");
      $("tr:first", this).before($("tr:first", this).clone());
  var w = $("#toggle");
      clonedHeaderRow = $("tr:first", this)
  var l = $("#toggle-content");
      clonedHeaderRow.addClass("tableFloatingHeader");
 
      clonedHeaderRow.css("position", "absolute");
  w.height(l.outerHeight(true));
      clonedHeaderRow.css("top", "0px");
 
      clonedHeaderRow.css("left", "0px");
  b.click(function() {
      clonedHeaderRow.css("visibility", "hidden");
 
  });
    if(w.hasClass('open')) {
  UpdateTableHeaders();
      w.removeClass('open');
  $(window).scroll(UpdateTableHeaders);
      w.height(0);
    } else {
      w.addClass('open');
      w.height(l.outerHeight(true));
    }
 
  });
});
});

Latest revision as of 03:44, 30 March 2024

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

    // Start of custom navbar js
(function($) { // Begin jQuery
  $(function() { // DOM ready
    // If a link has a dropdown, add sub menu toggle.
    $('nav ul li a:not(:only-child)').click(function(e) {
      $(this).siblings('.nav-dropdown').toggle();
      // Close one dropdown when selecting another
      $('.nav-dropdown').not($(this).siblings()).hide();
      e.stopPropagation();
    });
    // Clicking away from dropdown will remove the dropdown class
    $('html').click(function() {
      $('.nav-dropdown').hide();
    });
    // Toggle open and close nav styles on click
    $('#nav-toggle').click(function() {
      $('nav ul').slideToggle();
    });
    // Hamburger to X toggle
    $('#nav-toggle').on('click', function() {
      this.classList.toggle('active');
    });
  }); // end DOM ready
})(jQuery); // end jQuery
    // End of custom navbar

// Collapsible menus...
$(function() {
  var b = $("#toggle-button");
  var w = $("#toggle");
  var l = $("#toggle-content");
  
  w.height(l.outerHeight(true));

  b.click(function() {
  
    if(w.hasClass('open')) {
      w.removeClass('open');
      w.height(0);
    } else {
      w.addClass('open');
      w.height(l.outerHeight(true));
    }
  
  });
});