Zuletzt bearbeitet vor 2 Monaten
von Mark Wagner

MediaWiki:Common.js: Unterschied zwischen den Versionen

Keine Kategorien vergebenBearbeiten
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Zeile 34: Zeile 34:
});
});
});
});
/* MediaWiki:Common.js */
$(function() {
$(function() {
   // 1) Klick merken
   // Relativer Pfad der aktuellen Seite
   $('body').on('click', 'a.mws-tree-item-label', function() {
   var current = window.location.pathname;
    try {
      window.name = JSON.stringify({ lastNav: this.getAttribute('href') });
    } catch (e) {}
  });


   // 2) Polling & Aufklappen + Inline‐Styling
   // Lese gespeichertes lastNav
  var lastNav = null;
  try {
    lastNav = JSON.parse(window.name || '{}').lastNav;
  } catch (e) {}
 
  // Funktion: schließe alle active-Links wieder
  function collapseAllActive() {
    $('a.mws-tree-item-label.active').each(function() {
      var $link    = $(this),
          relHref  = $link.attr('href'),
          $parents = $link.parents('li.mws-tree-item');
      // entferne active-Stil
      $link.removeClass('active').css({
        'background-color': '',
        'font-weight': '',
        'color': '',
        'border-left': '',
        'padding-left': ''
      });
      // schließe jeden Parent-Zweig
      $parents.each(function() {
        var $li      = $(this),
            $exp      = $li.children('div').children('a.mws-tree-expander.expanded'),
            $submenu = $li.children('ul.mws-tree-item-children');
        if ($exp.length) {
          $exp
            .removeClass('expanded')
            .addClass('collapsed')
            .attr('aria-expanded','false');
        }
        if ($submenu.length) {
          $submenu.hide();
        }
      });
    });
  }
 
  // Wenn lastNav existiert aber nicht mit current übereinstimmt, collapse all
  if (lastNav && lastNav !== current) {
    collapseAllActive();
    return; // kein neues Aufklappen
  }
 
  // Ab hier: lastNav === current → öffne Zweig und markiere
   var attempts = 0,
   var attempts = 0,
       interval = setInterval(function() {
       interval = setInterval(function() {
     attempts++;
     attempts++;
    var data = {};
     if (!lastNav || attempts > 10) {
    try {
      data = JSON.parse(window.name || '{}');
    } catch (e) {}
    var last = data.lastNav;
     if (!last || attempts > 10) {
       clearInterval(interval);
       clearInterval(interval);
       return;
       return;
     }
     }
     var $link = $('a.mws-tree-item-label[href="' + last + '"]');
     var $link = $('a.mws-tree-item-label[href="' + lastNav + '"]');
     if ($link.length) {
     if ($link.length) {
       clearInterval(interval);
       clearInterval(interval);
       // Zweige aufklappen
       // aufklappen
       $link.parents('li.mws-tree-item').each(function() {
       $link.parents('li.mws-tree-item').each(function() {
         var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed');
         var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed');
Zeile 65: Zeile 101:
         }
         }
       });
       });
       // Inline‐Styles setzen
       // inline-highlight & class active
       $link.css({
       $link
        'background-color': '#eef',
        .addClass('active')
        'font-weight': 'bold',
        .css({
        'color': '#000',
          'background-color': '#eef',
        'border-left': '3px solid #60AE24',
          'font-weight': 'bold',
        'padding-left': '0.5em'
          'color': '#003366',
      });
          'border-left': '3px solid #3878C7',
       // optional scrollen
          'padding-left': '0.5em'
        });
       // scroll
       $('html, body').scrollTop($link.offset().top - 80);
       $('html, body').scrollTop($link.offset().top - 80);
     }
     }
   }, 300);
   }, 300);
});
});

Version vom 11. Juni 2025, 21:18 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */
/**
 * Entfernt das Wort „Fortsetzung“ aus allen SMW-Spalten-Headern (div.smw-column-header).
 * Leg die Datei MediaWiki:Common.js (oder Discovery.js) an bzw. bearbeite sie:
 *
 * 1. Gehe als Admin auf Special:Edit/MediaWiki:Common.js
 * 2. Füge diesen Code ans Ende ein und speichere.
 * 3. Leere den Browser-Cache (STRG + F5), damit das neue JS geladen wird.
 */
mw.loader.using(['jquery'], function () {
    $(document).ready(function () {
        $('.smw-column-header').each(function () {
            // aktuellen HTML-Inhalt holen
            var html = $(this).html();
            // "Fortsetzung" entfernen, Leerzeichen ggf. bereinigen
            var newHtml = html.replace(/Fortsetzung/g, '').trim();
            // falls nach dem Entfernen gar kein Text übrig ist, komplette Header-Box ausblenden:
            if (newHtml === '') {
                $(this).hide();
            } else {
                // ansonsten nur den Text überschreiben, sodass z. B. "B Fortsetzung" → "B" wird
                $(this).html(newHtml);
            }
        });
        $(function () {
			    $('<style>')
			      .prop('type', 'text/css')
			      .html(
			        '.breadcrumb-item { font-size: 17px !important; }' +
			        '.breadcrumb-nav  { border-bottom: 2px solid #85bc20!important; margin-bottom: 20px !important; }'
			      )
			      .appendTo('head');
		});
	});
});
/* MediaWiki:Common.js */
$(function() {
  // Relativer Pfad der aktuellen Seite
  var current = window.location.pathname;

  // Lese gespeichertes lastNav
  var lastNav = null;
  try {
    lastNav = JSON.parse(window.name || '{}').lastNav;
  } catch (e) {}

  // Funktion: schließe alle active-Links wieder
  function collapseAllActive() {
    $('a.mws-tree-item-label.active').each(function() {
      var $link    = $(this),
          relHref  = $link.attr('href'),
          $parents = $link.parents('li.mws-tree-item');
      // entferne active-Stil
      $link.removeClass('active').css({
        'background-color': '',
        'font-weight': '',
        'color': '',
        'border-left': '',
        'padding-left': ''
      });
      // schließe jeden Parent-Zweig
      $parents.each(function() {
        var $li       = $(this),
            $exp      = $li.children('div').children('a.mws-tree-expander.expanded'),
            $submenu = $li.children('ul.mws-tree-item-children');
        if ($exp.length) {
          $exp
            .removeClass('expanded')
            .addClass('collapsed')
            .attr('aria-expanded','false');
        }
        if ($submenu.length) {
          $submenu.hide();
        }
      });
    });
  }

  // Wenn lastNav existiert aber nicht mit current übereinstimmt, collapse all
  if (lastNav && lastNav !== current) {
    collapseAllActive();
    return; // kein neues Aufklappen
  }

  // Ab hier: lastNav === current → öffne Zweig und markiere
  var attempts = 0,
      interval = setInterval(function() {
    attempts++;
    if (!lastNav || attempts > 10) {
      clearInterval(interval);
      return;
    }
    var $link = $('a.mws-tree-item-label[href="' + lastNav + '"]');
    if ($link.length) {
      clearInterval(interval);
      // aufklappen
      $link.parents('li.mws-tree-item').each(function() {
        var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed');
        if ($exp.length) {
          $exp.trigger('click');
        }
      });
      // inline-highlight & class active
      $link
        .addClass('active')
        .css({
          'background-color': '#eef',
          'font-weight': 'bold',
          'color': '#003366',
          'border-left': '3px solid #3878C7',
          'padding-left': '0.5em'
        });
      // scroll
      $('html, body').scrollTop($link.offset().top - 80);
    }
  }, 300);
});