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
 
(24 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($) {
    // Start of custom navbar js
  $.fn.fixMe = function() {
(function($) { // Begin jQuery
      return this.each(function() {
  $(function() { // DOM ready
        var $this = $(this),
    // If a link has a dropdown, add sub menu toggle.
            $t_fixed;
    $('nav ul li a:not(:only-child)').click(function(e) {
        function init() {
      $(this).siblings('.nav-dropdown').toggle();
            $this.wrap('<div class="container" />');
      // Close one dropdown when selecting another
            $t_fixed = $this.clone();
      $('.nav-dropdown').not($(this).siblings()).hide();
            $t_fixed.find("tbody").remove().end().addClass("fixed").insertBefore($this);
      e.stopPropagation();
            resizeFixed();
    });
        }
    // Clicking away from dropdown will remove the dropdown class
        function resizeFixed() {
    $('html').click(function() {
          $t_fixed.width($this.outerWidth());
      $('.nav-dropdown').hide();
            $t_fixed.find("th").each(function(index) {
    });
              $(this).css("width",$this.find("th").eq(index).outerWidth()+"px");
    // Toggle open and close nav styles on click
            });
    $('#nav-toggle').click(function() {
        }
      $('nav ul').slideToggle();
        function scrollFixed() {
    });
            var offsetY = $(this).scrollTop(),
    // Hamburger to X toggle
            offsetX = $(this).scrollLeft(),
    $('#nav-toggle').on('click', function() {
            tableOffsetTop = $this.offset().top,
      this.classList.toggle('active');
            tableOffsetBottom = tableOffsetTop + $this.height() - $this.find("thead").height(),
    });
            tableOffsetLeft = $this.offset().left;
  }); // end DOM ready
            if(offsetY < tableOffsetTop || offsetY > tableOffsetBottom)
})(jQuery); // end jQuery
              $t_fixed.hide();
    // End of custom navbar
            else if(offsetY >= tableOffsetTop && offsetY <= tableOffsetBottom && $t_fixed.is(":hidden"))
              $t_fixed.show();
            $t_fixed.css("left", tableOffsetLeft - offsetX + "px");
        }
        $(window).resize(resizeFixed);
        $(window).scroll(scrollFixed);
        init();
      });
  };
})(jQuery);


$(document).ready(function(){
// Collapsible menus...
  $("table").fixMe();
$(function() {
  $(".up").click(function() {
  var b = $("#toggle-button");
       $('html, body').animate({
  var w = $("#toggle");
       scrollTop: 0
  var l = $("#toggle-content");
  }, 2000);
 
});
  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));
    }
 
  });
});
});

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));
    }
  
  });
});