Jump to content
🚛
Streamline your cross-border operation. From ACE & ACI eManifests to PARS tracking and U.S. In-Bond filing, BorderConnect is the fastest way to cross.

MediaWiki:Common.js: Difference between revisions

From BorderConnect Wiki
No edit summary
No edit summary
Line 3: Line 3:
window.wpDarkModeAutoToggle = true;
window.wpDarkModeAutoToggle = true;


/* --- Inject Hero Search Bar on Main Page (With Search Suggestions) --- */
/* --- Inject Hero Search Bar on Main Page (Fixed Suggestions) --- */
$(function() {
$(function() {
     // Only run this if the placeholder exists
     // Only run this if the placeholder exists
Line 10: Line 10:
             '<form action="/index.php" id="searchform">' +
             '<form action="/index.php" id="searchform">' +
             '<input type="hidden" name="title" value="Special:Search">' +
             '<input type="hidden" name="title" value="Special:Search">' +
            // Container
             '<div style="position: relative; max-width: 600px; margin: 0 auto;">' +
             '<div style="position: relative; max-width: 600px; margin: 0 auto;">' +
              
              
             // The Input Field (Added id="heroSearchInput" and autocomplete="off")
             // ADDED: class="mw-searchInput"
             '<input id="heroSearchInput" name="search" type="search" placeholder="Search for In-Bond, ACE Manifest..." autocomplete="off" style="width: 100%; padding: 15px 120px 15px 25px; border-radius: 50px; border: none; font-size: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); outline: none;">' +
            // ADDED: accesskey="f" (Standard MediaWiki hotkey)
             '<input id="heroSearchInput" class="mw-searchInput" name="search" type="search" placeholder="Search for In-Bond, ACE Manifest..." autocomplete="off" accesskey="f" style="width: 100%; padding: 15px 120px 15px 25px; border-radius: 50px; border: none; font-size: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); outline: none;">' +
              
              
            // The Button
             '<button type="submit" name="go" value="Go" style="position: absolute; right: 5px; top: 5px; bottom: 5px; background: #266065; color: white; border: none; border-radius: 50px; padding: 0 25px; font-weight: bold; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2);">Search</button>' +
             '<button type="submit" name="go" value="Go" style="position: absolute; right: 5px; top: 5px; bottom: 5px; background: #266065; color: white; border: none; border-radius: 50px; padding: 0 25px; font-weight: bold; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2);">Search</button>' +
           
             '</div>' +
             '</div>' +
             '</form>';
             '</form>';
Line 24: Line 22:
         $('#bc-hero-search').html(searchHTML);
         $('#bc-hero-search').html(searchHTML);


         // --- ACTIVATE SEARCH SUGGESTIONS ---
         // --- MANUALLY BIND SUGGESTIONS ---
         // This tells MediaWiki to attach the "preview box" logic to our new input
         // We wait for the module to load, then force the bind
         mw.loader.using( 'mediawiki.searchSuggest', function () {
         mw.loader.using( 'mediawiki.searchSuggest', function () {
             $( '#heroSearchInput' ).searchSuggest();
             $( '#heroSearchInput' ).searchSuggest();

Revision as of 17:30, 30 January 2026

/* Any JavaScript here will be loaded for all users on every page load. */

window.wpDarkModeAutoToggle = true;

/* --- Inject Hero Search Bar on Main Page (Fixed Suggestions) --- */
$(function() {
    // Only run this if the placeholder exists
    if ($('#bc-hero-search').length) {
        var searchHTML = 
            '<form action="/index.php" id="searchform">' +
            '<input type="hidden" name="title" value="Special:Search">' +
            '<div style="position: relative; max-width: 600px; margin: 0 auto;">' +
            
            // ADDED: class="mw-searchInput"
            // ADDED: accesskey="f" (Standard MediaWiki hotkey)
            '<input id="heroSearchInput" class="mw-searchInput" name="search" type="search" placeholder="Search for In-Bond, ACE Manifest..." autocomplete="off" accesskey="f" style="width: 100%; padding: 15px 120px 15px 25px; border-radius: 50px; border: none; font-size: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); outline: none;">' +
            
            '<button type="submit" name="go" value="Go" style="position: absolute; right: 5px; top: 5px; bottom: 5px; background: #266065; color: white; border: none; border-radius: 50px; padding: 0 25px; font-weight: bold; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2);">Search</button>' +
            '</div>' +
            '</form>';
            
        $('#bc-hero-search').html(searchHTML);

        // --- MANUALLY BIND SUGGESTIONS ---
        // We wait for the module to load, then force the bind
        mw.loader.using( 'mediawiki.searchSuggest', function () {
            $( '#heroSearchInput' ).searchSuggest();
        });
    }
});