MediaWiki:Common.js: Difference between revisions

From EQOA Sandstorm Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
$(function () {
    // Make sure p-search exists
    var original = $('#p-search form');
    if (original.length) {
        // Clone only the search form, not the whole portlet
        var searchClone = original.clone(true);
        // Create top search bar
        var topBar = $('<div id="top-search-bar"></div>');
        topBar.append(searchClone);
        // Insert into body top
        $('body').prepend(topBar);
    }
});
$('body').addClass('ready');
$(document).ready(function () {
$(document).ready(function () {
     // Remove existing search box in sidebar
     // Remove sidebar search
     $("#p-search").remove();
     $("#p-search").remove();


     // Add new fixed search bar at top
     // Insert top search bar AFTER the tabs container
     $("body").prepend(`
     var searchBar = $(`
         <div id="top-search-bar">
         <div id="top-search-bar">
             <form action="/index.php" method="get">
             <form action="/index.php" method="get">
Line 35: Line 13:
         </div>
         </div>
     `);
     `);
    // Insert after personal and namespaces tabs
    $("#p-namespaces").after(searchBar);
});
});

Revision as of 11:33, 25 November 2025

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function () {
    // Remove sidebar search
    $("#p-search").remove();

    // Insert top search bar AFTER the tabs container
    var searchBar = $(`
        <div id="top-search-bar">
            <form action="/index.php" method="get">
                <input type="hidden" name="title" value="Special:Search">
                <input type="search" name="search" placeholder="Search..." />
            </form>
        </div>
    `);

    // Insert after personal and namespaces tabs
    $("#p-namespaces").after(searchBar);
});