MediaWiki:Staatslexikon.js: Unterschied zwischen den Versionen

(Die Seite wurde neu angelegt: „// Add submenu links to About this encyclopedia-link $(document).ready(function () { var myElement = document.getElementById('n-.C3.9Cber-das-Lexikon'); my…“)
 
K
 
Zeile 22: Zeile 22:
 
.not('[href="#"]')
 
.not('[href="#"]')
 
.not('[href="#0"]')
 
.not('[href="#0"]')
 +
.not('[href="#mobile-navigation"]')
 
.click(function(event) {
 
.click(function(event) {
 
   // On-page links
 
   // On-page links

Aktuelle Version vom 9. Juli 2018, 14:49 Uhr

// Add submenu links to About this encyclopedia-link
$(document).ready(function () {
  var myElement = document.getElementById('n-.C3.9Cber-das-Lexikon');
  myElement.insertAdjacentHTML('beforeend', '<ul class="dropdown"><li class="dropdown__item"><a href="/index.php/Das_Staatslexikon_der_G%C3%B6rres-Gesellschaft" class="dropdown__link">Das Staatslexikon</a></li><li class="dropdown__item"><a href="/index.php/Antworten_auf_Herausforderungen_der_Gegenwart_-_Vorwort" class="dropdown__link">Vorwort zur Print-Ausgabe</a></li><li class="dropdown__item"><a href="/index.php/Hinweise_zur_Benutzung_des_Lexikons" class="dropdown__link">Hinweise zur Benutzung</a></li><li class="dropdown__item"><a href="/index.php/Die_Redaktion" class="dropdown__link">Die Redaktion</a></li><li class="dropdown__item"><a href="/index.php/Die_Herausgeber" class="dropdown__link">Die Herausgeber</a></li></ul>');
});


// Show hidden dropdown submenu when hovering over About this encyclopedia-link
$(document).ready(function() {
  if ( $(window).width() > 767) {
    $(".navigation__links .mw-portlet-body > ul > li:last-child").hover(
      function() {
        $(".dropdown").fadeToggle("fast");
      }
    );
  }
});

// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.not('[href="#mobile-navigation"]')
.click(function(event) {
  // On-page links
  if (
    location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 
    && 
    location.hostname == this.hostname
  ) {
    // Figure out element to scroll to
    var target = $(this.hash);
    target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
    // Does a scroll target exist?
    if (target.length) {
      // Only prevent default if animation is actually gonna happen
      event.preventDefault();
      $('html, body').animate({
        scrollTop: target.offset().top
      }, 1000, function() {
        // Callback after animation
        // Must change focus!
        var $target = $(target);
        $target.focus();
        if ($target.is(":focus")) { // Checking if the target was focused
          return false;
        } else {
          $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
          $target.focus(); // Set focus again
        };
      });
    }
  }
});

// Show or hide Scroll To Top-Button
$(window).scroll(function(){
  if ($(this).scrollTop() > 50) {
      $('#scrollToTop').fadeIn('slow');
  } else {
      $('#scrollToTop').fadeOut('slow');
  }
});

// Animate scrolling to top
$('#scrollToTop').click(function(){
    $("html, body").animate({ scrollTop: 0 }, 500);
    return false;
});