„MediaWiki:Common.js” változatai közötti eltérés

Innen: Sanctum2 Wikipédia
Ugrás a navigációhozUgrás a kereséshez
Nincs szerkesztési összefoglaló
Nincs szerkesztési összefoglaló
2. sor: 2. sor:
$(document).ready(function() {
$(document).ready(function() {
     // Add search box with styled input
     // Add search box with styled input
     $('table.wikitable').before('<div id="searchBox" style="margin-bottom: 10px; padding: 10px; background-color: #333; border-radius: 5px;">' +
     var searchBoxHtml = '<div id="searchBox" style="position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 1000; background-color: #333; padding: 10px; border-radius: 5px; width: 90%;">' +
                                '<label for="tableSearch" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés név alapján:</label>' +
                      '<label for="tableSearch" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés név alapján:</label>' +
                                '<input type="text" id="tableSearch" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F; color: #333;">' +
                      '<input type="text" id="tableSearch" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F; color: #333; width: 70%;">' +
                                '</div>');
                      '</div>';


    $('table.wikitable').before(searchBoxHtml);
    // Search functionality
     $('#tableSearch').on('keyup', function() {
     $('#tableSearch').on('keyup', function() {
         var value = $(this).val().toLowerCase();
         var value = $(this).val().toLowerCase();
12. sor: 15. sor:
             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
         });
         });
    });
    // Adjust search box on scroll
    $(window).scroll(function() {
        var scrollPosition = $(window).scrollTop();
        var searchBox = $('#searchBox');
        var tableOffset = $('table.wikitable').offset().top;
        if (scrollPosition > tableOffset) {
            searchBox.css({
                'position': 'fixed',
                'top': '10px'  // Adjust top position as needed
            });
        } else {
            searchBox.css({
                'position': 'absolute',
                'top': 'auto'
            });
        }
     });
     });
});
});

A lap 2024. június 24., 09:28-kori változata

// MediaWiki:Common.js
$(document).ready(function() {
    // Add search box with styled input
    var searchBoxHtml = '<div id="searchBox" style="position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 1000; background-color: #333; padding: 10px; border-radius: 5px; width: 90%;">' +
                       '<label for="tableSearch" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés név alapján:</label>' +
                       '<input type="text" id="tableSearch" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F; color: #333; width: 70%;">' +
                       '</div>';

    $('table.wikitable').before(searchBoxHtml);

    // Search functionality
    $('#tableSearch').on('keyup', function() {
        var value = $(this).val().toLowerCase();
        $('table.wikitable tr').filter(function() {
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
        });
    });

    // Adjust search box on scroll
    $(window).scroll(function() {
        var scrollPosition = $(window).scrollTop();
        var searchBox = $('#searchBox');
        var tableOffset = $('table.wikitable').offset().top;

        if (scrollPosition > tableOffset) {
            searchBox.css({
                'position': 'fixed',
                'top': '10px'  // Adjust top position as needed
            });
        } else {
            searchBox.css({
                'position': 'absolute',
                'top': 'auto'
            });
        }
    });
});