From Wikipedia, the free encyclopedia
Content deleted Content added
|
 |
|||
| Line 73: | Line 73: | ||
|
$headerStart.prepend( $searchPortlet ); |
$headerStart.prepend( $searchPortlet ); |
||
|
} |
} |
||
|
// Small gap so it doesn’t hug the logo/menu |
|||
|
$searchPortlet.css( ‘margin-left’, ‘0.5rem’ ); |
|||
|
} ); |
} ); |
||
|
} ); |
} ); |
||
Latest revision as of 05:31, 28 November 2025
// Hides the "Add to Watchlist" (star) button on all pages
$('.mw-watchlink').hide();
mw.loader.using( 'mediawiki.util' ).then( function () {
// --- CSS: icon-only search, plus fix right-side alignment ---
mw.util.addCSS( `
/* Vector 2022: collapse main header search into the icon */
/* Default state: hide the big search UI... */
body.skin-vector-2022 .vector-header.mw-header .vector-search-box .vector-typeahead-search-container {
display: none !important;
}
/* ...and force the magnifying-glass icon button to be visible */
body.skin-vector-2022 .vector-header.mw-header .vector-search-box .search-toggle {
display: inline-flex !important;
}
/* When the header is in the "search open" state, show the full box again... */
body.skin-vector-2022 .vector-header.mw-header.vector-header-search-toggled
.vector-search-box .vector-typeahead-search-container {
display: block !important;
}
/* ...and hide the icon while it’s open */
body.skin-vector-2022 .vector-header.mw-header.vector-header-search-toggled
.vector-search-box .search-toggle {
display: none !important;
}
/* Ensure the *other* header icons stay right-aligned */
body.skin-vector-2022 .vector-header.mw-header .vector-header-end {
margin-left: auto !important;
justify-content: flex-end !important;
}
` );
// --- JS: move ONLY the search to the left side of the main header ---
$( function () {
if ( !document.body.classList.contains( 'skin-vector-2022' ) ) {
return;
}
var $header = $( '.vector-header.mw-header' ).first();
if ( !$header.length ) {
return;
}
// Search portlet (contains .vector-search-box)
var $searchPortlet = $( '#p-search' );
if ( !$searchPortlet.length ) {
$searchPortlet = $header.find( '.vector-search-box' ).first().closest( '#p-search, .mw-portlet, .vector-search-box' );
}
// Left-hand container (logo + main menu)
var $headerStart = $header.find( '.vector-header-start' ).first();
if ( !$searchPortlet.length || !$headerStart.length ) {
return;
}
// Detach just the search portlet from wherever it is now
$searchPortlet = $searchPortlet.detach();
// Insert it after the logo if possible, otherwise at the start
var $afterLogo = $headerStart.find( '.mw-logo, .vector-header-logo' ).last();
if ( $afterLogo.length ) {
$afterLogo.after( $searchPortlet );
} else {
$headerStart.prepend( $searchPortlet );
}
} );
} );


