MediaWiki:Common.js: Difference between revisions

From EQOA Sandstorm Wiki
Jump to navigationJump to search
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: $(function () { // Clone the search portlet and move it to a top bar var searchBox = $('#p-search').clone(); // Create top search bar container var topBar = $('<div id="top-search-bar"></div>'); topBar.append(searchBox); // Add to top of page $('body').prepend(topBar); });")
 
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 () {
$(function () {
    // Clone the search portlet and move it to a top bar
    var searchBox = $('#p-search').clone();


     // Create top search bar container
     // Make sure p-search exists
    var topBar = $('<div id="top-search-bar"></div>');
    var original = $('#p-search form');
    topBar.append(searchBox);
 
    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);
    }


    // Add to top of page
    $('body').prepend(topBar);
});
});

Revision as of 11:25, 25 November 2025

/* 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);
    }

});