MediaWiki:Common.js: Porovnání verzí

Z TEST Wiki
Ofara (diskuse | příspěvky)
Bez shrnutí editace
značka: revertováno
Ofara (diskuse | příspěvky)
Bez shrnutí editace
značka: revertováno
Řádek 14: Řádek 14:
});
});


mw.loader.using(['jquery', 'mediawiki.util'], function () {
mw.loader.using(['jquery'], function () {
   $(function () {
   $(function () {
    // Funkce, která přepíše stylování tlačítek
     function styleAFTButtons() {
     function styleAFTButtons() {
       $('.articleFeedbackv5 .articleFeedbackv5-button-placeholder.ui-button').each(function () {
       const $buttons = $('.articleFeedbackv5 .articleFeedbackv5-button-placeholder.ui-button');
         $(this).css({
      if ($buttons.length === 0) {
          'background-color': '#0052cc',
         // Tlačítka ještě nejsou vykreslena, zkus to znovu za 250ms
          'color': '#ffffff',
        setTimeout(styleAFTButtons, 250);
          'font-weight': 'bold',
        return;
          'border': 'none',
      }
          'border-radius': '4px',
 
          'padding': '8px 16px',
      // Jsou na stránce – přepiš styly
          'box-shadow': '0 2px 4px rgba(0, 0, 0, 0.1)',
      $buttons.css({
          'text-decoration': 'none'
        'background-color': '#0052cc',
         });
        'color': '#ffffff',
        'font-weight': 'bold',
        'border': 'none',
        'border-radius': '4px',
        'padding': '8px 16px',
        'box-shadow': '0 2px 4px rgba(0, 0, 0, 0.1)',
        'text-decoration': 'none'
      });
 
      // Hover efekt (simulovaný)
      $buttons.on('mouseenter', function () {
         $(this).css('background-color', '#003d99');
      }).on('mouseleave', function () {
        $(this).css('background-color', '#0052cc');
       });
       });
     }
     }


     // Spuštění po načtení obsahu stránky
     // Spustíme čekací funkci
     mw.hook('wikipage.content').add(function () {
     styleAFTButtons();
      // Počkej až se načte i ArticleFeedbackV5 widget
      setTimeout(styleAFTButtons, 500); // lze zvýšit na 1000ms pokud potřeba
    });
   });
   });
});
});
alert('Common.js funguje!');

Verze z 9. 6. 2025, 09:47

/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */
$(document).ready(function() {
    var searchForm = $("#searchform");
    if (searchForm.length > 0) {
        var searchInput = searchForm.find("input[name='search']");
        if (searchInput.length > 0) {
            var currentAction = searchForm.attr("action");

            // Přepíšeme `profile=default` na `profile=all`
            var newAction = currentAction.replace("profile=default", "profile=all");
            searchForm.attr("action", newAction);
        }
    }
});

mw.loader.using(['jquery'], function () {
  $(function () {
    function styleAFTButtons() {
      const $buttons = $('.articleFeedbackv5 .articleFeedbackv5-button-placeholder.ui-button');
      if ($buttons.length === 0) {
        // Tlačítka ještě nejsou vykreslena, zkus to znovu za 250ms
        setTimeout(styleAFTButtons, 250);
        return;
      }

      // Jsou na stránce – přepiš styly
      $buttons.css({
        'background-color': '#0052cc',
        'color': '#ffffff',
        'font-weight': 'bold',
        'border': 'none',
        'border-radius': '4px',
        'padding': '8px 16px',
        'box-shadow': '0 2px 4px rgba(0, 0, 0, 0.1)',
        'text-decoration': 'none'
      });

      // Hover efekt (simulovaný)
      $buttons.on('mouseenter', function () {
        $(this).css('background-color', '#003d99');
      }).on('mouseleave', function () {
        $(this).css('background-color', '#0052cc');
      });
    }

    // Spustíme čekací funkci
    styleAFTButtons();
  });
});