MediaWiki:Common.js: Difference between revisions
(Auto-pin sidebar navigation via Soulscribe) |
(Auto-pin sidebar navigation via Soulscribe) |
||
| Line 1: | Line 1: | ||
/* Soulscribe — auto-generated, do not edit manually */ | /* Soulscribe — auto-generated, do not edit manually */ | ||
/* Auto-pin the main navigation menu to the left sidebar on desktop | |||
/* ── Auto-pin the main navigation menu to the left sidebar on desktop ── */ | |||
( function () { | ( function () { | ||
if ( window.innerWidth < 1000 ) { return; } | if ( window.innerWidth < 1000 ) { return; } | ||
var pinBtn = document.querySelector( | var pinBtn = document.querySelector( | ||
'.vector-pinnable-header-pin-button[data-event-name="pinnable-header.vector-main-menu.pin"]' | '.vector-pinnable-header-pin-button[data-event-name="pinnable-header.vector-main-menu.pin"]' | ||
); | ); | ||
if ( pinBtn ) { pinBtn.click(); } | if ( pinBtn ) { pinBtn.click(); } | ||
}() ); | |||
/* ── Relationship table live filter ────────────────────────────────── */ | |||
/* Filters rows in any .wb-relationship-table as the user types. */ | |||
( function () { | |||
function initFilters() { | |||
document.querySelectorAll( '.wb-rel-filter' ).forEach( function ( input ) { | |||
var wrap = input.closest( '.wb-rel-filter-wrap' ); | |||
if ( !wrap ) { return; } | |||
var table = wrap.nextElementSibling; | |||
// step past any whitespace text nodes to find the table | |||
while ( table && table.nodeType !== 1 ) { table = table.nextSibling; } | |||
if ( !table || table.tagName !== 'TABLE' ) { return; } | |||
input.addEventListener( 'input', function () { | |||
var q = input.value.toLowerCase().trim(); | |||
var rows = table.querySelectorAll( 'tbody tr' ); | |||
rows.forEach( function ( row ) { | |||
var text = row.textContent.toLowerCase(); | |||
row.style.display = ( !q || text.indexOf( q ) !== -1 ) ? '' : 'none'; | |||
} ); | |||
} ); | |||
} ); | |||
} | |||
if ( document.readyState === 'loading' ) { | |||
document.addEventListener( 'DOMContentLoaded', initFilters ); | |||
} else { | |||
initFilters(); | |||
} | |||
}() ); | }() ); | ||
Revision as of 08:29, 28 April 2026
/* Soulscribe — auto-generated, do not edit manually */
/* ── Auto-pin the main navigation menu to the left sidebar on desktop ── */
( function () {
if ( window.innerWidth < 1000 ) { return; }
var pinBtn = document.querySelector(
'.vector-pinnable-header-pin-button[data-event-name="pinnable-header.vector-main-menu.pin"]'
);
if ( pinBtn ) { pinBtn.click(); }
}() );
/* ── Relationship table live filter ────────────────────────────────── */
/* Filters rows in any .wb-relationship-table as the user types. */
( function () {
function initFilters() {
document.querySelectorAll( '.wb-rel-filter' ).forEach( function ( input ) {
var wrap = input.closest( '.wb-rel-filter-wrap' );
if ( !wrap ) { return; }
var table = wrap.nextElementSibling;
// step past any whitespace text nodes to find the table
while ( table && table.nodeType !== 1 ) { table = table.nextSibling; }
if ( !table || table.tagName !== 'TABLE' ) { return; }
input.addEventListener( 'input', function () {
var q = input.value.toLowerCase().trim();
var rows = table.querySelectorAll( 'tbody tr' );
rows.forEach( function ( row ) {
var text = row.textContent.toLowerCase();
row.style.display = ( !q || text.indexOf( q ) !== -1 ) ? '' : 'none';
} );
} );
} );
}
if ( document.readyState === 'loading' ) {
document.addEventListener( 'DOMContentLoaded', initFilters );
} else {
initFilters();
}
}() );