Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 32: | Zeile 32: | ||
.appendTo('head'); | .appendTo('head'); | ||
}); | }); | ||
$(function() { | $(function() { | ||
var storageKey = 'bs_lastNav'; | var storageKey = 'bs_lastNav', | ||
lastHref; | |||
// Klick | // 1) Klick merken | ||
$('a.mws-tree-item-label').on('click', function() { | $('a.mws-tree-item-label').on('click', function() { | ||
try { | try { | ||
window.name = JSON.stringify({ lastNav: href }); | window.name = JSON.stringify({ lastNav: this.href }); | ||
} catch(e) { | } catch (e) { /* ignore */ } | ||
}); | }); | ||
// | // 2) Auslesen | ||
try { | try { | ||
var | var data = JSON.parse(window.name || '{}'); | ||
lastHref = data.lastNav; | |||
} catch(e) { /* ignore */ } | } catch (e) { /* ignore */ } | ||
if (! | if (!lastHref) return; | ||
// | // 3) Nach kurzer Verzögerung aufklappen | ||
setTimeout(function() { | setTimeout(function() { | ||
var $link = $('a.mws-tree-item-label[href="' + | var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]'); | ||
if (!$link.length) return; | if (!$link.length) return; | ||
// | // Für jeden Vorgänger-<li>: | ||
$link.parents('li.mws-tree-item'). | $link.parents('li.mws-tree-item').each(function() { | ||
var $exp = $ | var $li = $(this), | ||
$exp = $li.children('div').children('a.mws-tree-expander'), | |||
$submenu = $li.children('ul.mws-tree-item-children'); | |||
// Expander optisch öffnen | |||
$exp | |||
.removeClass('collapsed') | |||
.addClass('expanded') | |||
.attr('aria-expanded', 'true'); | |||
// Untermenü anzeigen | |||
$submenu.css('display', 'block'); | |||
}); | }); | ||
// | // optional scrollen | ||
$('html, body').scrollTop($link.offset().top - 100); | $('html, body').scrollTop($link.offset().top - 100); | ||
}, 200); | }, 200); | ||
}); | }); | ||
}); | }); |
Version vom 11. Juni 2025, 19:27 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');
});
$(function() {
var storageKey = 'bs_lastNav',
lastHref;
// 1) Klick merken
$('a.mws-tree-item-label').on('click', function() {
try {
window.name = JSON.stringify({ lastNav: this.href });
} catch (e) { /* ignore */ }
});
// 2) Auslesen
try {
var data = JSON.parse(window.name || '{}');
lastHref = data.lastNav;
} catch (e) { /* ignore */ }
if (!lastHref) return;
// 3) Nach kurzer Verzögerung aufklappen
setTimeout(function() {
var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]');
if (!$link.length) return;
// Für jeden Vorgänger-<li>:
$link.parents('li.mws-tree-item').each(function() {
var $li = $(this),
$exp = $li.children('div').children('a.mws-tree-expander'),
$submenu = $li.children('ul.mws-tree-item-children');
// Expander optisch öffnen
$exp
.removeClass('collapsed')
.addClass('expanded')
.attr('aria-expanded', 'true');
// Untermenü anzeigen
$submenu.css('display', 'block');
});
// optional scrollen
$('html, body').scrollTop($link.offset().top - 100);
}, 200);
});
});